|
Re: Possible bug in Xtext 1.0.1 with +/- [message #635802 is a reply to message #635482] |
Thu, 28 October 2010 07:40 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
Am 27.10.10 05:08, schrieb pgbackup@yahoo.com:
> Hi,
>
> I'm not sure if this is a possible bug in Xtext, but consider the rule:
>
>
> Expression : val1=INT op='+' val2=INT;
>
>
> In the editor, if I type '3 + 4' and '3+ 4' it matches OK, but '3+4' and
> '3 +4' fail on the '+' operator. Same with the '-' operator. However, it
> works OK with '*'. Since +/- can be used as sign, is there a way to
> resolve this or is this a bug in Xtext?
We have almost the same rule in the arithmetics example, and I cannot
reproduce this.
>
> Also I noticed that the rule for INT is ('0'..'9')+. Do I need to define
> my own rule to handle negative integers? Or should I redefine the INT
> terminal? Thanks.
You should define a datatype rule, as the parser should decide whether
the '-' in '-1' is a minus operator or a prefix to denote a negative
integer. Having that as a terminal rule would always yield a token '-1'
thus shadowing the minus operator.
MyInt returns ecore::EInt:
'-'? INT;
As we are using the default EcoreFactory to convert the parsed string to
an ecore::EInt, you do not even have to write a value converter.
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
|
Powered by
FUDForum. Page generated in 0.03063 seconds