Author: marek
Date: 2007-06-20 14:19:11 -0400 (Wed, 20 Jun 2007)
New Revision: 80343

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/cs-parser.jay
Log:
2007-06-20  Marek Safar  <[EMAIL PROTECTED]>

        * cs-parser.jay: Reworked var keyword handling. We cannot handle var as
        static keyword because var becomes keyword only if no type with the var
        name exists in the scope of variable which uses var declaration.



Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2007-06-20 18:14:49 UTC (rev 80342)
+++ trunk/mcs/gmcs/ChangeLog    2007-06-20 18:19:11 UTC (rev 80343)
@@ -1,3 +1,9 @@
+2007-06-20  Marek Safar  <[EMAIL PROTECTED]>
+
+       * cs-parser.jay: Reworked var keyword handling. We cannot handle var as
+       static keyword because var becomes keyword only if no type with the var
+       name exists in the scope of variable which uses var declaration.
+       
 2007-06-18  Marek Safar  <[EMAIL PROTECTED]>
 
        * cs-parser.jay: Add implicitly typed local variable checks.

Modified: trunk/mcs/gmcs/cs-parser.jay
===================================================================
--- trunk/mcs/gmcs/cs-parser.jay        2007-06-20 18:14:49 UTC (rev 80342)
+++ trunk/mcs/gmcs/cs-parser.jay        2007-06-20 18:19:11 UTC (rev 80343)
@@ -224,7 +224,6 @@
 /* C# keywords which are not really keywords */
 %token GET           "get"
 %token SET           "set"
-%token VAR
 
 %left LAST_KEYWORD
 
@@ -1136,7 +1135,6 @@
                anonymous_host = (IAnonymousHost) $1;
                if (RootContext.Documentation != null)
                        Lexer.doc_state = XmlCommentState.NotAllowed;
-               Lexer.VarParsing = true;
          }
          method_body
          {
@@ -1150,7 +1148,6 @@
 
                if (RootContext.Documentation != null)
                        Lexer.doc_state = XmlCommentState.Allowed;
-               Lexer.VarParsing = false;
          }
        ;
 
@@ -2956,10 +2953,6 @@
          }
        | array_type
        | pointer_type
-       | VAR
-         {
-               $$ = new VarExpr (lexer.Location);
-         }
        ;
 
 pointer_type
@@ -3530,7 +3523,7 @@
                        $$ = null;
                }
                else
-                       $$ = new ArrayCreation (new VarExpr((Location) $1), 
(string) $2, (ArrayList) $3, (Location) $1);
+                       $$ = new ImplicitlyTypedArrayCreation ((string) $2, 
(ArrayList) $3, (Location) $1);
          }
        | NEW error
          {
@@ -4689,34 +4682,15 @@
 local_variable_declaration
        : local_variable_type variable_declarators
          {
-               if ($1 != null)
+               if ($1 != null) {
+                       VarExpr ve = $1 as VarExpr;
+                       if (ve != null)
+                               ve.VariableInitializer = (ArrayList)$2;
+                               
                        $$ = new DictionaryEntry ($1, $2);
-               else
+               } else
                        $$ = null;
          }
-       | VAR variable_declarators
-         {
-               ArrayList decls = (ArrayList)$2;
-               if (decls.Count > 1) {
-                       Location loc = ((VariableDeclaration)decls 
[1]).Location;
-                       Report.Error (819, loc, "An implicitly typed local 
variable declaration cannot include multiple declarators");
-               }
-               
-               VariableDeclaration vd = (VariableDeclaration)decls [0];
-               if (vd.expression_or_array_initializer == null) {
-                       Report.Error (818, vd.Location, "An implicitly typed 
local variable declarator must include an initializer");
-               }
-               
-               if (vd.expression_or_array_initializer is NullLiteral) {
-                       Report.Error (815, vd.Location, "An implicitly typed 
local variable declaration cannot be initialized with `null'");
-               }
-
-               if (vd.expression_or_array_initializer is ArrayCreation) {
-                       Report.Error (820, vd.Location, "An implicitly typed 
local variable declarator cannot use an array initializer");
-               }
-
-               $$ = new DictionaryEntry (new VarExpr (lexer.Location), decls);
-         }
        | local_variable_pointer_type opt_rank_specifier_or_nullable 
variable_declarators
          {
                if ($1 != null){
@@ -5031,12 +5005,10 @@
 
                LocatedToken lt = (LocatedToken) $4;
                Location l = lt.Location;
-               LocalInfo vi;
-
-               vi = foreach_block.AddVariable ((Expression) $3, lt.Value, l);
+               LocalInfo vi = foreach_block.AddVariable ((Expression) $3, 
lt.Value, l);
                if (vi != null) {
                        vi.SetReadOnlyContext 
(LocalInfo.ReadOnlyContext.Foreach);
-
+                       
                        // Get a writable reference to this read-only variable.
                        //
                        // Note that the $$ here refers to the value of _this_ 
code block,
@@ -5612,9 +5584,6 @@
        {
                this.identifier = lt.Value;
                if (eoai is ArrayList) {
-                       if (CSharpParser.current_array_type == null)
-                               Report.Error (622, lt.Location,
-                                       "Can only use array initializer 
expressions to assign to array types. Try using a new expression instead.");
                        this.expression_or_array_initializer = new 
ArrayCreation (CSharpParser.current_array_type, "", (ArrayList)eoai, 
lt.Location);
                } else {
                        this.expression_or_array_initializer = (Expression)eoai;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to