Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Expression ordering
Expression ordering [message #1027347] Tue, 26 March 2013 22:02 Go to next message
Robert Heath is currently offline Robert Heath
Messages: 12
Registered: October 2012
Location: San Mateo
Junior Member
Thank you in advance for your patience with my string of posts Smile

I have a general question about the ordering of actions in a rule body.

Say I have 2 lists I'm appending to in a rule:

(
list1+=type1 |
list2+=type2
)*

Without create a superclass that represents both types and a single list to store them in, is there a way to allow these types of expressions to be interleaved in a grammar? Creating a single list isn't very practical for use at runtime in some cases, and only allowing instances of each time in a contiguous sequence is restrictive on the grammar. One approach is to generate a new model based on the model used for parsing, but a big bonus for using xtext is the automated serializer.

2nd question, I think the best approach is to handle this in a validator, BUT I thought I'd ask just for the sake of it. If the existence of an element of the grammar depends on the existence of something else in the grammar, but they can be in any order, is there a way to enforce this syntax in the parser?
Re: Expression ordering [message #1032133 is a reply to message #1027347] Tue, 02 April 2013 15:59 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian Zarnekow
Messages: 2908
Registered: July 2009
Senior Member
Hi Robert,

no, there is no straight forward way to achieve that. You may want to
digg into feature maps or use EObject as the common super-type.

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 26.03.13 23:02, schrieb Robert Heath:
> Thank you in advance for your patience with my string of posts :)
>
> I have a general question about the ordering of actions in a rule body.
>
> Say I have 2 lists I'm appending to in a rule:
>
> (
> list1+=type1 |
> list2+=type2
> )*
>
> Without create a superclass that represents both types and a single list
> to store them in, is there a way to allow these types of expressions to
> be interleaved in a grammar? Creating a single list isn't very
> practical for use at runtime in some cases, and only allowing instances
> of each time in a contiguous sequence is restrictive on the grammar.
> One approach is to generate a new model based on the model used for
> parsing, but a big bonus for using xtext is the automated serializer.
> 2nd question, I think the best approach is to handle this in a
> validator, BUT I thought I'd ask just for the sake of it. If the
> existence of an element of the grammar depends on the existence of
> something else in the grammar, but they can be in any order, is there a
> way to enforce this syntax in the parser?
Re: Expression ordering [message #1032175 is a reply to message #1032133] Tue, 02 April 2013 16:58 Go to previous message
Robert Heath is currently offline Robert Heath
Messages: 12
Registered: October 2012
Location: San Mateo
Junior Member
Thanks Sebastian, I figured that was the case.
Previous Topic:No src_gen code are automatically generated for the ".dmodel" file in the "domain-mod
Next Topic:Why there is an additional ".smap" file when code are automatically generated?
Goto Forum:
  


Current Time: Fri Oct 24 08:39:06 GMT 2014

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

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