[Mesa-dev] [PATCH V3 2/8] glsl: Add arrays_of_arrays to yacc definition

Pohjolainen, Topi topi.pohjolainen at intel.com
Wed Jan 22 22:58:05 PST 2014


On Wed, Jan 22, 2014 at 10:33:01PM +1100, Timothy Arceri wrote:
> Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
> ---
>  src/glsl/glsl_parser.yy | 128 +++++++++++++++++++++---------------------------
>  1 file changed, 56 insertions(+), 72 deletions(-)
> 
> diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
> index 5451b76..2786e92 100644
> --- a/src/glsl/glsl_parser.yy
> +++ b/src/glsl/glsl_parser.yy
> @@ -97,6 +97,7 @@ static bool match_layout_qualifier(const char *s1, const char *s2,
>  
>     ast_node *node;
>     ast_type_specifier *type_specifier;
> +   ast_array_specifier *array_specifier;

Isn't this undefined symbol at this point? I see that class
"ast_array_specifier" is defined in the next patch of the series.

>     ast_fully_specified_type *fully_specified_type;
>     ast_function *function;
>     ast_parameter_declarator *parameter_declarator;
> @@ -202,6 +203,7 @@ static bool match_layout_qualifier(const char *s1, const char *s2,
>  %type <type_qualifier> interface_qualifier
>  %type <type_specifier> type_specifier
>  %type <type_specifier> type_specifier_nonarray
> +%type <array_specifier> array_specifier
>  %type <identifier> basic_type_specifier_nonarray
>  %type <fully_specified_type> fully_specified_type
>  %type <function> function_prototype
> @@ -880,7 +882,7 @@ parameter_declarator:
>        $$->type->specifier = $1;
>        $$->identifier = $2;
>     }
> -   | type_specifier any_identifier '[' constant_expression ']'
> +   | type_specifier any_identifier array_specifier
>     {
>        void *ctx = state;
>        $$ = new(ctx) ast_parameter_declarator();
> @@ -889,8 +891,7 @@ parameter_declarator:
>        $$->type->set_location(yylloc);
>        $$->type->specifier = $1;
>        $$->identifier = $2;
> -      $$->is_array = true;
> -      $$->array_size = $4;
> +      $$->array_specifier = $3;
>     }
>     ;
>  
> @@ -983,40 +984,20 @@ init_declarator_list:
>        $$->declarations.push_tail(&decl->link);
>        state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
>     }
> -   | init_declarator_list ',' any_identifier '[' ']'
> +   | init_declarator_list ',' any_identifier array_specifier
>     {
>        void *ctx = state;
> -      ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL);
> +      ast_declaration *decl = new(ctx) ast_declaration($3, true, $4, NULL);
>        decl->set_location(yylloc);
>  
>        $$ = $1;
>        $$->declarations.push_tail(&decl->link);
>        state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
>     }
> -   | init_declarator_list ',' any_identifier '[' constant_expression ']'
> +   | init_declarator_list ',' any_identifier array_specifier '=' initializer
>     {
>        void *ctx = state;
> -      ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL);
> -      decl->set_location(yylloc);
> -
> -      $$ = $1;
> -      $$->declarations.push_tail(&decl->link);
> -      state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
> -   }
> -   | init_declarator_list ',' any_identifier '[' ']' '=' initializer
> -   {
> -      void *ctx = state;
> -      ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7);
> -      decl->set_location(yylloc);
> -
> -      $$ = $1;
> -      $$->declarations.push_tail(&decl->link);
> -      state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
> -   }
> -   | init_declarator_list ',' any_identifier '[' constant_expression ']' '=' initializer
> -   {
> -      void *ctx = state;
> -      ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8);
> +      ast_declaration *decl = new(ctx) ast_declaration($3, true, $4, $6);
>        decl->set_location(yylloc);
>  
>        $$ = $1;
> @@ -1053,37 +1034,19 @@ single_declaration:
>        $$->set_location(yylloc);
>        $$->declarations.push_tail(&decl->link);
>     }
> -   | fully_specified_type any_identifier '[' ']'
> +   | fully_specified_type any_identifier array_specifier
>     {
>        void *ctx = state;
> -      ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL);
> +      ast_declaration *decl = new(ctx) ast_declaration($2, true, $3, NULL);
>  
>        $$ = new(ctx) ast_declarator_list($1);
>        $$->set_location(yylloc);
>        $$->declarations.push_tail(&decl->link);
>     }
> -   | fully_specified_type any_identifier '[' constant_expression ']'
> +   | fully_specified_type any_identifier array_specifier '=' initializer
>     {
>        void *ctx = state;
> -      ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL);
> -
> -      $$ = new(ctx) ast_declarator_list($1);
> -      $$->set_location(yylloc);
> -      $$->declarations.push_tail(&decl->link);
> -   }
> -   | fully_specified_type any_identifier '[' ']' '=' initializer
> -   {
> -      void *ctx = state;
> -      ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6);
> -
> -      $$ = new(ctx) ast_declarator_list($1);
> -      $$->set_location(yylloc);
> -      $$->declarations.push_tail(&decl->link);
> -   }
> -   | fully_specified_type any_identifier '[' constant_expression ']' '=' initializer
> -   {
> -      void *ctx = state;
> -      ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7);
> +      ast_declaration *decl = new(ctx) ast_declaration($2, true, $3, $5);
>  
>        $$ = new(ctx) ast_declarator_list($1);
>        $$->set_location(yylloc);
> @@ -1584,19 +1547,51 @@ storage_qualifier:
>     }
>     ;
>  
> -type_specifier:
> -   type_specifier_nonarray
> -   | type_specifier_nonarray '[' ']'
> +array_specifier:
> +   '[' ']'
> +   {
> +      void *ctx = state;
> +      $$ = new(ctx) ast_array_specifier(yylloc);
> +   }
> +   | '[' constant_expression ']'
> +   {
> +      void *ctx = state;
> +      $$ = new(ctx) ast_array_specifier(yylloc, $2);
> +   }
> +   | array_specifier '[' ']'
> +   {
> +      $$ = $1;
> +
> +      if (!state->ARB_arrays_of_arrays_enable) {
> +         _mesa_glsl_error(& @1, state,
> +                          "GL_ARB_arrays_of_arrays "
> +                          "required for defining arrays of arrays");
> +      } else {
> +         _mesa_glsl_error(& @1, state,
> +                          "only the outermost array dimension can "
> +                          "be unsized");
> +      }
> +   }
> +   | array_specifier '[' constant_expression ']'
>     {
>        $$ = $1;
> -      $$->is_array = true;
> -      $$->array_size = NULL;
> +
> +      if (!state->ARB_arrays_of_arrays_enable) {
> +         _mesa_glsl_error(& @1, state,
> +                          "GL_ARB_arrays_of_arrays "
> +                          "required for defining arrays of arrays");
> +      }
> +
> +      $$->add_dimension($3);
>     }
> -   | type_specifier_nonarray '[' constant_expression ']'
> +   ;
> +
> +type_specifier:
> +   type_specifier_nonarray
> +   | type_specifier_nonarray array_specifier
>     {
>        $$ = $1;
> -      $$->is_array = true;
> -      $$->array_size = $3;
> +      $$->array_specifier = $2;
>     }
>     ;
>  
> @@ -1779,16 +1774,10 @@ struct_declarator:
>        $$ = new(ctx) ast_declaration($1, false, NULL, NULL);
>        $$->set_location(yylloc);
>     }
> -   | any_identifier '[' ']'
> +   | any_identifier array_specifier
>     {
>        void *ctx = state;
> -      $$ = new(ctx) ast_declaration($1, true, NULL, NULL);
> -      $$->set_location(yylloc);
> -   }
> -   | any_identifier '[' constant_expression ']'
> -   {
> -      void *ctx = state;
> -      $$ = new(ctx) ast_declaration($1, true, $3, NULL);
> +      $$ = new(ctx) ast_declaration($1, true, $2, NULL);
>        $$->set_location(yylloc);
>     }
>     ;
> @@ -2288,15 +2277,10 @@ instance_name_opt:
>        $$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
>                                            $1, false, NULL);
>     }
> -   | NEW_IDENTIFIER '[' constant_expression ']'
> -   {
> -      $$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
> -                                          $1, true, $3);
> -   }
> -   | NEW_IDENTIFIER '[' ']'
> +   | NEW_IDENTIFIER array_specifier
>     {
>        $$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
> -                                          $1, true, NULL);
> +                                          $1, true, $2);
>     }
>     ;
>  
> -- 
> 1.8.3.1
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list