diff options
Diffstat (limited to 'include/expr.h')
-rw-r--r-- | include/expr.h | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/include/expr.h b/include/expr.h index 5a16f30..5f57349 100644 --- a/include/expr.h +++ b/include/expr.h @@ -1,6 +1,7 @@ #ifndef CERC_EXPR_H #define CERC_EXPR_H #include <stdbool.h> +#include "cmd.h" #include "lex.h" #include "type.h" @@ -15,6 +16,38 @@ struct array_e { int elemsz, elemlen; }; +struct elseif { + struct disjunction_e *cond; + struct ast_block blk; +}; + +struct if_e { + struct disjunction_e *cond; + struct ast_block blk; + struct elseif *alts; + struct ast_block *alt; + int altsz, altlen; +}; + +struct for_e { + struct ast_assign *init, *action; + struct disjunction_e *cond; + struct ast_block blk; +}; + +enum control { + CTL_IF, + CTL_FOR, +}; + +struct control_e { + enum control kind; + union { + struct if_e branch; + struct for_e loop; + } ctl; +}; + enum literal { LIT_BOOL, LIT_STRING, @@ -32,26 +65,52 @@ struct literal_e { } lit; }; -struct call_e { +struct location_e { struct path *path; + struct loc_postfix *subs; + int subsz, sublen; +}; + +struct assign_e { + struct location_e dst; + struct ast_expr *value; +}; + +struct call_e { + struct location_e *loc; struct disjunction_e *args; int argsz, arglen; }; +enum named { + NMD_ASSIGN, + NMD_CALL, + NMD_LOCATION, +}; + +struct named_e { + enum named kind; + struct location_e loc; + union { + struct assign_e assign; + struct call_e call; + } nmd; +}; + enum primary { + PRM_CONTROL, PRM_GROUPING, PRM_LITERAL, - PRM_CALL, - PRM_PATH, + PRM_NAMED, }; struct primary_e { enum primary kind; union { + struct control_e ctl; struct disjunction_e *grp; struct literal_e lit; - struct call_e call; - struct path *path; + struct named_e nmd; } prim; }; |