[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.modeling.tmf] Re: Removing left recursion...
|
Hi Henrik,
one left recursion is in TerminalArithmeticExpression which can be a
BinaryArithmenticExpression which can again be a
TerminalArithmeticExpression etc.
Note that in LL grammars (i.e. those that don't like left recursion) one
also defines the precedence of operators using the left factoring.
This is a typical example of how one creates non-left recursive
mathmatical expressions, for instance:
Add :
Multi ('+' Multi)*;
Multi :
Primary ('*' Primary)*;
Primary :
NUMBER |
'(' Add ')';
Hope that helps,
Sven
TerminalArithmeticExpression returns LogicExpression: var=ID
| number=INT
| BinaryArithmeticExpression
| UnaryArithmeticExpression | '('
TerminalArithmeticExpression ')'
;
BinaryArithmeticExpression:
expression=TerminalArithmeticExpression ({Operation.left=current}
op=ArithmeticBinOperator)?;
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com