From 6d8b0392bb0c0df82285eec1b0f692113e66eb1a Mon Sep 17 00:00:00 2001 From: hachem Date: Sat, 19 Sep 2026 15:47:03 +0200 Subject: feat: enable_if --- sfinae.y | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'sfinae.y') diff --git a/sfinae.y b/sfinae.y index 1acb4d0..f97147f 100644 --- a/sfinae.y +++ b/sfinae.y @@ -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 TOK_CHAR %type name char_list -%type statements statement type value condition +%type 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 -- cgit v1.3