adding utils with enum_print
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* LEXER.C
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
typedef enum t_token_type
|
||||
{
|
||||
TOKEN_VARIABLE, // x, y, etc.
|
||||
TOKEN_NUMBER_INT, // int
|
||||
@@ -26,7 +26,7 @@ typedef enum
|
||||
TOKEN_END // null (end of input)
|
||||
} token_type;
|
||||
|
||||
typedef enum
|
||||
typedef enum t_token_tag
|
||||
{
|
||||
TOKEN_NO_TAG,
|
||||
TOKEN_NUMBER,
|
||||
@@ -41,6 +41,7 @@ typedef struct
|
||||
union
|
||||
{
|
||||
char value_char;
|
||||
int value_int;
|
||||
double value_double;
|
||||
};
|
||||
} token;
|
||||
@@ -51,35 +52,35 @@ int lexerize(const char *input, token *tokens);
|
||||
* PARSER.C
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
typedef enum t_term_position
|
||||
{
|
||||
TERM_LEFT, // a in "a = b"
|
||||
TERM_RIGHT, // b in "a = b"
|
||||
TERM_END, // last term
|
||||
} term_position;
|
||||
|
||||
typedef enum
|
||||
typedef enum t_term_sign
|
||||
{
|
||||
TERM_PLUS, // +
|
||||
TERM_MINUS, // -
|
||||
TERM_NULL, // null -> for the last term
|
||||
} term_sign;
|
||||
|
||||
typedef struct
|
||||
typedef struct t_term
|
||||
{
|
||||
term_position position;
|
||||
term_sign sign;
|
||||
double coefficient;
|
||||
double exponent;
|
||||
int exponent;
|
||||
} term;
|
||||
|
||||
int parse(token *tokens, term *terms, int terms_count_max);
|
||||
|
||||
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* ERRORS.C
|
||||
* UTILS/ERRORS.C
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
typedef enum t_program_error
|
||||
{
|
||||
ERROR_BASE = 1, // start at 1 to avoid exit(0) for errors
|
||||
ERROR_TOKEN_COUNT,
|
||||
@@ -94,6 +95,15 @@ typedef enum
|
||||
|
||||
int stop_errors(program_error err, const char *format, ...);
|
||||
|
||||
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* UTILS/PRINT_ENUMS.C
|
||||
*/
|
||||
|
||||
const char *token_type_to_str(token_type type);
|
||||
const char *token_tag_to_str(token_tag tag);
|
||||
const char *term_position_to_str(term_position pos);
|
||||
const char *term_sign_to_str(term_sign sign);
|
||||
|
||||
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* GLOBALS
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user