Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext import parser rule!!(how does the grammar manage that!!)
icon5.gif  Xtext import parser rule!! [message #754385] Wed, 02 November 2011 11:52 Go to next message
Mokhtar Alshubei is currently offline Mokhtar AlshubeiFriend
Messages: 121
Registered: November 2011
Location: Germany
Senior Member
Hello great people Rolling Eyes
i am a new here and working with Xtext! please help me to understand this:
Where: Xtext grammar from the demo example in the documentation (see below)
My question: how does xtext enable the import rule to exactly allow the referenced Entity to be written without its qualified name??
i'm feeling either magic or that it was meant exactly solely for that!
in the line ('extends' superType = [Entity | QualifiedName])? OK it says that the bar is for specifying the syntax of the parsed string of Entity(?) BUT HOW could it work to write:
entity Post extends my.company.common.hasAuthor {..} instead of
entity Post extends hasAuthor {..}
JUST by specifying the import statement before like this
import my.company.common.* ????????

Domainmodel:
(elements += AbstractElement)* ;
PackageDeclaration:
'package' name = QualifiedName '{'
(elements += AbstractElement)* '}'
;
AbstractElement:
PackageDeclaration | Type | Import
;
QualifiedName:
ID ('.' ID)* ;
Import:
'import' importedNamespace = QualifiedNameWithWildcard

;

QualifiedNameWithWildcard:
QualifiedName '.*'?
;
Type:
DataType | Entity
.
.
Entity:
'entity' name = ID
('extends' superType = [Entity | QualifiedName])?
'{'
(features += Feature)* '}'
;

Vielen Dank,
Mokhtar
Re: Xtext import parser rule!! [message #754388 is a reply to message #754385] Wed, 02 November 2011 12:02 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

the short answer is: this is intended magic. The "importedNamespace" in the grammar tells Xtext to use those strings for normalising qualified names. See the documentation. You may also start digging starting at ImportNormalizer and its uses.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Xtext import parser rule!! [message #754395 is a reply to message #754388] Wed, 02 November 2011 12:30 Go to previous messageGo to next message
Mokhtar Alshubei is currently offline Mokhtar AlshubeiFriend
Messages: 121
Registered: November 2011
Location: Germany
Senior Member
Oook thank you! so 'importedNamespace' is like a keyword but i will have to provide the related parser rules as they are here? except maybe to change ID('.'ID)* to something like ID('::'ID)* ?

thank you for helping.
Mokhtar
Re: Xtext import parser rule!! [message #754798 is a reply to message #754395] Fri, 04 November 2011 12:18 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Yes.

Some call it magic, I call it a naming convention.


Am 02.11.11 13:30, schrieb Xtexter:
> Oook thank you! so 'importedNamespace' is like a keyword but i will have
> to provide the related parser rules as they are here? except maybe to
> change ID('.'ID)* to something like ID('::'ID)* ?
>
> thank you for helping.
> Mokhtar


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:Using Xtext programmatically
Next Topic:Mwe2Launcher in a standalone wrapper application
Goto Forum:
  


Current Time: Thu Apr 18 06:54:24 GMT 2024

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

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

Back to the top