[antlr-interest] Can't get "\<" to work in inline template rule?
Peter Nann
peter.nann at vecommerce.com.au
Wed Apr 16 06:54:18 PDT 2008
Oh, I have just got it to work using the "<<" and ">>" delimiters, which
seem to be directly replacable in place of double-quotes, even on a
single line.
But the lack of support in the double-quoted format is a bug, yes?
________________________________
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Peter Nann
Sent: Wednesday, 16 April 2008 11:41 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Can't get "\<" to work in inline template
rule?
Just starting out with what I hope should be a simple translator...
For now, as a start, I am simply trying to turn:
[ a ]
Into:
<one-of> a </one-of>
But I can't get an angle bracket verbatim in the output!!!
In the code below, you will see I am only trying to produce the first
'<'.
Simply escaping the '<' does not seem to work as advertised...
I have tried double, triple escaping, to no avail.
- Take the "\<" out of this grammar, and it works fine.
Please help, I am a little dissappointed to have run into trouble so
early...
Woe is me...
Here's my Test.g file:
---- Test.g ----
grammar Test;
options {output=template; rewrite=true;}
gslfile : orlist ;
orlist
: '[' WORD ']'
-> template(oi={$WORD.text}) "\<one-of <oi> /one-of"
;
WORD : ('a'..'z'|'-'|'_'|'\'') ('a'..'z'|'-'|'_'|'\'')* ;
WS : ( ' ' | '\t' | '\r' | '\n' )+ {$channel = HIDDEN;} ;
-----------------------------------------
And here's the error output:
ANTLR Parser Generator Version 3.0.1 (August 13, 2007) 1989-2007
error(10): internal error: Test.g : Test.g:8:34: expecting '"', found
'<'
org.antlr.tool.ANTLRLexer.nextToken(ANTLRLexer.java:321)
antlr.TokenStreamRewriteEngine.nextToken(TokenStreamRewriteEngine.java:1
61)
antlr.TokenBuffer.fill(TokenBuffer.java:69)
antlr.TokenBuffer.LT(TokenBuffer.java:86)
antlr.LLkParser.LT(LLkParser.java:56)
org.antlr.tool.ANTLRParser.rewrite_template(ANTLRParser.java:3306)
org.antlr.tool.ANTLRParser.rewrite_alternative(ANTLRParser.java:3177)
org.antlr.tool.ANTLRParser.rewrite(ANTLRParser.java:1885)
org.antlr.tool.ANTLRParser.altList(ANTLRParser.java:1451)
org.antlr.tool.ANTLRParser.rule(ANTLRParser.java:1236)
org.antlr.tool.ANTLRParser.rules(ANTLRParser.java:655)
org.antlr.tool.ANTLRParser.grammar(ANTLRParser.java:389)
org.antlr.tool.Grammar.setGrammarContent(Grammar.java:521)
org.antlr.tool.Grammar.<init>(Grammar.java:456)
org.antlr.Tool.getGrammar(Tool.java:331)
org.antlr.Tool.process(Tool.java:267)
org.antlr.Tool.main(Tool.java:70)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080416/6923a664/attachment-0001.html
More information about the antlr-interest
mailing list