Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

M2M/ATL/Syntax

< M2M‎ | ATL

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 and manually beautified.

Identifiers like unit and module denote non-terminals. Terminals are given between single quotes (e.g., 'module', 'create'). The left hand side and right hand side of each production rule are separated by the colon-colon-equals (::=) operator. Traditional EBNF operators have the following semantics: * denotes a possibly empty repetition, + denotes a repetition with at least one occurrence, and ? denotes an optional single occurrence. Each production rule is terminated by a semicolon (;). The start symbol is unit.

unit ::= module | library | query;

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

library ::= 'library' IDENTIFIER ';' libraryRef* helper*;

query ::= 'query' IDENTIFIER '=' oclExpression ';' libraryRef* 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* '}')? outPattern? actionBlock? '}';

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

calledRule ::= 'entrypoint'? 'endpoint'? 'rule' IDENTIFIER '(' (parameter (',' parameter)*)? ')' '{' ('using' '{' 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 ::= ifStat | expressionStat | bindingStat | forStat;

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

expressionStat ::= oclExpression ';';

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

forStat ::= 'for' '(' iterator 'in' oclExpression ')' '{' 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* '}')? 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 ')';

Back to the top