grammar org.openhab.model.Sitemap with org.eclipse.xtext.common.Terminals

import "http://www.eclipse.org/emf/2002/Ecore" as ecore

generate sitemap "http://www.openhab.org/model/Sitemap"

SitemapModel :
	'sitemap' Sitemap;

Sitemap :
		name=ID ('label=' label=STRING)? ('icon=' icon=STRING)? '{'
			(children+=Widget)+
		'}';

Widget :
	(LinkableWidget | ((Switch | Selection | Slider | List) ));	

LinkableWidget :
	(Text | Group | Image | Frame) ('label=' label=(ID|STRING))? ('icon=' icon=(ID|STRING))?
	('{'
			(children+=Widget)+
	'}')?;

Frame : 'Frame' {Frame} ('item=' item=ID)?;

Text : 
	'Text' {Text} ('item=' item=ID)?;
	
Group : 
	'Group' ('item=' item=ID);

Image : 
	'Image' ('item=' item=ID)? ('url=' url=(STRING));
	
Switch : 
	'Switch' ('item=' item=ID) ('label=' label=(ID|STRING))? ('icon=' icon=(ID|STRING))? ('mappings=[' mappings+=Mapping (',' mappings+=Mapping)* ']')?;
	
Slider :
	'Slider' ('item=' item=ID) ('label=' label=(ID|STRING))? ('icon=' icon=(ID|STRING))? ('sendFrequency=' frequency=ID)? (switchEnabled?='switchSupport')?;
	
Selection : 
	'Selection' ('item=' item=ID) ('label=' label=(ID|STRING))? ('icon=' icon=(ID|STRING))? ('mappings=[' mappings+=Mapping (',' mappings+=Mapping)* ']')?;

List : 
	'List' ('item=' item=ID) ('label=' label=(ID|STRING))? ('icon=' icon=(ID|STRING))? ('separator=' separator=STRING);

Mapping :
	cmd=(ID|STRING) '=' label=(ID|STRING);

terminal ID : '^'?('a'..'z'|'A'..'Z'|'_'|'0'..'9')+;
	
terminal INT returns ecore::EInt: '/*deactivate int definition as we dont need it*/';
