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:
'type' name=ID 'specializes' (superTypes+=[Type|QualifiedName])*
( '{'
( properties+=PropertyDeclaration )*
'}')? ';'
;
Instance:
'instance' name=ID ':' (types+=[Type|QualifiedName])*
( '{'
( propertyAssignments+=PropertyAssignments )*
'}')? ';'
;
PropertyDeclaration:
name=ID ':' type=[Type|QualifiedName]
;
PropertyAssignment:
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"
Person.name = "Bob Marley"
SystemUser.name = "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.