Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Terminal rule named INT not awaiting an Integer
Terminal rule named INT not awaiting an Integer [message #982862] Tue, 13 November 2012 13:31 Go to next message
Franck Malartic is currently offline Franck MalarticFriend
Messages: 8
Registered: September 2012
Junior Member

Just to let you know that I run into a problem by using a grammar with terminal rule defined like this :

terminal fragment SIGN               :   '+' | '-' ;
terminal fragment DIGIT              : ('0'..'9');
terminal INT returns ecore::ELong   : SIGN? DIGIT+;

Note that my grammar is not using common terminals (org.eclipse.xtext.common.Terminals).

The problem when parsing is a conversion exception : "java.lang.Integer cannot be cast to java.lang.Long".

With the debugger, it appears that org.eclipse.xtext.conversion.impl.AbstractDeclarativeValueConverterService#getConverter(String lexerRule) returns an instance of org.eclipse.xtext.conversion.impl.INTValueConverter instead of the DefaultTerminalConverter.

By changing the terminal rule name to LONG (or anything else) it works fine (so that is not a issue for me anymore).

I am not sure if this is bug or if INT is a some kind of reserved terminal rule name.
Hope that can help,

PS: using eclipse Indigo with xtext 2.2.1.
Re: Terminal rule named INT not awaiting an Integer [message #982877 is a reply to message #982862] Tue, 13 November 2012 13:43 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13940
Registered: July 2009
Senior Member
Hi you have to bind a proper ivalueconverterservice yourself

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

Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Re: Terminal rule named INT not awaiting an Integer [message #982917 is a reply to message #982877] Tue, 13 November 2012 14:28 Go to previous message
Boris Brodski is currently offline Boris BrodskiFriend
Messages: 111
Registered: July 2009
Senior Member

You can also watch this screencast about terminals and IValueConverters:

In your special case you have to define a new terminal (LINT for example), IValueConverter and hide or reuse the INT terminal:

terminal fragment SIGN : '+' | '-' ;
terminal LINT returns ecore::ELong : SIGN? INT;


Previous Topic:Conflicting content assist proposal handlers
Next Topic:Validator - Error/Warning Message Syntax
Goto Forum:

Current Time: Mon May 17 16:14:23 GMT 2021

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

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

Back to the top