Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Terminal (Terminal Overlapping )
Terminal [message #1138802] Tue, 15 October 2013 10:38 Go to next message
Vishal seth is currently offline Vishal sethFriend
Messages: 32
Registered: April 2010
Member
Hi,

While creating a rule, I am facing issue related to overlapping of terminals. In grammar below I am trying to input Reference one1.111GGG.two.three but it fails as the terminal conflicts with whole number terminal being a '.' in between.

It can however be resolved by either creating the Greeting name as a terminal rule or by changing NUM & TOKEN_STARTING_WITH_NUMBER to a non terminal rule. But converting from non terminal rule to a data type rule would have performance impact.

What should be the ideal ways to handle such use cases?

Model:
'Reference' hello=GreetingName
;

GreetingName:
ID '.' TOKEN_STARTING_WITH_NUMBER '.' ID '.' ID;


terminal ID:
'^'? ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9' | '-' | '+')*;

terminal NUM:
('0'..'9')* ('.' ('0'..'9')+)?
;

terminal TOKEN_STARTING_WITH_NUMBER:
('0'..'9')* ID;

terminal INT returns ecore::EInt:
"not to be used";

Attaching xtext file for various scenarios along with junit test case.

Regards
Vishal
Re: Terminal [message #1139065 is a reply to message #1138802] Tue, 15 October 2013 14:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

why dont you use a datatype rule aka

TOKEN_STARTING_WITH_NUMBER:
INT? ID;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Terminal [message #1139928 is a reply to message #1139065] Wed, 16 October 2013 03:29 Go to previous messageGo to next message
Vishal seth is currently offline Vishal sethFriend
Messages: 32
Registered: April 2010
Member
Hi,

That's what I have done in MyDsl_datatyperule_working.xtext. My concerns for this is having a performance impact & secondly there are some other number related terminal rules, which again I have to convert into a datatype rule.


Just wanted to know what should have been the better way of handling such cases, i.e. one mentioned in MyDsl_terminal_working.xtext/ MyDsl_datatyperule_working.xtext or any other better way.

Regards
Vishal
Re: Terminal [message #1140040 is a reply to message #1139928] Wed, 16 October 2013 05:12 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
It is the property way to do (besides avoiding the use case)

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:problem with xtext and antlr
Next Topic:Formatting configuration
Goto Forum:
  


Current Time: Fri Mar 29 07:01:20 GMT 2024

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

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

Back to the top