[antlr-interest] Simple grammar which hangs the code generator

Jie Lu jielu64 at gmail.com
Tue May 20 08:04:09 PDT 2008


Hi,
I'm extremely new to Antlr (I've only been messing around with it for about
a day), so I generally assume that any problems I get is just a result of my
presence. This problem though, is just a little too wierd to not ask people
about.

While experimenting with various rules, I got to a grammar (shown below)
which seems to hang the code generator. In ANTLRWorks, if I do
Generate->Generate Code, the progress dialog comes up and stays forever. The
problem seems to have started when I added (...)+ around the CHAR_CONTENTS
rule. Does the Antlr code generator normally hang on certain grammars?

Btw, while I'm at it, has anyone encountered the issue of the ANTLRWorks
save dialog box freezing for 20 sec. every time you select a folder?

Thanks for any insights.

grammar JavaLang;

file : charLiteral;

charLiteral : '\'' CHAR_CONTENTS '\'';

stringLiteral :    '"' STRING_CONTENTS? '"';

CHAR_CONTENTS : (~('\''|'\\') | ('\\' .))+;

STRING_CONTENTS : (~('"'|'\\') | ('\\' .))+;

SPACING :    (WS | COMMENT | LINE_COMMENT)+;

WS : ' ' | '\r' | '\t' | '\u000C' | '\n';

COMMENT :   '/*' (options {greedy=false;} : .)* '*/';

LINE_COMMENT : '//' ~('\n'|'\r')*;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080520/0dab0129/attachment.html 


More information about the antlr-interest mailing list