Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [AText] a question releated to removing left recursion.
[AText] a question releated to removing left recursion. [message #46444] Fri, 29 May 2009 10:39 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:Cross reference items not available in .chk files
Next Topic:[xtext] abstract types
Goto Forum:
  


Current Time: Sun Jul 13 09:14:23 EDT 2025

Powered by FUDForum. Page generated in 0.24146 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top