diff options
Diffstat (limited to 'sfinae.y')
| -rw-r--r-- | sfinae.y | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -33,9 +33,16 @@ void yyerror(const char* message); %token TOK_TUPLE_SIZE %token TOK_INTEGRAL_CONSTANT %token TOK_VALUE +%token TOK_CONDITIONAL_T +%token TOK_CONDITIONAL +%token TOK_TRUE_TYPE +%token TOK_FALSE_TYPE +%token TOK_IS_SAME +%token TOK_EQUAL +%token TOK_LESS %token <character> TOK_CHAR -%type <node> statements statement type value +%type <node> statements statement type value condition %% @@ -69,6 +76,8 @@ type { $$ = node_unary(TYPE_REMOVE_CV, $4); } | TOK_COLONCOLON TOK_ARRAY '<' type ',' value '>' { $$ = node_binary(TYPE_ARRAY, $4, $6); } + | TOK_COLONCOLON TOK_CONDITIONAL_T '<' condition ',' type ',' type '>' + { $$ = node_ternary(TYPE_CONDITIONAL, $4, $6, $8); } | TOK_COLONCOLON TOK_DECLTYPE '(' value ')' { $$ = node_unary(TYPE_DECLTYPE, $4); } ; @@ -89,6 +98,21 @@ value | TOK_COLONCOLON TOK_INTEGRAL_CONSTANT '<' TOK_COLONCOLON TOK_SIZE_T ',' value '>' TOK_COLONCOLON TOK_VALUE { $$ = node_unary(VALUE_INTEGRAL_CONSTANT, $7); } + | TOK_COLONCOLON TOK_CONDITIONAL '<' condition ',' value ',' value '>' + { $$ = node_ternary(VALUE_CONDITIONAL, $4, $6, $8); } + ; + +condition + : TOK_COLONCOLON TOK_TRUE_TYPE TOK_COLONCOLON TOK_VALUE + { $$ = node_leaf(COND_TRUE); } + | TOK_COLONCOLON TOK_FALSE_TYPE TOK_COLONCOLON TOK_VALUE + { $$ = node_leaf(COND_FALSE); } + | TOK_COLONCOLON TOK_IS_SAME '<' type ',' type '>' TOK_COLONCOLON TOK_VALUE + { $$ = node_binary(COND_IS_SAME, $4, $6); } + | TOK_COLONCOLON TOK_EQUAL '<' value ',' value '>' TOK_COLONCOLON TOK_VALUE + { $$ = node_binary(COND_EQUAL, $4, $6); } + | TOK_COLONCOLON TOK_LESS '<' value ',' value '>' TOK_COLONCOLON TOK_VALUE + { $$ = node_binary(COND_LESS, $4, $6); } ; %% |
