Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to solve multiple inheritance within a DSL(Problem to solve member collision in a C++ like approach)
How to solve multiple inheritance within a DSL [message #1733166] Tue, 24 May 2016 14:34 Go to next message
Claudenir Fonseca is currently offline Claudenir FonsecaFriend
Messages: 8
Registered: February 2016
Junior Member
Hello all,

I'm having a problem which envolves multiple inheritance/instantiation, scopping and qualified names. I've tried but I don't even know how to find a solution.

I'm developing a DSL where one can declare types and their properties, and instances and the values of properties. The grammar looks like this.

     'type' name=ID 'specializes' (superTypes+=[Type|QualifiedName])*
     ( '{'
          ( properties+=PropertyDeclaration )* 
     '}')? ';'

     'instance' name=ID ':' (types+=[Type|QualifiedName])*
     ( '{'
          ( propertyAssignments+=PropertyAssignments )* 
     '}')? ';'

     name=ID ':' type=[Type|QualifiedName]

     property=[Property] '=' value=STRING

An example code could be:
type String;

type Person {
     name : String

instance Bob : Person {
     name = "Bob Marley"

As you can imagine, a instance can only assign a value to a instantiated property. In case of name collision (due to multiple instantion) I want to write a code like this:

type Person {
     name : String
     age : String
type SystemUser {
     name : String

instance Bob : Person SystemUser {
     age = "30" = "Bob Marley" = "bobmarley123"

Does anyone knows how to implement this? I don't want to force a DSL user to write a QualifiedName for every property assignment. I would like to have non-collision cases automatically resolved.
Re: How to solve multiple inheritance within a DSL [message #1733214 is a reply to message #1733166] Wed, 25 May 2016 13:06 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Write a scope provider that offers the properties of all types with their qualified name and the non-ambiguous ones with their simple name.

Allow QualifiedName syntax in the x-ref as well:

     property=[Property|QualifiedName] '=' value=STRING

The QualifiedName should also allow simple names, e.g:

 ID ('.' ID)*;

Get professional support from the Xtext committers at
Previous Topic:Terminal rule for any text
Next Topic:Real business benefits of Xtext
Goto Forum:

Current Time: Thu Feb 29 00:04:08 GMT 2024

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

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

Back to the top