[antlr-interest] discrepancy between antlrworks and antlr generated parser

Indhu Bharathi indhu.b at s7software.com
Thu Apr 9 00:10:08 PDT 2009


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

This should give you compile error. There must be a ';' immediately 
after 'HIDDEN'. ( {$channel=HIDDEN;} )

Are you using tab instead of space in input?

David Cournapeau wrote:
> Hi,
>
> I have started using antlr to catch up my lack of knowledge in
> parsers. This is a great product, thanks a lot !
>
> I am trying to create my own DSL, and started very simply with parsing
> the following
>
> name: foo;
>
> But got a problem while using antlworks. I get space-related problem:
>
> name:foo; -> works
> name: foo; -> antlrworks gives me an error (mismatchedTokenExpression exception)
>
> But if I use the generated parser from antlworks, both expressions
> with and without spaces are correctly parsed.
>
> The grammar boils down to:
>
> grammar T;
> program	:	statement+;
> statement
> 	:	metadata;	
> metadata
> 	:	'name:'  WORD ENDSTMT;	
> WORD: 'a'..'z'+ ;
> WS: (' ' | '\n' | '\r' )+ {$channel=HIDDEN};
> ENDSTMT	:	';';
>
> I use python for the generated parser, if that matters,
>
> thank you,
>
> David
>
> 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