Starting chapter 5 now. This is the first part needed to start implementing the syntax tree.

This commit is contained in:
2022-02-22 19:30:44 +00:00
parent 227d566261
commit 693519a248
+44
View File
@@ -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