Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Referencing in a "fully qualified" way
Referencing in a "fully qualified" way [message #673516] Mon, 23 May 2011 22:52 Go to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

I'm not sure how I can absolutely reference stuff in my DSL. I'm
experimenting a bit xText to create a DSL that takes the informations
from Qt-Header-Files.

The DSL allows me already to write things like this:

namespace Bla {
enumeration Bli {
BLI_1 = 0
BLI_2 = 1
BLI_3 = BLI_1
}
}

Now I need to reference stuff in an absolute way e.g. like this:

namespace Blo {
enumeration Bli {
BLI_1 = 0
BLI_2 = 1
BLI_3 = Bla.Bli.BLI_1
}
}

How do I have to express this using xText? You can see my current
xtext-File in my github-repository [1]. I've already read the example
given in http://www.eclipse.org/forums/index.php/t/209569/ and think I
have to define something similar but I have no idea what I'd write in my
case.

Tom

[1]https://github.com/tomsontom/model-qt/blob/master/modules/org.ufacekit.qt.idl.dsl/src/org/ufacekit/qt/idl/dsl/QIdl.xtext
Re: Referencing in a "fully qualified" way [message #673518 is a reply to message #673516] Mon, 23 May 2011 23:08 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 24.05.11 00:52, schrieb Tom Schindl:
> Hi,
>
> I'm not sure how I can absolutely reference stuff in my DSL. I'm
> experimenting a bit xText to create a DSL that takes the informations
> from Qt-Header-Files.
>
> The DSL allows me already to write things like this:
>
> namespace Bla {
> enumeration Bli {
> BLI_1 = 0
> BLI_2 = 1
> BLI_3 = BLI_1
> }
> }
>
> Now I need to reference stuff in an absolute way e.g. like this:
>
> namespace Blo {
> enumeration Bli {
> BLI_1 = 0
> BLI_2 = 1
> BLI_3 = Bla.Bli.BLI_1
> }
> }
>
> How do I have to express this using xText? You can see my current
> xtext-File in my github-repository [1]. I've already read the example
> given in http://www.eclipse.org/forums/index.php/t/209569/ and think I
> have to define something similar but I have no idea what I'd write in my
> case.
>
> Tom
>
> [1]https://github.com/tomsontom/model-qt/blob/master/modules/org.ufacekit.qt.idl.dsl/src/org/ufacekit/qt/idl/dsl/QIdl.xtext


Or even better:

namespace Bla {
namespace Blu {
enumeration Bli {
BLI_1 = 0
BLI_2 = 1
BLI_3 = BLI_1
}
}
}

namespace Blo {
enumeration Bli {
BLI_1 = 0
BLI_2 = 1
BLI_3 = Bla.Blu.Bli.BLI_1
}
}

Tom
Re: Referencing in a "fully qualified" way [message #673565 is a reply to message #673518] Tue, 24 May 2011 06:28 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

this is supported out of the box. Have a look at the domainmodel example shipped with Xtext. The key is the datatype rule

QualifiedName: ID ('.' ID)*;

and doing the cross references like that

ref=[Type|QualifiedName]

meaning (refer to an element of type Type using the string representation of a Qualified name (x.y.z). It the element lies in the same namespace (x.z) z can be referenced via its short name (z) automatically (but also via x.y.z). The documenation briefly covers namespaces and namespace imports.

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: Referencing in a "fully qualified" way [message #673933 is a reply to message #673565] Wed, 25 May 2011 08:11 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Alexander,

Works like a charme. Thanks.

Tom

Am 24.05.11 08:28, schrieb Alexander Nittka:
> Hi,
>
> this is supported out of the box. Have a look at the domainmodel example
> shipped with Xtext. The key is the datatype rule
>
> QualifiedName: ID ('.' ID)*;
>
> and doing the cross references like that
>
> ref=[Type|QualifiedName]
>
> meaning (refer to an element of type Type using the string
> representation of a Qualified name (x.y.z). It the element lies in the
> same namespace (x.z) z can be referenced via its short name (z)
> automatically (but also via x.y.z). The documenation briefly covers
> namespaces and namespace imports.
>
> Alex
>
>
>
Previous Topic:MWE2 workflow can't find MANIFEST.MF
Next Topic:Syntax Graph formatting
Goto Forum:
  


Current Time: Wed Sep 25 03:08:53 GMT 2024

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

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

Back to the top