Skip to main content



      Home
Home » Modeling » TMF (Xtext) » INT terminal rule for negative values
INT terminal rule for negative values [message #907988] Tue, 04 September 2012 10:00 Go to next message
Eclipse UserFriend
Hi,

is there a way to use negative values with the builtin terminal rule 'INT'? It only seems to accept numbers without a leading minus.

I can build something like this:
SignedInt:
	sign=('-')? value=INT
;

But this does not behave very intuitively in ContentAssist, and the sign has to be parsed manually.

So, is there a better way to do that?

Re: INT terminal rule for negative values [message #908859 is a reply to message #907988] Thu, 06 September 2012 02:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

this is what datatype rules are for.

SignedInt returns ecore::EInt: '-'? INT;

look at the Terminals grammar as you will have to import the Ecore for referencing the return type.

Alex
Re: INT terminal rule for negative values [message #909036 is a reply to message #908859] Thu, 06 September 2012 08:52 Go to previous message
Eclipse UserFriend
That works fine. Thank you.

To get the contentAssist to propose something one needs to add this to ProposalProvider:
	public void complete_SignedInt(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		complete_INT(model, ruleCall, context, acceptor);
	}
Previous Topic:headless xtext plugins
Next Topic:Inject issue with Eclipse Juno
Goto Forum:
  


Current Time: Tue Jul 08 12:11:53 EDT 2025

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

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

Back to the top