ATSyRA Studio

ATSyRA ATG Language Reference

ATSyRA ATG Language Reference
TODO list of ATG language keyword and links to other section in the user guide

1. ATG language textual syntax

ATG comes with several concrete syntaxes, one of them is a textual syntax written with xText.

1.1. ATG language XText grammar

ATG xText grammar from fr.irisa.atsyra.atsyragoal.xtext plugin :

building.xtext
// automatically generated by Xtext
grammar fr.irisa.atsyra.atsyragoal.xtext.AtsyRAGoal with org.eclipse.xtext.common.Terminals

//import "platform:/resource/fr.irisa.atsyra.atsyragoal.model/model/atsyragoal.ecore"
import "http://www.irisa.fr/atsyra/atsyragoal" 
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
//import "http://www.eclipse.org/emf/2003/XMLType" as type

AtsyraGoalModel returns AtsyraGoalModel:
	{AtsyraGoalModel}
	(imports += Import)*
	
	'AtsyraGoalModel'
	'{'
		('defaults' '{' defaultValues+=DefaultValues (  defaultValues+=DefaultValues)* '}' )?
		('types' '{' types+=Type (  types+=Type)* '}' )?
		('features' '{' typedElements+=TypedElementDecl (  typedElements+=TypedElementDecl)* '}' )?
		('atsyragoals' '{' atsyragoals+=AtsyraGoal (  atsyragoals+=AtsyraGoal)* '}' )?
		('trees' '{' trees+=AtsyraTree (  trees+=AtsyraTree)* '}' )?
	'}';

Import returns Import:
    'import' importURI = EString;


Type returns Type:
	InternalType | SystemType;


GoalCondition returns GoalCondition:
	OrCondition ;
	
OrCondition returns GoalCondition:
	AndCondition ({OrCondition.operands+=current} 
    ('or' | 'OR') operands+=AndCondition)*
	;
	
AndCondition returns GoalCondition:
	TerminalCondition ({AndCondition.operands+=current} 
    ('and' | 'AND') operands+=TerminalCondition)*
	;	

TerminalCondition returns GoalCondition:
	'(' GoalCondition ')'|
	{NotCondition} ('not' | 'NOT') operands+= TerminalCondition|
	EqualOrBooleanCond 
	;


EqualOrBooleanCond returns AtomicCondition:
	{BooleanSystemCondition} source=[TypedElement|TypedElementString] |
	{EqualsCondition} source=[TypedElement|TypedElementString] (=>'=' target=[TypedElement|TypedElementString])
	;

TypedElementDecl returns TypedElement:
	'const' BooleanLiteral | BuildingSystemFeature | 'const' BuildingSystemConstFeature ;

EString returns ecore::EString:
	STRING | ID;
	
TypedElementString returns ecore::EString:
	STRING | ID | "true" | "false";

AtsyraGoal returns AtsyraGoal:
	'Goal'
	name=EString
	'{'
		('pre' ('with' defaultUsedInPre=[DefaultValues|EString])? ':' precondition=GoalCondition)? &
		('post' ('with' defaultUsedInPost=[DefaultValues|EString])?':' postcondition=GoalCondition)? 
	'}';


DefaultValues returns DefaultValues:
	{DefaultValues}
	name=EString
	'{'
 		(defaultValueAssignments+= DefaultValueAssignments ( "," defaultValueAssignments+=DefaultValueAssignments)* )?
	'}';

DefaultValueAssignments returns DefaultAssignment:
	{DefaultAssignment}
	target=[SystemFeature|EString] '=' assignedValue=[TypedElement|TypedElementString]
	;

	
AbstractAtsyraTree returns AbstractAtsyraTree:
	AtsyraTree | AtsyraTreeReference;

AtsyraTreeReference returns AtsyraTreeReference:
	referencedTree=[AtsyraTree|EString];

AtsyraTree returns AtsyraTree:
	{AtsyraTree}
	name=EString
	'[' (mainGoal=[AtsyraGoal] )?']'
	(operator=AtsyraTreeOperator  '(' operands+=AbstractAtsyraTree ( "," operands+=AbstractAtsyraTree)* ')')? 
	;

BooleanLiteral returns BooleanLiteral:
	{BooleanLiteral}
	name=("true" | "false") '('  type=[Type|EString]  ')';

enum AtsyraTreeOperator:
    OR='OR' | SAND='SAND' | AND='AND';

BuildingSystemFeature returns SystemFeature:
	name=EString '('  type=[Type|EString]  ')'
	;

BuildingSystemConstFeature returns SystemConstFeature:
	name=EString '('  type=[Type|EString]  ')'
	;



InternalType returns InternalType:
	{InternalType}
	'InternalType'
	name=EString
	;

SystemType returns SystemType:
	{SystemType}
	'SystemType'
	name=EString
	;


terminal ID : 
 '^'?('a'..'z'|'A'..'Z'|'_')('a'..'z'|'A'..'Z'|'.'|'_'|'0'..'9')*;