primary_expression:
variable_identifier
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL);
$$->set_location(yylloc);
$$->primary_expression.identifier = $1;
}
| INTCONSTANT
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL);
$$->set_location(yylloc);
$$->primary_expression.int_constant = $1;
}
| UINTCONSTANT
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL);
$$->set_location(yylloc);
$$->primary_expression.uint_constant = $1;
}
| FLOATCONSTANT
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL);
$$->set_location(yylloc);
$$->primary_expression.float_constant = $1;
}
| BOOLCONSTANT
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL);
$$->set_location(yylloc);
$$->primary_expression.bool_constant = $1;
primary_expression
| postfix_expression '[' integer_expression ']'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL);
$$->set_location(yylloc);
}
}
| postfix_expression '.' IDENTIFIER
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL);
$$->set_location(yylloc);
$$->primary_expression.identifier = $3;
}
| postfix_expression INC_OP
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL);
$$->set_location(yylloc);
}
| postfix_expression DEC_OP
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL);
$$->set_location(yylloc);
}
function_call_generic
| postfix_expression '.' function_call_generic
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_field_selection, $1, $3, NULL);
$$->set_location(yylloc);
}
function_identifier:
type_specifier
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_function_expression($1);
$$->set_location(yylloc);
}
| IDENTIFIER
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_expression *callee = new(ctx) ast_expression($1);
$$ = new(ctx) ast_function_expression(callee);
$$->set_location(yylloc);
}
| FIELD_SELECTION
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_expression *callee = new(ctx) ast_expression($1);
$$ = new(ctx) ast_function_expression(callee);
$$->set_location(yylloc);
postfix_expression
| INC_OP unary_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL);
$$->set_location(yylloc);
}
| DEC_OP unary_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL);
$$->set_location(yylloc);
}
| unary_operator unary_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression($1, $2, NULL, NULL);
$$->set_location(yylloc);
}
unary_expression
| multiplicative_expression '*' unary_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_mul, $1, $3);
$$->set_location(yylloc);
}
| multiplicative_expression '/' unary_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_div, $1, $3);
$$->set_location(yylloc);
}
| multiplicative_expression '%' unary_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_mod, $1, $3);
$$->set_location(yylloc);
}
multiplicative_expression
| additive_expression '+' multiplicative_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_add, $1, $3);
$$->set_location(yylloc);
}
| additive_expression '-' multiplicative_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_sub, $1, $3);
$$->set_location(yylloc);
}
additive_expression
| shift_expression LEFT_OP additive_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3);
$$->set_location(yylloc);
}
| shift_expression RIGHT_OP additive_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3);
$$->set_location(yylloc);
}
shift_expression
| relational_expression '<' shift_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_less, $1, $3);
$$->set_location(yylloc);
}
| relational_expression '>' shift_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_greater, $1, $3);
$$->set_location(yylloc);
}
| relational_expression LE_OP shift_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3);
$$->set_location(yylloc);
}
| relational_expression GE_OP shift_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3);
$$->set_location(yylloc);
}
relational_expression
| equality_expression EQ_OP relational_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_equal, $1, $3);
$$->set_location(yylloc);
}
| equality_expression NE_OP relational_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3);
$$->set_location(yylloc);
}
equality_expression
| and_expression '&' equality_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3);
$$->set_location(yylloc);
}
and_expression
| exclusive_or_expression '^' and_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3);
$$->set_location(yylloc);
}
exclusive_or_expression
| inclusive_or_expression '|' exclusive_or_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3);
$$->set_location(yylloc);
}
inclusive_or_expression
| logical_and_expression AND_OP inclusive_or_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3);
$$->set_location(yylloc);
}
logical_and_expression
| logical_xor_expression XOR_OP logical_and_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3);
$$->set_location(yylloc);
}
logical_xor_expression
| logical_or_expression OR_OP logical_xor_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3);
$$->set_location(yylloc);
}
logical_or_expression
| logical_or_expression '?' expression ':' assignment_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5);
$$->set_location(yylloc);
}
conditional_expression
| unary_expression assignment_operator assignment_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression($2, $1, $3, NULL);
$$->set_location(yylloc);
}
}
| expression ',' assignment_expression
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
if ($1->oper != ast_sequence) {
$$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL);
$$->set_location(yylloc);
function_header:
fully_specified_type IDENTIFIER '('
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_function();
$$->set_location(yylloc);
$$->return_type = $1;
parameter_declarator:
type_specifier IDENTIFIER
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_parameter_declarator();
$$->set_location(yylloc);
$$->type = new(ctx) ast_fully_specified_type();
}
| type_specifier IDENTIFIER '[' constant_expression ']'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_parameter_declarator();
$$->set_location(yylloc);
$$->type = new(ctx) ast_fully_specified_type();
}
| parameter_type_qualifier parameter_qualifier parameter_type_specifier
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$1.i |= $2.i;
$$ = new(ctx) ast_parameter_declarator();
}
| parameter_qualifier parameter_type_specifier
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_parameter_declarator();
$$->set_location(yylloc);
$$->type = new(ctx) ast_fully_specified_type();
single_declaration
| init_declarator_list ',' IDENTIFIER
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL);
decl->set_location(yylloc);
}
| init_declarator_list ',' IDENTIFIER '[' ']'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL);
decl->set_location(yylloc);
}
| init_declarator_list ',' IDENTIFIER '[' constant_expression ']'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL);
decl->set_location(yylloc);
}
| init_declarator_list ',' IDENTIFIER '[' ']' '=' initializer
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7);
decl->set_location(yylloc);
}
| init_declarator_list ',' IDENTIFIER '[' constant_expression ']' '=' initializer
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8);
decl->set_location(yylloc);
}
| init_declarator_list ',' IDENTIFIER '=' initializer
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5);
decl->set_location(yylloc);
single_declaration:
fully_specified_type
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
if ($1->specifier->type_specifier != ast_struct) {
_mesa_glsl_error(& @1, state, "empty declaration list\n");
YYERROR;
}
| fully_specified_type IDENTIFIER
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
$$ = new(ctx) ast_declarator_list($1);
}
| fully_specified_type IDENTIFIER '[' ']'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL);
$$ = new(ctx) ast_declarator_list($1);
}
| fully_specified_type IDENTIFIER '[' constant_expression ']'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL);
$$ = new(ctx) ast_declarator_list($1);
}
| fully_specified_type IDENTIFIER '[' ']' '=' initializer
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6);
$$ = new(ctx) ast_declarator_list($1);
}
| fully_specified_type IDENTIFIER '[' constant_expression ']' '=' initializer
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7);
$$ = new(ctx) ast_declarator_list($1);
}
| fully_specified_type IDENTIFIER '=' initializer
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
$$ = new(ctx) ast_declarator_list($1);
}
| INVARIANT IDENTIFIER // Vertex only.
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
$$ = new(ctx) ast_declarator_list(NULL);
fully_specified_type:
type_specifier
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_fully_specified_type();
$$->set_location(yylloc);
$$->specifier = $1;
}
| type_qualifier type_specifier
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_fully_specified_type();
$$->set_location(yylloc);
$$->qualifier = $1.q;
type_specifier_nonarray:
basic_type_specifier_nonarray
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_type_specifier($1);
$$->set_location(yylloc);
}
| struct_specifier
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_type_specifier($1);
$$->set_location(yylloc);
}
| IDENTIFIER
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_type_specifier($1);
$$->set_location(yylloc);
}
struct_specifier:
STRUCT IDENTIFIER '{' struct_declaration_list '}'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_struct_specifier($2, $4);
$$->set_location(yylloc);
}
| STRUCT '{' struct_declaration_list '}'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_struct_specifier(NULL, $3);
$$->set_location(yylloc);
}
struct_declaration:
type_specifier struct_declarator_list ';'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
type->set_location(yylloc);
struct_declarator:
IDENTIFIER
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_declaration($1, false, NULL, NULL);
$$->set_location(yylloc);
}
| IDENTIFIER '[' constant_expression ']'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_declaration($1, true, $3, NULL);
$$->set_location(yylloc);
}
compound_statement:
'{' '}'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_compound_statement(true, NULL);
$$->set_location(yylloc);
}
| '{' statement_list '}'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_compound_statement(true, $2);
$$->set_location(yylloc);
}
compound_statement_no_new_scope:
'{' '}'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_compound_statement(false, NULL);
$$->set_location(yylloc);
}
| '{' statement_list '}'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_compound_statement(false, $2);
$$->set_location(yylloc);
}
expression_statement:
';'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_statement(NULL);
$$->set_location(yylloc);
}
| expression ';'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_expression_statement($1);
$$->set_location(yylloc);
}
selection_statement_matched:
IF '(' expression ')' statement_matched ELSE statement_matched
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_selection_statement($3, $5, $7);
$$->set_location(yylloc);
}
selection_statement_unmatched:
IF '(' expression ')' statement_matched
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_selection_statement($3, $5, NULL);
$$->set_location(yylloc);
}
| IF '(' expression ')' statement_unmatched
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_selection_statement($3, $5, NULL);
$$->set_location(yylloc);
}
| IF '(' expression ')' statement_matched ELSE statement_unmatched
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_selection_statement($3, $5, $7);
$$->set_location(yylloc);
}
}
| fully_specified_type IDENTIFIER '=' initializer
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
ast_declarator_list *declarator = new(ctx) ast_declarator_list($1);
decl->set_location(yylloc);
iteration_statement:
WHILE '(' condition ')' statement_no_new_scope
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while,
NULL, $3, NULL, $5);
$$->set_location(yylloc);
}
| DO statement WHILE '(' expression ')' ';'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while,
NULL, $5, NULL, $2);
$$->set_location(yylloc);
}
| FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for,
$3, $4.cond, $4.rest, $6);
$$->set_location(yylloc);
jump_statement:
CONTINUE ';'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL);
$$->set_location(yylloc);
}
| BREAK ';'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL);
$$->set_location(yylloc);
}
| RETURN ';'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL);
$$->set_location(yylloc);
}
| RETURN expression ';'
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2);
$$->set_location(yylloc);
}
| DISCARD ';' // Fragment shader only.
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL);
$$->set_location(yylloc);
}
function_definition:
function_prototype compound_statement_no_new_scope
{
- void *ctx = talloc_parent(state);
+ void *ctx = state;
$$ = new(ctx) ast_function_definition();
$$->set_location(yylloc);
$$->prototype = $1;