Signed-off-by: Timothy Arceri <t_arc...@yahoo.com.au>
---
 src/glsl/glsl_parser.yy | 153 +++++++++++++++++++++---------------------------
 1 file changed, 66 insertions(+), 87 deletions(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 1c56d6f..6d63668 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;
    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();
@@ -890,7 +892,7 @@ parameter_declarator:
       $$->type->specifier = $1;
       $$->identifier = $2;
       $$->is_array = true;
-      $$->array_size = $4;
+      $$->array_specifier = $3;
    }
    ;
 
@@ -983,53 +985,28 @@ 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);
+      ast_declaration *decl = new(ctx) ast_declaration($3, true, $4, $6);
       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));
-      if ($7->oper == ast_aggregate) {
-         ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$7;
-         ast_type_specifier *type = new(ctx) 
ast_type_specifier($1->type->specifier, true, NULL);
-         _mesa_ast_set_aggregate_type(type, ai, state);
-      }
-   }
-   | init_declarator_list ',' any_identifier '[' constant_expression ']' '=' 
initializer
-   {
-      void *ctx = state;
-      ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8);
-      decl->set_location(yylloc);
-
-      $$ = $1;
-      $$->declarations.push_tail(&decl->link);
-      state->symbols->add_variable(new(state) ir_variable(NULL, $3, 
ir_var_auto));
-      if ($8->oper == ast_aggregate) {
-         ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$8;
-         ast_type_specifier *type = new(ctx) 
ast_type_specifier($1->type->specifier, true, $5);
+      if ($6->oper == ast_aggregate) {
+         ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$6;
+         ast_type_specifier *type = new(ctx) 
ast_type_specifier($1->type->specifier, true, $4);
          _mesa_ast_set_aggregate_type(type, ai, state);
       }
    }
@@ -1067,49 +1044,26 @@ 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);
+      ast_declaration *decl = new(ctx) ast_declaration($2, true, $3, $5);
 
       $$ = 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);
-      if ($6->oper == ast_aggregate) {
-         ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$6;
-         ast_type_specifier *type = new(ctx) ast_type_specifier($1->specifier, 
true, NULL);
-         _mesa_ast_set_aggregate_type(type, ai, state);
-      }
-   }
-   | fully_specified_type any_identifier '[' constant_expression ']' '=' 
initializer
-   {
-      void *ctx = state;
-      ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7);
-
-      $$ = new(ctx) ast_declarator_list($1);
-      $$->set_location(yylloc);
-      $$->declarations.push_tail(&decl->link);
-      if ($7->oper == ast_aggregate) {
-         ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$7;
-         ast_type_specifier *type = new(ctx) ast_type_specifier($1->specifier, 
true, $4);
+      if ($5->oper == ast_aggregate) {
+         ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$5;
+         ast_type_specifier *type = new(ctx) ast_type_specifier($1->specifier, 
true, $3);
          _mesa_ast_set_aggregate_type(type, ai, state);
       }
    }
@@ -1611,19 +1565,55 @@ storage_qualifier:
    }
    ;
 
-type_specifier:
-   type_specifier_nonarray
-   | type_specifier_nonarray '[' ']'
+array_specifier:
+   '[' ']'
    {
-      $$ = $1;
-      $$->is_array = true;
-      $$->array_size = NULL;
+      void *ctx = state;
+      $$ = new(ctx) ast_array_specifier();
+      $$->is_unsized_array = true;
+      $$->set_location(yylloc);
+   }
+   | '[' constant_expression ']'
+   {
+      void *ctx = state;
+      $$ = new(ctx) ast_array_specifier();
+      $$->array_dimensions.push_tail(& $2->link);
+      $$->is_unsized_array = false;
+      $$->set_location(yylloc);
+   }
+   | array_specifier '[' ']'
+   {
+      if (!state->ARB_arrays_of_arrays_enable) {
+         _mesa_glsl_error(& @1, state,
+                          "#version 120 / 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");
+      }
    }
-   | type_specifier_nonarray '[' constant_expression ']'
+   | array_specifier '[' constant_expression ']'
+   {
+      if (!state->ARB_arrays_of_arrays_enable) {
+         _mesa_glsl_error(& @1, state,
+                          "#version 120 / GL_ARB_arrays_of_arrays "
+                          "required for defining arrays of arrays");
+      }
+
+      $$->array_dimensions.push_tail(& $3->link);
+      $$->dimension_count++;
+      $$->set_location(yylloc);
+   }
+   ;
+
+type_specifier:
+   type_specifier_nonarray
+   | type_specifier_nonarray array_specifier
    {
       $$ = $1;
       $$->is_array = true;
-      $$->array_size = $3;
+      $$->array_specifier = $2;
    }
    ;
 
@@ -1806,16 +1796,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);
    }
    ;
@@ -2315,15 +2299,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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to