Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » conflict between 'literals' and qualifiednames
conflict between 'literals' and qualifiednames [message #554755] Tue, 24 August 2010 10:50 Go to next message
F. Alexander Njemz is currently offline F. Alexander NjemzFriend
Messages: 20
Registered: July 2010
Junior Member
Hi,

say I have rules like

Model:
    'model' name=ID ...

QualifiedName:
    ID ('.' ID)*;

.

It now is impossible to use 'model' in qnames like 'org.example.model.myModel' because Xtext seems to interpret the 'model' in the qname as the beginning of the Model-rule. Is there a workaround?

Thanks.

Regards,


Alexander
Re: conflict between 'literals' and qualifiednames [message #554759 is a reply to message #554755] Tue, 24 August 2010 11:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello Alexander,

what about

Model:
    'model' name=ID fqn=QualifiedName;

QualifiedName:
    ('model' | ID) ('.' ('model' | ID))*;


Regards
Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: conflict between 'literals' and qualifiednames [message #554764 is a reply to message #554755] Tue, 24 August 2010 11:12 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

this is a standard problem as keywords are keywords wherever they
appear. You either introduce a separate data type rule for ID+keywords

IdOrKeywords: ID|'model';

and use IdOrKeyword wherever you would have used ID before or you simply
put it in the QualifiedName rule

QualifiedName: (ID|'model') ('.' (ID|'model'))*;


Note that you also can escape keywords.

^model will not be read as the keyword "model" but an ID with string
value "model". The caret is removed by the value converter.

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: conflict between 'literals' and qualifiednames [message #554785 is a reply to message #554755] Tue, 24 August 2010 12:06 Go to previous message
F. Alexander Njemz is currently offline F. Alexander NjemzFriend
Messages: 20
Registered: July 2010
Junior Member
Thanks for your help.

Kind regards,

Alexander
Previous Topic:Externalize workflow settings in xtext 1.0
Next Topic:Generating code from within DSL Editor
Goto Forum:
  


Current Time: Wed Apr 24 22:37:02 GMT 2024

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

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

Back to the top