48 lines
742 B
C
48 lines
742 B
C
#ifndef EXPRESSION_H
|
|
#define EXPRESSION_H
|
|
|
|
#include "scanner.h"
|
|
#include <stdarg.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 unary {
|
|
Token* op;
|
|
struct Expr* right;
|
|
};
|
|
|
|
struct Expr {
|
|
ExpressionType type;
|
|
union ex {
|
|
struct binary Binary;
|
|
struct grouping Grouping;
|
|
Token* Literal;
|
|
struct unary Unary;
|
|
} expression;
|
|
};
|
|
|
|
void VisitBinary(struct binary);
|
|
void VisitGrouping(struct grouping);
|
|
void VisitLiteral(Token);
|
|
void VisitUnary(struct unary);
|
|
|
|
#endif |