[antlr-interest] Beginner grammar question

Fabian Baboschi fabian20ro at gmail.com
Fri Sep 12 00:39:38 PDT 2008


Hi,
I have a question about the following grammar:

grammar test;

list     :    (element)+
    ;

element    :   BAR NAME
    ;

BAR    :     'bar'
    ;

NAME
    :     ('a'..'z'|'A'..'Z')('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
    ;

WS
    :  (' '|'\r'|'\t'|'\u000C'|'\n') {$channel=HIDDEN;}
    ;

I tried to use the following input: bar bar
and I get errors because the parser doesn't recognize that the second bar
should be treated as a name.
I tried to change the grammar or options but without success. What am I
missing?

If it matters I'm using antlrworks-1.2 and antlr-3.1.

Thank you,
Fabian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080912/4ef59227/attachment.html 


More information about the antlr-interest mailing list