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" #include "scanner.h"
typedef enum { typedef enum {
Expression, EXPRESSION,
Literal, LITERAL,
Grouping, GROUPING,
Unary, UNARY,
Binary, BINARY,
Operator OPERATOR
} ExpressionType; } ExpressionType;
typedef struct { typedef struct Expr expression;
ExpressionType type;
union ex {
struct binary;
struct grouping;
struct literal;
struct unary;
} expression;
} Expr;
typedef struct { struct binary {
Expr left; Expr* left;
TokenType op; TokenType op;
Expr right; Expr* right;
} binary; };
struct grouping { struct grouping {
Expr expression; Expr* expression;
}; };
struct literal { struct literal {
char* object; TokenType type; //Probably something to this effect.
void* object;
}; };
struct unary { struct unary {
TokenType op; 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 #endif