hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/sfinae.y
diff options
context:
space:
mode:
Diffstat (limited to 'sfinae.y')
-rw-r--r--sfinae.y33
1 files changed, 31 insertions, 2 deletions
diff --git a/sfinae.y b/sfinae.y
index 9fe994c..4e366a8 100644
--- a/sfinae.y
+++ b/sfinae.y
@@ -25,6 +25,11 @@ void yyerror(const char* message);
%token TOK_UNDECLARE
%token TOK_ENABLE_IF
%token TOK_REPEAT
+%token TOK_DEFINE
+%token TOK_PARAMETERS
+%token TOK_RETURN
+%token TOK_INVOKE_RESULT
+%token TOK_ARGUMENTS
%token TOK_SEQUENCE
%token TOK_NAME
%token TOK_VALUE_OF
@@ -55,7 +60,8 @@ void yyerror(const char* message);
%token <character> TOK_CHAR
%type <name> name char_list
-%type <node> statements statement sequence sequence_items type type_list value condition
+%type <node> statements statement sequence sequence_items parameters name_list
+%type <node> type type_list value condition
%%
@@ -84,9 +90,15 @@ statement
{ $$ = node_block(STMT_ENABLE_IF, $4, $6); }
| TOK_COLONCOLON TOK_REPEAT '<' value ',' sequence '>' TOK_COLONCOLON TOK_COMMIT
{ $$ = node_block(STMT_REPEAT, $4, $6); }
+ | TOK_COLONCOLON TOK_DEFINE '<' name ',' parameters ',' sequence '>' TOK_COLONCOLON TOK_COMMIT
+ {
+ $$ = node_named(STMT_DEFINE, &$4, $6);
+ $$->body = $8;
+ }
+ | TOK_COLONCOLON TOK_RETURN '<' type '>' TOK_COLONCOLON TOK_COMMIT
+ { $$ = node_unary(STMT_RETURN, $4); }
;
-// the statements inside are committed one by one, without the semicolons
sequence
: TOK_COLONCOLON TOK_SEQUENCE '<' sequence_items '>'
{ $$ = $4; }
@@ -101,6 +113,20 @@ sequence_items
{ $$ = node_append($1, $3); }
;
+parameters
+ : TOK_COLONCOLON TOK_PARAMETERS '<' name_list '>'
+ { $$ = $4; }
+ ;
+
+name_list
+ : /* nothing */
+ { $$ = NULL; }
+ | name
+ { $$ = node_named(NODE_PARAMETER, &$1, NULL); }
+ | name_list ',' name
+ { $$ = node_append($1, node_named(NODE_PARAMETER, &$3, NULL)); }
+ ;
+
name
: TOK_COLONCOLON TOK_NAME '<' char_list '>'
{ $$ = $4; }
@@ -146,6 +172,9 @@ type
{ $$ = node_unary(TYPE_CHAR_CONSTANT, $7); }
| TOK_COLONCOLON TOK_TUPLE '<' type_list '>'
{ $$ = node_unary(TYPE_TUPLE, $4); }
+ | TOK_COLONCOLON TOK_INVOKE_RESULT '<' name ','
+ TOK_COLONCOLON TOK_ARGUMENTS '<' type_list '>' '>'
+ { $$ = node_named(TYPE_INVOKE, &$4, $9); }
;
type_list