Did a bit of refactoring and fixed the syntax so the union structs all have proper names.

This commit is contained in:
2022-02-22 20:12:12 +00:00
parent 693519a248
commit b72645aed0
+25 -22
View File
@@ -4,41 +4,44 @@
#include "scanner.h"
typedef enum {
Expression,
Literal,
Grouping,
Unary,
Binary,
Operator
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 expression;
typedef struct {
Expr left;
struct binary {
Expr* left;
TokenType op;
Expr right;
} binary;
Expr* right;
};
struct grouping {
Expr expression;
Expr* expression;
};
struct literal {
char* object;
TokenType type; //Probably something to this effect.
void* object;
};
struct unary {
TokenType op;
Expr right;
Expr* right;
};
struct Expr {
ExpressionType type;
union ex {
struct binary Binary;
struct grouping Grouping;
struct literal Literal;
struct unary Unary;
} expression;
};
#endif