diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-02-22 12:45:12 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-02-22 12:45:12 -0500 |
| commit | 2ecd8e11fd9edc42f8593edf334dc54d3a2d6930 (patch) | |
| tree | f439c1ce77bedea699ad5d7330aebbde56d1da35 /ast.h | |
| parent | d915c5f5a256dcfa80444e0175a327570935b000 (diff) | |
Implement 'when' statement for matching on enums
Diffstat (limited to 'ast.h')
| -rw-r--r-- | ast.h | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -24,6 +24,11 @@ typedef struct ast_list_s { struct ast_list_s *next; } ast_list_t; +typedef struct when_clause_s { + ast_t *var, *tag_name, *body; + struct when_clause_s *next; +} when_clause_t; + typedef struct arg_ast_s { const char *name; type_ast_t *type; @@ -94,7 +99,7 @@ typedef enum { FunctionDef, Lambda, FunctionCall, KeywordArg, Block, - For, While, If, + For, While, If, When, Reduction, Skip, Stop, Pass, Return, @@ -200,6 +205,11 @@ struct ast_s { ast_t *condition, *body, *else_body; } If; struct { + ast_t *subject; + when_clause_t *clauses; + ast_t *else_body; + } When; + struct { ast_t *iter, *combination, *fallback; } Reduction; struct { |
