diff options
Diffstat (limited to 'src/uscxml/plugins/datamodel/promela/parser/promela.ypp')
-rw-r--r-- | src/uscxml/plugins/datamodel/promela/parser/promela.ypp | 196 |
1 files changed, 98 insertions, 98 deletions
diff --git a/src/uscxml/plugins/datamodel/promela/parser/promela.ypp b/src/uscxml/plugins/datamodel/promela/parser/promela.ypp index 5d45c71..cf8deea 100644 --- a/src/uscxml/plugins/datamodel/promela/parser/promela.ypp +++ b/src/uscxml/plugins/datamodel/promela/parser/promela.ypp @@ -46,34 +46,34 @@ using namespace uscxml; %type <node> expr pfld varref decl_lst stmnt_lst vardcl ivar var_list one_decl prargs %type <node> stmnt Stmnt const_expr nlst vis arg -%token VAR_ARRAY VARLIST DECL DECLLIST STMNT COLON EXPR NAMELIST +%token PML_VAR_ARRAY PML_VARLIST PML_DECL PML_DECLLIST PML_STMNT PML_COLON PML_EXPR PML_NAMELIST %token '(' ')' %token '[' ']' %token '{' '}' -%token ASSERT PRINT PRINTM -%token <value> LEN STRING -%token TYPEDEF MTYPE INLINE RETURN LABEL OF -%token GOTO BREAK ELSE SEMI ARROW -%token IF FI DO OD FOR SELECT IN SEP DOTDOT -%token HIDDEN SHOW ISLOCAL -%token <value> CONST TYPE XU /* val */ -%token <value> NAME UNAME PNAME INAME /* sym */ -%token CLAIM TRACE INIT LTL /* sym */ -%token COMMA - -%right ASGN -%left OR AND -%left BITOR BITXOR BITAND -%left EQ NE -%left GT LT GE LE -%left LSHIFT RSHIFT -%left PLUS MINUS -%left TIMES DIVIDE MODULO -%left INCR DECR -%left COMPL -%right NEG -%left DOT +%token PML_ASSERT PML_PRINT PML_PRINTM +%token <value> PML_LEN PML_STRING +%token PML_TYPEDEF PML_MTYPE PML_INLINE PML_RETURN PML_LABEL PML_OF +%token PML_GOTO PML_BREAK PML_ELSE PML_SEMI PML_ARROW +%token PML_IF PML_FI PML_DO PML_OD PML_FOR PML_SELECT PML_IN PML_SEP PML_DOTDOT +%token PML_HIDDEN PML_SHOW PML_ISLOCAL +%token <value> PML_CONST PML_TYPE PML_XU /* val */ +%token <value> PML_NAME PML_UNAME PML_PNAME PML_INAME /* sym */ +%token PML_CLAIM PML_TRACE PML_INIT PML_LTL /* sym */ +%token PML_COMMA + +%right PML_ASGN +%left PML_OR PML_AND +%left PML_BITOR PML_BITXOR PML_BITAND +%left PML_EQ PML_NE +%left PML_GT PML_LT PML_GE PML_LE +%left PML_LSHIFT PML_RSHIFT +%left PML_PLUS PML_MINUS +%left PML_TIMES PML_DIVIDE PML_MODULO +%left PML_INCR PML_DECR +%left PML_COMPL +%right PML_NEG +%left PML_DOT %% @@ -98,8 +98,8 @@ program : varref : cmpnd {} ; -pfld : NAME { $$ = ctx->value(NAME, $1); free($1); } - | NAME '[' expr ']' { $$ = ctx->node(VAR_ARRAY, 2, ctx->value(NAME, $1), $3); free($1); } +pfld : PML_NAME { $$ = ctx->value(PML_NAME, $1); free($1); } + | PML_NAME '[' expr ']' { $$ = ctx->node(PML_VAR_ARRAY, 2, ctx->value(PML_NAME, $1), $3); free($1); } ; cmpnd : pfld {} @@ -107,60 +107,60 @@ cmpnd : pfld {} ; sfld : /* empty */ {} - | DOT cmpnd %prec DOT {} + | PML_DOT cmpnd %prec PML_DOT {} ; /* -expr_lst: expr { $$ = ctx->node(EXPR, 1, $1); } - | expr SEMI { $$ = ctx->node(EXPR, 1, $1); } - | expr SEMI expr_lst { $$ = ctx->node(EXPR, 2, $1, $3); } +expr_lst: expr { $$ = ctx->node(PML_EXPR, 1, $1); } + | expr PML_SEMI { $$ = ctx->node(PML_EXPR, 1, $1); } + | expr PML_SEMI expr_lst { $$ = ctx->node(PML_EXPR, 2, $1, $3); } ; */ expr : '(' expr ')' { $$ = $2; } - | expr PLUS expr { $$ = ctx->node(PLUS, 2, $1, $3); } - | expr MINUS expr { $$ = ctx->node(MINUS, 2, $1, $3); } - | expr TIMES expr { $$ = ctx->node(TIMES, 2, $1, $3); } - | expr DIVIDE expr { $$ = ctx->node(DIVIDE, 2, $1, $3); } - | expr MODULO expr { $$ = ctx->node(MODULO, 2, $1, $3); } - | expr BITAND expr { $$ = ctx->node(BITAND, 2, $1, $3); } - | expr BITXOR expr { $$ = ctx->node(BITXOR, 2, $1, $3); } - | expr BITOR expr { $$ = ctx->node(BITOR, 2, $1, $3); } - | expr GT expr { $$ = ctx->node(GT, 2, $1, $3); } - | expr LT expr { $$ = ctx->node(LT, 2, $1, $3); } - | expr GE expr { $$ = ctx->node(GE, 2, $1, $3); } - | expr LE expr { $$ = ctx->node(LE, 2, $1, $3); } - | expr EQ expr { $$ = ctx->node(EQ, 2, $1, $3); } - | expr NE expr { $$ = ctx->node(NE, 2, $1, $3); } - | expr AND expr { $$ = ctx->node(AND, 2, $1, $3); } - | expr OR expr { $$ = ctx->node(OR, 2, $1, $3); } - | expr LSHIFT expr { $$ = ctx->node(LSHIFT, 2, $1, $3); } - | expr RSHIFT expr { $$ = ctx->node(RSHIFT, 2, $1, $3); } - | NEG expr { $$ = ctx->node(NEG, 1, $2); } - | MINUS expr %prec MINUS { $$ = ctx->node(MINUS, 1, $2); } - - | LEN '(' varref ')' { $$ = ctx->node(LEN, 1, $3); } + | expr PML_PLUS expr { $$ = ctx->node(PML_PLUS, 2, $1, $3); } + | expr PML_MINUS expr { $$ = ctx->node(PML_MINUS, 2, $1, $3); } + | expr PML_TIMES expr { $$ = ctx->node(PML_TIMES, 2, $1, $3); } + | expr PML_DIVIDE expr { $$ = ctx->node(PML_DIVIDE, 2, $1, $3); } + | expr PML_MODULO expr { $$ = ctx->node(PML_MODULO, 2, $1, $3); } + | expr PML_BITAND expr { $$ = ctx->node(PML_BITAND, 2, $1, $3); } + | expr PML_BITXOR expr { $$ = ctx->node(PML_BITXOR, 2, $1, $3); } + | expr PML_BITOR expr { $$ = ctx->node(PML_BITOR, 2, $1, $3); } + | expr PML_GT expr { $$ = ctx->node(PML_GT, 2, $1, $3); } + | expr PML_LT expr { $$ = ctx->node(PML_LT, 2, $1, $3); } + | expr PML_GE expr { $$ = ctx->node(PML_GE, 2, $1, $3); } + | expr PML_LE expr { $$ = ctx->node(PML_LE, 2, $1, $3); } + | expr PML_EQ expr { $$ = ctx->node(PML_EQ, 2, $1, $3); } + | expr PML_NE expr { $$ = ctx->node(PML_NE, 2, $1, $3); } + | expr PML_AND expr { $$ = ctx->node(PML_AND, 2, $1, $3); } + | expr PML_OR expr { $$ = ctx->node(PML_OR, 2, $1, $3); } + | expr PML_LSHIFT expr { $$ = ctx->node(PML_LSHIFT, 2, $1, $3); } + | expr PML_RSHIFT expr { $$ = ctx->node(PML_RSHIFT, 2, $1, $3); } + | PML_NEG expr { $$ = ctx->node(PML_NEG, 1, $2); } + | PML_MINUS expr %prec PML_MINUS { $$ = ctx->node(PML_MINUS, 1, $2); } + + | PML_LEN '(' varref ')' { $$ = ctx->node(PML_LEN, 1, $3); } | varref { } - | CONST { $$ = ctx->value(CONST, $1); free($1); } + | PML_CONST { $$ = ctx->value(PML_CONST, $1); free($1); } ; -vis : /* empty */ { $$ = ctx->node(SHOW, 0); } - | HIDDEN { $$ = ctx->node(HIDDEN, 0); } - | SHOW { $$ = ctx->node(SHOW, 0); } - | ISLOCAL { $$ = ctx->node(ISLOCAL, 0); } +vis : /* empty */ { $$ = ctx->node(PML_SHOW, 0); } + | PML_HIDDEN { $$ = ctx->node(PML_HIDDEN, 0); } + | PML_SHOW { $$ = ctx->node(PML_SHOW, 0); } + | PML_ISLOCAL { $$ = ctx->node(PML_ISLOCAL, 0); } ; -one_decl: vis TYPE var_list { $$ = ctx->node(DECL, 3, $1, ctx->value(TYPE, $2), $3); free($2); } - | vis UNAME var_list { $$ = ctx->node(UNAME, 2, $1, $3); } - | vis TYPE ASGN '{' nlst '}' { $$ = ctx->node(DECL, 3, $1, ctx->value(TYPE, $2), $5); free($2); } +one_decl: vis PML_TYPE var_list { $$ = ctx->node(PML_DECL, 3, $1, ctx->value(PML_TYPE, $2), $3); free($2); } + | vis PML_UNAME var_list { $$ = ctx->node(PML_UNAME, 2, $1, $3); } + | vis PML_TYPE PML_ASGN '{' nlst '}' { $$ = ctx->node(PML_DECL, 3, $1, ctx->value(PML_TYPE, $2), $5); free($2); } ; decl_lst: one_decl { $$ = $1; } - | one_decl SEMI { $$ = $1; } - | one_decl SEMI decl_lst { - $$ = ctx->node(DECLLIST, 1, $1); - if($3->type == DECLLIST) { + | one_decl PML_SEMI { $$ = $1; } + | one_decl PML_SEMI decl_lst { + $$ = ctx->node(PML_DECLLIST, 1, $1); + if($3->type == PML_DECLLIST) { $$->merge($3); delete $3; } else { $$->push($3); @@ -168,59 +168,59 @@ decl_lst: one_decl { $$ = $1; } } ; -var_list: ivar { $$ = ctx->node(VARLIST, 1, $1); } - | ivar COMMA var_list { $$ = ctx->node(VARLIST, 1, $1); $$->merge($3); delete $3; } +var_list: ivar { $$ = ctx->node(PML_VARLIST, 1, $1); } + | ivar PML_COMMA var_list { $$ = ctx->node(PML_VARLIST, 1, $1); $$->merge($3); delete $3; } ; ivar : vardcl { $$ = $1; } - | vardcl ASGN expr { $$ = ctx->node(ASGN, 2, $1, $3); } + | vardcl PML_ASGN expr { $$ = ctx->node(PML_ASGN, 2, $1, $3); } ; -vardcl : NAME { $$ = ctx->value(NAME, $1); free($1); } - | NAME COLON CONST { $$ = ctx->node(COLON, 2, ctx->value(NAME, $1), ctx->value(CONST, $3)); free($1); free($3); } - | NAME '[' const_expr ']' { $$ = ctx->node(VAR_ARRAY, 2, ctx->value(NAME, $1), $3); free($1); } +vardcl : PML_NAME { $$ = ctx->value(PML_NAME, $1); free($1); } + | PML_NAME PML_COLON PML_CONST { $$ = ctx->node(PML_COLON, 2, ctx->value(PML_NAME, $1), ctx->value(PML_CONST, $3)); free($1); free($3); } + | PML_NAME '[' const_expr ']' { $$ = ctx->node(PML_VAR_ARRAY, 2, ctx->value(PML_NAME, $1), $3); free($1); } ; -const_expr: CONST { $$ = ctx->value(CONST, $1); free($1); } - | MINUS const_expr %prec MINUS { $$ = ctx->node(MINUS, 1, $2); } +const_expr: PML_CONST { $$ = ctx->value(PML_CONST, $1); free($1); } + | PML_MINUS const_expr %prec PML_MINUS { $$ = ctx->node(PML_MINUS, 1, $2); } | '(' const_expr ')' { $$ = $2; } - | const_expr PLUS const_expr { $$ = ctx->node(PLUS, 2, $1, $3); } - | const_expr MINUS const_expr { $$ = ctx->node(MINUS, 2, $1, $3); } - | const_expr TIMES const_expr { $$ = ctx->node(TIMES, 2, $1, $3); } - | const_expr DIVIDE const_expr { $$ = ctx->node(DIVIDE, 2, $1, $3); } - | const_expr MODULO const_expr { $$ = ctx->node(MODULO, 2, $1, $3); } - ; - -nlst : NAME { $$ = ctx->value(NAME, $1); free($1); } - | nlst NAME { - if ($1->type == NAME) { - $$ = ctx->node(NAMELIST, 1, $1); - $$->push(ctx->value(NAME, $2)); + | const_expr PML_PLUS const_expr { $$ = ctx->node(PML_PLUS, 2, $1, $3); } + | const_expr PML_MINUS const_expr { $$ = ctx->node(PML_MINUS, 2, $1, $3); } + | const_expr PML_TIMES const_expr { $$ = ctx->node(PML_TIMES, 2, $1, $3); } + | const_expr PML_DIVIDE const_expr { $$ = ctx->node(PML_DIVIDE, 2, $1, $3); } + | const_expr PML_MODULO const_expr { $$ = ctx->node(PML_MODULO, 2, $1, $3); } + ; + +nlst : PML_NAME { $$ = ctx->value(PML_NAME, $1); free($1); } + | nlst PML_NAME { + if ($1->type == PML_NAME) { + $$ = ctx->node(PML_NAMELIST, 1, $1); + $$->push(ctx->value(PML_NAME, $2)); } else { - $1->push(ctx->value(NAME, $2)); + $1->push(ctx->value(PML_NAME, $2)); } free($2); } - | nlst COMMA { $$ = $1; } + | nlst PML_COMMA { $$ = $1; } ; stmnt_lst: stmnt { $$ = $1; } - | stmnt SEMI { $$ = $1; } - | stmnt SEMI stmnt_lst { $$ = ctx->node(STMNT, 2, $1, $3); } + | stmnt PML_SEMI { $$ = $1; } + | stmnt PML_SEMI stmnt_lst { $$ = ctx->node(PML_STMNT, 2, $1, $3); } ; stmnt : Stmnt { $$ = $1; } ; -Stmnt : varref ASGN expr { $$ = ctx->node(ASGN, 2, $1, $3); } - | varref INCR { $$ = ctx->node(INCR, 1, $1); } - | varref DECR { $$ = ctx->node(DECR, 1, $1); } - | PRINT '(' STRING prargs ')' { $$ = ctx->node(PRINT, 2, ctx->value(STRING, $3), $4); free($3); } - | PRINTM '(' varref ')' { $$ = ctx->node(PRINTM, 1, $3); } - | PRINTM '(' CONST ')' { $$ = ctx->node(PRINTM, 1, ctx->value(CONST, $3)); free($3); } - | ASSERT expr { } +Stmnt : varref PML_ASGN expr { $$ = ctx->node(PML_ASGN, 2, $1, $3); } + | varref PML_INCR { $$ = ctx->node(PML_INCR, 1, $1); } + | varref PML_DECR { $$ = ctx->node(PML_DECR, 1, $1); } + | PML_PRINT '(' PML_STRING prargs ')' { $$ = ctx->node(PML_PRINT, 2, ctx->value(PML_STRING, $3), $4); free($3); } + | PML_PRINTM '(' varref ')' { $$ = ctx->node(PML_PRINTM, 1, $3); } + | PML_PRINTM '(' PML_CONST ')' { $$ = ctx->node(PML_PRINTM, 1, ctx->value(PML_CONST, $3)); free($3); } + | PML_ASSERT expr { } | expr { $$ = $1; } - | varref ASGN INAME { } '(' args ')' Stmnt { } + | varref PML_ASGN PML_INAME { } '(' args ')' Stmnt { } ; args : /* empty */ { } @@ -228,11 +228,11 @@ args : /* empty */ { } ; prargs : /* empty */ { $$ = ctx->value(0, ""); } - | COMMA arg { $$ = $2; } + | PML_COMMA arg { $$ = $2; } ; arg : expr { $$ = $1; } - | expr COMMA arg { $$ = ctx->node(0, 2, $1, $3); } + | expr PML_COMMA arg { $$ = ctx->node(0, 2, $1, $3); } ; |