aboutsummaryrefslogtreecommitdiffstats
path: root/src/backend/targets
diff options
context:
space:
mode:
authorGalin Simeonov <gts@volconst.com>2021-07-14 01:43:40 +0300
committerGalin Simeonov <gts@volconst.com>2021-07-15 18:07:29 +0300
commitfbb038282af00eb09bc5a8ef7a0e7a7b76998683 (patch)
treef36565027c4da5edd5c03b53a78db4998b5cfb7c /src/backend/targets
parent3877ff9860d2cbeda7127d932e45573ff0d9600b (diff)
downloadMEGATRON-fbb038282af00eb09bc5a8ef7a0e7a7b76998683.tar.gz
added ability to attach statements to entry and exit of a given state
Diffstat (limited to 'src/backend/targets')
-rw-r--r--src/backend/targets/C/ast_to_c.c5
-rw-r--r--src/backend/targets/print/print.c6
2 files changed, 10 insertions, 1 deletions
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;i<vector->number_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");
}