Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xpand/Xtend editor errors
Xpand/Xtend editor errors [message #717164] Fri, 19 August 2011 13:40 Go to next message
Bruce L. is currently offline Bruce L.Friend
Messages: 81
Registered: June 2011
Member
Hi,
I know this has been discussed already (e.g. http://www.eclipse.org/forums/index.php/m/662163/?srch=xpand+editor+property#msg_662163), but sorry, I cannot really figure out the solution.

Here is a simple grammar
grammar dsl.Crapdsl with org.eclipse.xtext.common.Terminals
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

generate crapdsl "dsl.Crapdsl"

Point:
    name = ID
    coordinate = Coordinate
;
Coordinate:
    x = FLOAT
    y = ID
    z = ID
;
terminal FLOAT returns ecore::EFloat : ('+'?|'-')('0'..'9')*'.'('0'..'9')+;


Why does the Xpand/Xtend editor underline with red 'coordinate.x', complaining that it cannot find such property? y and z are fine, I assume because their type is not EFLoat.
The code generation works perfectly, so it is really an issue with the editor.
In the preferences, I have already selected 'JavaBeans metamodel' and 'EMF metamodel', with no success.
I am using Eclipse Helios, Xtext 1.0.2

Thank you
B
Re: Xpand/Xtend editor errors [message #717165 is a reply to message #717164] Fri, 19 August 2011 13:48 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

first note that the Xtend/Xpand editors *are* buggy and that usually it is good practice to use datatype rules instead of terminal rules for these constructs (preventing lexing/parsing problems in larger grammars). Have you tried other number types as well?

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Xpand/Xtend editor errors [message #717169 is a reply to message #717164] Fri, 19 August 2011 14:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
Hi,

i cannot reproduce this using Xtext 1.0.2 / Xpand 1.0.1 using emf metamodel nor using Xtext 2.0.0 / Xpand 1.1.0
using Java Beans Metamodel i can reproduce it in both versions.
can you please file a bug against the editor?
does it work with both metamodels configured in the workflow? if not file a bug for this too

~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: Xpand/Xtend editor errors [message #717172 is a reply to message #717165] Fri, 19 August 2011 14:07 Go to previous messageGo to next message
Bruce L. is currently offline Bruce L.Friend
Messages: 81
Registered: June 2011
Member
Hi,

yes I tried
terminal MY_ID returns ecore::EInt: ('1'..'9')('0'..'9')*;

and properties of this type seem recognized by the editor (e.g. code completion suggests them).

What would be a possible data type rule to substitute my FLOAT?
Something like
Float returns ecore::EFloat :
      value = ('+'?|'-')('0'..'9')*'.'('0'..'9')+;


would result in an additional indirectness.. i.e. I would need to write coordinate.x.value, instead of coordinate.x ...
Is this a good solution?
Thank you

B

Re: Xpand/Xtend editor errors [message #717184 is a reply to message #717169] Fri, 19 August 2011 14:28 Go to previous messageGo to next message
Bruce L. is currently offline Bruce L.Friend
Messages: 81
Registered: June 2011
Member
sorry Christian,
I don't see any metamodel configuration in my workflow file. What do you mean?
I thought metamodels are set in the project properties -> Xtend/Xpand. (for the generator project)
There, I set JavaBeans. If I choose EMF, the errors are even more.
Re: Xpand/Xtend editor errors [message #717204 is a reply to message #717184] Fri, 19 August 2011 15:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
you can set the metamodel in the generator component. javabeans is the default. ~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: Xpand/Xtend editor errors [message #717252 is a reply to message #717172] Fri, 19 August 2011 17:53 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

no, this is not a datatype rule (see the documentation as well!).
Float returns ecore::EFloat :
      ('+'?|'-')('0'..'9')*'.'('0'..'9')+;


The big difference between a terminal and a data type rule (apart from the "missing" keyword terminal in the grammar) is as follows. Terminal rules (along with keywords) are essential for the lexing phase where the document is chopped up into tokens. This happens regardless of the context (i.e. not taking into account what the grammar would allow at the given position). Datatype rules are evaluated in the parsing phase, so there the grammar context matters.

The main problem with self defined terminal rules is that they often overlap, i.e. the same content could be chopped into tokens using different ways (but only one will be used, frequently not the expected one). So datatype rules allow you reduce the number of terminal rules but at the same time you get "one" simple value (a number, a string...) although it may be composed of multiple tokens.

Alex
Re: Xpand/Xtend editor errors [message #718079 is a reply to message #717252] Tue, 23 August 2011 07:50 Go to previous message
Bruce L. is currently offline Bruce L.Friend
Messages: 81
Registered: June 2011
Member
I see. Thanks for the explanation.

Unfortunately the problem persists, even if I avoid completely custom terminal rules:
Coordinate:
    x = Float
    y = ID
    z = ID
;
Float returns ecore::EFloat :
    ('+'?|'-')(Digit)*'.'(Digit)+;
Digit:
    ('0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'); 


(I also had to provide a custom ValueConverter to transform a string like -13.093 to a Float)
I'm sure this is not the best neither most elegant way to do what I want; anyway, even though there are no terminal rules, the xpand editor still complains about the property coordinate.x. Looks like the problem is with ecore types.

B

[Updated on: Tue, 23 August 2011 08:52]

Report message to a moderator

Previous Topic:When the Xtextmydsl editor plugin is installed
Next Topic:Folding swallowed newlines
Goto Forum:
  


Current Time: Mon Apr 19 01:14:06 GMT 2021

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

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

Back to the top