#define MAX_TOK_LEN 26 /* Hard coded max length of a token */ /* * Temporary buffer for tokens. * */ typedef struct TokenBuffer_s { char tok[MAX_TOK_LEN]; int next; } TokenBuffer; /* * Struct that collects parser related data. * */ typedef struct ParserState_s { char* file_name; FILE* in; int cur_line; TokenBuffer* buf; } ParserState; /* * Used for temporary storage of transitions. * */ typedef struct Quadruple_s { char* src_state; char* input; char* output; char* to_state; } Quadruple; /* * Stores a transition. * */ typedef struct Transition_s { char* src_state; int input; char* output; char* to_state; } Transition; /* * The transducer struct. * num_transitions and max_transitions are used for memory management. * */ typedef struct Transducer_s { char* start_state; Transition* transitions; int num_transitions; int max_transitions; ParserState* p; } Transducer; /* * Struct that stores the string file. * max_chars and num_chars are used for memory management. * */ typedef struct StringFile_s { char* buf; int read_pos; int max_chars; int num_chars; } StringFile; /* * Struct for output. * */ typedef struct OutputList_s { struct OutputList_s* next; char* output; } OutputList; /* * Struct for iterator pattern. * */ typedef struct TransIter_s { char* src_state; int input; Transducer* t; Transition* found; } TransIter;