[antlr-interest] "google like" quoted string parser/lexer

tony at bill.assist.uci.edu tony at bill.assist.uci.edu
Thu Feb 23 20:36:22 PST 2006


Hi,

Can anyone point me in the right direction of how I'd write a lexer/parser 
that handles quoted strings.  Ultimately what I'm doing would be used as a 
translator into SQL, but I'm interested in anything that deals with 
quoted strings.  

It would have rules such as this:

1. this that -- the words 'this' and 'that' would have to appear somewhere 
in the text.

2. "a phrase" -- word/words quoted would signify that the words would have 
to appear exactly in the text as typed in a keyword search.

3. "some search terms" qualifier -- same as above, and the word 
'qualifier' would also have to appear anywhere in the text.  In other words,
there's an implicit "and" between the quoted string and the word 'qualifier'.  
There could be a 0 or more qualifier words, as well as 0 or more quoted 
strings.

4. There could also be typos that have a starting double quote, with no 
ending double quote (ie "not a phrase).  These would be treated as #1 
above, basically just stripping out the unbalanced quote.

Does anyone have or know of an example that I can use as a starting point?
I'm quiet a neophyte at using a lexer/parser so anything is useful.

Thanks a lot,
Tony






More information about the antlr-interest mailing list