[stringtemplate-interest] [ST4 Beta-3] Endless loop when template comment is not closed.

Terence Parr parrt at cs.usfca.edu
Sat Feb 5 11:23:02 PST 2011


fixed. now it's like this:

t.stg 1:20: Nonterminated comment starting at 1:1: '!>' missing

Ter
On Feb 3, 2011, at 10:22 AM, Udo Borkowski wrote:

> A template comment that is not closed, e.g.
> 
> t() ::= <<
> <!bad comment>
> ...
> >>
> 
> leads to an endless loop.
> 
> 
> I changed STLexer#COMMENT to work around this issue:
> 
>     void COMMENT() {
>         match('!');
>         while ( !(c=='!' && input.LA(2)==delimiterStopChar) ) {
>         	if (c==EOF) {
> 				RecognitionException re =
> 					new MismatchedTokenException((int)'!', input);
> 				re.line = input.getLine();
> 				re.charPositionInLine = input.getCharPositionInLine();
> 				errMgr.lexerError(input.getSourceName(), "Comment not closed. '!"+delimiterStopChar+"' missing", templateToken, re);
> 				break;        		
>         	}
>         	consume();
>         }
>         consume(); consume(); // kill !>
>     }
> 
> 
> This fix works. However I guess it would be better if the error message could refer to the opening "<!", but I am not sure how to write this.
> 
> Udo
> 
> 
> 
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110205/964abcaf/attachment.html 


More information about the stringtemplate-interest mailing list