#ifndef CERC_EXPR_H #define CERC_EXPR_H #include #include "lex.h" #include "literal.h" #include "type.h" enum valuekind { V_LITERAL, V_NAME, }; struct value_e { struct location loc; enum valuekind kind; union { struct literal lit; const char *name; } v; }; struct grp_e { struct location loc; int isgrouped; union { struct expr *grouped; struct value_e value; } inner; }; struct call_e { struct location loc; struct expr *args; int argsz, arglen; }; enum access { AC_NONE, AC_FIELD, AC_INDEX, AC_CALL, }; struct access_e { struct location loc; enum access kind; union { const char *field; struct expr *index; struct call_e call; } ac; struct access_e *next; }; struct tag_e { struct location loc; int dotagof; struct grp_e grp; struct access_e *access; }; enum signop { SIGN_NONE, SIGN_POS, SIGN_NEG, }; struct sign_e { struct location loc; enum signop op; struct tag_e tag; }; enum invop { INV_NONE, INV_BITS, INV_BOOL, }; struct inv_e { struct location loc; enum invop op; union { struct inv_e *inv; struct sign_e sign; } oper; }; struct deref_e { struct location loc; int doderef; union { struct deref_e *deref; struct inv_e inv; } inner; }; struct ref_e { struct location loc; int doref; struct deref_e inner; }; struct as_e { struct location loc; struct ref_e lhs; struct type *cast; }; struct bitand_e { struct location loc; struct as_e lhs; struct bitand_e *rhs; }; struct bitxor_e { struct location loc; struct bitand_e lhs; struct bitxor_e *rhs; }; struct bitor_e { struct location loc; struct bitxor_e lhs; struct bitor_e *rhs; }; enum productop { PRODUCT_NONE, PRODUCT_MUL, PRODUCT_DIV, PRODUCT_REM, }; struct product_e { struct location loc; struct bitor_e lhs; enum productop op; struct product_e *rhs; }; enum sumop { SUM_NONE, SUM_ADD, SUM_SUB, }; struct sum_e { struct location loc; struct product_e lhs; enum sumop op; struct sum_e *rhs; }; enum shiftop { SHIFT_NONE, SHIFT_LEFT, SHIFT_RIGHT, }; struct shift_e { struct location loc; struct sum_e lhs; enum shiftop op; struct shift_e *rhs; }; enum cmpop { CMP_NONE, CMP_LESS, CMP_LESS_EQ, CMP_EQ, CMP_NEQ, CMP_GREATER_EQ, CMP_GREATER, }; struct cmp_e { struct location loc; struct shift_e lhs; enum cmpop op; struct shift_e *rhs; }; struct conjunction_e { struct location loc; struct cmp_e lhs; struct conjunction_e *rhs; }; struct expr { struct location loc; struct conjunction_e lhs; struct expr *rhs; }; #endif