Starting chapter 5 now. This is the first part needed to start implementing the syntax tree.
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user