Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » (newbie) Rule error on CrossReferences(CrossReferences help)
(newbie) Rule error on CrossReferences [message #1770173] Tue, 08 August 2017 20:14 Go to next message
Sheshadri Mantha is currently offline Sheshadri ManthaFriend
Messages: 2
Registered: August 2017
Junior Member
Hello,
I'm new to DSL and even to EBNF (I can read it fine and am learning how to write).

I'm getting the following error:
warning(200): ../org.unjaana.geegee/src-gen/org/unjaana/geegee/parser/antlr/internal/InternalGeeGeeDSL.g:524:3: 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.unjaana.geegee/src-gen/org/unjaana/geegee/parser/antlr/internal/InternalGeeGeeDSL.g:524:3: The following alternatives can never be matched: 2


My rule is:
Instr: 
	'Create' (element=[Node] | element=[Edge]) 
	('min' minCount=INT)?
	'max' maxCount=INT 

Where Node and Edge are other classes in the same DSL and defined as:
Node:
	'node'  name=ID;

Edge:
	'edge' name=ID 
	'from' from = [Node]
	'to' to = [Node]
	'multiplicity' multi = Multiplicity;


What am I doing wrong?

Thanks,
Sheshadri
Re: (newbie) Rule error on CrossReferences [message #1770392 is a reply to message #1770173] Thu, 10 August 2017 16:12 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 12243
Registered: July 2009
Senior Member
(element=[Node] | element=[Edge])

is short for

(element=[Node|ID] | element=[Edge|ID])

which means it will be parsed as


(element=ID| element=ID)

which im ambigous.

you can introduce a common supertype for Node and Edge and use that one for the reference

NodeOrEdge: Node | Edge; // uncalled rule
Instr:
'Create' (element=[NodeOrEdge])
....


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: (newbie) Rule error on CrossReferences [message #1770455 is a reply to message #1770392] Fri, 11 August 2017 17:46 Go to previous message
Sheshadri Mantha is currently offline Sheshadri ManthaFriend
Messages: 2
Registered: August 2017
Junior Member
Thank you Christian - your reply explains the issue I faced very well.

I already had a common supertype called "Type" and when I used that and it worked.
Previous Topic:Xtext 2.12 migration issue (ComputationExceptionStackOverflow)
Next Topic:new project with Oxygen and xtext 2.12
Goto Forum:
  


Current Time: Tue Sep 25 14:34:05 GMT 2018

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

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

Back to the top