Skip to main content


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 12:13 Go to next message
Thomas Hergenröder is currently offline Thomas HergenröderFriend
Messages: 22
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 20:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
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)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Grammar equivalent for Java interface [message #1062959 is a reply to message #1062695] Tue, 11 June 2013 14:20 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Grammar equivalent for Java interface [message #1065252 is a reply to message #1062959] Tue, 25 June 2013 06:32 Go to previous message
Thomas Hergenröder is currently offline Thomas HergenröderFriend
Messages: 22
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: Tue Mar 19 03:38:38 GMT 2024

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

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

Back to the top