Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Exclude Keyword from ID in specific Context
Exclude Keyword from ID in specific Context [message #1771054] Mon, 21 August 2017 14:05 Go to next message
Erwann Traisnel is currently offline Erwann TraisnelFriend
Messages: 14
Registered: June 2017
Junior Member
Hello,

I'm currently working on a very basic DSL,
My problem here is , I would like to exclude a keyword from IDs (keyword here is "Ref" , only in a particular context . Please find below the example and the grammar

GRAMMAR

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model: elements+=Element* ';' ;
Element: Item | ItemReference ;
Item: name=QName ;
ItemReference: ref=[Item|QName] REF_KEYWORD ;
QName: ID ('.'ID)* ;
REF_KEYWORD: '.Ref'; //I Also tried with terminal

-------------------------------------------------------------------
model

a.b // This one is good
a.b.Ref // This one is good
a.b.Real // Error Expecting f instead of a
a.b.Reference //Mismatched input

in which I can "navigate" the underlined items,
However I got an error on "a.b.Real" -> "expected f instead of a ", and the "Ref" in "Reference" is parsed as the REF_KEYWORD , which I don't want .

How can I make a rule that specifies that if a QName ends with .Ref , then don't take the .Ref ?

Thanks in advance

Erwann


Re: Exclude Keyword from ID in specific Context [message #1771090 is a reply to message #1771054] Mon, 21 August 2017 20:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12324
Registered: July 2009
Senior Member
hmmm very wired behaviour

can you try

Model: elements+=Element* ';' ;
Element: Item | ItemReference ;
Item: name=QName ;
ItemReference: ref=[Item|QName] "." "Ref" ;
QName: ID ('.'ID)* ;


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Exclude Keyword from ID in specific Context [message #1771121 is a reply to message #1771090] Tue, 22 August 2017 07:25 Go to previous messageGo to next message
Erwann Traisnel is currently offline Erwann TraisnelFriend
Messages: 14
Registered: June 2017
Junior Member
Dear Christian,

Thank you so much for that answer,
Indeed that made it work !

Would you explain why two keywords work better than one ?

Erwann

Re: Exclude Keyword from ID in specific Context [message #1771140 is a reply to message #1771121] Tue, 22 August 2017 11:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12324
Registered: July 2009
Senior Member
Have no idea

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Exclude Keyword from ID in specific Context [message #1771150 is a reply to message #1771140] Tue, 22 August 2017 14:19 Go to previous message
Erwann Traisnel is currently offline Erwann TraisnelFriend
Messages: 14
Registered: June 2017
Junior Member
Okay,

Thanks anyway :)

Erwann
Previous Topic:grammar mixin and inheritance
Next Topic:[LSP] IOutputConfigurationProvider is not working with LSP
Goto Forum:
  


Current Time: Mon Oct 22 15:04:14 GMT 2018

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

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

Back to the top