[antlr-interest] Bug report: handling of % (and $)

Wincent Colaiuta win at wincent.com
Fri Jun 8 08:12:11 PDT 2007


El 7/6/2007, a las 16:07, Benjamin Niemann escribió:

> mm... usually \% should do the trick.
> testing..
> mmm?!?
>
> Without \ I get
> error(146): /tmp/Simple.g:3:17: invalid StringTemplate % shorthand
> syntax: '%'
> error(146): /tmp/Simple.g:2:10: invalid StringTemplate % shorthand
> syntax: '%'
>
> The first one is the 'expected' error. And it goes away when the % is
> escaped.
> The second error is nonsense... there is nothing at 2:10, line 2 is  
> empty -
> where does this come from?
>
> Strange...

Just discovered another inconsistency, again only shows up in the  
lexer-specific space:

// Next line is fine...
// \$Id$

@lexer::header {
// Next line triggers a StringTemplate error...
// \$Id$
}

@header {
// Next line is fine...
// \$Id$
}

Those are Id tags which get auto-updated by Subversion/SVK when  
committing. The backslash before the leading $ is necessary to  
suppress StringTemplate warnings. Just like in the example previously  
posted, the escaping doesn't work in the @lexer-specific section,  
except this time it's a "$" in the "header" section which is the  
issue rather than a "%" in the "members" section. And once again the  
line number information is way off.

Cheers,
Wincent



More information about the antlr-interest mailing list