diff options
Diffstat (limited to 'mesalib/src/glsl/glsl_parser.yy')
-rw-r--r-- | mesalib/src/glsl/glsl_parser.yy | 215 |
1 files changed, 114 insertions, 101 deletions
diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy index 8751524c2..3798af455 100644 --- a/mesalib/src/glsl/glsl_parser.yy +++ b/mesalib/src/glsl/glsl_parser.yy @@ -389,35 +389,35 @@ primary_expression: { void *ctx = state; $$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); - $$->set_location(yylloc); + $$->set_location(@1); $$->primary_expression.identifier = $1; } | INTCONSTANT { void *ctx = state; $$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); - $$->set_location(yylloc); + $$->set_location(@1); $$->primary_expression.int_constant = $1; } | UINTCONSTANT { void *ctx = state; $$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); - $$->set_location(yylloc); + $$->set_location(@1); $$->primary_expression.uint_constant = $1; } | FLOATCONSTANT { void *ctx = state; $$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); - $$->set_location(yylloc); + $$->set_location(@1); $$->primary_expression.float_constant = $1; } | BOOLCONSTANT { void *ctx = state; $$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); - $$->set_location(yylloc); + $$->set_location(@1); $$->primary_expression.bool_constant = $1; } | '(' expression ')' @@ -432,7 +432,7 @@ postfix_expression: { void *ctx = state; $$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @4); } | function_call { @@ -442,20 +442,20 @@ postfix_expression: { void *ctx = state; $$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); $$->primary_expression.identifier = $3; } | postfix_expression INC_OP { void *ctx = state; $$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); } | postfix_expression DEC_OP { void *ctx = state; $$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); } ; @@ -473,7 +473,7 @@ function_call_or_method: { void *ctx = state; $$ = new(ctx) ast_expression(ast_field_selection, $1, $3, NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -491,13 +491,13 @@ function_call_header_with_parameters: function_call_header assignment_expression { $$ = $1; - $$->set_location(yylloc); + $$->set_location(@1); $$->expressions.push_tail(& $2->link); } | function_call_header_with_parameters ',' assignment_expression { $$ = $1; - $$->set_location(yylloc); + $$->set_location(@1); $$->expressions.push_tail(& $3->link); } ; @@ -514,21 +514,23 @@ function_identifier: { void *ctx = state; $$ = new(ctx) ast_function_expression($1); - $$->set_location(yylloc); + $$->set_location(@1); } | variable_identifier { void *ctx = state; ast_expression *callee = new(ctx) ast_expression($1); + callee->set_location(@1); $$ = new(ctx) ast_function_expression(callee); - $$->set_location(yylloc); + $$->set_location(@1); } | FIELD_SELECTION { void *ctx = state; ast_expression *callee = new(ctx) ast_expression($1); + callee->set_location(@1); $$ = new(ctx) ast_function_expression(callee); - $$->set_location(yylloc); + $$->set_location(@1); } ; @@ -546,13 +548,13 @@ method_call_header_with_parameters: method_call_header assignment_expression { $$ = $1; - $$->set_location(yylloc); + $$->set_location(@1); $$->expressions.push_tail(& $2->link); } | method_call_header_with_parameters ',' assignment_expression { $$ = $1; - $$->set_location(yylloc); + $$->set_location(@1); $$->expressions.push_tail(& $3->link); } ; @@ -565,8 +567,9 @@ method_call_header: { void *ctx = state; ast_expression *callee = new(ctx) ast_expression($1); + callee->set_location(@1); $$ = new(ctx) ast_function_expression(callee); - $$->set_location(yylloc); + $$->set_location(@1); } ; @@ -577,19 +580,19 @@ unary_expression: { void *ctx = state; $$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL); - $$->set_location(yylloc); + $$->set_location(@1); } | DEC_OP unary_expression { void *ctx = state; $$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL); - $$->set_location(yylloc); + $$->set_location(@1); } | unary_operator unary_expression { void *ctx = state; $$ = new(ctx) ast_expression($1, $2, NULL, NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); } ; @@ -607,19 +610,19 @@ multiplicative_expression: { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_mul, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } | multiplicative_expression '/' unary_expression { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_div, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } | multiplicative_expression '%' unary_expression { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_mod, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -629,13 +632,13 @@ additive_expression: { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_add, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } | additive_expression '-' multiplicative_expression { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_sub, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -645,13 +648,13 @@ shift_expression: { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } | shift_expression RIGHT_OP additive_expression { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -661,25 +664,25 @@ relational_expression: { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_less, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } | relational_expression '>' shift_expression { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_greater, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } | relational_expression LE_OP shift_expression { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } | relational_expression GE_OP shift_expression { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -689,13 +692,13 @@ equality_expression: { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_equal, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } | equality_expression NE_OP relational_expression { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -705,7 +708,7 @@ and_expression: { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_bit_and, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -715,7 +718,7 @@ exclusive_or_expression: { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -725,7 +728,7 @@ inclusive_or_expression: { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -735,7 +738,7 @@ logical_and_expression: { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -745,7 +748,7 @@ logical_xor_expression: { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -755,7 +758,7 @@ logical_or_expression: { void *ctx = state; $$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -765,7 +768,7 @@ conditional_expression: { void *ctx = state; $$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5); - $$->set_location(yylloc); + $$->set_location_range(@1, @5); } ; @@ -775,7 +778,7 @@ assignment_expression: { void *ctx = state; $$ = new(ctx) ast_expression($2, $1, $3, NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -803,7 +806,7 @@ expression: void *ctx = state; if ($1->oper != ast_sequence) { $$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); $$->expressions.push_tail(& $1->link); } else { $$ = $1; @@ -865,7 +868,7 @@ function_header: { void *ctx = state; $$ = new(ctx) ast_function(); - $$->set_location(yylloc); + $$->set_location(@2); $$->return_type = $1; $$->identifier = $2; @@ -879,9 +882,9 @@ parameter_declarator: { void *ctx = state; $$ = new(ctx) ast_parameter_declarator(); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); $$->type = new(ctx) ast_fully_specified_type(); - $$->type->set_location(yylloc); + $$->type->set_location(@1); $$->type->specifier = $1; $$->identifier = $2; } @@ -889,9 +892,9 @@ parameter_declarator: { void *ctx = state; $$ = new(ctx) ast_parameter_declarator(); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); $$->type = new(ctx) ast_fully_specified_type(); - $$->type->set_location(yylloc); + $$->type->set_location(@1); $$->type->specifier = $1; $$->identifier = $2; $$->array_specifier = $3; @@ -908,8 +911,9 @@ parameter_declaration: { void *ctx = state; $$ = new(ctx) ast_parameter_declarator(); - $$->set_location(yylloc); + $$->set_location(@2); $$->type = new(ctx) ast_fully_specified_type(); + $$->type->set_location_range(@1, @2); $$->type->qualifier = $1; $$->type->specifier = $2; } @@ -981,7 +985,7 @@ init_declarator_list: { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($3, NULL, NULL); - decl->set_location(yylloc); + decl->set_location(@3); $$ = $1; $$->declarations.push_tail(&decl->link); @@ -991,7 +995,7 @@ init_declarator_list: { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($3, $4, NULL); - decl->set_location(yylloc); + decl->set_location_range(@3, @4); $$ = $1; $$->declarations.push_tail(&decl->link); @@ -1001,7 +1005,7 @@ init_declarator_list: { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($3, $4, $6); - decl->set_location(yylloc); + decl->set_location_range(@3, @4); $$ = $1; $$->declarations.push_tail(&decl->link); @@ -1011,7 +1015,7 @@ init_declarator_list: { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($3, NULL, $5); - decl->set_location(yylloc); + decl->set_location(@3); $$ = $1; $$->declarations.push_tail(&decl->link); @@ -1026,51 +1030,56 @@ single_declaration: void *ctx = state; /* Empty declaration list is valid. */ $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); + $$->set_location(@1); } | fully_specified_type any_identifier { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL); + decl->set_location(@2); $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); $$->declarations.push_tail(&decl->link); } | fully_specified_type any_identifier array_specifier { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, $3, NULL); + decl->set_location_range(@2, @3); $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); $$->declarations.push_tail(&decl->link); } | fully_specified_type any_identifier array_specifier '=' initializer { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, $3, $5); + decl->set_location_range(@2, @3); $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); $$->declarations.push_tail(&decl->link); } | fully_specified_type any_identifier '=' initializer { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, NULL, $4); + decl->set_location(@2); $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); $$->declarations.push_tail(&decl->link); } | INVARIANT variable_identifier // Vertex only. { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL); + decl->set_location(@2); $$ = new(ctx) ast_declarator_list(NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); $$->invariant = true; $$->declarations.push_tail(&decl->link); @@ -1082,14 +1091,14 @@ fully_specified_type: { void *ctx = state; $$ = new(ctx) ast_fully_specified_type(); - $$->set_location(yylloc); + $$->set_location(@1); $$->specifier = $1; } | type_qualifier type_specifier { void *ctx = state; $$ = new(ctx) ast_fully_specified_type(); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); $$->qualifier = $1; $$->specifier = $2; } @@ -1697,12 +1706,14 @@ array_specifier: '[' ']' { void *ctx = state; - $$ = new(ctx) ast_array_specifier(yylloc); + $$ = new(ctx) ast_array_specifier(@1); + $$->set_location_range(@1, @2); } | '[' constant_expression ']' { void *ctx = state; - $$ = new(ctx) ast_array_specifier(yylloc, $2); + $$ = new(ctx) ast_array_specifier(@1, $2); + $$->set_location_range(@1, @3); } | array_specifier '[' ']' { @@ -1746,19 +1757,19 @@ type_specifier_nonarray: { void *ctx = state; $$ = new(ctx) ast_type_specifier($1); - $$->set_location(yylloc); + $$->set_location(@1); } | struct_specifier { void *ctx = state; $$ = new(ctx) ast_type_specifier($1); - $$->set_location(yylloc); + $$->set_location(@1); } | TYPE_IDENTIFIER { void *ctx = state; $$ = new(ctx) ast_type_specifier($1); - $$->set_location(yylloc); + $$->set_location(@1); } ; @@ -1889,7 +1900,7 @@ struct_specifier: { void *ctx = state; $$ = new(ctx) ast_struct_specifier($2, $4); - $$->set_location(yylloc); + $$->set_location_range(@2, @5); state->symbols->add_type($2, glsl_type::void_type); state->symbols->add_type_ast($2, new(ctx) ast_type_specifier($$)); } @@ -1897,7 +1908,7 @@ struct_specifier: { void *ctx = state; $$ = new(ctx) ast_struct_specifier(NULL, $3); - $$->set_location(yylloc); + $$->set_location_range(@2, @4); } ; @@ -1919,7 +1930,7 @@ struct_declaration: { void *ctx = state; ast_fully_specified_type *const type = $1; - type->set_location(yylloc); + type->set_location(@1); if (type->qualifier.flags.i != 0) _mesa_glsl_error(&@1, state, @@ -1927,7 +1938,7 @@ struct_declaration: "structure members"); $$ = new(ctx) ast_declarator_list(type); - $$->set_location(yylloc); + $$->set_location(@2); $$->declarations.push_degenerate_list_at_head(& $2->link); } @@ -1951,13 +1962,13 @@ struct_declarator: { void *ctx = state; $$ = new(ctx) ast_declaration($1, NULL, NULL); - $$->set_location(yylloc); + $$->set_location(@1); } | any_identifier array_specifier { void *ctx = state; $$ = new(ctx) ast_declaration($1, $2, NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); } ; @@ -1978,7 +1989,7 @@ initializer_list: { void *ctx = state; $$ = new(ctx) ast_aggregate_initializer(); - $$->set_location(yylloc); + $$->set_location(@1); $$->expressions.push_tail(& $1->link); } | initializer_list ',' initializer @@ -2012,7 +2023,7 @@ compound_statement: { void *ctx = state; $$ = new(ctx) ast_compound_statement(true, NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); } | '{' { @@ -2022,7 +2033,7 @@ compound_statement: { void *ctx = state; $$ = new(ctx) ast_compound_statement(true, $3); - $$->set_location(yylloc); + $$->set_location_range(@1, @4); state->symbols->pop_scope(); } ; @@ -2037,13 +2048,13 @@ compound_statement_no_new_scope: { void *ctx = state; $$ = new(ctx) ast_compound_statement(false, NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); } | '{' statement_list '}' { void *ctx = state; $$ = new(ctx) ast_compound_statement(false, $2); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -2074,13 +2085,13 @@ expression_statement: { void *ctx = state; $$ = new(ctx) ast_expression_statement(NULL); - $$->set_location(yylloc); + $$->set_location(@1); } | expression ';' { void *ctx = state; $$ = new(ctx) ast_expression_statement($1); - $$->set_location(yylloc); + $$->set_location(@1); } ; @@ -2089,7 +2100,7 @@ selection_statement: { $$ = new(state) ast_selection_statement($3, $5.then_statement, $5.else_statement); - $$->set_location(yylloc); + $$->set_location_range(@1, @5); } ; @@ -2116,8 +2127,8 @@ condition: void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration($2, NULL, $4); ast_declarator_list *declarator = new(ctx) ast_declarator_list($1); - decl->set_location(yylloc); - declarator->set_location(yylloc); + decl->set_location_range(@2, @4); + declarator->set_location(@1); declarator->declarations.push_tail(&decl->link); $$ = declarator; @@ -2132,7 +2143,7 @@ switch_statement: SWITCH '(' expression ')' switch_body { $$ = new(state) ast_switch_statement($3, $5); - $$->set_location(yylloc); + $$->set_location_range(@1, @5); } ; @@ -2140,12 +2151,12 @@ switch_body: '{' '}' { $$ = new(state) ast_switch_body(NULL); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); } | '{' case_statement_list '}' { $$ = new(state) ast_switch_body($2); - $$->set_location(yylloc); + $$->set_location_range(@1, @3); } ; @@ -2153,12 +2164,12 @@ case_label: CASE expression ':' { $$ = new(state) ast_case_label($2); - $$->set_location(yylloc); + $$->set_location(@2); } | DEFAULT ':' { $$ = new(state) ast_case_label(NULL); - $$->set_location(yylloc); + $$->set_location(@2); } ; @@ -2169,7 +2180,7 @@ case_label_list: labels->labels.push_tail(& $1->link); $$ = labels; - $$->set_location(yylloc); + $$->set_location(@1); } | case_label_list case_label { @@ -2182,7 +2193,7 @@ case_statement: case_label_list statement { ast_case_statement *stmts = new(state) ast_case_statement($1); - stmts->set_location(yylloc); + stmts->set_location(@2); stmts->stmts.push_tail(& $2->link); $$ = stmts; @@ -2198,7 +2209,7 @@ case_statement_list: case_statement { ast_case_statement_list *cases= new(state) ast_case_statement_list(); - cases->set_location(yylloc); + cases->set_location(@1); cases->cases.push_tail(& $1->link); $$ = cases; @@ -2216,21 +2227,21 @@ iteration_statement: void *ctx = state; $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, NULL, $3, NULL, $5); - $$->set_location(yylloc); + $$->set_location_range(@1, @4); } | DO statement WHILE '(' expression ')' ';' { void *ctx = state; $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, NULL, $5, NULL, $2); - $$->set_location(yylloc); + $$->set_location_range(@1, @6); } | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope { void *ctx = state; $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, $3, $4.cond, $4.rest, $6); - $$->set_location(yylloc); + $$->set_location_range(@1, @6); } ; @@ -2266,31 +2277,31 @@ jump_statement: { void *ctx = state; $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); - $$->set_location(yylloc); + $$->set_location(@1); } | BREAK ';' { void *ctx = state; $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); - $$->set_location(yylloc); + $$->set_location(@1); } | RETURN ';' { void *ctx = state; $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); - $$->set_location(yylloc); + $$->set_location(@1); } | RETURN expression ';' { void *ctx = state; $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); } | DISCARD ';' // Fragment shader only. { void *ctx = state; $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); - $$->set_location(yylloc); + $$->set_location(@1); } ; @@ -2306,7 +2317,7 @@ function_definition: { void *ctx = state; $$ = new(ctx) ast_function_definition(); - $$->set_location(yylloc); + $$->set_location_range(@1, @2); $$->prototype = $1; $$->body = $2; @@ -2455,11 +2466,13 @@ instance_name_opt: { $$ = new(state) ast_interface_block(*state->default_uniform_qualifier, $1, NULL); + $$->set_location(@1); } | NEW_IDENTIFIER array_specifier { $$ = new(state) ast_interface_block(*state->default_uniform_qualifier, $1, $2); + $$->set_location_range(@1, @2); } ; @@ -2481,7 +2494,7 @@ member_declaration: { void *ctx = state; ast_fully_specified_type *type = $1; - type->set_location(yylloc); + type->set_location(@1); if (type->qualifier.flags.q.attribute) { _mesa_glsl_error(& @1, state, @@ -2494,7 +2507,7 @@ member_declaration: } $$ = new(ctx) ast_declarator_list(type); - $$->set_location(yylloc); + $$->set_location(@2); $$->declarations.push_degenerate_list_at_head(& $2->link); } |