Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Integer-based qualified IDs
Integer-based qualified IDs [message #1400650] Mon, 14 July 2014 14:14 Go to next message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
Hi,

I'm trying to build a rule to have integer-based IDs, of the form INT('.'INT)* (like the usual qualified ID rule, but only with integers).

However, as a result with that rule, I always have to put a space between the INT and the dot, like for example, 1 .1

I cannot use the fully-qualified ID rule since IDs are always starting with a letter. I tried many other alternatives, without any success and I'm running out of ideas. Any clue?

Thanks in advance,
Fabian
Re: Integer-based qualified IDs [message #1400681 is a reply to message #1400650] Mon, 14 July 2014 15:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

please share a complete reproduceable grammar.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Integer-based qualified IDs [message #1400734 is a reply to message #1400681] Mon, 14 July 2014 16:43 Go to previous messageGo to next message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
By making the following MWE, I found the rule works. It looks like I have another thing that is messing up.

Thanks for your hint, the rule is working as expected.

Model :
  'package' pname=FQN';'
  imports+=Import*
  'model' name=ID revision=REVNUMBER';'
  types+=Type*
  elements+=Element*;

Import :
  'import' importedNamespace=FQNWithWildCard';';

Type :
  'type' name=ID';';

Element :
  name=ID type=[Type|FQN]';';

FQN :
  ID('.'ID)*;

FQNWithWildCard :
  FQN '.*'?;

REVNUMBER :
  INT('.'INT)*;


thanks for your help,
Fabian
Re: Integer-based qualified IDs [message #1400769 is a reply to message #1400734] Mon, 14 July 2014 17:39 Go to previous messageGo to next message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
Ok, I found the problem. It seems the below rules are conflicting (tested on the MWE):

terminal DECIMALVALUE returns ecore::EBigDecimal:
  ('0'..'9')+ '.' ('0'..'9')+;

REVNUMBER :
  INT('.'INT)*;


Any idea on how I can define both a decimal number representation and a "dotted integer ID" concurrently ? I could simply write a validator, but maybe a smart grammar rule can make it for me.

Thanks for your advice,
Fabian
Re: Integer-based qualified IDs [message #1400772 is a reply to message #1400769] Mon, 14 July 2014 17:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
terminals are lexed and the lexer is greedy. turn DECIMALVALUE into a datatype rule

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Integer-based qualified IDs [message #1401063 is a reply to message #1400772] Tue, 15 July 2014 04:33 Go to previous message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
That made the trick, thanks Christian.
Previous Topic:Using Existing Ecore in XText
Next Topic:createInjectorAndDoEMFRegistration Vs Guice.createInjector
Goto Forum:
  


Current Time: Thu Apr 18 14:25:40 GMT 2024

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

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

Back to the top