[antlr-interest] Tokens match more characters than they should.

Chris Dew chris at sidwells.com
Mon Mar 31 13:36:49 PDT 2008


I'm sure that this is an error in my understanding, as I'm new to antlr.
Hopefully someone can point out my mistake.  I'm using ANTLRWorks 1.1.7,
(which says that it is for antlr v3 grammars).

I believe the grammar, attached at the end of the email, should only match
"foo bar wibble".  The *interpreter* (built into ANTLRWorks) matches many
more characters than I expect.  For example: "fooabarb cwibble" seems to be
valid.  It forms 'foo' 'a bar' 'b cwibble'.  Does anyone know why?

Thanks,

Chris.

P.S. The grammar is just a toy grammer, which illustrates a problem I have
with a much more complicated grammar.



grammar test;

command    :    FOO BAR WIBBLE    ;

FOO    :    'foo'        ;
BAR    :    'bar'        ;
WIBBLE    :    'wibble'    ;

WS    :    (' '|'\r'|'\n')+ {$channel = HIDDEN;} ;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080331/809570ca/attachment.html 


More information about the antlr-interest mailing list