2003/03/04 Rafael Teixeira <rafaelteixeirabr@hotmail.com>
authorRafael Teixeira <monoman@gmail.com>
Tue, 4 Mar 2003 19:58:58 +0000 (19:58 -0000)
committerRafael Teixeira <monoman@gmail.com>
Tue, 4 Mar 2003 19:58:58 +0000 (19:58 -0000)
* mb-parser.jay: added rule for Imports with alias
* mb-parser.jay: Friend (internal) modifier was missing,
 Shared modifier was expecting Static token erroneously
 Modules must accept only a static constructor rule added
 Constant declaration rule added
* makefile & makefile.gnu : actually run the compiled program on test target

svn path=/trunk/mcs/; revision=12191

mcs/mbas/ChangeLog
mcs/mbas/makefile
mcs/mbas/makefile.gnu
mcs/mbas/mb-parser.jay
mcs/mbas/module.cs
mcs/mbas/testmbas/WriteOK.vb
mcs/mbas/testmbas/WriteOK2.mbs

index 4c0a948ef1ba7fd8c861f91c6e58175dcb0bf62e..74e1e644565c60386ff25e17b06c8a9b6cd7ebc1 100644 (file)
@@ -1,3 +1,11 @@
+2003/03/04  Rafael Teixeira <rafaelteixeirabr@hotmail.com>\r
+       * mb-parser.jay: added rule for Imports with alias\r
+       * mb-parser.jay: Friend (internal) modifier was missing,\r
+                                        Shared modifier was expecting Static token erroneously\r
+                                        Modules must accept only a static constructor rule added\r
+                                        Constant declaration rule added\r
+       * makefile & makefile.gnu : actually run the compiled program on test target \r
+\r
 2003/03/03  Rafael Teixeira <rafaelteixeirabr@hotmail.com>\r
        * mb-tokenizer.cs : new semi-keywords: Compare, Explicit, Strict, On, Off, Binary, Text\r
        * mb-parser.jay: tokens for above semi-keywords, and rules for option directives\r
index 0037b61d06eb1e369dc5a059c783d8424248e221..19b4b42b1e0f06d5c10457c452bd4f1a102fb079 100644 (file)
@@ -42,6 +42,7 @@ all: mbas.exe
 
 test: mbas.exe
        mono mbas.exe --main WriteOK testmbas/WriteOK.vb testmbas/WriteOK2.mbs
+       mono testmbas/WriteOK.exe
 
 verbose: mbas.exe
        mono mbas.exe --verbose --main WriteOK testmbas/WriteOK.vb testmbas/WriteOK2.mbs | less
index 6e280978eb4880f0ff97b305be32d25440af8567..4ab4f8f7001c0774e1ab571f54b3f5c3a40a30ff 100644 (file)
@@ -56,6 +56,7 @@ install: all
 
 test: mbas.exe
        mono mbas.exe --main WriteOK testmbas/WriteOK.vb testmbas/WriteOK2.mbs
+       mono testmbas/WriteOK.exe
 
 verbose: mbas.exe
        mono mbas.exe --verbose --main WriteOK testmbas/WriteOK.vb testmbas/WriteOK2.mbs | less
index b610421cd4f304629e2333481f19345a6a73561c..4c6aebb3e573b88e891f73c4ce0d9e98f2911121 100644 (file)
@@ -520,14 +520,22 @@ imports_directives
        ;
 
 imports_directive
-       : /* imports_alias_directive
-       | */ imports_namespace_directive
+       : IMPORTS imports_terms EOL
        ;
 
-imports_namespace_directive
-       : IMPORTS qualified_identifier EOL 
+imports_terms
+       : imports_term
+       | imports_terms COMMA imports_terms
+       ;
+       
+imports_term
+       : qualified_identifier
+         {
+               current_namespace.Using ((string) $1, lexer.Location);
+         }
+       | qualified_identifier ASSIGN qualified_identifier
          {
-               current_namespace.Using ((string) $2, lexer.Location);
+               current_namespace.UsingAlias ((string) $1, (string) $3, lexer.Location);
          }
        ;
 
@@ -828,8 +836,8 @@ modifier
        : PUBLIC                { $$ = Modifiers.PUBLIC; }
        | PROTECTED             { $$ = Modifiers.PROTECTED; }
        | PRIVATE               { $$ = Modifiers.PRIVATE; }
-       | STATIC                { $$ = Modifiers.STATIC; }
-       /* FIXME: FRIEND and PROTECTED FRIEND are missing */
+       | SHARED                { $$ = Modifiers.STATIC; }
+       | FRIEND                { $$ = Modifiers.INTERNAL; }
        ;
 
 module_declaration
@@ -837,11 +845,10 @@ module_declaration
          { 
                Module new_module;
                string name;
-               // FIXME : Check for valid module modifiers
                name = MakeName((string) $2);
                new_module = new Module(current_container, 
                                                                name, 
-                                                               current_modifiers, 
+                                                               current_modifiers, // already checks then
                                                                (Attributes) current_attributes,
                                                                lexer.Location);
                current_container = new_module;
@@ -860,6 +867,49 @@ module_declaration
          }
        ;
 
+opt_module_member_declarations
+       : /* empty */
+       | module_member_declarations
+       ;
+
+module_member_declarations
+       : module_member_declaration
+       | module_member_declarations module_member_declaration
+       ;
+
+module_member_declaration
+       :  opt_attributes
+          opt_modifiers
+          { 
+               current_attributes = (Attributes) $1;
+               current_modifiers = (int) $2 | (int)Modifiers.STATIC; // FIXME: for type_declaration it can result in trouble
+          }
+          module_member_declarator
+          {
+               $$ = $3;
+          }
+       ;
+
+module_member_declarator
+       :  static_constructor_declaration
+       |  method_declaration
+          { 
+               Method method = (Method) $1;
+               CheckDef (current_container.AddMethod (method), method.Name, method.Location);
+          }    
+       |  field_declaration
+       |  withevents_declaration       /* This is a field but must be treated specially, see below */
+       |  constant_declaration
+       |  property_declaration                 
+       |  event_declaration    
+       |  type_declaration                     
+       ;
+       
+constant_declaration // TODO: implement truly the logic
+       : CONST identifier ASSIGN constant_expression
+       | CONST identifier AS qualified_identifier ASSIGN constant_expression
+       ;
+          
 opt_class_member_declarations
        : /* empty */
        | class_member_declarations
@@ -891,6 +941,7 @@ class_member_declarator
                CheckDef (current_container.AddMethod (method), method.Name, method.Location);
           }    
        |  field_declaration
+       |  constant_declaration
        |  property_declaration                 
        |  event_declaration    
        |  withevents_declaration       /* This is a field but must be treated specially, see below */
@@ -1539,23 +1590,35 @@ opt_evt_handler
                $$ = (Expression) DecomposeQI ((string)$2, lexer.Location);     
        }
        ;       
+
+opt_empty_parens
+       : /* empty */
+       | OPEN_PARENS CLOSE_PARENS
+       ;       
        
-constructor_declaration
-       : constructor_declarator
+static_constructor_declaration
+       : SHARED SUB NEW opt_empty_parens EOL
+         {
+               current_local_parameters = Parameters.EmptyReadOnlyParameters;
+               start_block();
+               oob_stack.Push (lexer.Location);
+
+               Location l = (Location) oob_stack.Pop ();
+               $$ = new Constructor ((string) "New", Parameters.EmptyReadOnlyParameters, (ConstructorInitializer) null, l);
+         }
          opt_statement_list
          { 
                Constructor c = (Constructor) $1;
                c.Block = (Block) end_block();
                c.ModFlags = (int) current_modifiers;
-               c.OptAttributes = (Attributes) null;
+               c.OptAttributes = current_attributes;
                
-               CheckDef (current_container.AddConstructor (c), c.Name, c.Location);
+               CheckDef (current_container.AddConstructor(c), c.Name, c.Location);
                current_local_parameters = null;
          }
          END SUB EOL
-       ;
-
-constructor_declarator
+       
+constructor_declaration
        : SUB NEW OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS EOL
          {
                current_local_parameters = (Parameters) $4;
@@ -1565,9 +1628,19 @@ constructor_declarator
                Location l = (Location) oob_stack.Pop ();
                $$ = new Constructor ((string) "New", (Parameters) $4, (ConstructorInitializer) null, l);
          }
+         opt_statement_list
+         { 
+               Constructor c = (Constructor) $1;
+               c.Block = (Block) end_block();
+               c.ModFlags = (int) current_modifiers;
+               c.OptAttributes = current_attributes;
+               
+               CheckDef (current_container.AddConstructor(c), c.Name, c.Location);
+               current_local_parameters = null;
+         }
+         END SUB EOL
        ;
        
-       
 opt_formal_parameter_list
        : /* empty */                   
          { 
index ec9982d7e025ec1ead43d9b3f48029e045a6acd7..20677a847675272ed52ab761e415c7aa2fa8a804 100644 (file)
@@ -42,7 +42,8 @@ namespace Mono.MonoBASIC
                // </summary>
                public new const int AllowedModifiers =
                        Modifiers.PUBLIC |
-                       Modifiers.INTERNAL;
+                       Modifiers.INTERNAL
+                       ;
 
                public Module(TypeContainer parent, string name, int mod, Attributes attrs, Location l)
                        : base (parent, name, 0, null, l)
index 6245fb7134e1027c1ec2a19383d065cf06f17e95..75f854b80e0654a69fbb210c881a7d08f09a83ae 100644 (file)
@@ -2,24 +2,36 @@ Option Explicit
 Option Strict Off\r
 Option Compare Text\r
 \r
-Imports System
+Imports System, IO = System.Console
 
 Module WriteOK\r
 \r
     Sub Main()\r
+               Dim nodim as integer ' comment out to test explicit\r
+               \r
         REM Testing old-fashioned comments\r
         Console.WriteLine("OK!") ' Simple comments\r
+               WriteOK2.[Sub]()\r
+               IO.WriteLine("OK! via aliased name") ' from alias\r
+               nodim = 1 ' test for explicit\r
+        Console.WriteLine(nodim)\r
+               WriteOK5.ModuleSub()\r
     End Sub\r
 \r
 End Module\r
 \r
-Module WriteOK2\r
+Public Class WriteOK2\r
 \r
-    Sub [Sub]() ' Escaped identifier\r
+    Friend Shared Sub [Sub]() ' Escaped identifier\r
                Dim Text as string ' here 'Text' isn't a keyword\r
-               \r
-        Console.WriteLine("Sub:OK!")\r
+               Text = "This is a test!"\r
+        Console.WriteLine("Sub:OK! - " & Text)\r
     End Sub\r
 \r
-End Module\r
+End Class\r
 \r
+Public Module WriteOK5\r
+    Public Sub ModuleSub()\r
+        Console.WriteLine("ModuleSub:OK!")\r
+    End Sub\r
+End Module\r
index 93a07ab5dccb1e59ee1f2a98156b19483ef33162..e93034600b107ec9d179388063bf52137a7dce37 100644 (file)
@@ -1,5 +1,3 @@
-Option Explicit\r
-Option Strict Off\r
 Option Compare Text\r
 \r
 Imports System
@@ -7,8 +5,13 @@ Imports System
 Module WriteOK3\r
 \r
     Sub Main()\r
-        REM Testing old-fashioned comments\r
+               Dim nodim as integer\r
+               \r
+               REM Testing old-fashioned comments\r
+               \r
         Console.WriteLine("OK!") ' Simple comments\r
+               nodim = 1 ' test for explicit\r
+        Console.WriteLine(nodim)\r
     End Sub\r
 \r
 End Module\r