Skip to main content



      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 07:03 Go to next message
Eclipse UserFriend
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 07:20 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: using multiple alternatives - but there are no alternatives?!?! [message #714537 is a reply to message #714340] Wed, 10 August 2011 14:50 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: using multiple alternatives - but there are no alternatives?!?! [message #714750 is a reply to message #714336] Thu, 11 August 2011 08:43 Go to previous messageGo to next message
Eclipse UserFriend
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 08:59 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

the question is:
what should this become?
exampleToken
exampleToken


~Christian
Re: using multiple alternatives - but there are no alternatives?!?! [message #715150 is a reply to message #714336] Fri, 12 August 2011 10:40 Go to previous message
Eclipse UserFriend
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: Sun Jul 27 10:12:25 EDT 2025

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

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

Back to the top