[antlr-interest] Parsing advice: predicate needed?
Rick Schumeyer
rschumeyer at gmail.com
Wed Dec 9 07:18:30 PST 2009
I have a lexer rule
LETTER : ('a'..'z')|('A'..'Z');
At a certain point in my parser, I want to know if the next several letters
are the word 'Article'. I don't want an article token, because that word
can appear at other points, and I don't care.
Can I simply define a parser rule
article_string : 'A' 'r' 't' 'i' 'c' 'l' 'e';
If this works, then I'm really confused because I would think that the lexer
would have already decided that there are several LETTER tokens, so I'm not
sure how the parser would see an 'A' and an 'r', etc.
Or should I use a predicate, something like
my_rule : (do the next several letters spell article)? => LETTER LETTER
LETTER etc.
| next alternative
If so, then how exactly do I implement "do the next several letters spell
article" ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091209/92779a1f/attachment.html
More information about the antlr-interest
mailing list