Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » XCORE and XTEXT Grammar(XCORE and XTEXT Grammar)
icon5.gif  XCORE and XTEXT Grammar [message #1078570] Sat, 03 August 2013 07:07 Go to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi,
I am using .xcore file as meta model for my grammar, which looks something like this,

class Sample{
Integer bit
....
.....
....
}

And my grammar:
Sample:
'Sample'....
....

('BIT' | 'BYTE') bit=INT

This "bit=INT" I am referring from my xcore model.
MY PROBLEM IS THAT I WANT TO EITHER TYPE "BIT AND THEN BIT VALUE" OR "BYTE AND THEN BYTE VALUE" IN MY LANGUAGE.
BUT WHEN I WRITE "BYTE AND BYTE VALUE" , I AM CONVERTING BITS INTO BYTES AND THEN STORING IT IN SAME METAMODEL FIELD "bit".
SO LATER WHEN I READ THE "RESOURCE" I WILL GET THE BIT VALUE BUT I AM UNAWARE WHETHER IT IS "BIT OR BYTE"...
"I DON'T WANT TO STORE ONE MORE VARIABLE FOR BYTE IN XCORE".
CAN ANYONE HELP ME OUT WITH THIS PROBLEM ? OR ANY BETTER SUGGESTIONS FOR THIS ??
Thanks in advance ! Smile


Arshad
Re: XCORE and XTEXT Grammar [message #1078612 is a reply to message #1078570] Sat, 03 August 2013 08:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Arshad,

Comments below.

On 03/08/2013 9:04 AM, Arshad Adavani wrote:
> Hi,
> I am using .xcore file as meta model for my grammar, which looks
> something like this,
>
> class Sample{
> Integer bit
> ...
> ....
> ...
> }
>
> And my grammar:
> Sample:
> 'Sample'....
> ...
>
> ('BIT' | 'BYTE') bit=INT
> This "bit=INT" I am referring from my xcore model.
> MY PROBLEM IS THAT I WANT TO EITHER TYPE "BIT AND THEN BIT VALUE" OR
> "BYTE AND THEN BYTE VALUE" IN MY LANGUAGE.
> BUT WHEN I WRITE "BYTE AND BYTE VALUE" , I AM CONVERTING BITS INTO
> BYTES AND THEN STORING IT IN SAME METAMODEL FIELD "bit".
> SO LATER WHEN I READ THE "RESOURCE" I WILL GET THE BIT VALUE BUT I AM
> UNAWARE WHETHER IT IS "BIT OR BYTE"...
> "I DON'T WANT TO STORE ONE MORE VARIABLE FOR BYTE IN XCORE".
> CAN ANYONE HELP ME OUT WITH THIS PROBLEM ? OR ANY BETTER SUGGESTIONS
> FOR THIS ??
If I understand correctly, your model has no way to record or to know
whether you've represented the value in the grammar as bit or byte. So,
given just an instance of a Sample with a field of type Integer (why not
use int?) you'd have no way to know how that should be serialized
according to your grammar as either a BIT or a BYTE. You need something
else in your model to record such information, e.g., a boolean field or
an enum field for recording the BIT verses BYTE keyword.
Thanks in advance !


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XCORE and XTEXT Grammar [message #1078640 is a reply to message #1078612] Sat, 03 August 2013 09:42 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hello,
First of all thanks for your reply. Yes I can use a boolean field in my xcore and use it. But when i type in my xtext editor i will have to type that boolean value also, HOW DO I AVOID IT?

And, when i type either 'bit 8' or 'byte 1' in my dsl file, HOW DO I MAKE SURE THAT THE VALUE OF BOOLEAN IS SET PROPERLY IN THE BACKGROUND ??

Thanks in advance ! Smile


Arshad
Re: XCORE and XTEXT Grammar [message #1078647 is a reply to message #1078640] Sat, 03 August 2013 09:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

what about

('BIT' bit=INT | 'BYTE' bit=BYTE ) ;
BYTE: INT;


and a custom ivalueconverter for BYTE


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: XCORE and XTEXT Grammar [message #1078658 is a reply to message #1078647] Sat, 03 August 2013 10:20 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 a lot for your reply:)
Actually I am new to xtext so exploring the things now.
I will definitely try with your suggestion.Smile


Arshad
Re: XCORE and XTEXT Grammar [message #1079821 is a reply to message #1078647] Mon, 05 August 2013 05:51 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hello Christian,
I tried with this:
('BIT' bit=INT | 'BYTE' bit=BYTE ) ;
BYTE: INT;

But it gives me:
"Cannot find compatible feature bit in sealed EClass Sample from imported package http://somepath: The existing feature 'bit' has an incompatible type 'EIntegerObject' [java.lang.Integer]. The expected type is 'Byte'."

Any suggestions from anyone?
Thanks in advance! Smile


Arshad
Re: XCORE and XTEXT Grammar [message #1079860 is a reply to message #1079821] Mon, 05 August 2013 07:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Arshad,

These are Xtext questions best asked on the Xtext forum.

On 05/08/2013 7:51 AM, Arshad Adavani wrote:
> Hello Christian,
> I tried with this:
> ('BIT' bit=INT | 'BYTE' bit=BYTE ) ;
> BYTE: INT;
>
> But it gives me: "Cannot find compatible feature bit in sealed EClass
> Sample from imported package http://somepath: The existing feature
> 'bit' has an incompatible type 'EIntegerObject' [java.lang.Integer].
> The expected type is 'Byte'."
>
> Any suggestions from anyone?
> Thanks in advance! :)
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XCORE and XTEXT Grammar [message #1146514 is a reply to message #1079860] Sun, 20 October 2013 07:36 Go to previous messageGo to next message
Hirdesh Agrawal is currently offline Hirdesh AgrawalFriend
Messages: 13
Registered: October 2013
Junior Member
Dear All,

I need your favor or suggestion regarding migrate the xtext version from 1.0.1 to 2.3.0 in custom application.

I followed all following process for migrate the xtext version.
1. Delete the old plug-ins and update the latest plug-ins in target platform.
2. Update the Plug-in Dependencies and Import Statements.
3. Introduction of the Qualified Name.
4. Changes in the index and in find references.
5. Rewritten Node Model.
6. AutoEditStrategy.
7. Other Noteworthy API Changes
To consider the above steps, I started the work with Eclipse-4.2, Which has a xtext-2.3.0 dependency. Successfully I completed the all above steps and removed the compilation error.

Problem: After that I start the testing and getting below error Messages:
[XtextLinkingDiagnostic: null:6 Couldn't resolve reference to Material 'MPS_RECUR'.,
XtextLinkingDiagnostic: null:9 Couldn't resolve reference to Cstic 'NUM_OF_ALLOC'.,
XtextLinkingDiagnostic: null:15 Couldn't resolve reference to Cstic 'INSTANCE_NUM'.,
XtextLinkingDiagnostic: null:14 Couldn't resolve reference to Class 'ALLOC'.]
Re: XCORE and XTEXT Grammar [message #1146916 is a reply to message #1146514] Sun, 20 October 2013 13:55 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Did you mean to post this on Xtext's eclipse.tmf forum?

On 20/10/2013 9:36 AM, Hirdesh Agrawal wrote:
> Dear All,
>
> I need your favor or suggestion regarding migrate the xtext version
> from 1.0.1 to 2.3.0 in custom application.
> I followed all following process for migrate the xtext version.
> 1. Delete the old plug-ins and update the latest plug-ins in target
> platform.
> 2. Update the Plug-in Dependencies and Import Statements.
> 3. Introduction of the Qualified Name.
> 4. Changes in the index and in find references.
> 5. Rewritten Node Model.
> 6. AutoEditStrategy.
> 7. Other Noteworthy API Changes
> To consider the above steps, I started the work with Eclipse-4.2,
> Which has a xtext-2.3.0 dependency. Successfully I completed the all
> above steps and removed the compilation error.
>
> Problem: After that I start the testing and getting below error Messages:
> [XtextLinkingDiagnostic: null:6 Couldn't resolve reference to Material
> 'MPS_RECUR'., XtextLinkingDiagnostic: null:9 Couldn't resolve
> reference to Cstic 'NUM_OF_ALLOC'., XtextLinkingDiagnostic: null:15
> Couldn't resolve reference to Cstic 'INSTANCE_NUM'.,
> XtextLinkingDiagnostic: null:14 Couldn't resolve reference to Class
> 'ALLOC'.]
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[texo] [teneo]? Support for opposites
Next Topic:Undo throws 'no duplicates' constraint in eclipse juno
Goto Forum:
  


Current Time: Fri Mar 29 13:05:53 GMT 2024

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

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

Back to the top