Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » QualifiedName resolving
QualifiedName resolving [message #886841] Fri, 15 June 2012 18:00 Go to next message
Jean-Michel Syrotas is currently offline Jean-Michel SyrotasFriend
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
package NAME 
end NAME;
If the package is inside a package, the file only begins with
within PACK_NAME;

index.php/fa/10314/0/

With the same way, we can define some models, with the same principle: if the model is inside a package, the file begins with
within PACK_NAME;
and the model is defined like
model NAME 
end NAME;

index.php/fa/10315/0/

The problem in my example, is when I want to create something in a package within another package like NAME1.NAME2
index.php/fa/10316/0/

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 329 times)
  • Attachment: v2.png
    (Size: 77.62KB, Downloaded 297 times)
  • Attachment: v3.png
    (Size: 72.56KB, Downloaded 295 times)
Re: QualifiedName resolving [message #887206 is a reply to message #886841] Sat, 16 June 2012 07:45 Go to previous messageGo to next message
Kevin Sun is currently offline Kevin SunFriend
Messages: 32
Registered: August 2010
Location: China
Member

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.
Re: QualifiedName resolving [message #887927 is a reply to message #887206] Sun, 17 June 2012 11:20 Go to previous message
Jean-Michel Syrotas is currently offline Jean-Michel SyrotasFriend
Messages: 4
Registered: June 2012
Junior Member
Thank you for the clue... I'll try to change the "importedNamespace" to EString type!!
Previous Topic:Can I remove things from AST
Next Topic:How to add copyright headers to generated sources
Goto Forum:
  


Current Time: Fri Apr 26 14:26:23 GMT 2024

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

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

Back to the top