Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Datatype rules(How datatype rules handle varied types)
Datatype rules [message #707536] Mon, 01 August 2011 15:38 Go to next message
Eclipse UserFriend
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 15:45 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Datatype rules [message #707544 is a reply to message #707539] Mon, 01 August 2011 15:52 Go to previous message
Eclipse UserFriend
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: Sat Jul 05 06:12:36 EDT 2025

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

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

Back to the top