Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Keyword escape and compound name(How can one use a keyword for the localname of a compound name?)
Keyword escape and compound name [message #651594] Mon, 31 January 2011 19:04 Go to next message
Andrew Crapo is currently offline Andrew CrapoFriend
Messages: 7
Registered: January 2011
Junior Member
In my Xtext grammar "type" is a keyword. However, "type" is also a name in an imported namespace with prefix "rdf". I would like to be able to reference the concept ("rdf:type") but I get an error. If I use "rdf:^type" it parses ok but the caret is still there after the parsing. Using "^rdf:type" results in a parser error just as does "rdf:type". Is there a way around this problem?
Re: Keyword escape and compound name [message #651602 is a reply to message #651594] Mon, 31 January 2011 19:59 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Declare an ID_OR_KW data rule and use that instead of ID in places where
keywords are acceptable as ID.

ID_OR_KW : ID | 'type' | 'whatever' | ... ;

You also probably want to adjust highlighting.

Regards
- henrik

On 1/31/11 8:05 PM, crapo@research.ge.com wrote:
> In my Xtext grammar "type" is a keyword. However, "type" is also a name
> in an imported namespace with prefix "rdf". I would like to be able to
> reference the concept ("rdf:type") but I get an error. If I use
> "rdf:^type" it parses ok but the caret is still there after the parsing.
> Using "^rdf:type" results in a parser error just as does "rdf:type". Is
> there a way around this problem?
Re: Keyword escape and compound name [message #651604 is a reply to message #651602] Mon, 31 January 2011 20:35 Go to previous messageGo to next message
Andrew Crapo is currently offline Andrew CrapoFriend
Messages: 7
Registered: January 2011
Junior Member
The "rdf:type" was an example only. Any keyword could potentially be used in some RDF vocabulary in some namespace. The beauty of the escape character is that it allows a keyword to be used in some context as a user concept, e.g., "^type". However, when the user concept that colides with a keyword requires a prefix to disambiguate it, e.g., "rdf:type" versus "dc:type", it doesn't seem possible to use the escape character to get the Xtext-generated parser to handle the name correctly, that is, to treat the keyword as a user-defined name in that specific instance. Is there someway to use the escape character in a qualified name?
Re: Keyword escape and compound name [message #651622 is a reply to message #651604] Mon, 31 January 2011 22:42 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi,

make sure to register a value converter for your qualified name rule.
Please refer to the documentation for details.

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

Am 31.01.11 21:35, schrieb crapo@research.ge.com:
> The "rdf:type" was an example only. Any keyword could potentially be
> used in some RDF vocabulary in some namespace. The beauty of the escape
> character is that it allows a keyword to be used in some context as a
> user concept, e.g., "^type". However, when the user concept that colides
> with a keyword requires a prefix to disambiguate it, e.g., "rdf:type"
> versus "dc:type", it doesn't seem possible to use the escape character
> to get the Xtext-generated parser to handle the name correctly, that is,
> to treat the keyword as a user-defined name in that specific instance.
> Is there someway to use the escape character in a qualified name?
Re: Keyword escape and compound name [message #651856 is a reply to message #651622] Tue, 01 February 2011 19:24 Go to previous message
Andrew Crapo is currently offline Andrew CrapoFriend
Messages: 7
Registered: January 2011
Junior Member
Thanks! I didn't realize that this behavior wasn't embedded in Xtext.
Previous Topic:when is "pushed to master" fixes available in nightly ?
Next Topic:Using Xtext to transform XML to XML with XSLT
Goto Forum:
  


Current Time: Fri Apr 26 09:12:06 GMT 2024

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

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

Back to the top