diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-07-04 18:00:01 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-07-04 18:00:01 -0400 |
| commit | 6a105fbd801f10bd6c8cee32fd6d45a279f33e1b (patch) | |
| tree | dc03ec9eec0ac65b40d6cb6053d55475dc132fb2 /parse.c | |
| parent | 78960b1461a8fb184de4ffddf2d2ec4df729fb05 (diff) | |
Add 'defer'
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -49,7 +49,7 @@ int op_tightness[] = { static const char *keywords[] = { "yes", "xor", "while", "when", "use", "then", "struct", "stop", "skip", "return", "or", "not", "no", "mod1", "mod", "pass", "lang", "import", "inline", "in", "if", - "func", "for", "extern", "enum", "else", "do", "and", "_min_", "_max_", + "func", "for", "extern", "enum", "else", "do", "defer", "and", "_min_", "_max_", NULL, }; @@ -1186,6 +1186,13 @@ PARSER(parse_pass) { return match_word(&pos, "pass") ? NewAST(ctx->file, start, pos, Pass) : NULL; } +PARSER(parse_defer) { + const char *start = pos; + if (!match_word(&pos, "defer")) return NULL; + ast_t *body = expect(ctx, start, &pos, parse_block, "I expected a block to be deferred here"); + return NewAST(ctx->file, start, pos, Defer, .body=body); +} + PARSER(parse_skip) { const char *start = pos; if (!match_word(&pos, "skip")) return NULL; @@ -1266,6 +1273,7 @@ PARSER(parse_term_no_suffix) { || (term=parse_array(ctx, pos)) || (term=parse_reduction(ctx, pos)) || (term=parse_pass(ctx, pos)) + || (term=parse_defer(ctx, pos)) || (term=parse_skip(ctx, pos)) || (term=parse_stop(ctx, pos)) || (term=parse_return(ctx, pos)) |
