diff --git a/expr.h b/expr.h new file mode 100644 index 0000000..7d9ac4e --- /dev/null +++ b/expr.h @@ -0,0 +1,44 @@ +#ifndef EXPRESSION_H +#define EXPRESSION_H + +#include "scanner.h" + +typedef enum { + Expression, + Literal, + Grouping, + Unary, + Binary, + Operator +} ExpressionType; + +typedef struct { + ExpressionType type; + union ex { + struct binary; + struct grouping; + struct literal; + struct unary; + } expression; +} Expr; + +typedef struct { + Expr left; + TokenType op; + Expr right; +} binary; + +struct grouping { + Expr expression; +}; + +struct literal { + char* object; +}; + +struct unary { + TokenType op; + Expr right; +}; + +#endif \ No newline at end of file