Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Value Converters in Xtext(Value Converters in Xtext)
icon5.gif  Value Converters in Xtext [message #1114705] Mon, 23 September 2013 05:15 Go to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hello all,
Can we use Value Convertes in xtext for the rules which are not terminal?
If yes then , Can someone let me know how do I do it ?

Thanks in advance Smile


Arshad
Re: Value Converters in Xtext [message #1114711 is a reply to message #1114705] Mon, 23 September 2013 05:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi

I guess you are not talking about data type rules (which are actually
parsed)

For the rest: no.

Can you give some more hints on your usecase

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Value Converters in Xtext [message #1114718 is a reply to message #1114711] Mon, 23 September 2013 05:39 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Christian,
Thanks for your reply Smile
Ok Let me explain you my use case,

I have a grammar something like:

SomeExpression:
SomeOtherExpr (rest part of the grammar);

SomeOtherExpr:
SomeAnotherExpr (rest part of the grammar);

SomeAnotherExpr:
INT | DOUBLE| LONG ;

For me , SomeExpression rule will return some value at the end which I am interested in.
So can I write the value converter for SomeExpression ?

Thanks in advance Smile


Arshad
Re: Value Converters in Xtext [message #1114723 is a reply to message #1114718] Mon, 23 September 2013 05:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

the problem is; your snippet is incomplete, you dont use assignments, so i cannot say.
if you dont use assignment then rulecalls mean "is a" and thus inheritance

SomeOtherExpr:
value=SomeAnotherExpr (rest part of the grammar);

SomeAnotherExpr:
INT | DOUBLE| LONG ;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Value Converters in Xtext [message #1114751 is a reply to message #1114723] Mon, 23 September 2013 06:42 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Christian,
I missed one point.
In my grammar, I have the assignment like:
value=SomeExpression
And this SomeExpression has sub rules and assignments as written above.
I want to write a value Converter for this SomeExpression. I tried writing it. The method is getting called but I get string as null value in toValue(final String string, final INode node) method.
Any suggestions??

Thanks in advance Smile


Arshad
Re: Value Converters in Xtext [message #1114755 is a reply to message #1114751] Mon, 23 September 2013 06:46 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Please show all relevant parts of the grammar.
Strip it down to a simple example grammar.

Please note: do not use any assignments In datatye rules.BTW your
type is string (the grammar snippet indicates that)

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Two similar rules, but with different cross-references
Next Topic:URIImport of a non-xtext resource and referencing of its declared objects
Goto Forum:
  


Current Time: Fri Apr 19 22:32:27 GMT 2024

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

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

Back to the top