Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Possible bug in Xtext 1.0.1 with +/-
Possible bug in Xtext 1.0.1 with +/- [message #635482] Wed, 27 October 2010 03:08 Go to next message
No real name is currently offline No real nameFriend
Messages: 101
Registered: August 2010
Senior Member
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?

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.
Re: Possible bug in Xtext 1.0.1 with +/- [message #635802 is a reply to message #635482] Thu, 28 October 2010 07:40 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
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
Previous Topic:Problem with recursive LL grammar
Next Topic:problems with EcoreDsl example
Goto Forum:
  


Current Time: Sat Apr 27 00:26:13 GMT 2024

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

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

Back to the top