[antlr-interest] Escape chars in templates within grammar files

Xavier xverges at gmail.com
Mon Jan 21 11:59:43 PST 2008


I'm using
options {
        language=CSharp;
        output=template;
        rewrite=true;
}
and would like to use new lines in the templates that are inlined in
the grammar file.

My understanding was that I should use <\n> in the template, but it is
causing an error:

ANTLR Parser Generator  Version 3.0.1 (August 13, 2007)  1989-2007
    error(10):  internal error: LineTest.g : LineTest.g:29:17:
expecting '"', found 'n'
    org.antlr.tool.ANTLRLexer.nextToken(ANTLRLexer.java:321)
    antlr.TokenStreamRewriteEngine.nextToken(TokenStreamRewriteEngine.java:161)
    ...

(LineTest.g:29:17 is the "n" in <\n>)
line:	foo NewLine -> template()
			       "LINE<\n>";

Am I missing something, or is this a bug? And if it is, any suggestion
to bypass it?

Thanks in advance.

-Xavier


More information about the antlr-interest mailing list