Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [SOLVED] keyword as identifier
[SOLVED] keyword as identifier [message #1734335] Tue, 07 June 2016 09:19 Go to next message
Jonathan L. is currently offline Jonathan L.Friend
Messages: 24
Registered: May 2016
Junior Member
Hi,

I got the following rule:
WCLOCKK:
	(INT 'h')? (INT 'min')? (INT 's')? (INT 'ms')? (INT 'us')?
;

so the time units will get highlighted and thats correct.
But in the language it also should be possible to set these as an identifier like:
var int ms;
var int h;

The ID rule for variables is:
terminal ID_VAR:
	( ('a'..'z') ('a'..'z' | 'A'..'Z' | '0'..'9' | '_' )*) | '_'
;


So in the moment there will occur an error.
Is there a way to make this possible?

Thanks in advance.

[Updated on: Tue, 07 June 2016 10:37]

Report message to a moderator

Re: keyword as identifier [message #1734337 is a reply to message #1734335] Tue, 07 June 2016 09:23 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
you have to introduce a datatype rule and use it instead of ID

MyID: ID | "keyword1" .... | "keywordn";


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:disable mandatory whitespaces at certain positions
Next Topic:Disable terminal rule on selected parser rule?
Goto Forum:
  


Current Time: Sat Sep 21 23:08:41 GMT 2024

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

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

Back to the top