Les syntaxes sont décrites en utilisant le formalisme yacc.
%token Name StringLiteral IntegerLiteral "-option"
%token INVERSE ENUM TYPE LABEL TRUE FALSE INFINITY
%token "{" "}" "[" "]" ";" "," ":" "." "#" "*" "|" "-" ":="
%%
specification : definitionRpt0;
definition
: typeDefinition SCOpt
| classDefinition SCOpt;
typeDefinition
: TYPE identifier stereotypeRpt0 ":" ENUM "{" enumeratorList "}" stereotypeRpt0 labelOpt
| TYPE identifier stereotypeRpt0 ":" identifier stereotypeRpt0 labelOpt;
enumeratorList
: enumElement
| enumeratorList "," enumElement;
enumElement : identifier labelOpt;
classDefinition : classHeader inheritanceOpt stereotypeRpt0 "{" attributeRpt0 "}" labelOpt;
classHeader : classId;
inheritance : ":" identifier;
attribute : identifier ":" identifier multiplicityOpt initialValueOpt inverseOpt stereotypeRpt0 labelOpt SCOpt;
initialValue : ":=" literal;
inverse : INVERSE identifier;
multiplicity
: "[" integer "." "." integer "]"
| "[" integer "." "." "*" "]"
| "[" integer "]"
| "[" "*" "]";
stereotype : "-option" | "-option" "[" literal "]";
label : LABEL string;
literal : string | IntegerLiteral | "-" IntegerLiteral | INFINITY | TRUE | FALSE | "#" identifier | identifier "#" identifier;
classId : identifier;
integer : IntegerLiteral;
identifier : Name;
string : StringLiteral | StringLiteral "|" StringLiteral;
inverseOpt : | inverse;
multiplicityOpt : | multiplicity;
inheritanceOpt : | inheritance;
definitionRpt0 : | definitionRpt0 definition;
attributeRpt0 : | attributeRpt0 attribute;
stereotypeRpt0 : | stereotypeRpt0 stereotype;
SCOpt : | ";";
labelOpt : | label;
initialValueOpt : | initialValue;
%token FORM METHOD RULE CLUSTER BROWSER DIAGRAM DOCUMENT INVERSE EXHAUSTIVE
%token CLASS FIELDS LABEL NAME PRIMITIVE LIBRARY VERSION EXPLAIN REPAIR PRINT WHEN DISPLAY COLOR FILL DO CREATE INSERT ASK CLICK SELECT BUTTON WIDTH HEIGHT TMP NONE SORTBY
%token SYNTAXEXPR SYNTAXINTERFACE SYNTAXMAIN
%token THIS EACH EACHINDEX ISA TRUE FALSE
%token ALL IN SOME NEW VOID
%token "=" "/=" "$=" "$*" "$+" "$-" "$<" DEFAULT
%token IF ELSE
%token "+=" "<" "<=" ">" ">="
%token "+" "-" "*" "/" "|"
%token "(" ")" "{" "}" "[" "]"
%token ";" "," ":" "." "#" "^" INFINITY
%token Name StringLiteral IntegerLiteral RealLiteral
%token "-option"
%%
specification
: SYNTAXINTERFACE definitionRpt0
| SYNTAXEXPR statementRpt1SC SCOpt
| SYNTAXMAIN mainHeader "{" moduleRpt0 "}" SCOpt;
mainHeader : identifier ":" labelOpt versionOpt;
module : identifier labelOpt;
definition
: oneClassDefinition
| groupClassDefinition
| globalVariableDecl;
oneClassDefinition
: METHOD classHeader ":" ":" methodSpecification ";"
| RULE classHeader ":" ":" ruleSpecification ";"
| CLUSTER classHeader ":" ":" clusterSpecification ";"
| FORM classHeader ":" ":" formSpecification ";"
| BROWSER classHeader ":" ":" browserSpecification ";"
| DIAGRAM classHeader ":" ":" diagramSpecification ";"
| DOCUMENT classHeader ":" ":" docSpecification ";"
| LABEL classHeader ":" ":" labelSpecification ";"
;
groupClassDefinition : classHeader "{" classConfigurationRpt0 "}";
classHeader : classId stereotypeRpt0;
classConfiguration
: METHODOpt methodSpecification ";"
| RULE ruleSpecification ";"
| CLUSTER clusterSpecification ";"
| FORM formSpecification ";"
| BROWSER browserSpecification ";"
| DIAGRAM diagramSpecification ";"
| DOCUMENT docSpecification ";"
| LABEL labelSpecification ";"
;
methodSpecification : identifier argsOpt stereotypeRpt0 ":" navigation labelOpt;
methodSpecification : identifier argsOpt stereotypeRpt0 ":" PRIMITIVE identifier labelOpt;
methodSpecification : identifier argsOpt stereotypeRpt0 ":" PRIMITIVE identifier LIBRARY string labelOpt;
ruleSpecification : identifier stereotypeRpt0 ":" navigation labelOpt explainOpt repairOpt;
clusterSpecification : gCl stereotypeRpt0 clusterSectionRpt0;
formSpecification : identifier stereotypeRpt0 ":" labelOpt widthOpt conditionOpt "{" formFieldRpt0 "}";
browserSpecification : identifier stereotypeRpt0 ":" gBr listDefinition;
diagramSpecification : identifier stereotypeRpt0 ":" gDi listDefinition;
docSpecification : identifier stereotypeRpt0 ":" gDoc listDefinition;
labelSpecification : string | identifier string;
gCl : ;
clusterSection
: label
| print
| do
| create;
gBr : ;
gDi : ;
gDoc : ;
formField
: fieldAtt stereotypeRpt0 conditionOpt gff1 labelOpt widthOpt heightOpt printOpt doRpt0 createRpt0 insertOpt gff2 ";";
/* | DISPLAY navigation stereotypeRpt0 conditionOpt gff1 labelOpt widthOpt heightOpt printOpt gff2 ";"; */
| displayField stereotypeRpt0 conditionOpt gff1 labelOpt widthOpt heightOpt printOpt gff2 ";";
| FILL stereotypeRpt0 labelOpt widthOpt heightOpt ";";
| BUTTON navigation stereotypeRpt0 conditionOpt labelOpt widthOpt heightOpt ";";
gff1 : ;
gff2 : ;
displayField
: DISPLAY navigation
| DISPLAY navigation gdf DO navigation;
gdf : ;
fieldAtt : navigation;
condition : WHEN navigation;
print : PRINT navigation;
color : COLOR navigation;
width
: WIDTH IntegerLiteral
| WIDTH IntegerLiteral "+" IntegerLiteral;
height : HEIGHT IntegerLiteral;
do :
DO navigation conditionOpt label stereotypeRpt0;
insert
: insertHeader gi1 navigation gi2
| insertHeader gi1 navigation gi2 ":" block
| insertHeader NONE;
insertHeader : INSERT labelOpt stereotypeRpt0;
gi1 : ;
gi2 : ;
create
: createHeader block
| createHeader NONE;
createHeader : CREATE classIdOpt labelOpt stereotypeRpt0;
gcs1 : ;
range : ":" navigation;
listDefinition : listDefinitionSectionRpt0 subListDefinitionsOpt;
listDefinitionSection
: DISPLAY identifier graphArgsOpt stereotypeRpt0;
| label | print stereotypeRpt0 | color | create | insert | do | temps | EXHAUSTIVE navigation;
graphArgs
: "(" navigationRpt0CM ")";
subListDefinitions : "{" tempsOpt subListDefinitionRpt0 "}";
subListDefinition : transition CLOpt listDefinition ";";
transition : directTransition inverseTransition transitionName;
directTransition : navigation;
inverseTransition : INVERSE navigation | ;
transitionName : nameOpt;
/* navigation: */
navigation
: navigation0;
navigation0
: navigation1
| attributeId "+=" navigation0
| navigation2 "." attributeId "+=" navigation0
| navigation1 ifSelectorRpt1;
ifSelector
: IF literal ":" navigation1
| ELSE ":" navigation1;
navigation1
: navigation2
| navigation1 op navigation2
| navigation1 ISA classId;
navigation2
: navigation3
| navigation2 "." attributeId
| navigation2 "." attributeId "(" navigationRpt0CM ")"
| navigation2 "." beginEach "*" block
| navigation2 "." beginEach "*" classId gEach ":" ":" block
| navigation2 "." beginEach block
| navigation2 "[" beginEach navigation1 "]"
| navigation2 "." beginEach SORTBY "(" navigation ")";
gEach : ;
beginEach : ;
navigation3
: attributeId
| attributeId "(" navigationRpt0CM ")"
| "^" attributeId
| "^" attributeId "(" navigationRpt0CM ")"
| THIS | each
| literal
| instruction
| block;
each
: EACH | EACHINDEX
| "^" each;
statement
: navigation
| dialog stereotypeRpt0;
block
: "(" navigation ")"
| "{" tempsOpt statementRpt1SC SCOpt "}";
instruction
: ALL classId
| ALL classId IN navigation3
| SOME classId
| VOID classId
| NEW classId;
dialog
: ASK fieldAtt rangeOpt gcs1 labelOpt widthOpt heightOpt printOpt createRpt0
| CLICK fieldAtt rangeOpt gcs1 labelOpt createRpt0
| SELECT fieldAtt rangeOpt gcs1 labelOpt createRpt0;
op : "=" | "/=" | "$=" | "$*" | "$+" | "$-" | "$<" | DEFAULT | "+" | "-" | "*" | "/" | "<" | "<=" | ">" | ">=";
literal : string | IntegerLiteral | "-" IntegerLiteral | RealLiteral | "-" RealLiteral | INFINITY | TRUE | FALSE | "#" identifier | identifier "#" identifier;
variableDecl : identifier ":" identifier;
temps : TMP variableDeclRpt0CM ";";
args : "(" variableDeclRpt0CM ")";
globalVariableDecl : TMP identifier ":" identifier ";";
stereotype : "-option" | "-option" "[" navigation "]";
classId : identifier;
attributeId : identifier;
label : LABEL string;
name : NAME string;
version : VERSION string;
explain : EXPLAIN navigation labelOpt;
repair : REPAIR navigation;
identifier : Name;
string : StringLiteral | StringLiteral "|" StringLiteral;
classConfigurationRpt0 : | classConfigurationRpt0 classConfiguration;
definitionRpt0 : | definitionRpt0 definition;
subListDefinitionRpt0 : | subListDefinitionRpt0 subListDefinition;
METHODOpt : | METHOD;
labelOpt : | label;
versionOpt : | version;
classIdOpt : | classId;
explainOpt : | explain;
repairOpt : | repair;
printOpt : | print;
widthOpt : | width;
heightOpt : | height;
formFieldRpt0 : | formFieldRpt0 formField;
subListDefinitionsOpt : | subListDefinitions;
rangeOpt : | range;
ifSelectorRpt1 : ifSelector | ifSelectorRpt1 ifSelector;
variableDeclRpt1CM : variableDecl | variableDeclRpt1CM "," variableDecl;
variableDeclRpt0CM : | variableDeclRpt1CM;
stereotypeRpt0 : | stereotypeRpt0 stereotype;
listDefinitionSectionRpt0 : | listDefinitionSectionRpt0 listDefinitionSection;
createRpt0 : | createRpt0 create;
doRpt0 : | doRpt0 do;
clusterSectionRpt0 : | clusterSectionRpt0 clusterSection;
navigationRpt1CM : navigation | navigationRpt1CM "," navigation;
navigationRpt0CM : | navigationRpt1CM;
moduleRpt0 : | moduleRpt0 module;
statementRpt1SC : statement | statementRpt1SC ";" statement;
SCOpt : | ";";
tempsOpt : | temps;
argsOpt : | args;
graphArgsOpt : | graphArgs;
insertOpt : | insert;
nameOpt : | name;
conditionOpt : | condition;
CLOpt : | ":";