2005-01-19 Sureshkumar T <tsureshkumar@novell.com>
[mono.git] / mcs / mbas / mb-parser.jay
index 2dd59f84e1b6f216f7b495ba30991f3b8897ae54..8802a2ffaac970798616263e2c049a7fe4e14e9e 100644 (file)
@@ -42,6 +42,7 @@ namespace Mono.MonoBASIC
        {
        
 
+
                /// <summary>
                ///   Current block is used to add statements as we find
                ///   them.  
@@ -751,11 +752,17 @@ declaration
                } else
                        break;
 
-               if ((mod_flags & (Modifiers.PRIVATE|Modifiers.PROTECTED)) != 0){
+               if ((mod_flags & (Modifiers.PRIVATE)) != 0){
+                       Report.Error (
+                               31089, lexer.Location, 
+                               "Namespace elements cannot be explicitly " +
+                               "declared private in '" + name + "'");
+                       }
+               else if ((mod_flags & (Modifiers.PROTECTED)) != 0){
                        Report.Error (
-                               1527, lexer.Location, 
+                               31047, lexer.Location, 
                                "Namespace elements cannot be explicitly " +
-                               "declared private or protected in '" + name + "'");
+                               "declared protected in '" + name + "'");
                }
          }
        ;
@@ -1119,7 +1126,7 @@ type_spec_declaration
        ;
 
 class_declaration
-       : CLASS identifier logical_end_of_line opt_inherits opt_implements
+       : CLASS identifier end_of_stmt opt_inherits opt_implements
          {
                // Module members are static by default, but Class *can't* be declared static
                // so we must fix it, if mbas was the one actually responsible for this
@@ -1163,12 +1170,12 @@ class_declaration
 
 opt_inherits
        : /* empty */                           { $$ = null; }
-       | INHERITS type_list logical_end_of_line        { $$ = $2; }
+       | INHERITS type_list end_of_stmt        { $$ = $2; }
        ;
 
 opt_implements
        : /* empty */                           { $$ = null; }
-       | IMPLEMENTS type_list logical_end_of_line      { $$ = $2; }
+       | IMPLEMENTS type_list end_of_stmt              { $$ = $2; }
        ;
 
 opt_modifiers
@@ -1280,7 +1287,7 @@ module_member_declarator
        ;
        
 constant_declaration
-       : CONST constant_declarators logical_end_of_line
+       : CONST constant_declarators end_of_stmt
        {
                // Module members are static by default, but constants *can't* be declared static
                // so we must fix it, if mbas was the one actually responsible for this
@@ -1464,7 +1471,6 @@ sub_declaration
                                                evt_target + " is not declared with WithEvents");
                        }
                  } else if (handles_exp is BaseAccess) {
-                               string evt_id = ((BaseAccess) $4).member;
                                Statement addhnd = (Statement) new AddHandler ((Expression) $4, 
                                                                                        DecomposeQI((string) $2, loc), 
                                                                                        loc);   
@@ -1509,7 +1515,7 @@ func_declaration
        ;               
 
 struct_declaration
-       : STRUCTURE identifier logical_end_of_line
+       : STRUCTURE identifier end_of_stmt
          opt_implement_clause
          {
                Struct new_struct;
@@ -1959,6 +1965,17 @@ abstract_propery_declaration
  non_abstract_propery_declaration
          : PROPERTY identifier opt_type_character opt_property_parameters opt_type_with_ranks opt_implement_clause logical_end_of_line
          {
+               if ((current_modifiers & Modifiers.DEFAULT) > 0) {
+                       if (current_container.DefaultPropName != null 
+                                 && current_container.DefaultPropName != (string) $2)
+                               Report.Error (30359, 
+                                               lexer.Location,
+                                               "Type '" + current_container.Name +
+                                               "' cannot have more than one 'Default Property' ");
+                                               
+                       current_container.DefaultPropName = (string) $2;
+               }               
+         
                get_implicit_value_parameter_type  = 
                        ($5 == null) ? (($3 == null) ? 
                                TypeManager.system_object_expr : (Expression) $3 ) : (Expression) $5;
@@ -2163,7 +2180,7 @@ opt_set_parameter
                        
 field_declaration
        : opt_dim_stmt 
-         variable_declarators logical_end_of_line
+         variable_declarators end_of_stmt
          {               
                int mod = (int) current_modifiers;
 
@@ -2466,8 +2483,6 @@ statement
            }
          | embedded_statement
            {
-                 Statement s = (Statement) $1;
-
                  current_block.AddStatement ((Statement) $1);
            } 
          | labeled_statement 
@@ -2487,8 +2502,6 @@ statement
          /* | empty_statement */
          | with_statement 
            {
-                 Statement s = (Statement) $1;
-
              current_block.AddStatement ((Statement) $1);
            }     
          ;     
@@ -3134,8 +3147,6 @@ if_statement
 pre_embedded_statement
        : embedded_statement 
          {
-               Statement s = (Statement) $1;
-
                current_block.AddStatement ((Statement) $1);
          } 
        ;       
@@ -3159,7 +3170,6 @@ else_pre_embedded_statement
         tmp_blocks.Push(bl); 
         
                start_block();
-               Statement s = (Statement) $2;
                current_block.AddStatement ((Statement) $2);
          } 
        ;       
@@ -3530,7 +3540,6 @@ constant_declarator
                string varname = (string) vname.Name;
                current_rank_specifiers = (ArrayList) vname.Rank;
                object varinit = $3;
-               ArrayList a_dims = null;
 
                if (varinit == null)
                        Report.Error (
@@ -4359,9 +4368,9 @@ assignment_expression
          }
        | prefixed_unary_expression OP_EXP ASSIGN expression
          {
-               Location l = lexer.Location;
+               /*Location l = lexer.Location;
 
-               /* TODO: $$ = new CompoundAssign (
+                TODO: $$ = new CompoundAssign (
                        Binary.Operator.ExclusiveOr, (Expression) $1, (Expression) $4, l); */
          }
        | prefixed_unary_expression ASSIGN ADDRESSOF expression
@@ -4466,8 +4475,6 @@ pp_directive
          {
                if(tokenizerController.IsAcceptingTokens) 
                {
-                       string id = ($2 as string);
-               
                        if(!($2 as string).ToLower().Equals("region"))
                                Report.Error (30205, lexer.Location, "Invalid Pre-processor directive");
                        else
@@ -4896,7 +4903,6 @@ public class VariableDeclaration {
                
        public static void FixupArrayTypes (ArrayList vars)
        {
-               int varcount =  vars.Count;
                string dims;
                
                foreach (VariableDeclaration var in vars) {
@@ -4988,13 +4994,11 @@ void CheckAttributeTarget (string a)
 
 private void AddHandler (Block b, Expression evt_id, Expression handles_exp)
 {
-       Expression evt_target;
        Location loc = lexer.Location;
        
        Statement addhnd = (Statement) new AddHandler (evt_id, 
                                                                                                        handles_exp, 
                                                                                                        loc);                                                                                                   
-                                                                                                       
        b.AddStatement (addhnd);
 }
 
@@ -5009,7 +5013,6 @@ private void RaiseEvent (string evt_name, ArrayList args)
 
 private void RemoveHandler (Block b, Expression evt_definition, Expression handler_exp)
 {
-       Expression evt_target;
        Location loc = lexer.Location;
        
        Statement rmhnd = (Statement) new RemoveHandler (evt_definition, 
@@ -5110,7 +5113,6 @@ protected override int parse ()
        ifElseStateMachine = new IfElseStateMachine();
        tokenizerController = new TokenizerController(lexer);
        
-       StringBuilder value = new StringBuilder ();
        try {
                if (yacc_verbose_flag > 0)
                        yyparse (lexer, new yydebug.yyDebugSimple ());