diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-15 03:24:33 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-15 03:24:33 +0200 |
commit | cf3a29feb5887344b6633ead1b4b6d5657a15a4b (patch) | |
tree | f1149508f7305a48dba0226699dfafdd68d81969 /algorithms/transducer/transducer.h | |
parent | 5ddc763ab9953eebdaf78af4eb72288d7955b310 (diff) |
old stuff: algorithms
Diffstat (limited to 'algorithms/transducer/transducer.h')
-rw-r--r-- | algorithms/transducer/transducer.h | 90 |
1 files changed, 90 insertions, 0 deletions
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; + |