Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » xtext grammar for precision(xtext grammar for precision)
xtext grammar for precision [message #1742892] Thu, 08 September 2016 12:47 Go to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Hi,

How to write xtext grammar in order to use '%' as precision?

I tried this :

Precision: precision=('%'|'%t') (int=INT|float=FLOAT);

terminal FLOAT returns ecore::EFloat: ('0'..'9')* '.' ('0'..'9')*;

terminal INT returns ecore::EInt: '0'..'9' ('0'..'9')*;

Example:
%t.2 rem = i / 7

but I am getting an error like no viable alternative at input '.2'

It works if I use terminal rules like:
Precision: (int=INT|float=FLOAT);

terminal FLOAT returns ecore::EFloat: ('%'|'%t')? ('0'..'9')* '.' ('0'..'9')*;

terminal INT returns ecore::EInt: ('%'|'%t')? '0'..'9' ('0'..'9')*;

But this is not expected because precision can be misused for normal cases also.
Re: xtext grammar for precision [message #1742915 is a reply to message #1742892] Thu, 08 September 2016 14:38 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
the question is:

do you have anything else in your terminal bunch that conflicts?

(you grammar is too minimal)


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Failed to deploy artifacts ReasonPhrase: Forbidden
Next Topic:Xsemantics: Tycho build issue with extended DSL
Goto Forum:
  


Current Time: Fri May 14 13:32:39 GMT 2021

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

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

Back to the top