Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [very newbie] Obtain file name
[very newbie] Obtain file name [message #743187] Fri, 21 October 2011 07:55 Go to next message
Massimo Missing name is currently offline Massimo Missing nameFriend
Messages: 5
Registered: October 2011
Junior Member
Hi all!
I need your help, I have this grammar:
Xasm:
	starts+=Asm|Model
	greetings+=Greeting*
;

Model:
	asyncr?='asyncr'? 'model' name=ID	
	
;


Asm:
	asyncr?='asyncr'? 'asm' name=ID
;

Greeting:
	'Hello' name=ID '!'
;


I create a file named "test.asm" like this:
asm name_class
Hello ciao!


How can I check in definitions of grammar if name_class is the same word of the name file (like in Java)?

Thank you,
Massimo

Re: [very newbie] Obtain file name [message #743193 is a reply to message #743187] Fri, 21 October 2011 07:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,


you can ask any EObject (thus your Asm) for its eResource()
and the Resource for it's uri.
the uri contains the filename.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [very newbie] Obtain file name [message #747673 is a reply to message #743193] Mon, 24 October 2011 08:06 Go to previous messageGo to next message
Massimo Missing name is currently offline Massimo Missing nameFriend
Messages: 5
Registered: October 2011
Junior Member
I'm sorry but i don't understand.
Can you link a manual where the EObject are explained?

Thank you
Re: [very newbie] Obtain file name [message #747761 is a reply to message #747673] Mon, 24 October 2011 09:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
This is notwhere explained. Xtext reuses Ecore. for more information see http://download.eclipse.org/modeling/emf/emf/javadoc/2.7.0/org/eclipse/emf/ecore/package-summary.html

it is basically: object.eResource().getURI().trimFileExtension().lastSegment();
just wrap what into your check method.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [very newbie] Obtain file name [message #747793 is a reply to message #747761] Mon, 24 October 2011 09:35 Go to previous message
Massimo Missing name is currently offline Massimo Missing nameFriend
Messages: 5
Registered: October 2011
Junior Member
Thank you, I'll try it.
Previous Topic:Embed XText Editors in GMF Diagram
Next Topic:Matching braces in comments
Goto Forum:
  


Current Time: Thu Apr 25 15:30:05 GMT 2024

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

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

Back to the top