summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-03-02 17:21:54 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-03-02 17:21:54 -0500
commit153001dd24eece3aa38b57ae2dced25fc0856d0c (patch)
tree75ed3689b283f093e6f02a5dbac6f1498ea3801b /parse.c
parente12efeebae81d524f96eea33813f57d4b90020bc (diff)
started #if
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index 07af202..39a3863 100644
--- a/parse.c
+++ b/parse.c
@@ -1304,6 +1304,9 @@ static Status parse_expr(Parser *p, Expression *e, Token *end) {
Token *start = t->token;
+ if (token_is_direct(t->token, DIRECT_IF)) {
+ goto if_expr;
+ }
if (t->token->kind == TOKEN_KW) switch (t->token->kw) {
case KW_FN: {
/* this is a function */
@@ -1327,8 +1330,13 @@ static Status parse_expr(Parser *p, Expression *e, Token *end) {
return false;
goto success;
}
- case KW_IF: {
+ case KW_IF:
+ if_expr: {
IfExpr *i = e->if_ = parser_malloc(p, sizeof *i);
+ i->flags = 0;
+ if (t->token->kind == TOKEN_DIRECT) {
+ i->flags |= IF_STATIC;
+ }
e->kind = EXPR_IF;
++t->token;
Token *cond_end = expr_find_end(p, EXPR_CAN_END_WITH_LBRACE);
@@ -1360,6 +1368,7 @@ static Status parse_expr(Parser *p, Expression *e, Token *end) {
next->where.start = t->token;
curr->next_elif = next;
IfExpr *nexti = next->if_ = parser_malloc(p, sizeof *nexti);
+ nexti->flags = 0;
if (is_else) {
++t->token;
nexti->cond = NULL;
@@ -1853,6 +1862,9 @@ static Status parse_expr(Parser *p, Expression *e, Token *end) {
Expression *single_arg = NULL; /* points to an expr if this is a directive with one expression argument */
switch (t->token->direct) {
+ case DIRECT_IF:
+ assert(0); /* handled above */
+ break;
case DIRECT_C:
e->kind = EXPR_C;
single_arg = e->c.code = parser_new_expr(p);