[antlr-interest] n00b Question

Johannes Luber jaluber at gmx.de
Thu Aug 21 03:06:00 PDT 2008


Anders Karlsson schrieb:
> Thanks Tom,
> 
> I did as you said 
> 
> expr
> 	:	(IDENTIFIER '=' VALUE ) 
> 	;
> 
> // lex rules
> 
> IDENTIFIER
>     :	LETTER (LETTER|DIGIT)*
>     ;
> 
> VALUE
>     :	'"' (LETTER|DIGIT)* '"'
>     ;
> 
> so now it works. I was wondering how to ignore the end of file value, what is the normal way to do that?

EOF is already ignored. This has the side effect that parsing is still
correct for input which conforms in the first part of it to the grammar.
To enforce a complete scanning of the input file, use

start: expr* EOF;

Furthermore, please don't use parentheses to group expressions where
they aren't needed like in your expr rule.

Johannes
> 
> BR/Anders.
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 



More information about the antlr-interest mailing list