Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » using multiple alternatives - but there are no alternatives?!?!
using multiple alternatives - but there are no alternatives?!?! [message #714336] Wed, 10 August 2011 11:03 Go to next message
Robin  is currently offline Robin Friend
Messages: 25
Registered: August 2010
Junior Member
Hi,

so I got another stupid question, but I totally don't get it. Please help me!

I have the following grammar:
Model:

	(examples+=Example)*;

Example : 
	
 	{Example} // to get rid of the compiler warning
	(
	'exampleToken'
	exampleTokens+=ID
	'end'
	)*
	
	(
	'meaningToken'
	meaningTokens+=ID
	'end'
	)*
	;



And it gives the errors:
Decision can match input such as "{EOF, 'exampleToken', 'meaningToken'}" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input

The following alternatives are unreachable: 2

Decision can match input such as "'exampleToken'" using multiple alternatives: 1, 2

Decision can match input such as "'meaningToken'" using multiple alternatives: 1, 2


How? Why? It is just two sequential list of elements that can be repeated. What am I doing wrong??

Regards, Robin
Re: using multiple alternatives - but there are no alternatives?!?! [message #714340 is a reply to message #714336] Wed, 10 August 2011 11:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13887
Registered: July 2009
Senior Member
Hi,

there are,

if you have multiple exampleToken/meaningToken do you create one example with multiple stuff within one many examples with one stuff within

=> so what separates the examples?

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: using multiple alternatives - but there are no alternatives?!?! [message #714537 is a reply to message #714340] Wed, 10 August 2011 18:50 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

and just in case Christian's answer was not clear enough, consider two consecutive exampleTokens. Is that one example with two tokens or are they two examples with one token each. As Christian points out, there is nothing that marks the end of one example (something like a semicolon or a "endExample"-keyword).

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: using multiple alternatives - but there are no alternatives?!?! [message #714750 is a reply to message #714336] Thu, 11 August 2011 12:43 Go to previous messageGo to next message
Robin  is currently offline Robin Friend
Messages: 25
Registered: August 2010
Junior Member
Hmmm! Thanks so much for the responses. I understand what you are saying, but when there's something else coming after 'meaningToken' then this should be the indicator that the example has ended. Why is that not enough? Sadly, that is the only indicator I have. Now I am not sure if my language will be compliant to EBNF...
When we are in the meaningToken loop there's no alternative to meaningToken except for ending the Example structure and then either have another Example or what is following (which is EOF in the grammar I originally stated).

I mean something like (very poor pseudo language):
exampleToken // first example start
exampleToken
exampleToken
meaningToken
exampleToken // second example start
meaningToken
meaningToken
meaningToken


Btw, I also want to chain the exampleTokens and meaningTokens together. So my goal is to transfer something like the above structure into a list of Examples consisting of an example and meaning String entry. Maybe I should look into xtext 2.0 for concatenating those tokens back together?

Regards, Robin
Re: using multiple alternatives - but there are no alternatives?!?! [message #714759 is a reply to message #714750] Thu, 11 August 2011 12:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13887
Registered: July 2009
Senior Member
Hi,

the question is:
what should this become?
exampleToken
exampleToken


~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: using multiple alternatives - but there are no alternatives?!?! [message #715150 is a reply to message #714336] Fri, 12 August 2011 14:40 Go to previous message
Robin  is currently offline Robin Friend
Messages: 25
Registered: August 2010
Junior Member
You asked the right question, Christian. Thank you so much!
The structure
exampleToken
exampleToken

cannot stand on it's own. It has to be followed by a (or to be specific at least one) meaningToken. The quantifier was wrong - if I ever get stuff done right the first time in xtext without bothering you guys I will throw a huge party... Wink

So, the correct grammar is ofc:

Model:

	(examples+=Example)+;
	
Example : 
	
 	{Example}
	(
	'exampleToken'
	exampleTokens+=ID
	'end'
	)+
	
	(
	'meaningToken'
	meaningTokens+=ID
	'end'
	)+
	;


I am still wondering though if I could use xtext 2.0 to easily chain the single exampleTokens to one string together...

Regards, Robin
Previous Topic:Re: Access a feature in a Xtext Model
Next Topic:[xbase/xcore] infer and refer to constructor
Goto Forum:
  


Current Time: Wed Apr 21 06:13:53 GMT 2021

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

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

Back to the top