diff options
| author | hachem <im@hachem.wtf> | 2026-09-19 15:47:03 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-19 15:47:03 +0200 |
| commit | 6d8b0392bb0c0df82285eec1b0f692113e66eb1a (patch) | |
| tree | c08fde36b934b759b1255bac33dc69ae1adf7169 /sfinae.y | |
| parent | e5cc80fb6a608aa1fbd0d6fabd1cf614a0fc004a (diff) | |
feat: enable_if
Diffstat (limited to 'sfinae.y')
| -rw-r--r-- | sfinae.y | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -23,6 +23,8 @@ void yyerror(const char* message); %token TOK_COMMIT %token TOK_DECLARE %token TOK_UNDECLARE +%token TOK_ENABLE_IF +%token TOK_SEQUENCE %token TOK_NAME %token TOK_VALUE_OF %token TOK_VOID @@ -50,7 +52,7 @@ void yyerror(const char* message); %token <character> TOK_CHAR %type <name> name char_list -%type <node> statements statement type value condition +%type <node> statements statement sequence sequence_items type value condition %% @@ -75,6 +77,23 @@ statement { $$ = node_named(STMT_DECLARE, &$4, $6); } | TOK_COLONCOLON TOK_UNDECLARE '<' name '>' TOK_COLONCOLON TOK_COMMIT { $$ = node_named(STMT_UNDECLARE, &$4, NULL); } + | TOK_COLONCOLON TOK_ENABLE_IF '<' condition ',' sequence '>' TOK_COLONCOLON TOK_COMMIT + { $$ = node_block(STMT_ENABLE_IF, $4, $6); } + ; + +// the statements inside are committed one by one, without the semicolons +sequence + : TOK_COLONCOLON TOK_SEQUENCE '<' sequence_items '>' + { $$ = $4; } + ; + +sequence_items + : /* nothing */ + { $$ = NULL; } + | statement + { $$ = $1; } + | sequence_items ',' statement + { $$ = node_append($1, $3); } ; name |
