2001-06-20 07:02:36 +00:00
|
|
|
typedef enum {
|
2001-06-25 22:11:20 +00:00
|
|
|
ex_label,
|
2001-06-26 03:33:01 +00:00
|
|
|
ex_block,
|
2001-06-20 21:18:04 +00:00
|
|
|
ex_expr, // binary expression
|
|
|
|
ex_uexpr, // unary expression
|
2001-06-15 19:38:43 +00:00
|
|
|
ex_def,
|
|
|
|
ex_int,
|
|
|
|
ex_float,
|
|
|
|
ex_string,
|
|
|
|
ex_vector,
|
|
|
|
ex_quaternion,
|
2001-06-20 07:02:36 +00:00
|
|
|
} expr_type;
|
|
|
|
|
2001-06-25 22:11:20 +00:00
|
|
|
typedef struct {
|
|
|
|
statref_t *refs;
|
|
|
|
dstatement_t *statement;
|
|
|
|
char *name;
|
|
|
|
} label_t;
|
|
|
|
|
2001-06-26 03:33:01 +00:00
|
|
|
typedef struct {
|
|
|
|
struct expr_s *head;
|
|
|
|
struct expr_s **tail;
|
|
|
|
} block_t;
|
|
|
|
|
2001-06-15 19:38:43 +00:00
|
|
|
typedef struct expr_s {
|
2001-06-20 21:18:04 +00:00
|
|
|
struct expr_s *next;
|
2001-06-20 07:02:36 +00:00
|
|
|
expr_type type;
|
2001-06-26 16:23:21 +00:00
|
|
|
int line;
|
|
|
|
string_t file;
|
2001-06-28 15:20:31 +00:00
|
|
|
int paren;
|
2001-06-15 19:38:43 +00:00
|
|
|
union {
|
2001-06-26 03:33:01 +00:00
|
|
|
label_t label;
|
|
|
|
block_t block;
|
2001-06-15 19:38:43 +00:00
|
|
|
struct {
|
|
|
|
int op;
|
|
|
|
type_t *type;
|
|
|
|
struct expr_s *e1;
|
|
|
|
struct expr_s *e2;
|
|
|
|
} expr;
|
|
|
|
def_t *def;
|
|
|
|
int int_val;
|
|
|
|
float float_val;
|
2001-06-25 22:53:15 +00:00
|
|
|
char *string_val;
|
2001-06-15 19:38:43 +00:00
|
|
|
float vector_val[3];
|
|
|
|
float quaternion_val[4];
|
|
|
|
} e;
|
|
|
|
} expr_t;
|
|
|
|
|
|
|
|
expr_t *new_expr (void);
|
2001-06-26 02:46:02 +00:00
|
|
|
expr_t *new_label_expr (void);
|
2001-06-26 03:33:01 +00:00
|
|
|
expr_t *new_block_expr (void);
|
2001-06-26 02:46:02 +00:00
|
|
|
expr_t *new_binary_expr (int op, expr_t *e1, expr_t *e2);
|
|
|
|
expr_t *new_unary_expr (int op, expr_t *e1);
|
2001-06-26 03:33:01 +00:00
|
|
|
|
|
|
|
expr_t *append_expr (expr_t *block, expr_t *e);
|
|
|
|
|
2001-06-25 17:15:56 +00:00
|
|
|
void print_expr (expr_t *e);
|
2001-06-20 07:02:36 +00:00
|
|
|
expr_t *binary_expr (int op, expr_t *e1, expr_t *e2);
|
|
|
|
expr_t *unary_expr (int op, expr_t *e);
|
2001-06-20 21:18:04 +00:00
|
|
|
expr_t *function_expr (expr_t *e1, expr_t *e2);
|
2001-06-26 07:21:20 +00:00
|
|
|
|
2001-06-26 22:43:28 +00:00
|
|
|
def_t *emit_statement (opcode_t *op, def_t *var_a, def_t *var_b, def_t *var_c);
|
2001-06-26 07:21:20 +00:00
|
|
|
void emit_expr (expr_t *e);
|
2001-06-28 21:26:40 +00:00
|
|
|
|
2001-07-03 20:53:49 +00:00
|
|
|
expr_t *error (expr_t *e, const char *fmt, ...) __attribute__((format(printf, 2,3)));
|
|
|
|
void warning (expr_t *e, const char *fmt, ...) __attribute__((format(printf, 2,3)));
|