primary_expression:
variable_identifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL);
$$->set_location(@1);
$$->primary_expression.identifier = $1;
}
| INTCONSTANT
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL);
$$->set_location(@1);
$$->primary_expression.int_constant = $1;
}
| UINTCONSTANT
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL);
$$->set_location(@1);
$$->primary_expression.uint_constant = $1;
}
| FLOATCONSTANT
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL);
$$->set_location(@1);
$$->primary_expression.float_constant = $1;
}
| DOUBLECONSTANT
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_double_constant, NULL, NULL, NULL);
$$->set_location(@1);
$$->primary_expression.double_constant = $1;
}
| BOOLCONSTANT
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL);
$$->set_location(@1);
$$->primary_expression.bool_constant = $1;
primary_expression
| postfix_expression '[' integer_expression ']'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL);
$$->set_location_range(@1, @4);
}
}
| postfix_expression DOT_TOK FIELD_SELECTION
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL);
$$->set_location_range(@1, @3);
$$->primary_expression.identifier = $3;
}
| postfix_expression INC_OP
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL);
$$->set_location_range(@1, @2);
}
| postfix_expression DEC_OP
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL);
$$->set_location_range(@1, @2);
}
function_identifier:
type_specifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_function_expression($1);
$$->set_location(@1);
}
| postfix_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_function_expression($1);
$$->set_location(@1);
}
postfix_expression
| INC_OP unary_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL);
$$->set_location(@1);
}
| DEC_OP unary_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL);
$$->set_location(@1);
}
| unary_operator unary_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression($1, $2, NULL, NULL);
$$->set_location_range(@1, @2);
}
unary_expression
| multiplicative_expression '*' unary_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_mul, $1, $3);
$$->set_location_range(@1, @3);
}
| multiplicative_expression '/' unary_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_div, $1, $3);
$$->set_location_range(@1, @3);
}
| multiplicative_expression '%' unary_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_mod, $1, $3);
$$->set_location_range(@1, @3);
}
multiplicative_expression
| additive_expression '+' multiplicative_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_add, $1, $3);
$$->set_location_range(@1, @3);
}
| additive_expression '-' multiplicative_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_sub, $1, $3);
$$->set_location_range(@1, @3);
}
additive_expression
| shift_expression LEFT_OP additive_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3);
$$->set_location_range(@1, @3);
}
| shift_expression RIGHT_OP additive_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3);
$$->set_location_range(@1, @3);
}
shift_expression
| relational_expression '<' shift_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_less, $1, $3);
$$->set_location_range(@1, @3);
}
| relational_expression '>' shift_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_greater, $1, $3);
$$->set_location_range(@1, @3);
}
| relational_expression LE_OP shift_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3);
$$->set_location_range(@1, @3);
}
| relational_expression GE_OP shift_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3);
$$->set_location_range(@1, @3);
}
relational_expression
| equality_expression EQ_OP relational_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_equal, $1, $3);
$$->set_location_range(@1, @3);
}
| equality_expression NE_OP relational_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3);
$$->set_location_range(@1, @3);
}
equality_expression
| and_expression '&' equality_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_bit_and, $1, $3);
$$->set_location_range(@1, @3);
}
and_expression
| exclusive_or_expression '^' and_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3);
$$->set_location_range(@1, @3);
}
exclusive_or_expression
| inclusive_or_expression '|' exclusive_or_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3);
$$->set_location_range(@1, @3);
}
inclusive_or_expression
| logical_and_expression AND_OP inclusive_or_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3);
$$->set_location_range(@1, @3);
}
logical_and_expression
| logical_xor_expression XOR_OP logical_and_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3);
$$->set_location_range(@1, @3);
}
logical_xor_expression
| logical_or_expression OR_OP logical_xor_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3);
$$->set_location_range(@1, @3);
}
logical_or_expression
| logical_or_expression '?' expression ':' assignment_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5);
$$->set_location_range(@1, @5);
}
conditional_expression
| unary_expression assignment_operator assignment_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression($2, $1, $3, NULL);
$$->set_location_range(@1, @3);
}
}
| expression ',' assignment_expression
{
- void *ctx = state;
+ void *ctx = state->linalloc;
if ($1->oper != ast_sequence) {
$$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL);
$$->set_location_range(@1, @3);
function_header:
fully_specified_type variable_identifier '('
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_function();
$$->set_location(@2);
$$->return_type = $1;
parameter_declarator:
type_specifier any_identifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_parameter_declarator();
$$->set_location_range(@1, @2);
$$->type = new(ctx) ast_fully_specified_type();
}
| type_specifier any_identifier array_specifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_parameter_declarator();
$$->set_location_range(@1, @3);
$$->type = new(ctx) ast_fully_specified_type();
}
| parameter_qualifier parameter_type_specifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_parameter_declarator();
$$->set_location(@2);
$$->type = new(ctx) ast_fully_specified_type();
single_declaration
| init_declarator_list ',' any_identifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($3, NULL, NULL);
decl->set_location(@3);
}
| init_declarator_list ',' any_identifier array_specifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($3, $4, NULL);
decl->set_location_range(@3, @4);
}
| init_declarator_list ',' any_identifier array_specifier '=' initializer
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($3, $4, $6);
decl->set_location_range(@3, @4);
}
| init_declarator_list ',' any_identifier '=' initializer
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($3, NULL, $5);
decl->set_location(@3);
single_declaration:
fully_specified_type
{
- void *ctx = state;
+ void *ctx = state->linalloc;
/* Empty declaration list is valid. */
$$ = new(ctx) ast_declarator_list($1);
$$->set_location(@1);
}
| fully_specified_type any_identifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL);
decl->set_location(@2);
}
| fully_specified_type any_identifier array_specifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($2, $3, NULL);
decl->set_location_range(@2, @3);
}
| fully_specified_type any_identifier array_specifier '=' initializer
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($2, $3, $5);
decl->set_location_range(@2, @3);
}
| fully_specified_type any_identifier '=' initializer
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($2, NULL, $4);
decl->set_location(@2);
}
| INVARIANT variable_identifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL);
decl->set_location(@2);
}
| PRECISE variable_identifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL);
decl->set_location(@2);
fully_specified_type:
type_specifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_fully_specified_type();
$$->set_location(@1);
$$->specifier = $1;
}
| type_qualifier type_specifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_fully_specified_type();
$$->set_location_range(@1, @2);
$$->qualifier = $1;
| any_identifier '=' constant_expression
{
memset(& $$, 0, sizeof($$));
- void *ctx = state;
+ void *ctx = state->linalloc;
if ($3->oper != ast_int_constant &&
$3->oper != ast_uint_constant &&
subroutine_type_list:
any_identifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($1, NULL, NULL);
decl->set_location(@1);
}
| subroutine_type_list ',' any_identifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($3, NULL, NULL);
decl->set_location(@3);
array_specifier:
'[' ']'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_array_specifier(@1, new(ctx) ast_expression(
ast_unsized_array_dim, NULL,
NULL, NULL));
}
| '[' constant_expression ']'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_array_specifier(@1, $2);
$$->set_location_range(@1, @3);
}
| array_specifier '[' ']'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = $1;
if (state->check_arrays_of_arrays_allowed(& @1)) {
type_specifier_nonarray:
basic_type_specifier_nonarray
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_type_specifier($1);
$$->set_location(@1);
}
| struct_specifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_type_specifier($1);
$$->set_location(@1);
}
| TYPE_IDENTIFIER
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_type_specifier($1);
$$->set_location(@1);
}
struct_specifier:
STRUCT any_identifier '{' struct_declaration_list '}'
{
- void *ctx = state;
- $$ = new(ctx) ast_struct_specifier($2, $4);
+ void *ctx = state->linalloc;
+ $$ = new(ctx) ast_struct_specifier(ctx, $2, $4);
$$->set_location_range(@2, @5);
state->symbols->add_type($2, glsl_type::void_type);
}
| STRUCT '{' struct_declaration_list '}'
{
- void *ctx = state;
- $$ = new(ctx) ast_struct_specifier(NULL, $3);
+ void *ctx = state->linalloc;
+ $$ = new(ctx) ast_struct_specifier(ctx, NULL, $3);
$$->set_location_range(@2, @4);
}
;
struct_declaration:
fully_specified_type struct_declarator_list ';'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_fully_specified_type *const type = $1;
type->set_location(@1);
struct_declarator:
any_identifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_declaration($1, NULL, NULL);
$$->set_location(@1);
}
| any_identifier array_specifier
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_declaration($1, $2, NULL);
$$->set_location_range(@1, @2);
}
initializer_list:
initializer
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_aggregate_initializer();
$$->set_location(@1);
$$->expressions.push_tail(& $1->link);
compound_statement:
'{' '}'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_compound_statement(true, NULL);
$$->set_location_range(@1, @2);
}
}
statement_list '}'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_compound_statement(true, $3);
$$->set_location_range(@1, @4);
state->symbols->pop_scope();
compound_statement_no_new_scope:
'{' '}'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_compound_statement(false, NULL);
$$->set_location_range(@1, @2);
}
| '{' statement_list '}'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_compound_statement(false, $2);
$$->set_location_range(@1, @3);
}
expression_statement:
';'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_statement(NULL);
$$->set_location(@1);
}
| expression ';'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_expression_statement($1);
$$->set_location(@1);
}
selection_statement:
IF '(' expression ')' selection_rest_statement
{
- $$ = new(state) ast_selection_statement($3, $5.then_statement,
- $5.else_statement);
+ $$ = new(state->linalloc) ast_selection_statement($3, $5.then_statement,
+ $5.else_statement);
$$->set_location_range(@1, @5);
}
;
}
| fully_specified_type any_identifier '=' initializer
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_declaration *decl = new(ctx) ast_declaration($2, NULL, $4);
ast_declarator_list *declarator = new(ctx) ast_declarator_list($1);
decl->set_location_range(@2, @4);
switch_statement:
SWITCH '(' expression ')' switch_body
{
- $$ = new(state) ast_switch_statement($3, $5);
+ $$ = new(state->linalloc) ast_switch_statement($3, $5);
$$->set_location_range(@1, @5);
}
;
switch_body:
'{' '}'
{
- $$ = new(state) ast_switch_body(NULL);
+ $$ = new(state->linalloc) ast_switch_body(NULL);
$$->set_location_range(@1, @2);
}
| '{' case_statement_list '}'
{
- $$ = new(state) ast_switch_body($2);
+ $$ = new(state->linalloc) ast_switch_body($2);
$$->set_location_range(@1, @3);
}
;
case_label:
CASE expression ':'
{
- $$ = new(state) ast_case_label($2);
+ $$ = new(state->linalloc) ast_case_label($2);
$$->set_location(@2);
}
| DEFAULT ':'
{
- $$ = new(state) ast_case_label(NULL);
+ $$ = new(state->linalloc) ast_case_label(NULL);
$$->set_location(@2);
}
;
case_label_list:
case_label
{
- ast_case_label_list *labels = new(state) ast_case_label_list();
+ ast_case_label_list *labels = new(state->linalloc) ast_case_label_list();
labels->labels.push_tail(& $1->link);
$$ = labels;
case_statement:
case_label_list statement
{
- ast_case_statement *stmts = new(state) ast_case_statement($1);
+ ast_case_statement *stmts = new(state->linalloc) ast_case_statement($1);
stmts->set_location(@2);
stmts->stmts.push_tail(& $2->link);
case_statement_list:
case_statement
{
- ast_case_statement_list *cases= new(state) ast_case_statement_list();
+ ast_case_statement_list *cases= new(state->linalloc) ast_case_statement_list();
cases->set_location(@1);
cases->cases.push_tail(& $1->link);
iteration_statement:
WHILE '(' condition ')' statement_no_new_scope
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while,
NULL, $3, NULL, $5);
$$->set_location_range(@1, @4);
}
| DO statement WHILE '(' expression ')' ';'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while,
NULL, $5, NULL, $2);
$$->set_location_range(@1, @6);
}
| FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for,
$3, $4.cond, $4.rest, $6);
$$->set_location_range(@1, @6);
jump_statement:
CONTINUE ';'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL);
$$->set_location(@1);
}
| BREAK ';'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL);
$$->set_location(@1);
}
| RETURN ';'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL);
$$->set_location(@1);
}
| RETURN expression ';'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2);
$$->set_location_range(@1, @2);
}
| DISCARD ';' // Fragment shader only.
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL);
$$->set_location(@1);
}
function_definition:
function_prototype compound_statement_no_new_scope
{
- void *ctx = state;
+ void *ctx = state->linalloc;
$$ = new(ctx) ast_function_definition();
$$->set_location_range(@1, @2);
$$->prototype = $1;
instance_name_opt:
/* empty */
{
- $$ = new(state) ast_interface_block(NULL, NULL);
+ $$ = new(state->linalloc) ast_interface_block(NULL, NULL);
}
| NEW_IDENTIFIER
{
- $$ = new(state) ast_interface_block($1, NULL);
+ $$ = new(state->linalloc) ast_interface_block($1, NULL);
$$->set_location(@1);
}
| NEW_IDENTIFIER array_specifier
{
- $$ = new(state) ast_interface_block($1, $2);
+ $$ = new(state->linalloc) ast_interface_block($1, $2);
$$->set_location_range(@1, @2);
}
;
member_declaration:
fully_specified_type struct_declarator_list ';'
{
- void *ctx = state;
+ void *ctx = state->linalloc;
ast_fully_specified_type *type = $1;
type->set_location(@1);