If you have this expression: +x?
, it can be analyzed two ways :
Expression
-> operatorExpr : OperatorExpr
-> +
-> expression : Expression
-> exprPrimary : ExprPrimary = x
-> condExpr : ?
Expression
-> operatorExpr : OperatorExpr
-> +
-> expression : Expression
-> exprPrimary : ExprPrimary = x
-> condExpr : ?
The condExpr may be set at the top Expression or the inner one.
To solve the problem, you may leave only the second condExpr in your main rule. Anyway, it is the default way xtext will solve your ambiguity (meaning that with your current grammar it will choose the second parsing).
If you do the other way, leaving only the first condExpr, you get two problems: 1) grammar is still ambiguous for an OperatorExpression with an inner OperatorExpression (++x?
for example), and 2) x?
will not match anymore.