From cf3a29feb5887344b6633ead1b4b6d5657a15a4b Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sun, 15 Jun 2014 03:24:33 +0200 Subject: old stuff: algorithms --- algorithms/transducer/transducer.h | 90 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 algorithms/transducer/transducer.h (limited to 'algorithms/transducer/transducer.h') diff --git a/algorithms/transducer/transducer.h b/algorithms/transducer/transducer.h new file mode 100644 index 0000000..7493317 --- /dev/null +++ b/algorithms/transducer/transducer.h @@ -0,0 +1,90 @@ +#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; + -- cgit v1.2.3