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

David Cournapeau cournape at gmail.com
Thu Apr 9 00:05:57 PDT 2009


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


More information about the antlr-interest mailing list