I implemented a fix for this as follows:<br><br><i>rewrite_template<br> : // -> template(a={...},...) "..." inline template<br> {input.LT(1).getText().equals("template")}?<br> id lp='(' rewrite_template_args ')'<br>
rewrite_template_quote<br> -> ^(TEMPLATE[$lp,"TEMPLATE"] id rewrite_template_args rewrite_template_quote)</i><br> | ...<br><br>And<br><br><i>rewrite_template_quote: DOUBLE_QUOTE_STRING_LITERAL | DOUBLE_ANGLE_STRING_LITERAL ;</i><br>
<br><br>And a similar change in ANTLRv3Tree.g<br><br>No sure if this is 'the' correct way to do this, but for so far it seems to work.<br><br>Jens<br><br><div class="gmail_quote">2008/7/8 Jens Boeykens <<a href="mailto:jens.boeykens@gmail.com">jens.boeykens@gmail.com</a>>:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Actually I still get an error whit this lexer rule, both in my project and in antlrworks. It parses the quotes now, but at the end it throws an exception as output:<br>
<br>Exception in thread "main" org.antlr.runtime.tree.RewriteEmptyStreamException: token st<br>
at org.antlr.runtime.tree.RewriteRuleElementStream._next(RewriteRuleElementStream.java:158)<br> at org.antlr.runtime.tree.RewriteRuleTokenStream.next(RewriteRuleTokenStream.java:57)<br> at stage.antlr.regeneration.grammar.ANTLRv3Parser.rewrite_template(ANTLRv3Parser.java:10135)<br>
at stage.antlr.regeneration.grammar.ANTLRv3Parser.rewrite_alternative(ANTLRv3Parser.java:8446)<br> at stage.antlr.regeneration.grammar.ANTLRv3Parser.rewrite(ANTLRv3Parser.java:8069)<br> at stage.antlr.regeneration.grammar.ANTLRv3Parser.altList(ANTLRv3Parser.java:3855)<br>
at stage.antlr.regeneration.grammar.ANTLRv3Parser.rule(ANTLRv3Parser.java:2460)<br> at __Test__.main(__Test__.java:16)<br><br>It doesn't specifically occurs with the quotes '"'. The angles '<<' '>>' throw the same exception...<br>
<br>Is there something wrong with my input?<br><br>r : a -> template() "this is a temp"; <br>r : a -> template() <<this is a temp>>; <br><br><br>Jens<br><br><br><div class="gmail_quote">2008/7/7 Terence Parr <<a href="mailto:parrt@cs.usfca.edu" target="_blank">parrt@cs.usfca.edu</a>>:<div>
<div></div><div class="Wj3C7c"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Wow... that freaked me out for a second... it turns out that there is a lexer error, which both of us fail to see; I clicked on the output tab and saw it. fix with this<br>
<br>
DOUBLE_QUOTE_STRING_LITERAL<br>
: '"' (ESC | ~('\\'|'"'))* '"'<br>
;<br>
<br>
<br>
Ter<div><div></div><div><br>
<br>
On Jul 7, 2008, at 12:02 PM, Jens Boeykens wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello all,<br>
<br>
I'm have an issue with parsing a particular input with ANTLRv3.g (<a href="http://www.antlr.org/grammar/ANTLR" target="_blank">http://www.antlr.org/grammar/ANTLR</a>).<br>
I'm trying to parse the following rule:<br>
<br>
r : a -> template() "Some test";<br>
<br>
This however doesn't parse, but I can't find a bug in ANTLRv3.g or a mistake in my input rule. Using ANTLRworks it seems to parse well until template() and than the match fails. Don't know what could be wrong with "..." though.<br>
<br>
Greetings<br>
</blockquote>
<br>
</div></div></blockquote></div></div></div><br>
</blockquote></div><br>