QualifiedName resolving [message #886841] |
Fri, 15 June 2012 18:00 |
Jean-Michel Syrotas Messages: 4 Registered: June 2012 |
Junior Member |
|
|
Hi!
I am trying to make a (very) simple grammar with ecore files, and reference resolving, but even since I read so many documents and tried so many times, I cannot make it works.
Here is my problem:
The project contains some folders (that correspond to the "packages", but every single folder contains a file named package.mydsl that contains the definition of the package.
A package is simply defined as If the package is inside a package, the file only begins with
With the same way, we can define some models, with the same principle: if the model is inside a package, the file begins with and the model is defined like
The problem in my example, is when I want to create something in a package within another package like NAME1.NAME2
So, I have actually 2 problems:
- pack1.pack2 cannot be resolved...
- I can define 2 models called ModelA in the same package pack1... why?
Here is my grammar:
Program returns program::Program:
{program::Program}
( withinClause=Within ';')?
( clazzes+=ClazzDefinition ';')*
;
Within returns within::Within:
{within::Within}
('within' importedNamespace=[clazz::Package|QualifiedName])?
;
ClazzDefinition returns clazz::Clazz:
ModelDefinition | PackageDefinition
;
ModelDefinition returns clazz::Model:
{clazz::Model}
(finalPrefix?='final')?
(partialPrefix?='partial')?
'model' name=ID
'end' endName=ID
;
PackageDefinition returns clazz::Package:
{clazz::Package}
(finalPrefix?='final')?
(partialPrefix?='partial')?
'package' name=ID
'end' endName=ID
;
QualifiedName:
ID ('.' ID)*;
Is my problem because of the grammar? the scope? the mwe2 file?
I am kinda lost right now... any help will be much appreciated!!!
Thank You...
-
Attachment: v1.png
(Size: 78.36KB, Downloaded 340 times) -
Attachment: v2.png
(Size: 77.62KB, Downloaded 308 times) -
Attachment: v3.png
(Size: 72.56KB, Downloaded 302 times)
|
|
|
Re: QualifiedName resolving [message #887206 is a reply to message #886841] |
Sat, 16 June 2012 07:45 |
|
First of all, I recommend that do not give the attribute "importedNamespace" other type instead of EString. As the attribute "name", "importedNamespace" has special meaning for Xtext. You may refer to the document about scope for details.
Secondly, the meaning of qualified name can be described on AST.
Qualified name "pack1.pack2" means that, on the AST,
There is an EObject (we may call it p1) who has attribute "name" and its value is "pack1"
There is an EObject (we may call it p2) who has attribute "name" and its value is "pack2"
"p1" is ancestor of "p2"
on the path from "p1" to "p2" there is no other EObject with attribute "name"
I hope this can help to find your way.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03323 seconds