Hi,
I'm having a little trouble with my grammar. Here I show a sample of my code.
Model:
'expression' expression=Expression
;
Expression:
Multiplication (({Plus.left=current} '+' | {Minus.left=current} '-') right=Multiplication)*
;
Multiplication:
Power (({Multi.left=current} '*' | {Div.left=current} '/') right=Power)*
;
Power:
PrimaryExpression (({Power.left=current} '^') right=PrimaryExpression)*
;
PrimaryExpression:
( FieldReference | MethodInvocation)
| Something
;
MethodInvocation :
method=[ecore::EObject]
;
FieldReference:
field=[ecore::EObject]
;
Something:
st='some rule'
;
I need to be able to place a sign "+" or "-" as prefix for FieldReference and MethodInvocation. I cannot write something like "sign=('+' | '-')" inside any of those rules because I use them in different parts of the grammar where the sign would make no sense. For example, with the recursive dot :
variable.FieldReference.MethodInvocation()
Also, I cannot place the sing before ( FieldReference | MethodInvocation) in the PrimaryExpression rule because I get "An unassigned rule call is not allowed, when the 'current' was already created".
How would you do this?
Thanks!