Files
clox/expr.h
T

52 lines
795 B
C

#ifndef EXPRESSION_H
#define EXPRESSION_H
#include "scanner.h"
typedef enum {
EXPRESSION,
LITERAL,
GROUPING,
UNARY,
BINARY,
OPERATOR
} ExpressionType;
typedef struct Expr Expr;
struct binary {
struct Expr* left;
Token* op;
struct Expr* right;
};
struct grouping {
struct Expr* expression;
};
struct literal {
Token* type;
void* object;
};
struct unary {
Token* op;
struct Expr* right;
};
struct Expr {
ExpressionType type;
union ex {
struct binary Binary;
struct grouping Grouping;
struct literal Literal;
struct unary Unary;
} expression;
};
void VisitBinary(struct binary);
void VisitGrouping(struct grouping);
void VisitLiteral(struct literal);
void VisitUnary(struct unary);
#endif