Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Extend XBase grammar
Extend XBase grammar [message #1186378] Thu, 14 November 2013 17:18 Go to next message
Aleksandar Toshovski is currently offline Aleksandar ToshovskiFriend
Messages: 78
Registered: December 2011
Member
Is it possible to extend the XBase grammar like this:

var customer = new Customer();
param var mcustomer = new Customer();


I'd like to mark the variables with the keyword "marked". So I tried to extend the XBase grammar with the following block:

XVariableDeclaration returns XExpression:
	{XVariableDeclaration}
	(param?='param')?(writeable?='var'|'val') (=>(type=JvmTypeReference name=ValidID) | name=ValidID) ('=' right=XExpression)?;


I read the article of Jan Köhnlein how to extend xbase grammar, but I don't really understand where to find the files DomainmodelTypeProvider and DomainmodelCompiler. Do I need to create them by myself in the dsl project?




Re: Extend XBase grammar [message #1186432 is a reply to message #1186378] Thu, 14 November 2013 18:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

the article might be outdate due massive refactorings to xbase.

There is no subclass of XbaseCompiler created by default. so you have to subclass it yourself.
the type computation was changed in depth too. (XbaseTypeProvider is deprecated)

XbaseTypeComputer may be a good starting point


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Extend XBase grammar [message #1186460 is a reply to message #1186432] Thu, 14 November 2013 18:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Btw what is the semantics of the param keyword?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Extend XBase grammar [message #1188043 is a reply to message #1186460] Fri, 15 November 2013 12:11 Go to previous messageGo to next message
Aleksandar Toshovski is currently offline Aleksandar ToshovskiFriend
Messages: 78
Registered: December 2011
Member
I use param as a marker in order to add an annotation to the generated java code.

Like that, but param controls whether there is an annotation or not.

@Param
public String name = "World";
Re: Extend XBase grammar [message #1188058 is a reply to message #1188043] Fri, 15 November 2013 12:25 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i am not quite sure what your grammar looks like but i think
dothing this using the JvmModelInferrer might be a lot easier.
(XVariableDeclaration can be used inside blocks (e.g. method body) as well)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Compiling Xassignment to FeatureCall
Next Topic:Context sensitive lexing
Goto Forum:
  


Current Time: Thu Apr 25 04:29:08 GMT 2024

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

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

Back to the top