Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » JvmFormalParameter rule ambigouous?
JvmFormalParameter rule ambigouous? [message #905501] Thu, 30 August 2012 14:01 Go to next message
Marcus Mathioudakis is currently offline Marcus MathioudakisFriend
Messages: 18
Registered: June 2012
Junior Member
I have a simple little grammar which keeps giving a multiple alternatives error when I try to generate Xtext artefacts.
The grammar is:

grammar org.xtext.example.hyrule.HyRule with org.eclipse.xtext.xbase.Xbase

generate hyRule (You can only use links to eclipse.org sites while you have fewer than 25 messages )

Start:
	rules+=Rule+
	;
	
Rule:
	'FOR''PAYLOAD'payload=PAYLOAD'ELEMENTS' elements+=JvmFormalParameter+'CONSTRAINED' 'BY' expressions+= XExpression*;

PAYLOAD:
	"Stacons"|"PFResults"|"any"
;



And the exact error I get is:
warning(200): ../org.xtext.example.hyrule/src-gen/org/xtext/example/hyrule/parser/antlr/internal/InternalHyRule.g:3197:2: Decision can match input such as "{RULE_ID, '=>', '('}" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
error(201): ../org.xtext.example.hyrule/src-gen/org/xtext/example/hyrule/parser/antlr/internal/InternalHyRule.g:3197:2: The following alternatives can never be matched: 2


I have attached the Syntax diagram for the generated antlr grammar in antlrworks, and can clearly see the multiple alternatives(JvmFormalParameter can match RULE_ID via the JvmTypeReference or the ValidID rule).

So it looks as if JvmFormalParameter is ambiguous...Apologies for my stupidity but could someone point out what it is I'm missing? Is there some way of overcoming this ambiguity when using the JvmFormalParameter rule in my grammar?




Re: JvmFormalParameter rule ambigouous? [message #905831 is a reply to message #905501] Fri, 31 August 2012 06:56 Go to previous message
Marcus Mathioudakis is currently offline Marcus MathioudakisFriend
Messages: 18
Registered: June 2012
Junior Member
Solution Courtesy of Sebastian Zarnekow:
Problem solved by using a delimiter, for example elements+=JvmFormalParameter (',' elements+=JvmFormalParameter)*
Previous Topic:quick fix that uses templates?
Next Topic:Generating complex enum literals
Goto Forum:
  


Current Time: Sun Feb 23 14:54:39 GMT 2020

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

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

Back to the top