[antlr-interest] operator inside a string

Bob Night antlr.fan at googlemail.com
Tue Jul 7 03:03:57 PDT 2009


Hi!
I have a following grammar. Most of the time it works fine. The problem
begins when I try to parse a string like this one:

"test_input OPERATOR another_test_input"

The operator inside quotes is still recognized as a OPERATOR token, while
I'd like it to be recognized as a WORD token that is part of the quote.

grammar test;
start_rule    :    expr (OPERATOR expr)* EOF;
expr    :  quote | WORD;
quote   :    '"' WORD+ '"';
OPERATOR : 'OPERATOR';
WORD     :    ('a'..'z'|'A'..'Z')+;

Any suggestions?

Thanks for any help,
Bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090707/77b3bca9/attachment.html 


More information about the antlr-interest mailing list