* mcs/cs-parser.jay: Use 'start_block' and 'end_block' rather than
[mono.git] / mcs / mcs / cs-parser.jay
index 2510be6a15b194b19ec737069390f05a25277f8e..ffcdceb761597bd191ad301327a2d738bb2ee273 100644 (file)
@@ -1918,13 +1918,13 @@ operator_body
        ; 
 operator_declarator
        : type OPERATOR overloadable_operator 
-         open_parens opt_parameter_modifier type IDENTIFIER CLOSE_PARENS
+         open_parens opt_attributes opt_parameter_modifier type IDENTIFIER CLOSE_PARENS
          {
                // TODO: wrong location
-               if ((Parameter.Modifier)$5 != Parameter.Modifier.NONE)
+               if ((Parameter.Modifier)$6 != Parameter.Modifier.NONE)
                        Error_ParameterModifierNotValid ((Location) $2);
          
-               LocatedToken lt = (LocatedToken) $7;
+               LocatedToken lt = (LocatedToken) $8;
                Operator.OpType op = (Operator.OpType) $3;
                CheckUnaryOperator (op, lt.Location);
 
@@ -1935,9 +1935,9 @@ operator_declarator
                        op = Operator.OpType.UnaryNegation;
 
                Parameter [] pars = new Parameter [1];
-               Expression type = (Expression) $6;
+               Expression type = (Expression) $7;
 
-               pars [0] = new Parameter (type, lt.Value, Parameter.Modifier.NONE, null, lt.Location);
+               pars [0] = new Parameter (type, lt.Value, Parameter.Modifier.NONE, (Attributes) $5, lt.Location);
 
                current_local_parameters = new Parameters (pars);
 
@@ -1951,25 +1951,25 @@ operator_declarator
          }
        | type OPERATOR overloadable_operator
          open_parens 
-               opt_parameter_modifier type IDENTIFIER COMMA
-               opt_parameter_modifier type IDENTIFIER 
+               opt_attributes opt_parameter_modifier type IDENTIFIER COMMA
+               opt_attributes opt_parameter_modifier type IDENTIFIER 
          CLOSE_PARENS
           {
                // TODO: wrong location
-               if ((Parameter.Modifier)$5 != Parameter.Modifier.NONE || (Parameter.Modifier)$9 != Parameter.Modifier.NONE)
+               if ((Parameter.Modifier)$6 != Parameter.Modifier.NONE || (Parameter.Modifier)$11 != Parameter.Modifier.NONE)
                        Error_ParameterModifierNotValid ((Location) $2);
 
-               LocatedToken ltParam1 = (LocatedToken) $7;
-               LocatedToken ltParam2 = (LocatedToken) $11;
+               LocatedToken ltParam1 = (LocatedToken) $8;
+               LocatedToken ltParam2 = (LocatedToken) $13;
                CheckBinaryOperator ((Operator.OpType) $3, (Location) $2);
 
                Parameter [] pars = new Parameter [2];
 
-               Expression typeL = (Expression) $6;
-               Expression typeR = (Expression) $10;
+               Expression typeL = (Expression) $7;
+               Expression typeR = (Expression) $12;
 
-              pars [0] = new Parameter (typeL, ltParam1.Value, Parameter.Modifier.NONE, null, ltParam1.Location);
-              pars [1] = new Parameter (typeR, ltParam2.Value, Parameter.Modifier.NONE, null, ltParam2.Location);
+              pars [0] = new Parameter (typeL, ltParam1.Value, Parameter.Modifier.NONE, (Attributes) $5, ltParam1.Location);
+              pars [1] = new Parameter (typeR, ltParam2.Value, Parameter.Modifier.NONE, (Attributes) $10, ltParam2.Location);
 
               current_local_parameters = new Parameters (pars);
 
@@ -1985,10 +1985,8 @@ operator_declarator
        | conversion_operator_declarator
        | type OPERATOR overloadable_operator
          open_parens 
-               opt_parameter_modifier type IDENTIFIER COMMA
-               opt_parameter_modifier type IDENTIFIER COMMA
-               opt_parameter_modifier type IDENTIFIER
-         CLOSE_PARENS
+               opt_attributes opt_parameter_modifier type IDENTIFIER COMMA
+               opt_attributes opt_parameter_modifier type IDENTIFIER COMMA error
          {
                Report.Error (1534, (Location) $2, "Overloaded binary operator `{0}' takes two parameters",
                        Operator.GetName ((Operator.OpType) $3));
@@ -4219,8 +4217,9 @@ for_statement
        : FOR open_parens 
          opt_for_initializer SEMICOLON
          {
-               Block assign_block = new Block (current_block);
-               current_block = assign_block;
+               Location l = lexer.Location;
+               start_block (l);  
+               Block assign_block = current_block;
 
                if ($3 is DictionaryEntry){
                        DictionaryEntry de = (DictionaryEntry) $3;
@@ -4236,7 +4235,6 @@ for_statement
                                if (vi == null)
                                        continue;
 
-                               Location l = lexer.Location;
                                Expression expr = decl.expression_or_array_initializer;
                                        
                                LocalVariableReference var;
@@ -4265,10 +4263,8 @@ for_statement
                For f = new For ((Statement) $5, (Expression) $6, (Statement) $8, (Statement) $10, l);
 
                current_block.AddStatement (f);
-               while (current_block.Implicit)
-                       current_block = current_block.Parent;
-               $$ = current_block;
-               current_block = current_block.Parent;
+
+               $$ = end_block (lexer.Location);
          }
        ;
 
@@ -4324,8 +4320,8 @@ foreach_statement
        | FOREACH open_parens type IDENTIFIER IN
          expression CLOSE_PARENS 
          {
-               Block foreach_block = new Block (current_block);
-               current_block = foreach_block;
+               start_block (lexer.Location);
+               Block foreach_block = current_block;
 
                LocatedToken lt = (LocatedToken) $4;
                Location l = lt.Location;
@@ -4354,10 +4350,7 @@ foreach_statement
                        current_block.AddStatement (f);
                }
 
-               while (current_block.Implicit)
-                         current_block = current_block.Parent;
-               $$ = current_block;
-               current_block = current_block.Parent;
+               $$ = end_block (lexer.Location);
          }
        ;
 
@@ -4555,9 +4548,8 @@ catch_clause
 
                                one.Add (new VariableDeclaration (lt, null));
 
-                               current_block = new Block (current_block);
-                               Block b = declare_local_variables (type, one, lt.Location);
-                               current_block = b;
+                               start_block (lexer.Location);
+                               current_block = declare_local_variables (type, one, lt.Location);
                        }
                }
          } block {
@@ -4572,10 +4564,7 @@ catch_clause
 
                        if (lt != null){
                                id = lt.Value;
-                               while (current_block.Implicit)
-                                       current_block = current_block.Parent;
-                               var_block = current_block;
-                               current_block = current_block.Parent;
+                               var_block = end_block (lexer.Location);
                        }
                }
 
@@ -4629,8 +4618,8 @@ fixed_statement
                Location l = (Location) $1;
                int top = list.Count;
 
-               Block assign_block = new Block (current_block);
-               current_block = assign_block;
+               start_block (lexer.Location);
+               Block assign_block = current_block;
 
                for (int i = 0; i < top; i++){
                        Pair p = (Pair) list [i];
@@ -4653,10 +4642,8 @@ fixed_statement
                Fixed f = new Fixed ((Expression) $3, (ArrayList) $4, (Statement) $7, l);
 
                current_block.AddStatement (f);
-               while (current_block.Implicit)
-                       current_block = current_block.Parent;
-               $$ = current_block;
-               current_block = current_block.Parent;
+
+               $$ = end_block (lexer.Location);
          }
        ;
 
@@ -4704,8 +4691,8 @@ lock_statement
 using_statement
        : USING open_parens resource_acquisition CLOSE_PARENS
          {
-               Block assign_block = new Block (current_block);
-               current_block = assign_block;
+               start_block (lexer.Location);
+               Block assign_block = current_block;
 
                if ($3 is DictionaryEntry){
                        DictionaryEntry de = (DictionaryEntry) $3;
@@ -4753,10 +4740,7 @@ using_statement
          {
                Using u = new Using ($5, (Statement) $6, (Location) $1);
                current_block.AddStatement (u);
-               while (current_block.Implicit)
-                       current_block = current_block.Parent;
-               $$ = current_block;
-               current_block = current_block.Parent;
+               $$ = end_block (lexer.Location);
          }
        ;