Merge branch 'BigIntegerParse'
[mono.git] / mcs / mcs / cs-parser.jay
index 9330a3eb02da5bbc0cbab366565604f40be949c1..54cfde6ae2d8f842a4d1487c564ba37577e48bd3 100644 (file)
@@ -54,7 +54,7 @@ namespace Mono.CSharp
                /// </summary>
                Block      current_block;
                
-               BlockVariableDeclaration current_variable;
+               BlockVariable current_variable;
 
                Delegate   current_delegate;
                
@@ -116,6 +116,8 @@ namespace Mono.CSharp
                // Keeps track of global data changes to undo on parser error
                //
                public Undo undo;
+
+               bool? interactive_async;
                
                Stack<Linq.QueryBlock> linq_clause_blocks;
 
@@ -417,7 +419,7 @@ extern_alias_directives
 extern_alias_directive
        : EXTERN_ALIAS IDENTIFIER IDENTIFIER SEMICOLON
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                string s = lt.Value;
                if (s != "alias") {
                        syntax_error (lt.Location, "`alias' expected");
@@ -425,7 +427,7 @@ extern_alias_directive
                        if (lang_version == LanguageVersion.ISO_1)
                                FeatureIsNotAvailable (lt.Location, "external alias");
 
-                       lt = (Tokenizer.LocatedToken) $3;
+                       lt = (LocatedToken) $3;
                        if (lt.Value == QualifiedAliasMember.GlobalAlias) {
                                RootNamespace.Error_GlobalNamespaceRedefined (report, lt.Location);
                        }
@@ -465,7 +467,7 @@ using_namespace
          }
        | USING IDENTIFIER ASSIGN namespace_or_type_expr SEMICOLON
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                if (lang_version != LanguageVersion.ISO_1 && lt.Value == "global") {
                        report.Warning (440, 2, lt.Location,
                         "An alias named `global' will not be used when resolving `global::'. The global namespace will be used instead");
@@ -555,13 +557,14 @@ opt_semicolon_error
 namespace_name
        : IDENTIFIER
          {
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                $$ = new MemberName (lt.Value, lt.Location);
          }
        | namespace_name DOT IDENTIFIER
          {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                $$ = new MemberName ((MemberName) $1, lt.Value, lt.Location);           
+               lbag.AddLocation ($$, GetLocation ($2));
          }
        | error
          {
@@ -667,7 +670,7 @@ attribute_sections
                var sect = (List<Attribute>) $2;
                if (attrs == null)
                        attrs = new Attributes (sect);
-               else
+               else if (sect != null)
                        attrs.AddAttributes (sect);
                $$ = attrs;
          }
@@ -727,7 +730,7 @@ attribute_section_cont
          {
                Error_SyntaxError (yyToken);
 
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                var tne = new SimpleName (lt.Value, null, lt.Location);
 
                $$ = new List<Attribute> () {
@@ -736,7 +739,7 @@ attribute_section_cont
          }
        | error
          {
-               $$ = CheckAttributeTarget (GetTokenName (yyToken), GetLocation ($1)); 
+               CheckAttributeTarget (yyToken, GetTokenName (yyToken), GetLocation ($1)); 
                $$ = null;
          }
        ;       
@@ -744,8 +747,8 @@ attribute_section_cont
 attribute_target
        : IDENTIFIER
          {
-               var lt = (Tokenizer.LocatedToken) $1;
-               $$ = CheckAttributeTarget (lt.Value, lt.Location);
+               var lt = (LocatedToken) $1;
+               $$ = CheckAttributeTarget (yyToken, lt.Value, lt.Location);
          }
        | EVENT  { $$ = "event"; }
        | RETURN { $$ = "return"; }
@@ -859,14 +862,14 @@ named_attribute_argument
          expression
          {
                --lexer.parsing_block;
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                $$ = new NamedArgument (lt.Value, lt.Location, (Expression) $4);          
                lbag.AddLocation ($$, GetLocation($2));
          }
        ;
        
 named_argument
-       : identifier_inside_body COLON opt_named_modifier expression
+       : identifier_inside_body COLON opt_named_modifier expression_or_error
          {
                if (lang_version <= LanguageVersion.V_3)
                        FeatureIsNotAvailable (GetLocation ($1), "named argument");
@@ -874,7 +877,7 @@ named_argument
                // Avoid boxing in common case (no modifier)
                var arg_mod = $3 == null ? Argument.AType.None : (Argument.AType) $3;
                        
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                $$ = new NamedArgument (lt.Value, lt.Location, (Expression) $4, arg_mod);
                lbag.AddLocation ($$, GetLocation($2));
          }
@@ -970,7 +973,11 @@ struct_declaration
          }
          opt_semicolon
          {
-               lbag.AppendToMember (current_container, GetLocation ($11), GetLocation ($14), GetLocation ($16));
+               if ($16 == null) {
+                       lbag.AppendToMember (current_container, GetLocation ($11), GetLocation ($14));
+               } else {
+                       lbag.AppendToMember (current_container, GetLocation ($11), GetLocation ($14), GetLocation ($16));
+               }
                $$ = pop_current_class ();
          }
        | opt_attributes opt_modifiers opt_partial STRUCT error
@@ -984,7 +991,7 @@ constant_declaration
          opt_modifiers
          CONST type IDENTIFIER
          {
-               var lt = (Tokenizer.LocatedToken) $5;
+               var lt = (LocatedToken) $5;
                var mod = (Modifiers) $2;
                current_field = new Const (current_type, (FullNamedExpression) $4, mod, new MemberName (lt.Value, lt.Location), (Attributes) $1);
                current_type.AddMember (current_field);
@@ -1035,7 +1042,7 @@ constant_declarators
 constant_declarator
        : COMMA IDENTIFIER constant_initializer
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                $$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) $3);
                lbag.AddLocation ($$, GetLocation ($1));
          }
@@ -1074,7 +1081,7 @@ field_declaration
                if (type.Type != null && type.Type.Kind == MemberKind.Void)
                        report.Error (670, GetLocation ($3), "Fields cannot have void type");
                        
-               var lt = (Tokenizer.LocatedToken) $4;
+               var lt = (LocatedToken) $4;
                current_field = new Field (current_type, type, (Modifiers) $2, new MemberName (lt.Value, lt.Location), (Attributes) $1);
                current_type.AddField (current_field);
                $$ = current_field;
@@ -1099,7 +1106,7 @@ field_declaration
                if (lang_version < LanguageVersion.ISO_2)
                        FeatureIsNotAvailable (GetLocation ($3), "fixed size buffers");
 
-               var lt = (Tokenizer.LocatedToken) $5;
+               var lt = (LocatedToken) $5;
                current_field = new FixedField (current_type, (FullNamedExpression) $4, (Modifiers) $2,
                        new MemberName (lt.Value, lt.Location), (Attributes) $1);
                        
@@ -1138,6 +1145,7 @@ opt_field_initializer
          {
                --lexer.parsing_block;
                current_field.Initializer = (Expression) $3;
+               lbag.AppendToMember (current_field, GetLocation ($1));
                end_block (lexer.Location);
                current_local_parameters = null;
          }
@@ -1162,7 +1170,7 @@ field_declarators
 field_declarator
        : COMMA IDENTIFIER
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                $$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null);
                lbag.AddLocation ($$, GetLocation ($1));
          }
@@ -1173,7 +1181,7 @@ field_declarator
          variable_initializer
          {
                --lexer.parsing_block;
-               var lt = (Tokenizer.LocatedToken) $2;     
+               var lt = (LocatedToken) $2;       
                $$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (Expression) $5);
                lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3));
          }
@@ -1198,7 +1206,7 @@ fixed_field_declarators
 fixed_field_declarator
        : COMMA IDENTIFIER fixed_field_size
          {
-               var lt = (Tokenizer.LocatedToken) $2;     
+               var lt = (LocatedToken) $2;       
                $$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) $3);
                lbag.AddLocation ($$, GetLocation ($1));
          }
@@ -1342,8 +1350,10 @@ method_header
 
                current_type.AddMember (method);
 
-               if ($11 != null)
-                       method.SetConstraints ((List<Constraints>) $11);
+               async_block = (method.ModFlags & Modifiers.ASYNC) != 0;
+
+               if ($12 != null)
+                       method.SetConstraints ((List<Constraints>) $12);
 
                if (doc_support)
                        method.DocComment = Lexer.consume_doc_comment ();
@@ -1506,7 +1516,7 @@ fixed_parameter
          parameter_type
          identifier_inside_body
          {
-               var lt = (Tokenizer.LocatedToken) $4;
+               var lt = (LocatedToken) $4;
                $$ = new Parameter ((FullNamedExpression) $3, lt.Value, (Parameter.Modifier) $2, (Attributes) $1, lt.Location);
          }
        | opt_attributes
@@ -1514,7 +1524,7 @@ fixed_parameter
          parameter_type
          identifier_inside_body OPEN_BRACKET CLOSE_BRACKET
          {
-               var lt = (Tokenizer.LocatedToken) $4;
+               var lt = (LocatedToken) $4;
                report.Error (1552, lt.Location, "Array type specifier, [], must appear before parameter name");
                $$ = new Parameter ((FullNamedExpression) $3, lt.Value, (Parameter.Modifier) $2, (Attributes) $1, lt.Location);
          }
@@ -1571,7 +1581,7 @@ fixed_parameter
                if ((valid_param_mod & ParameterModifierType.DefaultValue) == 0)
                        report.Error (1065, GetLocation ($5), "Optional parameter is not valid in this context");
                
-               var lt = (Tokenizer.LocatedToken) $4;
+               var lt = (LocatedToken) $4;
                $$ = new Parameter ((FullNamedExpression) $3, lt.Value, mod, (Attributes) $1, lt.Location);
                lbag.AddLocation ($$, GetLocation ($5));
                
@@ -1643,14 +1653,14 @@ parameter_modifier
 parameter_array
        : opt_attributes params_modifier type IDENTIFIER
          {
-               var lt = (Tokenizer.LocatedToken) $4;
+               var lt = (LocatedToken) $4;
                $$ = new ParamsParameter ((FullNamedExpression) $3, lt.Value, (Attributes) $1, lt.Location);
          }
        | opt_attributes params_modifier type IDENTIFIER ASSIGN constant_expression
          {
                report.Error (1751, GetLocation ($2), "Cannot specify a default value for a parameter array");
                
-               var lt = (Tokenizer.LocatedToken) $4;
+               var lt = (LocatedToken) $4;
                $$ = new ParamsParameter ((FullNamedExpression) $3, lt.Value, (Attributes) $1, lt.Location);            
          }
        | opt_attributes params_modifier type error
@@ -1936,7 +1946,11 @@ interface_declaration
          }
          opt_semicolon 
          {
-           lbag.AppendToMember (current_container, GetLocation ($11), GetLocation ($13));
+               if ($15 == null) {
+                       lbag.AppendToMember (current_container, GetLocation ($11), GetLocation ($13));
+               } else {
+                       lbag.AppendToMember (current_container, GetLocation ($11), GetLocation ($13), GetLocation ($15));
+               }
                $$ = pop_current_class ();
          }
        | opt_attributes opt_modifiers opt_partial INTERFACE error
@@ -2062,11 +2076,11 @@ operator_declarator
                                        Operator.GetName (op));
                        }
                } else {
-                       if (p_count > 2) {
+                       if (p_count == 1) {
+                               report.Error (1019, loc, "Overloadable unary operator expected");
+                       } else if (p_count != 2) {
                                report.Error (1534, loc, "Overloaded binary operator `{0}' takes two parameters",
                                        Operator.GetName (op));
-                       } else if (p_count != 2) {
-                               report.Error (1019, loc, "Overloadable unary operator expected");
                        }
                }
                
@@ -2203,7 +2217,7 @@ constructor_declarator
                valid_param_mod = 0;
                current_local_parameters = (ParametersCompiled) $6;
                
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                var mods = (Modifiers) $2;
                var c = new Constructor (current_type, lt.Value, mods, (Attributes) $1, current_local_parameters, lt.Location);
 
@@ -2300,7 +2314,7 @@ destructor_declaration
          }
          IDENTIFIER OPEN_PARENS CLOSE_PARENS method_body
          {
-               var lt = (Tokenizer.LocatedToken) $5;
+               var lt = (LocatedToken) $5;
                if (lt.Value != current_container.MemberName.Name){
                        report.Error (574, lt.Location, "Name of destructor must match name of class");
                } else if (current_container.Kind != MemberKind.Class){
@@ -2418,7 +2432,7 @@ event_declarators
 event_declarator
        : COMMA IDENTIFIER
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                $$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null);
                lbag.AddLocation ($$, GetLocation ($1));
          }
@@ -2429,7 +2443,7 @@ event_declarator
          event_variable_initializer
          {
                --lexer.parsing_block;
-               var lt = (Tokenizer.LocatedToken) $2;     
+               var lt = (LocatedToken) $2;       
                $$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (Expression) $5);
                lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3));
          }
@@ -2587,6 +2601,8 @@ enum_declaration
          }
          opt_enum_member_declarations
          {
+               lexer.parsing_modifiers = true;
+         
                // here will be evaluated after CLOSE_BLACE is consumed.
                if (doc_support)
                        Lexer.doc_state = XmlCommentState.Allowed;
@@ -2644,7 +2660,7 @@ enum_member_declarations
 enum_member_declaration
        : opt_attributes IDENTIFIER
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                var em = new EnumMember ((Enum) current_type, new MemberName (lt.Value, lt.Location), (Attributes) $1);
                ((Enum) current_type).AddEnumMember (em);
 
@@ -2667,7 +2683,7 @@ enum_member_declaration
          { 
                --lexer.parsing_block;
                
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                var em = new EnumMember ((Enum) current_type, new MemberName (lt.Value, lt.Location), (Attributes) $1);
                em.Initializer = new ConstInitializer (em, (Expression) $5, GetLocation ($4));
                ((Enum) current_type).AddEnumMember (em);
@@ -2681,7 +2697,7 @@ enum_member_declaration
          {
                Error_SyntaxError (yyToken);
          
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                var em = new EnumMember ((Enum) current_type, new MemberName (lt.Value, lt.Location), (Attributes) $1);
                ((Enum) current_type).AddEnumMember (em);
 
@@ -2755,8 +2771,8 @@ namespace_or_type_expr
        : member_name
        | qualified_alias_member IDENTIFIER opt_type_argument_list
          {
-               var lt1 = (Tokenizer.LocatedToken) $1;
-               var lt2 = (Tokenizer.LocatedToken) $2;
+               var lt1 = (LocatedToken) $1;
+               var lt2 = (LocatedToken) $2;
                
                $$ = new QualifiedAliasMember (lt1.Value, lt2.Value, (TypeArguments) $3, lt1.Location);
                lbag.AddLocation ($$, GetLocation ($2));
@@ -2767,7 +2783,7 @@ member_name
        : simple_name_expr
        | namespace_or_type_expr DOT IDENTIFIER opt_type_argument_list
          {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                $$ = new MemberAccess ((Expression) $1, lt.Value, (TypeArguments) $4, lt.Location);
                lbag.AddLocation ($$, GetLocation ($2));
          }
@@ -2776,7 +2792,7 @@ member_name
 simple_name_expr
        : IDENTIFIER opt_type_argument_list
          {
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                $$ = new SimpleName (lt.Value, (TypeArguments)$2, lt.Location);
          }
        ;
@@ -2826,7 +2842,7 @@ type_declaration_name
          opt_type_parameter_list
          {
                lexer.parsing_generic_declaration = false;
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                $$ = new MemberName (lt.Value, (TypeParameters)$3, lt.Location);
          }
        ;
@@ -2846,7 +2862,7 @@ method_declaration_name
        | explicit_interface IDENTIFIER opt_type_parameter_list
          {
                lexer.parsing_generic_declaration = false;        
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                $$ = new MemberName (lt.Value, (TypeParameters) $3, (ATypeNameExpression) $1, lt.Location);
          }
        ;
@@ -2867,21 +2883,21 @@ indexer_declaration_name
 explicit_interface
        : IDENTIFIER opt_type_argument_list DOT
          {
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                $$ = new SimpleName (lt.Value, (TypeArguments) $2, lt.Location);
                lbag.AddLocation ($$, GetLocation ($3));
          }
        | qualified_alias_member IDENTIFIER opt_type_argument_list DOT
          {
-               var lt1 = (Tokenizer.LocatedToken) $1;
-               var lt2 = (Tokenizer.LocatedToken) $2;
+               var lt1 = (LocatedToken) $1;
+               var lt2 = (LocatedToken) $2;
 
                $$ = new QualifiedAliasMember (lt1.Value, lt2.Value, (TypeArguments) $3, lt1.Location);
                lbag.AddLocation ($$, GetLocation ($4));
          }
        | explicit_interface IDENTIFIER opt_type_argument_list DOT
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                $$ = new MemberAccess ((ATypeNameExpression) $1, lt.Value, (TypeArguments) $3, lt.Location);
                lbag.AddLocation ($$, GetLocation ($4));
          }
@@ -2918,8 +2934,8 @@ type_parameters
 type_parameter
        : opt_attributes opt_type_parameter_variance IDENTIFIER
          {
-               var lt = (Tokenizer.LocatedToken)$3;
-               $$ = new TypeParameter (new MemberName (lt.Value, lt.Location), (Attributes)$1, (Variance) $2);
+               var lt = (LocatedToken)$3;
+               $$ = new TypeParameter (new MemberName (lt.Value, lt.Location), (Attributes)$1, (VarianceDecl) $2);
          }
        | error
          {
@@ -2928,7 +2944,7 @@ type_parameter
                else
                        Error_SyntaxError (yyToken);
                        
-               $$ = new TypeParameter (MemberName.Null, null, Variance.None);
+               $$ = new TypeParameter (MemberName.Null, null, null);
          }
        ;
 
@@ -3102,11 +3118,11 @@ primary_expression
 primary_expression_or_type
        : IDENTIFIER opt_type_argument_list
          {
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                $$ = new SimpleName (lt.Value, (TypeArguments)$2, lt.Location);   
          }
        | IDENTIFIER GENERATE_COMPLETION {
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
               $$ = new CompletionSimpleName (MemberName.MakeName (lt.Value, null), lt.Location);
          }
        | member_access
@@ -3159,26 +3175,26 @@ parenthesized_expression
 member_access
        : primary_expression DOT identifier_inside_body opt_type_argument_list
          {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                $$ = new MemberAccess ((Expression) $1, lt.Value, (TypeArguments) $4, lt.Location);
                lbag.AddLocation ($$, GetLocation ($2));
          }
        | builtin_types DOT identifier_inside_body opt_type_argument_list
          {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                $$ = new MemberAccess ((Expression) $1, lt.Value, (TypeArguments) $4, lt.Location);
                lbag.AddLocation ($$, GetLocation ($2));
          }
        | BASE DOT identifier_inside_body opt_type_argument_list
          {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                $$ = new MemberAccess (new BaseThis (GetLocation ($1)), lt.Value, (TypeArguments) $4, lt.Location);
                lbag.AddLocation ($$, GetLocation ($2));
          }
        | qualified_alias_member identifier_inside_body opt_type_argument_list
          {
-               var lt1 = (Tokenizer.LocatedToken) $1;
-               var lt2 = (Tokenizer.LocatedToken) $2;
+               var lt1 = (LocatedToken) $1;
+               var lt2 = (LocatedToken) $2;
 
                $$ = new QualifiedAliasMember (lt1.Value, lt2.Value, (TypeArguments) $3, lt1.Location);
                lbag.AddLocation ($$, GetLocation ($2));
@@ -3187,7 +3203,7 @@ member_access
                $$ = new CompletionMemberAccess ((Expression) $1, null,GetLocation ($3));
          }
        | primary_expression DOT IDENTIFIER GENERATE_COMPLETION {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                $$ = new CompletionMemberAccess ((Expression) $1, lt.Value, lt.Location);
          }
        | builtin_types DOT GENERATE_COMPLETION
@@ -3195,7 +3211,7 @@ member_access
                $$ = new CompletionMemberAccess ((Expression) $1, null, lexer.Location);
          }
        | builtin_types DOT IDENTIFIER GENERATE_COMPLETION {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                $$ = new CompletionMemberAccess ((Expression) $1, lt.Value, lt.Location);
          }
        ;
@@ -3274,13 +3290,13 @@ member_initializer_list
 member_initializer
        : IDENTIFIER ASSIGN initializer_value
          {
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                $$ = new ElementInitializer (lt.Value, (Expression)$3, lt.Location);
                lbag.AddLocation ($$, GetLocation ($2));
          }
        | AWAIT ASSIGN initializer_value
          {
-               var lt = (Tokenizer.LocatedToken) Error_AwaitAsIdentifier ($1);
+               var lt = (LocatedToken) Error_AwaitAsIdentifier ($1);
                $$ = new ElementInitializer (lt.Value, (Expression)$3, lt.Location);
                lbag.AddLocation ($$, GetLocation ($2));
          }
@@ -3298,14 +3314,17 @@ member_initializer
        | OPEN_BRACE expression_list CLOSE_BRACE
          {
                if ($2 == null)
-                       $$ = null;
+                       $$ = new CollectionElementInitializer (GetLocation ($1));
                else
                        $$ = new CollectionElementInitializer ((List<Expression>)$2, GetLocation ($1));
+
+               lbag.AddLocation ($$, GetLocation ($2));
          }
        | OPEN_BRACE CLOSE_BRACE
          {
                report.Error (1920, GetLocation ($1), "An element initializer cannot be empty");
-               $$ = null;
+               $$ = new CollectionElementInitializer (GetLocation ($1));
+               lbag.AddLocation ($$, GetLocation ($2));
          }
        ;
 
@@ -3609,13 +3628,13 @@ anonymous_type_parameters
 anonymous_type_parameter
        : identifier_inside_body ASSIGN variable_initializer
          {
-               var lt = (Tokenizer.LocatedToken)$1;
+               var lt = (LocatedToken)$1;
                $$ = new AnonymousTypeParameter ((Expression)$3, lt.Value, lt.Location);
                lbag.AddLocation ($$, GetLocation ($2));
          }
        | identifier_inside_body
          {
-               var lt = (Tokenizer.LocatedToken)$1;
+               var lt = (LocatedToken)$1;
                $$ = new AnonymousTypeParameter (new SimpleName (lt.Value, lt.Location),
                        lt.Value, lt.Location);
          }
@@ -3743,27 +3762,27 @@ typeof_type_expression
 unbound_type_name
        : identifier_inside_body generic_dimension
          {  
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
 
                $$ = new SimpleName (lt.Value, (int) $2, lt.Location);
          }
        | qualified_alias_member identifier_inside_body generic_dimension
          {
-               var lt1 = (Tokenizer.LocatedToken) $1;
-               var lt2 = (Tokenizer.LocatedToken) $2;
+               var lt1 = (LocatedToken) $1;
+               var lt2 = (LocatedToken) $2;
 
                $$ = new QualifiedAliasMember (lt1.Value, lt2.Value, (int) $3, lt1.Location);
                lbag.AddLocation ($$, GetLocation ($2));
          }
        | unbound_type_name DOT identifier_inside_body
          {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                
                $$ = new MemberAccess ((Expression) $1, lt.Value, lt.Location);         
          }
        | unbound_type_name DOT identifier_inside_body generic_dimension
          {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                
                $$ = new MemberAccess ((Expression) $1, lt.Value, (int) $4, lt.Location);               
          }
@@ -3773,7 +3792,7 @@ unbound_type_name
                if (tne.HasTypeArguments)
                        Error_TypeExpected (GetLocation ($4));
 
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                $$ = new MemberAccess (tne, lt.Value, (int) $4, lt.Location);           
          }
        ;
@@ -3791,7 +3810,7 @@ generic_dimension
 qualified_alias_member
        : IDENTIFIER DOUBLE_COLON
          {
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                if (lang_version == LanguageVersion.ISO_1)
                        FeatureIsNotAvailable (lt.Location, "namespace alias qualifier");
 
@@ -3845,7 +3864,7 @@ unchecked_expression
 pointer_member_access
        : primary_expression OP_PTR IDENTIFIER opt_type_argument_list
          {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                $$ = new MemberAccess (new Indirection ((Expression) $1, GetLocation ($2)), lt.Value, (TypeArguments) $4, lt.Location);
          }
        ;
@@ -3921,9 +3940,12 @@ unary_expression
                         if (current_anonymous_method is LambdaExpression) {
                                report.Error (4034, GetLocation ($1),
                                        "The `await' operator can only be used when its containing lambda expression is marked with the `async' modifier");
-                       } else if (current_anonymous_method is AnonymousMethodExpression) {
+                       } else if (current_anonymous_method != null) {
                                report.Error (4035, GetLocation ($1),
                                        "The `await' operator can only be used when its containing anonymous method is marked with the `async' modifier");
+                       } else if (interactive_async != null) {
+                               current_block.Explicit.RegisterAsyncAwait ();
+                               interactive_async = true;
                        } else {
                                report.Error (4033, GetLocation ($1),
                                        "The `await' operator can only be used when its containing method is marked with the `async' modifier");
@@ -4337,6 +4359,14 @@ conditional_expression
                $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, null, GetLocation ($2));
                lbag.AddLocation ($$, GetLocation ($4));
          }
+       | null_coalescing_expression INTERR expression COLON CLOSE_BRACE
+         {
+               Error_SyntaxError (Token.CLOSE_BRACE);
+
+               $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, null, GetLocation ($2));
+               lbag.AddLocation ($$, GetLocation ($4));
+               lexer.putback ('}');
+         }
        ;
 
 assignment_expression
@@ -4421,24 +4451,24 @@ lambda_parameter_list
 lambda_parameter
        : parameter_modifier parameter_type identifier_inside_body
          {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
 
                $$ = new Parameter ((FullNamedExpression) $2, lt.Value, (Parameter.Modifier) $1, null, lt.Location);
          }
        | parameter_type identifier_inside_body
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
 
                $$ = new Parameter ((FullNamedExpression) $1, lt.Value, Parameter.Modifier.NONE, null, lt.Location);
          }
        | IDENTIFIER
          {
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                $$ = new ImplicitLambdaParameter (lt.Value, lt.Location);
          }
        | AWAIT
          {
-               var lt = (Tokenizer.LocatedToken) Error_AwaitAsIdentifier ($1);
+               var lt = (LocatedToken) Error_AwaitAsIdentifier ($1);
                $$ = new ImplicitLambdaParameter (lt.Value, lt.Location);
          }
        ;
@@ -4487,7 +4517,7 @@ expression_or_error
 lambda_expression
        : IDENTIFIER ARROW 
          {
-               var lt = (Tokenizer.LocatedToken) $1;   
+               var lt = (LocatedToken) $1;     
                Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location);
                start_anonymous (true, new ParametersCompiled (p), false, lt.Location);
          }
@@ -4498,7 +4528,7 @@ lambda_expression
          }
        | AWAIT ARROW
          {
-               var lt = (Tokenizer.LocatedToken) Error_AwaitAsIdentifier ($1);
+               var lt = (LocatedToken) Error_AwaitAsIdentifier ($1);
                Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location);
                start_anonymous (true, new ParametersCompiled (p), false, lt.Location);
          }
@@ -4509,7 +4539,7 @@ lambda_expression
          }
        | ASYNC identifier_inside_body ARROW
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location);
                start_anonymous (true, new ParametersCompiled (p), true, lt.Location);
          }
@@ -4637,7 +4667,11 @@ class_declaration
          }
          opt_semicolon 
          {
-               lbag.AppendToMember (current_container, GetLocation ($11), GetLocation ($13), GetLocation ($15));
+               if ($15 == null) {
+                       lbag.AppendToMember (current_container, GetLocation ($11), GetLocation ($13));
+               } else {
+                       lbag.AppendToMember (current_container, GetLocation ($11), GetLocation ($13), GetLocation ($15));
+               }
                $$ = pop_current_class ();
          }
        ;       
@@ -4769,13 +4803,13 @@ opt_class_base
        : /* empty */
        | COLON type_list
         {
-               current_type.AddBasesForPart ((List<FullNamedExpression>) $2);
+               current_type.SetBaseTypes ((List<FullNamedExpression>) $2);
         }
        | COLON type_list error
          {
                Error_SyntaxError (yyToken);
 
-               current_type.AddBasesForPart ((List<FullNamedExpression>) $2);
+               current_type.SetBaseTypes ((List<FullNamedExpression>) $2);
          }
        ;
 
@@ -4815,7 +4849,7 @@ type_parameter_constraints_clauses
 type_parameter_constraints_clause
        : WHERE IDENTIFIER COLON type_parameter_constraints
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                $$ = new Constraints (new SimpleMemberName (lt.Value, lt.Location), (List<FullNamedExpression>) $4, GetLocation ($1));
                lbag.AddLocation ($$, GetLocation ($3));
          }
@@ -4823,7 +4857,7 @@ type_parameter_constraints_clause
          {
                Error_SyntaxError (yyToken);
          
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                $$ = new Constraints (new SimpleMemberName (lt.Value, lt.Location), null, GetLocation ($1));
          }
        ; 
@@ -4886,7 +4920,7 @@ type_parameter_constraint
 opt_type_parameter_variance
        : /* empty */
          {
-               $$ = Variance.None;
+               $$ = null;
          }
        | type_parameter_variance
          {
@@ -4900,11 +4934,11 @@ opt_type_parameter_variance
 type_parameter_variance
        : OUT
          {
-               $$ = Variance.Covariant;
+               $$ = new VarianceDecl (Variance.Covariant, GetLocation ($1));
          }
        | IN
          {
-               $$ = Variance.Contravariant;
+               $$ = new VarianceDecl (Variance.Contravariant, GetLocation ($1));
          }
        ;
 
@@ -5072,7 +5106,7 @@ empty_statement
 labeled_statement
        : identifier_inside_body COLON 
          {
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                LabeledStatement labeled = new LabeledStatement (lt.Value, current_block, lt.Location);
                lbag.AddLocation (labeled, GetLocation ($2));
                current_block.AddLabel (labeled);
@@ -5189,10 +5223,10 @@ identifier_inside_body
 block_variable_declaration
        : variable_type identifier_inside_body
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                var li = new LocalVariable (current_block, lt.Value, lt.Location);
                current_block.AddLocalName (li);
-               current_variable = new BlockVariableDeclaration ((FullNamedExpression) $1, li);
+               current_variable = new BlockVariable ((FullNamedExpression) $1, li);
          }
          opt_local_variable_initializer opt_variable_declarators SEMICOLON
          {
@@ -5205,10 +5239,10 @@ block_variable_declaration
          }
        | CONST variable_type identifier_inside_body
          {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location);
                current_block.AddLocalName (li);
-               current_variable = new BlockConstantDeclaration ((FullNamedExpression) $2, li);
+               current_variable = new BlockConstant ((FullNamedExpression) $2, li);
          }
          const_variable_initializer opt_const_declarators SEMICOLON
          {
@@ -5261,18 +5295,18 @@ variable_declarators
 variable_declarator
        : COMMA identifier_inside_body
          {
-               var lt = (Tokenizer.LocatedToken) $2;     
+               var lt = (LocatedToken) $2;       
                var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location);
-               var d = new BlockVariableDeclaration.Declarator (li, null);
+               var d = new BlockVariableDeclarator (li, null);
                current_variable.AddDeclarator (d);
                current_block.AddLocalName (li);
                lbag.AddLocation (d, GetLocation ($1));
          }
        | COMMA identifier_inside_body ASSIGN block_variable_initializer
          {
-               var lt = (Tokenizer.LocatedToken) $2;     
+               var lt = (LocatedToken) $2;       
                var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location);
-               var d = new BlockVariableDeclaration.Declarator (li, (Expression) $4);
+               var d = new BlockVariableDeclarator (li, (Expression) $4);
                current_variable.AddDeclarator (d);
                current_block.AddLocalName (li);
                lbag.AddLocation (d, GetLocation ($1), GetLocation ($3));
@@ -5303,9 +5337,9 @@ const_declarators
 const_declarator
        : COMMA identifier_inside_body ASSIGN constant_initializer_expr
          {
-               var lt = (Tokenizer.LocatedToken) $2;     
+               var lt = (LocatedToken) $2;       
                var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location);
-               var d = new BlockVariableDeclaration.Declarator (li, (Expression) $4);
+               var d = new BlockVariableDeclarator (li, (Expression) $4);
                current_variable.AddDeclarator (d);
                current_block.AddLocalName (li);
                lbag.AddLocation (d, GetLocation ($1), GetLocation ($3));
@@ -5356,7 +5390,6 @@ statement_expression
                ExpressionStatement s = $1 as ExpressionStatement;
                if (s == null) {
                        var expr = $1 as Expression;
-                       expr.Error_InvalidExpressionStatement (report);
                        $$ = new StatementErrorExpression (expr);
                } else {
                        $$ = new StatementExpression (s);
@@ -5368,10 +5401,7 @@ interactive_statement_expression
        : expression
          {
                Expression expr = (Expression) $1;
-               ExpressionStatement s;
-
-               s = new OptionalAssign (new SimpleName ("$retval", lexer.Location), expr, lexer.Location);
-               $$ = new StatementExpression (s);
+               $$ = new StatementExpression (new OptionalAssign (expr, lexer.Location));
          }
        | error
          {
@@ -5623,17 +5653,17 @@ opt_for_initializer
 for_initializer
        : variable_type identifier_inside_body
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                var li = new LocalVariable (current_block, lt.Value, lt.Location);
                current_block.AddLocalName (li);
-               current_variable = new BlockVariableDeclaration ((FullNamedExpression) $1, li);
+               current_variable = new BlockVariable ((FullNamedExpression) $1, li);
          }
          opt_local_variable_initializer opt_variable_declarators
          {
                $$ = current_variable;
                if ($4 != null)
                        lbag.AddLocation (current_variable, PopLocation ());
-                       
+
                current_variable = null;
          }
        | statement_expression_list
@@ -5691,7 +5721,7 @@ foreach_statement
                start_block (GetLocation ($2));
                current_block.IsCompilerGenerated = true;
                
-               var lt = (Tokenizer.LocatedToken) $4;
+               var lt = (LocatedToken) $4;
                var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location);
                current_block.AddLocalName (li);
                
@@ -5706,7 +5736,7 @@ foreach_statement
                start_block (GetLocation ($2));
                current_block.IsCompilerGenerated = true;
                
-               var lt = (Tokenizer.LocatedToken) $4;
+               var lt = (LocatedToken) $4;
                var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location);
                current_block.AddLocalName (li);
                $$ = li;
@@ -5757,7 +5787,7 @@ continue_statement
 goto_statement
        : GOTO identifier_inside_body SEMICOLON 
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                $$ = new Goto (lt.Value, GetLocation ($1));
                lbag.AddStatement ($$, GetLocation ($2), GetLocation ($3));
          }
@@ -5797,6 +5827,11 @@ throw_statement
                $$ = new Throw ((Expression) $2, GetLocation ($1));
                lbag.AddStatement ($$, GetLocation ($3));
          }
+       | THROW expression error
+         {
+               Error_SyntaxError (yyToken);
+               $$ = new Throw ((Expression) $2, GetLocation ($1));
+         }
        | THROW error
          {
                Error_SyntaxError (yyToken);
@@ -5807,7 +5842,7 @@ throw_statement
 yield_statement 
        : identifier_inside_body RETURN opt_expression SEMICOLON
          {
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                string s = lt.Value;
                if (s != "yield"){
                        report.Error (1003, lt.Location, "; expected");
@@ -5825,7 +5860,7 @@ yield_statement
          {
                Error_SyntaxError (yyToken);
 
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                string s = lt.Value;
                if (s != "yield"){
                        report.Error (1003, lt.Location, "; expected");
@@ -5841,7 +5876,7 @@ yield_statement
          }
        | identifier_inside_body BREAK SEMICOLON
          {
-               var lt = (Tokenizer.LocatedToken) $1;
+               var lt = (LocatedToken) $1;
                string s = lt.Value;
                if (s != "yield"){
                        report.Error (1003, lt.Location, "; expected");
@@ -5849,7 +5884,7 @@ yield_statement
                        FeatureIsNotAvailable (lt.Location, "iterators");
                }
                
-               current_block.Explicit.RegisterIteratorYield ();
+               current_block.ParametersBlock.TopBlock.IsIterator = true;
                $$ = new YieldBreak (lt.Location);
                lbag.AddStatement ($$, GetLocation ($2), GetLocation ($3));
          }
@@ -5867,12 +5902,12 @@ try_statement
          }
        | TRY block FINALLY block
          {
-               $$ = new TryFinally ((Statement) $2, (Block) $4, GetLocation ($1));
+               $$ = new TryFinally ((Statement) $2, (ExplicitBlock) $4, GetLocation ($1));
                lbag.AddStatement ($$, GetLocation ($3));
          }
        | TRY block catch_clauses FINALLY block
          {
-               $$ = new TryFinally (new TryCatch ((Block) $2, (List<Catch>) $3, Location.Null, true), (Block) $5, GetLocation ($1));
+               $$ = new TryFinally (new TryCatch ((Block) $2, (List<Catch>) $3, Location.Null, true), (ExplicitBlock) $5, GetLocation ($1));
                lbag.AddStatement ($$, GetLocation ($4));
          }
        | TRY block error
@@ -5912,16 +5947,16 @@ opt_identifier
 catch_clause 
        : CATCH block
          {
-               $$ = new Catch ((Block) $2, GetLocation ($1));
+               $$ = new Catch ((ExplicitBlock) $2, GetLocation ($1));
          }
        | CATCH open_parens_any type opt_identifier CLOSE_PARENS
          {
                start_block (GetLocation ($2));
-               var c = new Catch (current_block, GetLocation ($1));
+               var c = new Catch ((ExplicitBlock) current_block, GetLocation ($1));
                c.TypeExpression = (FullNamedExpression) $3;
 
                if ($4 != null) {
-                       var lt = (Tokenizer.LocatedToken) $4;
+                       var lt = (LocatedToken) $4;
                        c.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
                        current_block.AddLocalName (c.Variable);
                }
@@ -5954,7 +5989,7 @@ catch_clause
                c.TypeExpression = (FullNamedExpression) $3;
 
                if ($4 != null) {
-                       var lt = (Tokenizer.LocatedToken) $4;
+                       var lt = (LocatedToken) $4;
                        c.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
                }
 
@@ -6012,7 +6047,7 @@ fixed_statement
            start_block (GetLocation ($2));
            
                current_block.IsCompilerGenerated = true;
-               var lt = (Tokenizer.LocatedToken) $4;
+               var lt = (LocatedToken) $4;
                var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.FixedVariable | LocalVariable.Flags.Used, lt.Location);
                current_block.AddLocalName (li);
                current_variable = new Fixed.VariableDeclaration ((FullNamedExpression) $3, li);
@@ -6029,6 +6064,7 @@ fixed_statement
          
                Fixed f = new Fixed ((Fixed.VariableDeclaration) $9, (Statement) $10, GetLocation ($1));
                current_block.AddStatement (f);
+               lbag.AddStatement (f, GetLocation ($2), GetLocation ($8));
                $$ = end_block (GetLocation ($8));
          }
        ;
@@ -6039,7 +6075,7 @@ using_statement
            start_block (GetLocation ($2));
            
                current_block.IsCompilerGenerated = true;
-               var lt = (Tokenizer.LocatedToken) $4;
+               var lt = (LocatedToken) $4;
                var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.UsingVariable | LocalVariable.Flags.Used, lt.Location);
                current_block.AddLocalName (li);
                current_variable = new Using.VariableDeclaration ((FullNamedExpression) $3, li);
@@ -6143,21 +6179,23 @@ first_from_clause
          {
                current_block = new Linq.QueryBlock (current_block, lexer.Location);
          
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                var rv = new Linq.RangeVariable (lt.Value, lt.Location);
-               $$ = new Linq.QueryExpression (new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$4, rv, GetLocation ($1)));
+               var clause = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$4, rv, GetLocation ($1));
+               lbag.AddLocation (clause, GetLocation ($3));
+               $$ = new Linq.QueryExpression (clause);
          }
        | FROM_FIRST type identifier_inside_body IN expression
          {
                current_block = new Linq.QueryBlock (current_block, lexer.Location);
          
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                var rv = new Linq.RangeVariable (lt.Value, lt.Location);
-               $$ = new Linq.QueryExpression (
-                       new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$5, rv, GetLocation ($1)) {
+               var clause = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$5, rv, GetLocation ($1)) {
                                IdentifierType = (FullNamedExpression)$2
-                       }
-               );
+               };
+               lbag.AddLocation (clause, GetLocation ($4));
+               $$ = new Linq.QueryExpression (clause);
          }
        ;
 
@@ -6166,21 +6204,23 @@ nested_from_clause
          {
                current_block = new Linq.QueryBlock (current_block, lexer.Location);
          
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                var rv = new Linq.RangeVariable (lt.Value, lt.Location);
-               $$ = new Linq.QueryExpression (new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$4, rv, GetLocation ($1)));
+               var clause = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$4, rv, GetLocation ($1));
+               lbag.AddLocation (clause, GetLocation ($3));
+               $$ = new Linq.QueryExpression (clause);
          }
        | FROM type identifier_inside_body IN expression
          {
                current_block = new Linq.QueryBlock (current_block, lexer.Location);
          
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                var rv = new Linq.RangeVariable (lt.Value, lt.Location);
-               $$ = new Linq.QueryExpression (
-                       new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$5, rv, GetLocation ($1)) {
+               var clause = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$5, rv, GetLocation ($1)) {
                                IdentifierType = (FullNamedExpression)$2
-                       }
-               );
+               };
+               lbag.AddLocation (clause, GetLocation ($4));
+               $$ = new Linq.QueryExpression (clause);
          }
        ;
        
@@ -6191,7 +6231,7 @@ from_clause
          }
          expression_or_error
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                var sn = new Linq.RangeVariable (lt.Value, lt.Location);
                $$ = new Linq.SelectMany ((Linq.QueryBlock)current_block, sn, (Expression)$5, GetLocation ($1));
                
@@ -6199,6 +6239,7 @@ from_clause
                current_block = current_block.Parent;
                
                ((Linq.QueryBlock)current_block).AddRangeVariable (sn);
+               lbag.AddLocation ($$, GetLocation ($3));
          }       
        | FROM type identifier_inside_body IN
          {
@@ -6206,7 +6247,7 @@ from_clause
          }
          expression_or_error
          {
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                var sn = new Linq.RangeVariable (lt.Value, lt.Location);
 
                $$ = new Linq.SelectMany ((Linq.QueryBlock)current_block, sn, (Expression)$6, GetLocation ($1)) {
@@ -6217,6 +6258,8 @@ from_clause
                current_block = current_block.Parent;
                
                ((Linq.QueryBlock)current_block).AddRangeVariable (sn);
+               
+               lbag.AddLocation ($$, GetLocation ($4));
          }
        ;       
 
@@ -6336,7 +6379,7 @@ let_clause
          }
          expression_or_error
          {
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                var sn = new Linq.RangeVariable (lt.Value, lt.Location);
                $$ = new Linq.Let ((Linq.QueryBlock) current_block, sn, (Expression)$5, GetLocation ($1));
                lbag.AddLocation ($$, GetLocation ($3));
@@ -6395,7 +6438,7 @@ join_clause
                var outer_selector = linq_clause_blocks.Pop ();
                var block = linq_clause_blocks.Pop ();
 
-               var lt = (Tokenizer.LocatedToken) $2;   
+               var lt = (LocatedToken) $2;     
                var sn = new Linq.RangeVariable (lt.Value, lt.Location);
                Linq.RangeVariable into;
                
@@ -6415,7 +6458,7 @@ join_clause
                        
                        ((Linq.QueryBlock)current_block).AddRangeVariable (sn);
                
-                       lt = (Tokenizer.LocatedToken) $12;
+                       lt = (LocatedToken) $12;
                        into = new Linq.RangeVariable (lt.Value, lt.Location);
 
                        $$ = new Linq.GroupJoin (block, sn, (Expression)$5, outer_selector, (Linq.QueryBlock) current_block, into, GetLocation ($1));   
@@ -6457,7 +6500,7 @@ join_clause
                var outer_selector = linq_clause_blocks.Pop ();
                var block = linq_clause_blocks.Pop ();
                
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                var sn = new Linq.RangeVariable (lt.Value, lt.Location);
                Linq.RangeVariable into;
                
@@ -6466,6 +6509,7 @@ join_clause
                        $$ = new Linq.Join (block, sn, (Expression)$6, outer_selector, (Linq.QueryBlock) current_block, GetLocation ($1)) {
                                IdentifierType = (FullNamedExpression)$2
                        };
+                       lbag.AddLocation ($$, GetLocation ($3), GetLocation ($6), GetLocation ($9));
                } else {
                        //
                        // Set equals right side parent to beginning of linq query, it is not accessible therefore cannot cause name collisions
@@ -6478,7 +6522,7 @@ join_clause
                
                        ((Linq.QueryBlock)current_block).AddRangeVariable (sn);
                
-                       lt = (Tokenizer.LocatedToken) $13;
+                       lt = (LocatedToken) $13;
                        into = new Linq.RangeVariable (lt.Value, lt.Location); // TODO:
                        
                        $$ = new Linq.GroupJoin (block, sn, (Expression)$6, outer_selector, (Linq.QueryBlock) current_block, into, GetLocation ($1)) {
@@ -6601,7 +6645,7 @@ opt_query_continuation
          query_body
          {
                var current_block = linq_clause_blocks.Pop ();    
-               var lt = (Tokenizer.LocatedToken) $2;
+               var lt = (LocatedToken) $2;
                var rv = new Linq.RangeVariable (lt.Value, lt.Location);
                $$ = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, null, rv, GetLocation ($1)) {
                        next = (Linq.AQueryClause)$4
@@ -6639,27 +6683,30 @@ interactive_parsing
                        mods |= Modifiers.UNSAFE;
 
                current_local_parameters = pars;
-               Method method = new Method (
+               var method = new InteractiveMethod (
                        current_type,
                        new TypeExpression (compiler.BuiltinTypes.Void, Location.Null),
                        mods,
-                       new MemberName ("Host"),
-                       pars,
-                       null /* attributes */);
+                       pars);
                        
                current_type.AddMember (method);                        
-
                oob_stack.Push (method);
+
+               interactive_async = false;
+
                ++lexer.parsing_block;
                start_block (lexer.Location);
          }             
          interactive_statement_list opt_COMPLETE_COMPLETION
          {
                --lexer.parsing_block;
-               Method method = (Method) oob_stack.Pop ();
-
+               var method = (InteractiveMethod) oob_stack.Pop ();
                method.Block = (ToplevelBlock) end_block(lexer.Location);
 
+               if (interactive_async == true) {
+                       method.ChangeToAsync ();
+               }
+
                InteractiveResult = (Class) pop_current_class ();
                current_local_parameters = null;
          } 
@@ -6706,7 +6753,7 @@ doc_cref
          {
                module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)$1;
                module.DocumentationBuilder.ParsedParameters = (List<DocumentationParameter>)$4;
-               var lt = (Tokenizer.LocatedToken) $3;
+               var lt = (LocatedToken) $3;
                $$ = new MemberName (lt.Value);
          }
        | doc_type_declaration_name DOT THIS
@@ -6868,7 +6915,7 @@ object Error_AwaitAsIdentifier (object token)
 {
        if (async_block) {
                report.Error (4003, GetLocation (token), "`await' cannot be used as an identifier within an async method or lambda expression");
-               return new Tokenizer.LocatedToken ("await", GetLocation (token));
+               return new LocatedToken ("await", GetLocation (token));
        }
 
        return token;
@@ -6933,15 +6980,20 @@ Location PopLocation ()
        return location_stack.Pop ();
 }
 
-string CheckAttributeTarget (string a, Location l)
+string CheckAttributeTarget (int token, string a, Location l)
 {
        switch (a) {
        case "assembly" : case "module" : case "field" : case "method" : case "param" : case "property" : case "type" :
                        return a;
        }
 
-       report.Warning (658, 1, l,
-                "`{0}' is invalid attribute target. All attributes in this attribute section will be ignored", a);
+       if (!Tokenizer.IsValidIdentifier (a)) {
+               Error_SyntaxError (token);
+       } else {
+               report.Warning (658, 1, l,
+                        "`{0}' is invalid attribute target. All attributes in this attribute section will be ignored", a);
+       }
+
        return string.Empty;
 }
 
@@ -6993,7 +7045,7 @@ public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, Re
        lang_version = settings.Version;
        yacc_verbose_flag = settings.VerboseParserFlag;
        doc_support = settings.DocumentationFile != null;
-       lexer = new Tokenizer (reader, file, session);
+       lexer = new Tokenizer (reader, file, session, report);
        oob_stack = new Stack<object> ();
        lbag = session.LocationsBag;
        use_global_stacks = session.UseJayGlobalArrays;
@@ -7055,7 +7107,7 @@ void FeatureIsNotAvailable (Location loc, string feature)
 
 Location GetLocation (object obj)
 {
-       var lt = obj as Tokenizer.LocatedToken;
+       var lt = obj as LocatedToken;
        if (lt != null)
                return lt.Location;
                
@@ -7132,7 +7184,7 @@ AnonymousMethodExpression end_anonymous (ParametersBlock anon_block)
        retval = current_anonymous_method;
 
        async_block = (bool) oob_stack.Pop ();
-       current_variable = (BlockVariableDeclaration) oob_stack.Pop ();
+       current_variable = (BlockVariable) oob_stack.Pop ();
        current_local_parameters = (ParametersCompiled) oob_stack.Pop ();
        current_anonymous_method = (AnonymousMethodExpression) oob_stack.Pop ();
 
@@ -7241,7 +7293,7 @@ string GetSymbolName (int token)
        case Token.LITERAL:
                return ((Constant)lexer.Value).GetValue ().ToString ();
        case Token.IDENTIFIER:
-               return ((Tokenizer.LocatedToken)lexer.Value).Value;
+               return ((LocatedToken)lexer.Value).Value;
 
        case Token.BOOL:
                return "bool";