#ifndef LEX_H #define LEX_H #define LEX_DEBUG enum token_type { TOK_EOF, TOK_ERROR, TOK_NUMBER, TOK_PLUS, TOK_MINUS, TOK_MULTIPLY, TOK_DIVIDE, TOK_POWER, TOK_X, TOK_FUNCTION, TOK_LEFT_PAREN, TOK_RIGHT_PAREN }; enum math_fn { FN_ABS, FN_EXP, FN_LN, FN_LOG, FN_SIN, FN_COS, FN_TAN, FN_ASIN, FN_ACOS, FN_ATAN, FN_SINH, FN_COSH, FN_TANH }; struct token { enum token_type type; union token_val { double num; enum math_fn fn; } val; }; struct lexer; extern struct lexer *lex_create(const char *str); extern void lex_free(struct lexer *lex); extern void lex_next(struct lexer *lex); extern struct token *lex_token(struct lexer *lex); extern void lex_print_position(const struct lexer *lex); #ifdef LEX_DEBUG extern void lex_debug_print_token(const struct token *tok); #endif /* LEX_DEBUG */ #endif /* LEX_H */