[antlr-interest] Rookie problem

Adam Connelly adam.rpconnelly at googlemail.com
Thu Apr 3 09:31:53 PDT 2008


Not 100% on this, but I would guess that the "name" rule that's part of
"condition" is consuming the "then".  Basically if I'm right about this,
antlr thinks that the "then" keyword of the if statement is part of a name.

Unfortunately I don't know a solution for this of the top of my head.

Sorry,
Adam


On 03/04/2008, Marko Simovic <markobarko at gmail.com> wrote:
>
> Hi all,
>
> I've just started using Antlr and I'm having a bit of a problem with a
> grammar definiton. I want my grammar to support a language with multi-word
> variable names. However, making the adjustment breaks my if-then conditional
> recognition.
>
> The grammar at the end of this e-mail works fine for variable names
> without spaces. If i change the 'name' definition to the following:
>
> name: String (' ' String)*;
>
> then the 'if' statement can no longer be recognized. What am i doing
> wrong?
>
> Thanks,
> Marko
>
> grammar test;
>
> String : ('a'..'z' | 'A'..'Z')+;
>
> ConditionOperator
> : '<' | '>';
>
> name
> : String;
>
> condition
> : name (ConditionOperator name)*;
> selection
> : 'if' condition 'then' condition;
>
> statement
> : selection;
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080403/6af4d6d4/attachment.html 


More information about the antlr-interest mailing list