1 #ifndef PP_EXPR_H 2 #define PP_EXPR_H 3 4 #include <stdbool.h> 5 #include "pp_parser.h" 6 7 typedef struct 8 { 9 pp_token theToken; 10 enum {BINARY, UNARY, MULTI, LEAF} type; // MULTI refers to operators that can be unary or binary (+, -) 11 } nodedata; 12 13 // binary tree structure used for parsing and evaulating expressions 14 typedef struct node 15 { 16 nodedata *info; 17 struct node *left; 18 struct node *right; 19 } pp_expr; 20 21 pp_expr *pp_expr_parse(pp_parser *parser, bool paren); 22 void pp_expr_fix_precedence(pp_expr *self); 23 void pp_expr_destroy(pp_expr *node); 24 int pp_expr_eval(pp_expr *self); 25 int pp_expr_eval_expression(pp_parser *parser); 26 27 #endif 28 29