|
|
|
|
|
|
Re: How to build multiple entities in one rule? [message #1007011 is a reply to message #1006763] |
Sun, 03 February 2013 21:56 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
We have a rather elegant hook for such things. Your entry point for code
archeology is the org.eclipse.xtext.resource.DerivedStateAwareResource
The basic idea is: A resource can have multiple root elements. The first
one is the one produced by the Xtext parser, the remaining ones are
somehow derived from that during linking. This "derived state" is
discarded and recomputed everytime the parsed model changes.
So you have to
- implement your own IDerivedStateComputer that creates the missing
elements representing the declarations
- bind it in your runtime modulre
- bind DerivedStateResource for your models.
Am 01.02.13 18:34, schrieb Alexandre Frey:
> Hello:
>
> How would you handle this situation: I want to parse blocks of
> statements mixed with variable declarations. Something like this:
> {
> var y = x+z;
> z = 3;
> var z;
> }
>
> The line "var y = x + z;" is a shortcut for: "var y; y = x + z;"
>
> I'd like this equivalence to be reflected in the model: the model should
> define a class Block that contains a list of variable names and a list
> of statements. So, the line "var y = x + z" should produce both a
> variable declaration and a statement.
>
> How would you suggest to proceed in Xtext in this situation?
>
> Thanks, -- Alexandre.
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
|
Powered by
FUDForum. Page generated in 0.03788 seconds