Using C # I am trying to add a search function to the application I'm working on, but I would like to write a search provider that I can use again and again to be used in the query string that the user entered, and then parse it in the result dictionary . The dictionary will contain only the keyword and meaning. IE Keyword "last" and Meaning "Simpson"
I would like to allow the search field to accept simple strings, quoted strings, and parameter strings similar to Windows Search. It does not have to be as extensive as Windows Search. Obviously, something must parse the query string that the user enters, and then something else interprets the parsed query string in the query for the data source.
How is someone going to write a lexer or something that can analyze several options that the user can enter into actually something useful? Are there any frameworks that can simplify the task of defining keywords and parameters? Basically, I'm looking for some information on where to start, how to do it. I have no problem doing the actual work, I just lost information on where to start trying to do this. The simple string and quoted strings are easy to parse, but the parameterized strings were a ball of a curve that confuses me.
Example of plain query strings: - hello.txt - one two three Example of quoted strings: - "one two" - one "two three" Example of parametered strings: - last:simpson - first:bart - name:"Bart Simpson" - name:"Bart Simpson" age:12 - hello name:"Bart Simpson" fart age:12
source share