Skip to main content



      Home
Home » Modeling » TMF (Xtext) » keywords in grammar
keywords in grammar [message #1695433] Thu, 14 May 2015 11:52 Go to next message
Eclipse UserFriend
I have a grammar that has exponent values do I have to define a rule for exponents as below:
exponent returns Exponent:
Integer 'E' ('+'?|'-') Integer;

Variable returns VarDef:
'Var' name=ID;

The problem is when I am trying to define a variable in my language with a name E or e it gives an error and says that RULE_ID is expected.

any suggestions on how to define 'E' in the grammar and can be used at the same time as an ID
Re: keywords in grammar [message #1695441 is a reply to message #1695433] Thu, 14 May 2015 12:21 Go to previous messageGo to next message
Eclipse UserFriend
hi you have to use datatype rules for that:

MyID: ID | 'E';

Variable returns VarDef:
'Var' name=MyID;
Re: keywords in grammar [message #1695442 is a reply to message #1695441] Thu, 14 May 2015 12:22 Go to previous message
Eclipse UserFriend
Thanks Alot Smile
Previous Topic:How to handle left-recursive Call graphs in xtext?
Next Topic:XText 2.4.3 to 2.8.2 performance problems in getDeclaredMethods and isReadOnly
Goto Forum:
  


Current Time: Mon Sep 22 03:13:12 EDT 2025

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

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

Back to the top