Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » bound an integer in xtext(how to specify a range of value that must take an integer in xtext)
bound an integer in xtext [message #882820] Thu, 07 June 2012 09:09 Go to next message
frank fotso is currently offline frank fotsoFriend
Messages: 91
Registered: May 2012
Member
Hi,

just to know if it is possible to bounded an integer in xtext, that means just imagine you define your grammar and after running the workflow and the eclipse application, when you want to write your textual editor , you want one of your integer value , for example size to be in a certain range like if you choose to enter 25000 for the size that would be mark as an error and you can only choose value between for example 10 and 500.

 EEPROM_MANAGEMENTTYPE :
           'eEPROM_DEVICES' ( EEPROM_DEVICES+=EEPROM_DEVICESTYPE )+
	      
	      (EEPROM_ZONE+=EEPROM_ZONETYPE)+ 
	       
	       	;

EEPROM_DEVICESTYPE :

	  name=ID  code=ID
;
	     

EEPROM_ZONETYPE :
	 	
	'eEPROM_ZONE' 	    name=ID
	'size'    size=INT   
	'offset'  offset=INT   
	(transitions+=Transition)*
	('EEPROM_BLOCK' '{' EEPROM_BLOCK+=EEPROM_BLOCKTYPE ("," EEPROM_BLOCK+=EEPROM_BLOCKTYPE)* '}')?
;
	

EEPROM_BLOCKTYPE :
	
	
	
	'numberOfCopy'  numberOfCopy=INT   
	'numberOfZone' numberOfZone=INT   
	'priority'  priority=INT   
    'size'  size=INT   
	'EEPROM_BLOCKLOCAL' (EEPROM_BLOCKLOCAL=EEPROM_BLOCKLOCALTYPE)
	;

EEPROM_BLOCKLOCALTYPE :
	
	'{'
	'callBackFunction'  callBackFunction=STRING 
	'data'   data=STRING  
	'hasRAMImage'  hasRAMImage=STRING   
	'include'   include=Name  
	'isReadOnly' isReadOnly=STRING  
	'isSecured'   isSecured=STRING 
	'name'  name=STRING  
	'rAMImagePointer'   rAMImagePointer=STRING  
	'startupInit'  startupInit=STRING 
	'}';

Name :
	'in' localName=STRING
;

Transition:
	
	eEPROM_DEVICESTYPE=[EEPROM_DEVICESTYPE] 
	//'refer to' eEPROM_ZONETYPE=[EEPROM_ZONETYPE]
; 

that means for the integer value numberOfCopy in my example and only want to enter value between 2 and 10 and want the other values to be mark as an error if put it.
Re: bound an integer in xtext [message #882827 is a reply to message #882820] Thu, 07 June 2012 09:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13637
Registered: July 2009
Senior Member
Hi you do such constraints by implementing a check in
YourDslJavaValidator


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: bound an integer in xtext [message #882828 is a reply to message #882820] Thu, 07 June 2012 09:25 Go to previous messageGo to next message
frank fotso is currently offline frank fotsoFriend
Messages: 91
Registered: May 2012
Member
i've check and see that we can use OCL to add consraint to our model ,
is it a good way to answer the problem i stated before?
Re: bound an integer in xtext [message #882832 is a reply to message #882828] Thu, 07 June 2012 09:32 Go to previous message
frank fotso is currently offline frank fotsoFriend
Messages: 91
Registered: May 2012
Member
cool i have seen it.
thks
Previous Topic:quick fix for combination of issues?
Next Topic:Ecore Modell from extisting Grammar
Goto Forum:
  


Current Time: Sun Oct 25 06:17:50 GMT 2020

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

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

Back to the top