Skip to main content



      Home
Home » Modeling » TMF (Xtext) » How to use tree rewrite actions?
How to use tree rewrite actions? [message #54674] Thu, 02 July 2009 06:00 Go to next message
Eclipse UserFriend
Greetings!

I'm having a problem with some left recursive rules in my grammar. The
documentation gives a solution with left-factoring and tree rewrite rules
but it gives no further information on this subject. Does anyone know
where I can find more Information on these tree rewrite rules? Does it
have anything to do with the ANTLR rewrite rules?

Regards
Adalbert
Re: How to use tree rewrite actions? [message #54721 is a reply to message #54674] Thu, 02 July 2009 13:41 Go to previous message
Eclipse UserFriend
Hi Adalbert,

please have a look at the section about assigned actions. These are the
kind of "rewrite rules", that are supported by Xtext.

In fact, actions allow to create more than one EObject in a parser rule
and thereby you can insert new objects in your semantic model.

Consider the following grammar snippet:

Something:
First ({Second.field = current} 'foo')?

First:
name = ID;

The input "id" will create a semantic object of type 'First' that will
be returned by the rule something.

But if you have an input like "id foo", you'll end up with an instance
of 'First' that will be assigned to the feature 'field' of a second
instance of type "Second".

Actually, the documentation contains a more meaningful example :-)

Regards,
Sebastian

Am 02.07.2009 12:00 Uhr, schrieb Adalbert Gorecki:
> Greetings!
>
> I'm having a problem with some left recursive rules in my grammar. The
> documentation gives a solution with left-factoring and tree rewrite
> rules but it gives no further information on this subject. Does anyone
> know where I can find more Information on these tree rewrite rules? Does
> it have anything to do with the ANTLR rewrite rules?
>
> Regards
> Adalbert
>
Previous Topic:[Xtext] Problem modifying enumeration in post processing (Xtend)
Next Topic:Unicode literals in Xtext grammar
Goto Forum:
  


Current Time: Thu May 08 09:18:24 EDT 2025

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

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

Back to the top