Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext problem concerning grammar
Xtext problem concerning grammar [message #657344] Wed, 02 March 2011 14:03 Go to next message
Mehdi Missing name is currently offline Mehdi Missing nameFriend
Messages: 22
Registered: December 2010
Junior Member
hi,

i have defined my grammar as follow :

...

Application_data :
{Application_data}
(Instance_name=INT)"="(Instance_desc=EString)?"("(Instance_value=EString)") ;"
;
...

the problem is that in my model i want to have something like this :

1002=(LENGTH_TYOE()UNIT(*)SI(.MILL.,.METRES.)) ;

but when i create a model i must add the " in the Instance_value so i have this or else there are errors in my model :

1002=("LENGTH_TYOE()UNIT(*)SI(.MILL.,.METRES.)") ;

my question is how should i do to write (or correcte ) my grammar so that i do not have to write the instance_value between the " in my model ?

thank you for your help and time.
Re: Xtext problem concerning grammar [message #657385 is a reply to message #657344] Wed, 02 March 2011 16:09 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Not sure I fully understood your question, but if what you want is a
String datatype that preserves the quotes you can acheive this with a
value/data converter (the default String converter strips quotes and
translates escape sequences etc. into a java-string). If you need both
kinds (with and without quotes), simply have two different data rules
with different converters.

If you add this rule:
QuotedString : STRING ;

And associte the value converters with the rule name "QuotedString". You
will then get the default if you assign a STRING directly, and you get
the quoted variant if using QuotedString.

Example
MyRule : myUnquotedFeature=STRING myQuotedFeature=QuotedString ;

- henrik


On 3/2/11 3:03 PM, Mehdi wrote:
> hi,
>
> i have defined my grammar as follow :
>
> ..
>
> Application_data :
> {Application_data}
> (Instance_name=INT)"="(Instance_desc=EString)?"("(Instance_value=EString) ")
> ;"
> ;
> ..
>
> the problem is that in my model i want to have something like this :
>
> 1002=(LENGTH_TYOE()UNIT(*)SI(.MILL.,.METRES.)) ;
>
> but when i create a model i must add the " in the Instance_value so i
> have this or else there are errors in my model :
>
> 1002=("LENGTH_TYOE()UNIT(*)SI(.MILL.,.METRES.)") ;
>
> my question is how should i do to write (or correcte ) my grammar so
> that i do not have to write the instance_value between the " in my model ?
>
> thank you for your help and time.
Re: Xtext problem concerning grammar [message #657430 is a reply to message #657344] Wed, 02 March 2011 18:50 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

and if I understand you correctly, you should use a datatype rule instead of EString. Consider the following rule for accepting positive and negative floats:

Float hidden(): '-'? INT ('.'INT);
It accepts 3, -3, 2.7,-13.237

So if the instance_value has some kind of structure, you could express it similarly.

Alex

Re: Xtext problem concerning grammar [message #657948 is a reply to message #657344] Fri, 04 March 2011 17:15 Go to previous message
Mehdi Missing name is currently offline Mehdi Missing nameFriend
Messages: 22
Registered: December 2010
Junior Member
Thank you both of you for your response they were very helpful.

Regards.
Previous Topic:Is there any maven repo for xtext?
Next Topic:Build and add hidden EObjects to XtextEditor at runtime...
Goto Forum:
  


Current Time: Fri Apr 26 02:38:04 GMT 2024

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

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

Back to the top