Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Grammar equivalent for Java interface
Grammar equivalent for Java interface [message #1062695] Mon, 10 June 2013 08:13 Go to next message
Thomas Hergenröder is currently offline Thomas Hergenröder
Messages: 21
Registered: February 2012
Junior Member
I have ParserRule like this:

StringNamed:
Binding | Event | ViewType | KeyValue
;

they all have in common that they have a name attribute which translates to String.
The same attribute which is used for the qualified name.

Is there a way to enforce that?
And also ensure that the real JavaInterface allways contains the method:
String getName()

(and "void setName(String value)" - but I only use that for junit-Tests)
Re: Grammar equivalent for Java interface [message #1062810 is a reply to message #1062695] Mon, 10 June 2013 16:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 5843
Registered: July 2009
Senior Member
Hi,

there is no such thing in the grammar.
the way the metamodel inference works is described in the docs.
you may use IXtext2EcorePostProcessor to customize the inference (e.g. by adding that Supertype)
Re: Grammar equivalent for Java interface [message #1062959 is a reply to message #1062695] Tue, 11 June 2013 10:20 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan Koehnlein
Messages: 655
Registered: July 2009
Senior Member
Use an imported Ecore model instead of a generated one (see docs)
This is the standard procedure if Xtext's Ecore model inferrence doesn't
do exactly what you like.

Am 10.06.13 14:13, schrieb Thomas Hergenröder:
> I have ParserRule like this:
>
> StringNamed:
> Binding | Event | ViewType | KeyValue
> ;
>
> they all have in common that they have a name attribute which translates
> to String.
> The same attribute which is used for the qualified name.
>
> Is there a way to enforce that?
> And also ensure that the real JavaInterface allways contains the method:
> String getName()
>
> (and "void setName(String value)" - but I only use that for junit-Tests)


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Grammar equivalent for Java interface [message #1065252 is a reply to message #1062959] Tue, 25 June 2013 02:32 Go to previous message
Thomas Hergenröder is currently offline Thomas Hergenröder
Messages: 21
Registered: February 2012
Junior Member
right now I use this way:
StringNamed :
	name = ID
;

StringNamedRule returns StringNamed :
	Binding | Event | Renderable | GroupID | ViewType
	| SegmentInType | LayoutType | ViewProfiles | Scope | KeyValue | Module
;


It is allmost what I want - it just does not give me a compile error, when there is no name attribute that result in a java-String.
(although I think it would complain if the name attribute is a cross-reference).
It simply addes get/setName(String).
Previous Topic:Read Xtext resource as EMF resource
Next Topic:Proposal depending on cursor position
Goto Forum:
  


Current Time: Wed Apr 16 18:52:27 EDT 2014

Powered by FUDForum. Page generated in 0.01554 seconds