====== Grammaire Kmelia ====== **Modifs** : Peut-on remplacer "existe" et "forall" par "#" et "!" ? NOn: c'est illisible et ce sont des caracteres reserves ( commentaire et emission de message) class AnalyserSyn extends Parser; ===== Composant ===== component : "COMPONENT" name ( IMP_ML_COMMENT )? ( "status" WORD )? compinterface ( complibclause )? ( comptypesclause )? ( compconstantsclause )? ( compvariablesclause )? ( compinvariantclause )? ( comppropertiesclause )? ( compservpropertiesclause )? ( compinitializationclause )? services ( composition )? ; compinterface : "INTERFACE" ( providesclause )? ( requiresclause )? ; providesclause : "provides" COLON namelist ; requiresclause : "requires" COLON namelist ; complibclause : "USES" namelist ; comptypesclause : "TYPES" decl_types ; compconstantsclause : "CONSTANTS" decl_constants ; compobservvariablesclause : "VARIABLES" decl_variables_and_rename ; compobservinvariantclause : "INVARIANT" properties ; comppropertiesclause : "PROPERTIES" properties ; compservpropertiesclause : "SERVICE_PROPERTIES" servproperties ; compinitializationclause : "INITIALIZATION" init_variables ; ===== Composition ===== composition : "COMPOSITION" ( IMP_ML_COMMENT )? component_list COMMA linklist ; component_list : BLOCK_START ( componentoccurrence )* BLOCK_END ; componentoccurrence : ( WORD COLON )? WORD ; linklist : BLOCK_START ( toplevellink )* BLOCK_END ; toplevellink : PAR_START baselink sublinklist PAR_END ; sublinklist : ( PAR_START baselink PAR_END )* ; baselink : ( LINKTYPE )? WORD PERIOD WORD COMMA WORD PERIOD WORD ; ===== Services ===== services : "SERVICES" ( ( rp_service ) )* "END_SERVICES" ; a_service : ( external_service | service ) ; external_service : "external" WORD ; rp_service : ( "provided" a_service | "required" a_service ) ; service : WORD ( PAR_START ( decl_variables )? PAR_END )? ( return_type )? ( IMP_ML_COMMENT )? ( servinterface )? ( servpropertiesclause )? ( preclause )? ( servconstantsclause )? ( servvariablesclause )? ( servinitializationclause )? ( lts )? ( postclause )? "end" ; servinterface : "Interface" ( subprovidesclause )? ( calrequiresclause )? ( extrequiresclause )? ( intrequiresclause )? ( receptionsclause )? ( sendingsclause )? ; subprovidesclause : "subprovides" COLON namelist ; calrequiresclause : "calrequires" COLON namelist ; extrequiresclause : "extrequires" COLON namelist ; intrequiresclause : "intrequires" COLON namelist ; receptionsclause : "receptions" COLON namelist ; sendingsclause : "sendings" COLON namelist ; preclause : "Pre" properties ; postclause : "Post" properties ; servpropertiesclause : "Properties" namelist ; servconstantsclause : "Constants" decl_constants ; servvariablesclause : "Variables" decl_variables ; servinitializationclause : "Initialization" init_variables ; init_variables : identPrimary AFFECTE expression ( SEMICOLON identPrimary AFFECTE expression )* ( SEMICOLON ) ; ===== Variables ===== decl_variables_and_rename : ( "obs" )? decl_variables_untype_or_rename ( SEMICOLON ( "obs" )? decl_variables_untype_or_rename )* ; decl_variables_untype_or_rename : ( WORD ) ( COMMA WORD )* COLON typedef ( "from" identPrimary )? ; decl_constants : decl_aconstant ( SEMICOLON decl_aconstant )* ; decl_aconstant : ( "obs" )? WORD COLON a_typename AFFECTE expression ( "from" identPrimary )? ; decl_variables : decl_variables_untype ( SEMICOLON decl_variables_untype )* ; decl_variables_untype : ( WORD ( COMMA WORD )* )+ COLON typedef ; ===== Types ===== decl_types : a_type ( SEMICOLON a_type )* ; a_type : WORD COLON typedef ; typedef : ( a_typename | a_struct | an_array | an_enum | a_range | a_set ) ; a_struct : "struct" BLOCK_START decl_types BLOCK_END ; an_array : "array" BRACKET_START NUMBER PERIOD PERIOD NUMBER BRACKET_END "of" a_typename ; an_enum : "enum" namelist ; a_range : "range" NUMBER PERIOD PERIOD NUMBER ; a_set : "setOf" a_typename ; a_typename : ( WORD | INTEGER | BOOL | STRING ) ; ===== LTS ===== initial_state : "init" state ; final_states : "final" statelist ; statelist : state ( COMMA state )* ; state : WORD ; lts : ( "Behavior" | "Behaviour" ) initial_state final_states BLOCK_START lignes_lts BLOCK_END ; lignes_lts : ( state_line | transition_line ) ( COMMA ( state_line | transition_line ) )* ; state_line : state ( callable_service_list )? ; transition_line : state ARROW_START label ARROW_END state ; ===== Expressions ===== primaryExpression : identPrimary ( arg_list )? ( array_index )? | constant | TRUE | FALSE | PAR_START conditionalExpression PAR_END ; identPrimary : WORD ( PERIOD WORD )* ; array_index : BRACKET_START expression BRACKET_END ; simple_arg_list : PAR_START ( simple_args | ) PAR_END ; simple_args : primaryExpression ( COMMA primaryExpression )* ; arg_list : PAR_START ( expressionList )? PAR_END ; expression : assignmentExpression ; expressionList : expression ( COMMA expression )* ; assignmentExpression : conditionalExpression ( AFFECTE ( communicationbis | conditionalExpression ) )? ; conditionalExpression : PAR_START logicalImpliesExpression PAR_END | logicalImpliesExpression ; logicalImpliesExpression : logicalEquivExpression ( "implies" logicalEquivExpression )* ; logicalEquivExpression : logicalXorExpression ( "equiv" logicalXorExpression )* ; logicalXorExpression : logicalOrExpression ( "xor" logicalOrExpression )* ; logicalOrExpression : logicalAndExpression ( ( LOR | "or" ) logicalAndExpression )* ; logicalAndExpression : equalityExpression ( ( LAND | "and" ) equalityExpression )* ; equalityExpression : relationalExpression ( ( DIFF | "!=" | EQUAL ) relationalExpression )* ; relationalExpression : additiveExpression ( ( "<" | ">" | LE | GE | "=" | "<>" | "in" ) additiveExpression )* ; additiveExpression : multiplicativeExpression ( ( PLUS | MINUS ) multiplicativeExpression )* ; multiplicativeExpression : unaryExpression ( ( MULT | DIV ) unaryExpression )* ; unaryExpression : MINUS unaryExpression | PLUS unaryExpression | unaryExpressionNotPlusMinus ; unaryExpressionNotPlusMinus : BNOT unaryExpression | LNOT unaryExpression | "not" unaryExpression | postfixExpression ; postfixExpression : primaryExpression ( INCR | ARROW_START )? ; constant : NUMBER | CHAR_LITERAL | STRING_LITERAL ; ===== Properties and predicates ===== properties : property ( COMMA property )* ; property : ( WORD COLON )? predicate ; servproperties : WORD COLON WORD ( COMMA WORD COLON WORD )* ; return_type : COLON typedef ; predicate : ( "obs" )? ( "forall" decl_variables )? ( "exists" decl_variables )? expression ; ===== Labels et commandes ===== label : ( guard )? command ; guard : BRACKET_START expression BRACKET_END ; command : ( communicationbis | expression | ablock | mandatoryCallExpression ) ; conditionalAction : "if" conditionalExpression "then" expression ( "else" expression )? "fi" ; ablock : BLOCK_START command ( SEMICOLON command )* BLOCK_END ; ===== Communications ===== communicationbis : interlocutorSet ( servicecall ) ; interlocutorSet : PORT ( COLON WORD )? ( BRACKET_START selector BRACKET_END )? ; selector : ( COLON )? WORD | NUMBER ; mandatoryCallExpression : BRACKET_START BRACKET_START ( interlocutorSet PERIOD )? name BRACKET_END BRACKET_END ; servicecall : ( DB_EXCLAM_MARK | EXCLAM_MARK | DB_QUESTION_MARK | QUESTION_MARK ) WORD ( PAR_START ( expressionList )? PAR_END )? ; callable_service_list : "<" ( ( PIPE ) | ( "<" ) ) ( interlocutorSet PERIOD )? ( WORD | BLOCK_START WORD ( COMMA WORD )* BLOCK_END ) ( ( PIPE ) | ">" ) ">" ; ===== Vrac ===== namelist : BLOCK_START name ( COMMA name )* BLOCK_END ; name : WORD ;