Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Another cross-referencing question
Another cross-referencing question [message #1016625] Thu, 07 March 2013 08:16
Pascal Degenne is currently offline Pascal DegenneFriend
Messages: 5
Registered: September 2012
Junior Member
Hi everyone,

I built a DSL with XBase expressions. In order to create my own simple types, I added to the grammar something like that :
    Typedef : 'alias' name=ID type=JvmTypeReference

    Entity : 'entity' name=ID '{'
      (vardefs += EntVarDef)*

    EntVarDef : type = [Typedef] name=ID ;

I can then write things like :
    alias text java.lang.String
    alias geom my.own.GeomClass
    entity Foo {
      text fooId
      geom geometry

And with a JvmModelInferrer generating a class for every entity, it works great.

Now I would like to be able to reuse a declared entity as being the type for an entity internal variable. In other words, I'd like to be able to append to that model someting like this :
    entity Bar {
      text BarId
      Foo fooVar

I could do that if I was allowed to write this in the grammar :
    EntVarDef : type = [Typedef] | [Entity] name=ID;

But I am not allowed to do so. I tried to subtype JvmTypeReference but I am not allowed to do so either.

I tried several other things so far, like subtyping :
    EntVarDef : type = [VarType|ID] name=ID;
    VarType : Typedef | Entity

Which looks to be ok for validation but I run into problems when trying to write the JvmModelInferrer (how to give a JvmReferenceType to the toField() method ?)

I also tried a solution like this :
   Typedef returns JvmTypeReference : 'alias' name=ID type=JvmTypeReference
   EntVarDef : type = JvmTypeReference name=ID ;

and it allows me to reuse a declared entity but I do not have access to my alias types any more.

Well, in your opinion, what best way should I explore further to obtain the expected behavior ?

I advance, thank you for your help.

[Updated on: Thu, 07 March 2013 09:36]

Report message to a moderator

Previous Topic:Automatic Validation ( NoViableAltException)
Next Topic:Is Xtext right for me?
Goto Forum:

Current Time: Sat Feb 22 14:15:46 GMT 2020

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

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

Back to the top