[antlr-interest] is a non unique reference - error when trying to fix
Johannes Luber
jaluber at gmx.de
Sat May 3 07:13:36 PDT 2008
Hed Bar-Nissan schrieb:
> I get on this:/
> question: 'question:' WS SENTANCE ';;' WS
> 'answer:' WS SENTANCE ';;'
> {System.out.print("Question is" + $SENTANCE.getText() + ", Answer is
> " + $SENTANCE.getText());} ;/
>
> SENTANCE is a non unique reference which is fair,
I'd like to point out that one spells "sentence", not "sentance".
>
> but when i try to fix like i found here:
> http://www.antlr.org/pipermail/antlr-interest/2008-April/027854.html/
> {System.out.print("Question is" + $SENTANCE1.getText() + ", Answer
> is " + $SENTANCE2.getText());} ;
> /
> Generation succeeds but i get a compilation error because these lines
> are not generated:
> Token SENTANCE1=(Token)input.LT(1);
>
> A bug or misuse?
You didn't use labels correctly. Try
question: 'question:' WS s1=SENTENCE ';;' WS
'answer:' WS s2=SENTENCE ';;'
{System.out.print("Question is" + $s1.getText() + ", Answer is
" + $s2.getText());} ;
Instead "getText()" "text" should work, too, and is the preferred syntax.
Johannes
More information about the antlr-interest
mailing list