Switch to compiler-tester
[mono.git] / mcs / mbas / mb-parser.jay
index a88c5eff32534bf2a46eaba73d4d94bfda488bd5..dd573f538a89f1306f0d0e0627c9316089d66847 100644 (file)
@@ -2534,6 +2534,11 @@ constructor_declaration
          { 
                Constructor c = (Constructor) $1;
                c.Block = (Block) end_block();
+
+//To support "Sub New()" add default modifier "public"
+
+               if(current_modifiers ==0)
+                       current_modifiers = Modifiers.PUBLIC;
                c.ModFlags = (int) current_modifiers;
                c.OptAttributes = current_attributes;
                
@@ -3328,37 +3333,27 @@ for_statement
          }
           _mark_ opt_identifier 
          {
-                       string s = $3.ToString();
-                       string s1 = "";
-                       if ($16 != null)
-                               s1 = $16.ToString();            
-                       if (s1 != "" && s != s1)
-                               {               
-                                       Report.Error(30070, (Location)$15, "Next Control Variable '"+s1+"' does not match with For Loop control variable '"+s+"'");    
-                               }
+               string s = $3.ToString();
+               string s1 = "";
+               if ($16 != null)
+                       s1 = $16.ToString();            
+               if (s1 != "" && s != s1) {              
+                       Report.Error(30070, (Location)$15, "Next Control Variable '"+s1+"' does not match with For Loop control variable '"+s+"'");    
+               }
 
-                       Block inner_statement = end_block();
-                       Location l = (Location)$2;
-                       Expression for_var = (Expression) DecomposeQI ((string)$3, l);
+               Block inner_statement = end_block();
+               Location l = (Location)$2;
+               Expression for_var = (Expression) DecomposeQI ((string)$3, l);
                        
-            Expression assign_expr = new Assign (for_var, (Expression) $6, l);
-            Expression test_expr =  new Binary (Binary.Operator.LessThanOrEqual,
-                                                            for_var, (Expression) $8, l);
-            Expression step_expr = new Assign (for_var, (Expression) new Binary (Binary.Operator.Addition,
-                                             for_var, (Expression) $9, l), l);
-
-            Statement assign_stmt = new StatementExpression ((ExpressionStatement) assign_expr, l);
-            Statement step_stmt = new StatementExpression ((ExpressionStatement) step_expr, l);
-
-            For f = new For (assign_stmt, test_expr, step_stmt, inner_statement, l);
-                       if ($4 != null)
-                       {
-                               current_block.AddStatement (f);
-                               $$ = end_block();
-                       }
-                       else
-                               $$ = f;
-         }
+               For f = new For (for_var, (Expression) $6, (Expression) $8, (Expression) $9, inner_statement, l);
+               if ($4 != null)
+               {
+                       current_block.AddStatement (f);
+                       $$ = end_block();
+               }
+               else
+                       $$ = f;
+       }
        ;
 
 opt_step
@@ -3635,7 +3630,7 @@ case_section
                topmost.statements.Add (new Break (lexer.Location));
                
                ArrayList a = new ArrayList();
-               a.Add (new SwitchLabel (null, lexer.Location));                 
+               a.Add (new SwitchLabel (null, SwitchLabel.LabelType.Else, Binary.Operator.TOP, lexer.Location));                        
                $$ = new SwitchSection ((ArrayList) a, topmost);                
          }
        ;         
@@ -3643,20 +3638,14 @@ case_section
 case_clauses
        : case_clause
          {
-                if ($1 is ArrayList) //From expression TO expression 
-                         $$ = $1;
-               else {
-
-                       ArrayList labels = new ArrayList ();
-
-                       labels.Add ($1);
-                       $$ = labels;
-               }
+               ArrayList labels = new ArrayList ();
+               labels.Add ($1);
+               $$ = labels;
          }     
        | case_clauses COMMA case_clause
          {
                ArrayList labels = (ArrayList) ($1);
-               labels.Add ($2);
+               labels.Add ($3);
 
                $$ = labels;
          }     
@@ -3664,27 +3653,17 @@ case_clauses
        
 case_clause
        : opt_is comparison_operator expression
+         {
+               $$ = new SwitchLabel ((Expression) $3, SwitchLabel.LabelType.Operator, (Binary.Operator) $2, lexer.Location);
+         }
        | expression
          {
-               $$ = new SwitchLabel ((Expression) $1, lexer.Location);
+               $$ = new SwitchLabel ((Expression) $1, SwitchLabel.LabelType.Label, Binary.Operator.TOP, lexer.Location);
          }
        | expression TO expression
         {
-               //FIXME: need to handle when expressions are character strings.
-                       Constant start = (Constant) $1;
-                       Constant end = (Constant) $3;
-                       int i = 0, s = 0, e = 0;
-                       Location l = lexer.Location ;
-                       ArrayList labels = new ArrayList ();
-
-                       if (start != null) 
-                               s = (int) start.GetValue ();
-                       if(end != null) 
-                               e = (int) end.GetValue ();
-                       for(i = s; i <= e; i++) {
-                               labels.Add(new SwitchLabel ((Expression)new IntLiteral(i), l));
-                       }
-                       $$ = labels;
+               $$ = new SwitchLabel ((Expression) $1, (Expression) $3, SwitchLabel.LabelType.Range,
+                                        Binary.Operator.TOP, lexer.Location);
         }
 
        ;
@@ -3695,11 +3674,30 @@ opt_is
        ;
 
 comparison_operator
-       : OP_LT
+       : OP_LT 
+         {
+               $$ = Binary.Operator.LessThan;
+         }
        | OP_GT
+         {
+               $$ = Binary.Operator.GreaterThan;
+         }
+       | OP_GE
+         {
+               $$ = Binary.Operator.GreaterThanOrEqual;
+         }
        | OP_LE
+         {
+               $$ = Binary.Operator.LessThanOrEqual;
+         }
        | OP_NE
-       /*| OP_EQ */
+         {
+               $$ = Binary.Operator.Inequality;
+         }
+       | ASSIGN
+         {
+               $$ = Binary.Operator.Equality;
+         }
        ;
 
 opt_case
@@ -4168,10 +4166,10 @@ primary_expression
        | parenthesized_expression
        | this_access
        | base_access
-       | qualified_identifier _mark_
+       | qualified_identifier opt_type_character _mark_
          {
                string name = (string) $1;
-               $$ = DecomposeQI (name, (Location)$2);
+               $$ = DecomposeQI (name, (Location)$3);
          }
        | get_type_expression
        | member_access
@@ -4378,6 +4376,10 @@ argument
          {
                $$ = new Argument ((Expression) $2, Argument.AType.AddressOf);
          }
+       | identifier ATTR_ASSIGN expression 
+         {
+               $$ = new Argument ((string) $1, (Expression) $3, Argument.AType.Expression);
+         }
        ;
 
 variable_reference
@@ -5471,6 +5473,7 @@ private void AddHandler (Expression evt_definition, Expression handler_exp)
        AddHandler (current_block, evt_definition, handler_exp);
 }
 
+/*
 void CheckAttributeTarget (string a)
 {
        switch (a) {
@@ -5484,6 +5487,7 @@ void CheckAttributeTarget (string a)
                break;
        }
 }
+*/
 
 private void AddHandler (Block b, Expression evt_id, Expression handles_exp)
 {
@@ -5560,6 +5564,7 @@ private ConstructorInitializer CheckConstructorInitializer (ref ArrayList s)
        return ci;
 }
 
+/*
 void Error_ExpectingTypeName (Location l, Expression expr)
 {
        if (expr is Invocation){
@@ -5568,6 +5573,7 @@ void Error_ExpectingTypeName (Location l, Expression expr)
                Report.Error (-1, l, "Invalid Type definition");
        }
 }
+*/
 
 public static Expression SetLeftHandFlag (Expression expr) {
        if (expr is Invocation) {
@@ -5604,9 +5610,11 @@ public static Expression SetValueRequiredFlag (Expression expr) {
        return expr;
 }
 
+/*
 static bool AlwaysAccept (MemberInfo m, object filterCriteria) {
        return true;
 }
+*/
 
 private void ReportError9998()
 {