Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Referencing in a "fully qualified" way
Referencing in a "fully qualified" way [message #673516] Mon, 23 May 2011 18:52 Go to next message
Eclipse UserFriend
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 19:08 Go to previous messageGo to next message
Eclipse UserFriend
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 02:28 Go to previous messageGo to next message
Eclipse UserFriend
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


Re: Referencing in a "fully qualified" way [message #673933 is a reply to message #673565] Wed, 25 May 2011 04:11 Go to previous message
Eclipse UserFriend
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: Sat Jul 05 05:25:04 EDT 2025

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

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

Back to the top