|Syntactic sugar with assigned actions [message #1256294]
||Tue, 25 February 2014 09:29
| Daniels Umanovskis
Registered: February 2014
I'm working with a more complex grammar, but my case can be boiled down to the following example.|
Suppose I have Foo objects and Bar objects that my DSL can describe. Foo objects are standalone, Bar objects are created to correspond to Foo objects, so the grammar is like:
'foo' name = ID
//some optional parameters
'bar' 'for' nameLink = ID ('as' name = ID)?
BarExpression uses the ID terminal and not a proper cross-link to Foo because that's a constraint in my actual use-case, but that should not be relevant here.
So this grammar lets you write things like:
bar for myFoo1 as myBar1
bar for myFoo2
Now, I would like to also have a syntactic sugar element that would translate to creating a Foo and a Bar for it. That is, I imagine I would write:
and that would exactly correspond to
bar for myFoo3
The impression I got from Xtext's doc is that assigned actions are for creating and assigning objects of other rules, so my guess at the grammar element was:
That's not a valid element though, and in fact it seems like accessing fields of current is not possible.
How do I define my syntactic sugar element correctly?
[Updated on: Tue, 25 February 2014 13:31]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01608 seconds