[stringtemplate-interest] [ST4 Beta 2] Endless loop when loading invalid group file
Terence Parr
parrt at cs.usfca.edu
Tue Jan 25 11:24:18 PST 2011
Fixed. thanks!
T
On Jan 24, 2011, at 12:46 AM, Udo Borkowski wrote:
> Did some more debugging (and generated the GroupLexer.java ;-)
>
> It looks like the problem is in Group.g ANONYMOUS_TEMPLATE:
>
> ...
> while ( lexer.subtemplateDepth>=1 || t.getType()!=STLexer.RCURLY ) {
> t = lexer.nextToken();
> }
>
> One needs to check for the EOF_TYPE and raise an error if no closing brace is found.
>
> Here the code I am now using to work around this issue:
>
> while (lexer.subtemplateDepth >= 1 || t.getType() != STLexer.RCURLY) {
> t = lexer.nextToken();
> if (t.getType() == STLexer.EOF_TYPE) {
> throw new RuntimeException(
> String.format(
> "Anonymous template starting at %d:%d of %s is not closed (missing '}')",
> input.getLine(),
> input.getCharPositionInLine(),
> input.getSourceName()));
> }
> }
>
>
>
>
> Udo
>
>
> Begin forwarded message:
>
>> From: Udo Borkowski <ub at abego-software.de>
>> Date: 24. Januar 2011 00:48:08 MEZ
>> To: "stringtemplate-interest at antlr.org List" <stringtemplate-interest at antlr.org>
>> Subject: [stringtemplate-interest] [ST4 Beta 2] Endless loop when loading invalid group file
>>
>> Trying to load a group file with this content
>>
>> "main(p) ::= {"
>>
>> (without quotes)
>>
>> results into an endless loop. I didn't debug in details because of missing source files but it looks like the problem is located in
>>
>> GroupLexer.mANONYMOUS_TEMPLATE() line: 604
>>
>>
>> Udo
>>
>> P.S.: You may wonder why I come up with these strange files. I am currently working on an interactive application and then these "invalid" groups are created as "intermediate steps" while editing.
>>
>>
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list