[fix] #631810: Form.DialogResult needs to call its close events *before* closing.
[mono.git] / mcs / mcs / cs-parser.jay
index ceefd5177e929cd796f88dd5aad7c6fcdf434e7a..de1b01e4a858e557b95348750e627bb6e5ad27dc 100644 (file)
@@ -471,7 +471,7 @@ namespace_declaration
                        Report.Error(1671, name.Location, "A namespace declaration cannot have modifiers or attributes");
                }
 
-               current_namespace = new NamespaceEntry (
+               current_namespace = new NamespaceEntry (compiler,
                        current_namespace, file, name.GetName ());
                current_class = current_namespace.SlaveDeclSpace;
                current_container = current_class.PartialContainer;
@@ -497,7 +497,7 @@ qualified_identifier
          }
        | error
          {
-               syntax_error (lexer.Location, "`.' expected");
+               Error_SyntaxError (yyToken);
                $$ = new MemberName ("<invalid>", lexer.Location);
          }
        ;
@@ -1236,6 +1236,12 @@ fixed_field_size
 variable_initializer
        : expression
        | array_initializer
+       | error
+         {
+               // It has to be here for the parent to safely restore artificial block
+               Error_SyntaxError (yyToken);
+               $$ = null;
+         }
        ;
 
 method_declaration
@@ -3600,11 +3606,6 @@ variable_initializer_list
                list.Add ((Expression) $3);
                $$ = list;
          }
-       | error
-         {
-               Error_SyntaxError (yyToken);
-               $$ = new List<Expression> ();
-         }
        ;
 
 typeof_expression
@@ -3783,11 +3784,6 @@ cast_expression
                $$ = new Cast ((FullNamedExpression) $2, (Expression) $4, GetLocation ($1));
                lbag.AddLocation ($$, GetLocation ($3));
          }
-       | OPEN_PARENS builtin_types CLOSE_PARENS prefixed_unary_expression
-         {
-               $$ = new Cast ((FullNamedExpression) $2, (Expression) $4, GetLocation ($1));
-               lbag.AddLocation ($$, GetLocation ($3));
-         }
        ;
 
        //
@@ -4596,6 +4592,11 @@ embedded_statement
                  Report.Error (1023, GetLocation ($1), "An embedded statement may not be a declaration or labeled statement");
                  $$ = null;
          }
+       | error
+         {
+               Error_SyntaxError (yyToken);
+               $$ = new EmptyStatement (GetLocation ($1));
+         }
        ;
 
 empty_statement
@@ -5914,7 +5915,7 @@ opt_query_continuation
 
 interactive_parsing
        : EVAL_STATEMENT_PARSER EOF 
-       | EVAL_USING_DECLARATIONS_UNIT_PARSER using_directives 
+       | EVAL_USING_DECLARATIONS_UNIT_PARSER using_directives opt_COMPLETE_COMPLETION
        | EVAL_STATEMENT_PARSER { 
                Evaluator.LoadAliases (current_namespace);
 
@@ -6148,7 +6149,7 @@ public CSharpParser (SeekableStreamReader reader, CompilationUnit file, Compiler
 
        this.file = file;
        this.compiler = ctx;
-       current_namespace = new NamespaceEntry (null, file, null);
+       current_namespace = new NamespaceEntry (ctx, null, file, null);
        current_class = current_namespace.SlaveDeclSpace;
        current_container = current_class.PartialContainer; // == RootContest.ToplevelTypes
        oob_stack.Clear ();
@@ -6310,6 +6311,10 @@ void Error_SyntaxError (int token)
 
 void Error_SyntaxError (int error_code, int token, string msg)
 {
+       // An error message has been reported by tokenizer
+       if (token == Token.ERROR)
+               return;
+
        string symbol = GetSymbolName (token);
        string expecting = GetExpecting ();
        var loc = lexer.Location - symbol.Length;