[antlr-interest] ANTLR never completes when generating certain lexers
Jim Idle
jimi at temporal-wave.com
Fri Jul 13 09:29:26 PDT 2012
What if you do:
RULE :
EscapedIdent ('(' MacroExpr (',' MacroExpr )* ')')?
;
And it looks like your MacroExpression rule can be empty. So, make sure it
cannot be then alter the RULE above accordingly.
Jim
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of A Z
> Sent: Friday, July 13, 2012 7:16 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] ANTLR never completes when generating certain
> lexers
>
> I've been changing a lexer around in an effort to give better error
> messages and came across a case where ANTLR fails to terminate. The
> code below is the minimum I could find that causes the problem.
> In my working grammar, I have functionally equivalent code working
> and that entire grammar generates in about 6 seconds. After the
> changes, the ANTLR code generator never completes and eventually the
> Java VM quits after using all the system memory. Is there any debugging
> info ANTLR has that I should be looking at to fix this? To be clear I'm
> not looking for what's wrong with the grammar, just a means to isolate
> the problem faster. Thanks.
>
> lexer grammar Y;
>
> options
> {
> language = C;
> }
>
>
> RULE :
> EscapedIdent
> | EscapedIdent '(' MacroExpr (',' MacroExpr )* ')'
> ;
>
> fragment EscapedIdent : '\\' (~ ('\r'|' '|'\n'))+ (' ' | '\n' | EOF);
> fragment MacroExpr : (MacroSubExpr | ~(',' | '(' | '{' | ')' | '}' |
> '"'))*; fragment MacroSubExpr :
> '('
> (
> (
> ~('(' | '{' | '[' | ')')
> | MacroSubExpr
> )+ ')'
> | ')'
> )
> | '{'
> (
> (
> ~('(' | '{' | '[' | '}')
> | MacroSubExpr
> )+ '}'
> | '}'
> );
>
> 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