hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/sfinae.y
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-09-19 15:47:03 +0200
committerhachem <im@hachem.wtf>2026-09-19 15:47:03 +0200
commit6d8b0392bb0c0df82285eec1b0f692113e66eb1a (patch)
treec08fde36b934b759b1255bac33dc69ae1adf7169 /sfinae.y
parente5cc80fb6a608aa1fbd0d6fabd1cf614a0fc004a (diff)
feat: enable_if
Diffstat (limited to 'sfinae.y')
-rw-r--r--sfinae.y21
1 files changed, 20 insertions, 1 deletions
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 <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