[AText] a question releated to removing left recursion. [message #46444] |
Fri, 29 May 2009 10:39  |
Eclipse User |
|
|
|
Hi,
I have just read the document of XText: http://wiki.eclipse.org/Xtext/Documentation#Tree_Rewrite_Act ions. The following is an excertpion of the
text which is related to removing left recursion:
------------------------------------------------------------ ------------------------
Expression :
TerminalExpression ({Operation.left=current} op='+' right=TerminalExpression)?;
TerminalExpression returns Expression:
'(' Expression ')' |
{IntLiteral} value=INT;
------------------------------------------------------------ --------------------------
I have no idea of 'Operation'. Why do we need operation here? For example, my metamodel is already like so :
expresion{
left: expression
op: InfixedOp // InfixedOp is an enum
right:expression
}
I know this is left-recursive, however in removing this left recursive, I do not want to modify this metamodel or introduce any other unwanted
EObject. What can I do?
Cheers.
Michael
|
|
|
Re: [AText] a question releated to removing left recursion. [message #46532 is a reply to message #46444] |
Fri, 29 May 2009 16:47  |
Eclipse User |
|
|
|
Metamodels are not left recursive but grammars are.
You don't have to change your metamodel.
The {Operation.left=current} expression is an action which creates a new
instance of type Operation.
In your case the type is expression so it would be
{expression.left=current}.
That's it.
Cheers,
Sven
Michael schrieb:
> Hi,
> I have just read the document of XText:
> http://wiki.eclipse.org/Xtext/Documentation#Tree_Rewrite_Act ions. The
> following is an excertpion of the text which is related to removing left
> recursion:
> ------------------------------------------------------------ ------------------------
>
> Expression :
> TerminalExpression ({Operation.left=current} op='+'
> right=TerminalExpression)?;
>
> TerminalExpression returns Expression:
> '(' Expression ')' |
> {IntLiteral} value=INT;
> ------------------------------------------------------------ --------------------------
>
>
> I have no idea of 'Operation'. Why do we need operation here? For
> example, my metamodel is already like so :
> expresion{
> left: expression
> op: InfixedOp // InfixedOp is an enum
> right:expression
> }
> I know this is left-recursive, however in removing this left
> recursive, I do not want to modify this metamodel or introduce any other
> unwanted EObject. What can I do?
>
>
> Cheers.
> Michael
|
|
|
Powered by
FUDForum. Page generated in 0.24146 seconds