Outils pour utilisateurs

Outils du site


kmelia:gramkml

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 
;

componentlist : BLOCKSTART

( 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" 
;

aservice : ( externalservice | service )

;

external_service :

"external" WORD 
;

rpservice : ( “provided” aservice | “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

declvariablesandrename : ( “obs” )? declvariablesuntypeorrename ( SEMICOLON ( “obs” )? declvariablesuntypeor_rename )*

;

declvariablesuntypeorrename :

( WORD ) 
( COMMA WORD )* 
COLON typedef 
( "from" identPrimary )? 
;

declconstants : declaconstant

( SEMICOLON decl_aconstant )* 
;

declaconstant : ( “obs” )? WORD COLON atypename AFFECTE expression

( "from" identPrimary )? 
;

declvariables : declvariablesuntype ( SEMICOLON declvariables_untype )*

;

declvariablesuntype :

( WORD ( COMMA WORD )* )+ 
COLON typedef 
;

Types

decltypes : atype

( SEMICOLON a_type )* 
;

a_type :

WORD COLON typedef 
;

typedef :

( a_typename | a_struct | an_array | an_enum | a_range | a_set ) 
;

astruct : “struct” BLOCKSTART decltypes BLOCKEND

;

anarray : “array” BRACKETSTART NUMBER PERIOD PERIOD NUMBER BRACKETEND “of” atypename

;

an_enum :

"enum" namelist 
;

a_range :

"range" NUMBER PERIOD PERIOD NUMBER 
;

aset : “setOf” atypename

;

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 
;

ligneslts : ( stateline | transitionline ) ( COMMA ( stateline | transition_line ) )*

;

stateline : state ( callableservice_list )?

;

transitionline : state ARROWSTART label ARROW_END state

;

Expressions

primaryExpression :

identPrimary 
( arg_list )? 
( array_index )? 

| constant 
| TRUE 
| FALSE 
| PAR_START conditionalExpression PAR_END 
;

identPrimary :

WORD 
( PERIOD WORD )* 
;

arrayindex : BRACKETSTART expression BRACKET_END

;

simplearglist :

PAR_START 
( simple_args | ) 
PAR_END 
;

simple_args :

primaryExpression 
( COMMA primaryExpression )* 
;

arglist : PARSTART

( 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 )? 
;

callableservicelist :

"<" 
( ( PIPE ) | ( "<" ) ) 
( interlocutorSet PERIOD )? 
( WORD | BLOCK_START WORD ( COMMA WORD )* BLOCK_END ) 
( ( PIPE ) | ">" ) 
">" 
;

Vrac

namelist :

BLOCK_START name 
( COMMA name )* 
BLOCK_END 
;

name :

WORD 
;
kmelia/gramkml.txt · Dernière modification: 2018/04/03 16:59 (modification externe)