[antlr-interest] Escaping percentage character in lexer::header

Bart Kiers bkiers at gmail.com
Tue Jan 3 02:32:42 PST 2012


Although an error is printed to the stdout, doing:

@lexer::header {
  /* \% */
}

_does_ generate a lexer with `/* % */` placed at the start of the file.

I didn't get something working without an error though...

Regards,

Bart.


2012/1/3 Robert Gründler <r.gruendler at gmail.com>

> Hi,
>
> i'm unable to add String literals to the lexer::header section of my
> grammar, as it throws an
> invalid StringTemplate % shorthand syntax: '%s'exception.
>
> There's a thread in the list where Terence Parr replies:
>
> lexer *actions* and lexer::header stuff with % were recently
> discovered to require some kind of double escape ;)
>
>
> I've tried all sorts of escaping strategies, but i can't find a way to do
> it properly.
>
> Can anyone clarify how to escape percentage characters in lexer::header
> blocks of a grammar?
>
> regards
>
>
> -robert
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list