[antlr-interest] anonymous templete containing "<"

Johannes Luber JALuber at gmx.de
Mon Jun 16 15:36:27 PDT 2008


> Hi, my emitter at first generates literal templates for binary 
> operations, one of which is the "<" comparison.
> I get this exception:
> 
> line 1:1: unexpected char: '<'
>     at 
> org.antlr.stringtemplate.language.AngleBracketTemplateLexer.nextToken(AngleBracketTemplateLexer.java:149)
> 
> The templates are instanciated like this:
> 
> binaryOp
> @init {
> $st = %{$start.getText()};
> }
> 
> :
>     | PLUS
>     | MINUS
>     | MULT
>     | DIV
>     | MOD
>     | DIVMOD
>     | ADD
>     | REM
>     | LT
>     | GT
>     | LEQ
>     | GEQ
>     | EQ
>     | NEQ
>     | AND
>     | OR
>     ;

You may want to change '<' into '\<' in this case. StringTemplate escapes templates via '<' and '>'.

Johannes
-- 
"Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail


More information about the antlr-interest mailing list