MEGATRON



LOG | FILES | OVERVIEW


#ifndef BACKEND_H
#define BACKEND_H BACKEND_H
#include <parser.h>
#include <ast_to_c.h>
#include <map.h>

/*
 * describes a given state and the transitions coming out of it
 * I should probbably have done this in the parsing stage
 */
struct State_And_Transitions
{
	struct AST_State *state;
	size_t number_of_transitions;
	struct AST_Transition *transitions[];
};
/*returns an array of state_and_transition structs*/
struct State_And_Transitions** extract_transition_table(struct AST_States *states,struct AST_Transitions *transitions);
/*extracts a state from the expression that belongs in the states structure*/
struct AST_State* extract_state(struct AST *expression,struct AST_States *states);

void anotate_unchecked_states(struct AST_Translation_Unit *unit,struct Translation_Data *translation_data);
void anotate_machine(struct AST_Machine *machine,struct AST_Translation_Unit *unit,struct Translation_Data *translation_data);
struct AST* anotate_statement(struct AST *statement,struct AST_Translation_Unit *unit,struct AST_Machine *current_machine,struct Translation_Data *translation_data);
struct AST* anotate_expression(struct AST *expression,struct AST_Translation_Unit *unit,struct AST_Machine *current_machine,struct Translation_Data *translation_data);

_Bool expression_is_binary(struct AST* expression);
_Bool expression_is_unary(struct AST* expression);
_Bool state_is_in_states(struct AST_State *state,struct AST_States *states);
_Bool check_expression(struct AST *state,struct AST_Translation_Unit *unit);
_Bool check_transition(struct AST *state,struct AST_Translation_Unit *unit);
#endif