Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Datatype rules(How datatype rules handle varied types)
Datatype rules [message #707536] Mon, 01 August 2011 19:38 Go to next message
sungam  is currently offline sungam Friend
Messages: 21
Registered: March 2010
Junior Member
I have a grammar like:


grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

import "http://www.eclipse.org/emf/2002/Ecore" as ecore

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
greetings+=Greeting*;

Greeting:
'Hello' name=ID '!'
'Person:'value=ConstantValue;

ConstantValue:
value=(BooleanType | NullObjectType );

NullObjectType returns ecore::EJavaObject:
NULL_CONSTANT;

BooleanType returns ecore::EBoolean:
BOOLEAN_CONSTANT;

terminal BOOLEAN_CONSTANT returns ecore::EBoolean:
'true' | 'false';

terminal NULL_CONSTANT:
'null';

----------------

The above grammar shows errors, at the rule ConstantValue.

Seems like this could be because of the individual data type rules used within, each of which return different types.

Could someone advice how this can be handled in xtext2.0?

Thanks
Re: Datatype rules [message #707539 is a reply to message #707536] Mon, 01 August 2011 19:45 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13882
Registered: July 2009
Senior Member
Hi,

there is not type the value can be of => you have to split the constant up
ConstantValue: BooleanValue | NullValue;

BooleanValue: value=BooleanType;

NullValue: value=NullObjectType;


~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: Datatype rules [message #707544 is a reply to message #707539] Mon, 01 August 2011 19:52 Go to previous message
sungam  is currently offline sungam Friend
Messages: 21
Registered: March 2010
Junior Member
Wonderful, that worked.
Thanks
Previous Topic:How can I allow any character for a particular type
Next Topic:Content Assist error
Goto Forum:
  


Current Time: Tue Apr 13 19:13:35 GMT 2021

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

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

Back to the top