[antlr-interest] Syntactic Predicate does not work but Backtracking does

Alexander Gängel alexander at gaengel.de
Mon Mar 3 06:24:06 PST 2008


Sorry then I don't understand how Syntactic Predicates are working.

What I want is the possibility to have an expression or expression comma 
followed by another expression, but the number of comma Expression is 
not defined.

Alexander

Terence Parr schrieb:
>  those rules are totally different.  One has an alternative and the 
> other does not.
> Ter
> On Mar 1, 2008, at 1:00 AM, Alexander Gängel wrote:
>
>> sorry I send a wrong copy of the first version it should be:
>>
>> expression_comma options
>>     :(
>>     (expression COMMA)=>expression COMMA expression_comma 
>> ->expression expression_comma
>>     |expression->expression
>>     )
>>     ;
>>
>> Alexander Gängel schrieb:
>>>
>>> I have a rule in my grammar like this:
>>> expression_comma options
>>>     :(
>>>     (expression COMMA)=>expression (COMMA expression_comma)? 
>>> ->expression expression_comma?
>>>     |expression->expression
>>>     )
>>>     ;
>>>
>>> my some Input like expression, expression does not work even when 
>>> both parts left and rigth of the comma are expressions.
>>>
>>> if I use this rule with backtracking it works.
>>> oclExpression_comma options {backtrack=true;}
>>>     :
>>>     oclExpression (COMMA oclExpression_comma)? ->oclExpression 
>>> oclExpression_comma?
>>>     ;
>>>
>>> Am I wrong or should both work all right?
>>> Alexander
>
>


More information about the antlr-interest mailing list