diff options
Diffstat (limited to 'src/backend/backend.c')
-rw-r--r-- | src/backend/backend.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/backend/backend.c b/src/backend/backend.c index 512d247..ff9d0bf 100644 --- a/src/backend/backend.c +++ b/src/backend/backend.c @@ -20,10 +20,7 @@ struct State_And_Transitions** extract_transition_table(struct AST_States *state /*traverse transitions and push them into the queue of their coresponding state*/ for(i=0;i<transitions->size;++i) { - hold_state=extract_state(transitions->transitions[i]->from,states); - - assert(hold_state!=NULL); - + hold_state=transitions->transitions[i]->from; Queue_Push(qs+hold_state->number,transitions->transitions[i]); } @@ -101,7 +98,7 @@ void anotate_machine(struct AST_Machine *machine,struct AST_Translation_Unit *un size_t i; for(i=0;i<machine->transitions->size;++i) { - machine->transitions->transitions[i]->from=anotate_expression(machine->transitions->transitions[i]->from,unit,machine,translation_data); + machine->transitions->transitions[i]->statement=anotate_statement(machine->transitions->transitions[i]->statement,unit,machine,translation_data); } if(has_new_errors(translation_data)) { @@ -109,6 +106,17 @@ void anotate_machine(struct AST_Machine *machine,struct AST_Translation_Unit *un delete_ast_machine(machine); } } +struct AST* anotate_statement(struct AST *statement,struct AST_Translation_Unit *unit,struct AST_Machine *current_machine,struct Translation_Data *translation_data) +{ + if(statement==NULL)return NULL; + if(statement->type==AST_TYPE_IF) + { + ((struct AST_If_Statement*)statement)->condition=anotate_expression(((struct AST_If_Statement*)statement)->condition,unit,current_machine,translation_data); + }else + { + return statement; + } +} struct AST* anotate_expression(struct AST *expression,struct AST_Translation_Unit *unit,struct AST_Machine *current_machine,struct Translation_Data *translation_data) { struct AST_Machine *hold_machine; @@ -131,8 +139,17 @@ struct AST* anotate_expression(struct AST *expression,struct AST_Translation_Uni }else { hold_left=(struct AST*)ast_check_state((struct AST_Unchecked_State*)hold_right,hold_machine->states,translation_data); - ((struct AST_State*)hold_left)->parent=hold_machine; - return hold_left; + if(hold_left) + { + ((struct AST_State*)hold_left)->parent=hold_machine; + delete_ast(hold_right); + return hold_left; + }else + { + push_error_with_token("state id from foreign machine is undefined",((struct AST_Unchecked_State*)hold_right)->name,translation_data); + delete_ast(hold_right); + return NULL; + } } }else { |