Jump to: navigation, search

Difference between revisions of "M2M/ATL/Syntax"

< M2M‎ | ATL
(created a page for the ATL syntax)
(No difference)

Revision as of 10:43, 8 February 2008

This page presents the ATL textual syntax.

The authoritative ATL syntax is its specification in TCS: ATL.tcs. The following EBNF grammar has been automatically generated from this specification:

unit ::= module | library | query;

module ::= 'module' IDENTIFIER ';' 'create' oclModel (',' oclModel)* ('refining' | 'from') oclModel (',' oclModel)* ';' (libraryRef libraryRef*)? (moduleElement moduleElement*)?;

library ::= 'library' IDENTIFIER ';' (libraryRef libraryRef*)? (helper helper*)?;

query ::= 'query' IDENTIFIER '=' oclExpression ';' (libraryRef libraryRef*)? (helper helper*)?;

libraryRef ::= 'uses' IDENTIFIER ';';

moduleElement ::= helper | rule;

helper ::= 'helper' oclFeatureDefinition ';';

oclFeatureDefinition ::= oclContextDefinition? 'def' ':' oclFeature;

oclContextDefinition ::= 'context' oclType;

oclFeature ::= operation | attribute;

operation ::= IDENTIFIER '(' (parameter (',' parameter)*)? ')' ':' oclType '=' oclExpression;

parameter ::= IDENTIFIER ':' oclType;

attribute ::= IDENTIFIER ':' oclType '=' oclExpression;

rule ::= calledRule | matchedRule;

matchedRule ::= lazyMatchedRule | matchedRule_abstractContents;

lazyMatchedRule ::= 'unique'? 'lazy' 'abstract'? 'refining'? 'rule' IDENTIFIER ('extends' IDENTIFIER)? '{' inPattern ('using' '{' (ruleVariableDeclaration ruleVariableDeclaration*)? '}')? outPattern? actionBlock? '}';

ruleVariableDeclaration ::= IDENTIFIER ':' oclType '=' oclExpression ';';

calledRule ::= 'entrypoint'? 'endpoint'? 'rule' IDENTIFIER '(' (parameter (',' parameter)*)? ')' '{' ('using' '{' (ruleVariableDeclaration ruleVariableDeclaration*)? '}')? outPattern? actionBlock? '}';

inPattern ::= 'from' inPatternElement (',' inPatternElement)* ('(' oclExpression ')')?;

inPatternElement ::= simpleInPatternElement;

simpleInPatternElement ::= IDENTIFIER ':' oclType ('in' (IDENTIFIER (',' IDENTIFIER)*)?)?;

outPattern ::= 'to' outPatternElement (',' outPatternElement)*;

outPatternElement ::= simpleOutPatternElement | forEachOutPatternElement;

simpleOutPatternElement ::= IDENTIFIER ':' oclType ('in' IDENTIFIER)? ('mapsTo' IDENTIFIER)? ('(' (binding (',' binding)*)? ')')?;

forEachOutPatternElement ::= IDENTIFIER ':' 'distinct' oclType 'foreach' '(' iterator 'in' oclExpression ')' ('mapsTo' IDENTIFIER)? ('(' (binding (',' binding)*)? ')')?;

binding ::= IDENTIFIER '<-' oclExpression;

actionBlock ::= 'do' '{' (statement statement*)? '}';

statement ::= ifStat | expressionStat | bindingStat | forStat;

bindingStat ::= oclExpression '<-' oclExpression ';';

expressionStat ::= oclExpression ';';

ifStat ::= 'if' '(' oclExpression ')' (statement | '{' (statement statement*)? '}') ('else' (statement | '{' (statement statement*)? '}'))?;

forStat ::= 'for' '(' iterator 'in' oclExpression ')' '{' (statement statement*)? '}';

oclModel ::= IDENTIFIER ':' IDENTIFIER;

oclModelElement ::= IDENTIFIER '!' IDENTIFIER;

oclExpression ::= priority_5 | letExp;

iteratorExp ::= IDENTIFIER '(' iterator (',' iterator)* '|' oclExpression ')';

iterateExp ::= 'iterate' '(' iterator (',' iterator)* ';' variableDeclaration '|' oclExpression ')';

collectionOperationCallExp ::= IDENTIFIER '(' (oclExpression (',' oclExpression)*)? ')';

operationCallExp ::= IDENTIFIER '(' (oclExpression (',' oclExpression)*)? ')';

navigationOrAttributeCallExp ::= IDENTIFIER;

iterator ::= IDENTIFIER;

oclUndefinedExp ::= 'OclUndefined';

primitiveExp ::= numericExp | booleanExp | stringExp;

numericExp ::= integerExp | realExp;

booleanExp ::= 'true' | 'false';

integerExp ::= INTEGER;

realExp ::= FLOAT;

stringExp ::= STRING;

ifExp ::= 'if' oclExpression 'then' oclExpression 'else' oclExpression 'endif';

variableExp ::= IDENTIFIER;

superExp ::= 'super';

letExp ::= 'let' variableDeclaration 'in' oclExpression;

variableDeclaration ::= IDENTIFIER ':' oclType '=' oclExpression;

enumLiteralExp ::= '#' IDENTIFIER;

collectionExp ::= bagExp | setExp | orderedSetExp | sequenceExp;

bagExp ::= 'Bag' '{' (oclExpression (',' oclExpression)*)? '}';

setExp ::= 'Set' '{' (oclExpression (',' oclExpression)*)? '}';

orderedSetExp ::= 'OrderedSet' '{' (oclExpression (',' oclExpression)*)? '}';

sequenceExp ::= 'Sequence' '{' (oclExpression (',' oclExpression)*)? '}';

mapExp ::= 'Map' '{' (mapElement (',' mapElement)*)? '}';

mapElement ::= '(' oclExpression ',' oclExpression ')';

tupleExp ::= 'Tuple' '{' (tuplePart (',' tuplePart)*)? '}';

tuplePart ::= IDENTIFIER (':' oclType)? '=' oclExpression;

oclType ::= oclModelElement | oclAnyType | tupleType | mapType | primitive | collectionType | oclType_abstractContents;

oclAnyType ::= oclAnyType_abstractContents;

tupleType ::= 'TupleType' '(' (tupleTypeAttribute (',' tupleTypeAttribute)*)? ')';

tupleTypeAttribute ::= IDENTIFIER ':' oclType;

mapType ::= 'Map' '(' oclType ',' oclType ')';

primitive ::= numericType | booleanType | stringType;

numericType ::= integerType | realType;

integerType ::= 'Integer';

realType ::= 'Real';

booleanType ::= 'Boolean';

stringType ::= 'String';

collectionType ::= bagType | setType | orderedSetType | sequenceType | collectionType_abstractContents;

bagType ::= 'Bag' '(' oclType ')';

setType ::= 'Set' '(' oclType ')';

orderedSetType ::= 'OrderedSet' '(' oclType ')';

sequenceType ::= 'Sequence' '(' oclType ')';

priority_0 ::= primary_oclExpression ('.' (operationCallExp | navigationOrAttributeCallExp) | '->' (iteratorExp | iterateExp | collectionOperationCallExp))*;

priority_1 ::= 'not' priority_0 | '-' priority_0 | priority_0;

priority_2 ::= priority_1 ('*' priority_1 | '/' priority_1 | 'div' priority_1 | 'mod' priority_1)*;

priority_3 ::= priority_2 ('+' priority_2 | '-' priority_2)*;

priority_4 ::= priority_3 ('=' priority_3 | '>' priority_3 | '<' priority_3 | '>=' priority_3 | '<=' priority_3 | '<>' priority_3)*;

priority_5 ::= priority_4 ('and' priority_4 | 'or' priority_4 | 'xor' priority_4 | 'implies' priority_4)*;

matchedRule_abstractContents ::= 'nodefault'? 'abstract'? 'refining'? 'rule' IDENTIFIER ('extends' IDENTIFIER)? '{' inPattern ('using' '{' (ruleVariableDeclaration ruleVariableDeclaration*)? '}')? outPattern? actionBlock? '}';

oclType_abstractContents ::= 'OclType';

oclAnyType_abstractContents ::= 'OclAny';

collectionType_abstractContents ::= 'Collection' '(' oclType ')';

primary_oclExpression ::= variableExp | oclUndefinedExp | primitiveExp | ifExp | superExp | enumLiteralExp | collectionExp | mapExp | tupleExp | oclType | '(' oclExpression ')';