Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to use tree rewrite actions?
How to use tree rewrite actions? [message #54674] Thu, 02 July 2009 10:00 Go to next message
Adalbert Gorecki is currently offline Adalbert GoreckiFriend
Messages: 10
Registered: July 2009
Junior Member
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 17:41 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
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: Mon Jan 13 16:32:44 GMT 2025

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

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

Back to the top