#ifndef __PARSER_H__ #define __PARSER_H__ #include #include #include #include "matrix.h" #define T_BAD 0 #define T_TAG 1 #define T_MAT 2 #define T_INT 3 #define S_START 10 #define S_READ_MAT 20 #define S_READ_TAG 30 #define S_ERROR 40 #define E_EXPECTED_INT 0x10000000 #define E_EXPECTED_ELEMENT 0x20000000 #define E_AB_BEFORE_MNK 0x30000000 /* From the source file, read matricies. Input: source (the file to be read.) Output: A (Matrix A is placed in this struct pointer) B (Matrix B is placed in this struct pointer) returns 0 for success, any other value for error. */ int parse_input(char *source, matrix_t **A, matrix_t **B); /* Identify the type of the token, returning one of T_INT - integer T_TAG - M, N, K T_MAT - A, B T_BAD - anything else */ int type_of (char *token); /* Get the value of the token */ int value_of (char *token, int type); #endif