From fbb038282af00eb09bc5a8ef7a0e7a7b76998683 Mon Sep 17 00:00:00 2001 From: Galin Simeonov Date: Wed, 14 Jul 2021 01:43:40 +0300 Subject: added ability to attach statements to entry and exit of a given state --- src/backend/targets/C/ast_to_c.c | 5 ++++- src/backend/targets/print/print.c | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/backend') diff --git a/src/backend/targets/C/ast_to_c.c b/src/backend/targets/C/ast_to_c.c index 9b8f95c..cd01e67 100644 --- a/src/backend/targets/C/ast_to_c.c +++ b/src/backend/targets/C/ast_to_c.c @@ -209,7 +209,9 @@ void ast_transitions_of_state_to_c(FILE *out,struct AST_Machine *machine,struct if(vector->number_of_transitions>0) { - fprintf(out,"\n\t%smachine_states_lock=1;\n",context_arrow); + fprintf(out,"\n\t%smachine_states_lock=1;\n\n",context_arrow); + ast_statement_to_c(out,1,vector->state->on_exit_statement,options); + fprintf(out,"\n"); fprintf(out,"\tswitch(event)\n\t{\n"); for(i=0;inumber_of_transitions;++i) { @@ -227,6 +229,7 @@ void ast_transitions_of_state_to_c(FILE *out,struct AST_Machine *machine,struct //ast_pipeline_to_c(out,3,vector->transitions[i]->pipeline); ast_statement_to_c(out,indentation,vector->transitions[i]->statement,options); + ast_statement_to_c(out,indentation,vector->transitions[i]->to->on_entry_statement,options); ast_to_c_print_tabs(out,indentation); fprintf(out,"%smachine_states[",context_arrow); ast_token_to_c(out,machine->id); diff --git a/src/backend/targets/print/print.c b/src/backend/targets/print/print.c index cfe22e9..162031f 100644 --- a/src/backend/targets/print/print.c +++ b/src/backend/targets/print/print.c @@ -90,6 +90,12 @@ void print_keyword_enum(enum Keyword code) case KW_GRANTED: printf("KW_GRANTED"); break; + case KW_ENTERING: + printf("KW_ENTERING"); + break; + case KW_EXITING: + printf("KW_EXITING"); + break; default: printf("LEXERROR"); } -- cgit v1.2.3