Skip to main content



      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 05:09 Go to next message
Eclipse UserFriend
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 05:20 Go to previous messageGo to next message
Eclipse UserFriend
Hi you do such constraints by implementing a check in
YourDslJavaValidator
Re: bound an integer in xtext [message #882828 is a reply to message #882820] Thu, 07 June 2012 05:25 Go to previous messageGo to next message
Eclipse UserFriend
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 05:32 Go to previous message
Eclipse UserFriend
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: Sat Jul 05 01:33:56 EDT 2025

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

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

Back to the top