diff options
author | Galin Simeonov <gts@volconst.com> | 2021-06-04 16:42:52 +0300 |
---|---|---|
committer | Galin Simeonov <gts@volconst.com> | 2021-07-15 18:04:59 +0300 |
commit | a26684a417729699e95b335a3d00798237ffba9b (patch) | |
tree | 6cd73bc90fbe5fd435b8cc721455d0a70420a4ac /src/frontend/parser.h | |
parent | b845e4754be86d2216733d9bea75cb301f38739d (diff) | |
download | MEGATRON-a26684a417729699e95b335a3d00798237ffba9b.tar.gz |
added the if statement
Diffstat (limited to 'src/frontend/parser.h')
-rw-r--r-- | src/frontend/parser.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/frontend/parser.h b/src/frontend/parser.h index a9f6b89..4745f63 100644 --- a/src/frontend/parser.h +++ b/src/frontend/parser.h @@ -25,6 +25,7 @@ enum AST_Type AST_TYPE_OP_NOT, AST_TYPE_OP_SELECTOR, AST_TYPE_UNFINISHED_STATE, + AST_TYPE_IF, }; struct AST { @@ -58,10 +59,10 @@ struct AST_Events struct AST_Transition { enum AST_Type type; - struct AST *from; + struct AST_State *from; struct AST_State *to; struct AST_Event *event; - struct AST_Pipeline *pipeline; + struct AST *statement; }; struct AST_Command { @@ -114,6 +115,13 @@ struct AST_Unchecked_State enum AST_Type type; struct token *name; }; +struct AST_If_Statement +{ + enum AST_Type type; + struct AST *condition; + struct AST *body; + struct AST *else_statement; +}; struct AST* parse_source(struct Translation_Data *translation_data); @@ -126,6 +134,9 @@ struct AST_Events* parse_events_inner(struct Translation_Data *translation_data) struct AST_Event* parse_event(struct Translation_Data *translation_data); struct AST_Transitions* parse_transitions_inner(struct Translation_Data *translation_data,struct AST_States *states,struct AST_Events *events ); struct AST_Transition* parse_transition(struct Translation_Data *translation_data,struct AST_States *states,struct AST_Events *events); + +struct AST* parse_statement(struct Translation_Data *translation_data,struct AST_States *states,struct AST_Events *events); + struct AST_Pipeline* parse_pipeline(struct Translation_Data *translation_data); struct AST_Command* parse_command(struct Translation_Data *translation_data); struct AST_State* parse_start_on(struct Translation_Data *translation_data,struct AST_States *states); @@ -140,16 +151,17 @@ struct AST_State* get_ast_state(struct token *id); struct AST_Event* get_ast_event(struct token *id); struct AST_States* get_ast_states(struct Queue *states); struct AST_Events* get_ast_events(struct Queue *events); -struct AST_Transition* get_ast_transition(struct AST *from,struct AST_State *to,struct AST_Event *event,struct AST_Pipeline *pipeline); +struct AST_Transition* get_ast_transition(struct AST_State *from,struct AST_State *to,struct AST_Event *event,struct AST *statement); struct AST_Command* get_ast_command(struct token *function_name,struct token *argument); struct AST_Pipeline* get_ast_pipeline(struct Queue *pipeline); struct AST_Machine* get_ast_machine(struct token *id,struct AST_States *states,struct AST_Events *events,struct AST_Transitions *transitions,struct AST_State *starting_state); struct AST_Transitions* get_ast_transitions(struct Queue *transitions); struct AST_Translation_Unit* get_ast_translation_unit(struct Queue *machines,struct Map *command_map,struct Map *machines_map); - struct AST_Binary_Expression* get_ast_binary_expression(struct AST *left,struct AST *right,enum AST_Type type); struct AST_Unary_Expression* get_ast_unary_expression(struct AST *operand,enum AST_Type type); struct AST_Unchecked_State* get_ast_unchecked_state(struct token *name); +struct AST_If_Statement* get_ast_if_statement(struct AST *condition,struct AST *body,struct AST *else_statement); + struct AST_State* ast_check_state(struct AST_Unchecked_State *state,struct AST_States *states,struct Translation_Data *translation_data); @@ -168,6 +180,7 @@ void delete_ast_translation_unit(struct AST_Translation_Unit *ast); void delete_ast_binary_expression(struct AST_Binary_Expression *ast); void delete_ast_unary_expression(struct AST_Unary_Expression *ast); void delete_ast_unchecked_state(struct AST_Unchecked_State *ast); +void delete_ast_if_statement(struct AST_If_Statement *ast); void pointer_array_fill(void **array,struct Queue *q); |