65 lines
967 B
C
65 lines
967 B
C
#pragma once
|
|
typedef struct Expr Expr;
|
|
typedef struct Typespec Typespec;
|
|
|
|
typedef enum Expr_Sizeof_Kind{
|
|
SIZEOF_Expr,
|
|
SIZEOF_Type,
|
|
}Expr_Sizeof_Kind;
|
|
|
|
typedef enum Expr_Kind{
|
|
EK_None,
|
|
EK_Atom,
|
|
EK_Unary,
|
|
EK_Binary,
|
|
EK_Ternary,
|
|
EK_Cast,
|
|
EK_List,
|
|
EK_Call,
|
|
EK_Index,
|
|
EK_Sizeof,
|
|
} Expr_Kind;
|
|
|
|
struct Expr {
|
|
Expr_Kind kind;
|
|
Token *token;
|
|
Expr *next;
|
|
union {
|
|
struct {
|
|
Typespec *type;
|
|
Expr* expr;
|
|
} cast;
|
|
struct {
|
|
Expr *first;
|
|
Expr *last;
|
|
} list;
|
|
struct {
|
|
Expr *atom;
|
|
Expr *list;
|
|
} call;
|
|
struct {
|
|
Expr *atom;
|
|
Expr *index;
|
|
} index;
|
|
struct {
|
|
Expr* expr;
|
|
} unary;
|
|
struct {
|
|
Expr* left;
|
|
Expr* right;
|
|
} binary;
|
|
struct {
|
|
Expr* cond;
|
|
Expr* on_true;
|
|
Expr* on_false;
|
|
} ternary;
|
|
struct{
|
|
Expr_Sizeof_Kind kind;
|
|
union{
|
|
Typespec *type;
|
|
Expr *expr;
|
|
};
|
|
} size_of;
|
|
};
|
|
};
|