44 lines
574 B
C
44 lines
574 B
C
#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 |