Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Extend XBase grammar
Extend XBase grammar [message #1186378] Thu, 14 November 2013 12:18 Go to next message
Eclipse UserFriend
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 13:00 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Extend XBase grammar [message #1186460 is a reply to message #1186432] Thu, 14 November 2013 13:17 Go to previous messageGo to next message
Eclipse UserFriend
Btw what is the semantics of the param keyword?
Re: Extend XBase grammar [message #1188043 is a reply to message #1186460] Fri, 15 November 2013 07:11 Go to previous messageGo to next message
Eclipse UserFriend
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 07:25 Go to previous message
Eclipse UserFriend
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)
Previous Topic:Compiling Xassignment to FeatureCall
Next Topic:Context sensitive lexing
Goto Forum:
  


Current Time: Wed Jul 23 08:33:08 EDT 2025

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

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

Back to the top