Import built-in types as qualified names [message #1407392] |
Tue, 12 August 2014 09:51  |
Eclipse User |
|
|
|
Hey everyone,
My model language requires for built-in types to be imported in the file where they are used. The problem is that those types looks like this: 'com.type.ID' 'com.type.Binary' 'com.type.DynamicStructure' etc. I tried making grammar for that and here is what I could think of:
DomainModel:
packageDeclaration=PackageDeclaration;
PackageDeclaration:
"package" name=QualifiedName ";" importDeclarations+=ImportDeclaration*
abstractTypeDeclarations+=AbstractTypeDeclaration+;
ImportDeclaration:
"import" importedNamespace=QualifiedName ";";
AbstractTypeDeclaration:
modifier+=ClassOrInterfaceModifier* typeDeclaration=TypeDeclaration;
TypeDeclaration:
ClassDeclaration |
EnumDeclaration | InterfaceDeclaration
....
TypeRef:
SimpleTypeRef | Type;
SimpleTypeRef:
DynamicStructure;
DynamicStructure:
{DynamicStructure} 'com.type.DynamicStructure' (also tried with name='com.type.DynamicStructure');
Type:
referencedType=[TypeDeclaration|QualifiedName];
I am able to reference TypeRef for field parameter types for example:
FieldDeclaration:
type=TypeRef variableName=ValidID ';';
and it works. But when I try to use it as part of import statements it says 'Mismatch input 'com.type.DynamicStruture' expects 'RULE_ID'' and I suspect it is because of the QualifiedName definition of the ImportStatement.
Is it possible what I am trying to do? Or is it wrong?
Thanks a lot in advance!
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07504 seconds