public class CSharpParser {
NamespaceEntry current_namespace;
TypeContainer current_container;
- TypeContainer current_class;
+ DeclSpace current_class;
IIteratorContainer iterator_container;
/// Hack to help create non-typed array initializer
/// </summary>
public static Expression current_array_type;
+ Expression pushed_current_array_type;
/// <summary>
/// Used to determine if we are parsing the get/set pair
current_namespace = new NamespaceEntry (
current_namespace, file, name.GetName ());
+ current_class = current_namespace.SlaveDeclSpace;
+ current_container = current_class.PartialContainer;
}
namespace_body opt_semicolon
{
current_namespace = current_namespace.Parent;
+ current_class = current_namespace.SlaveDeclSpace;
+ current_container = current_class.PartialContainer;
}
;
opt_class_base
{
if ($7 != null)
- current_class.Bases = (ArrayList) $7;
+ current_container.AddBasesForPart (current_class, (ArrayList) $7);
if (RootContext.Documentation != null)
current_container.DocComment = Lexer.consume_doc_comment ();
}
opt_class_base
{
- current_class.Bases = (ArrayList) $7;
+ current_container.AddBasesForPart (current_class, (ArrayList) $7);
if (RootContext.Documentation != null) {
current_container.DocComment = Lexer.consume_doc_comment ();
| predefined_type DOT IDENTIFIER
{
LocatedToken lt = (LocatedToken) $3;
- $$ = new MemberAccess ((Expression) $1, lt.Value);
+ // TODO: Location is wrong as some predefined types doesn't hold a location
+ $$ = new MemberAccess ((Expression) $1, lt.Value, lt.Location);
}
;
;
typeof_expression
- : TYPEOF OPEN_PARENS VOID CLOSE_PARENS
- {
- $$ = new TypeOfVoid ((Location) $1);
+ : TYPEOF
+ {
+ pushed_current_array_type = current_array_type;
}
- | TYPEOF OPEN_PARENS type CLOSE_PARENS
+ OPEN_PARENS type CLOSE_PARENS
{
- $$ = new TypeOf ((Expression) $3, (Location) $1);
+ Expression type = (Expression)$4;
+ if (type == TypeManager.system_void_expr)
+ $$ = new TypeOfVoid ((Location) $1);
+ else
+ $$ = new TypeOf (type, (Location) $1);
+ current_array_type = pushed_current_array_type;
}
;
"The class System.Object cannot have a base " +
"class or implement an interface.");
}
- current_class.Bases = (ArrayList) $7;
+ current_container.AddBasesForPart (current_class, (ArrayList) $7);
}
if (RootContext.Documentation != null) {
opt_switch_sections
: /* empty */
{
- Report.Error (1522, lexer.Location, "Empty switch block");
+ Report.Warning (1522, 1, lexer.Location, "Empty switch block");
+ $$ = new ArrayList ();
}
| switch_sections
;
current_class = tc;
}
-TypeContainer pop_current_class ()
+DeclSpace pop_current_class ()
{
- TypeContainer retval = current_class;
+ DeclSpace retval = current_class;
- current_class = (TypeContainer) current_class.Parent;
+ current_class = current_class.Parent;
current_container = current_class.PartialContainer;
return retval;
public CSharpParser (SeekableStreamReader reader, SourceFile file, ArrayList defines)
{
- current_namespace = new NamespaceEntry (null, file, null);
this.name = file.Name;
this.file = file;
- current_container = RootContext.ToplevelTypes;
- // TODO: Make RootContext.ToplevelTypes a PartialContainer.
- current_class = current_container;
- current_container.NamespaceEntry = current_namespace;
+ current_namespace = new NamespaceEntry (null, file, null);
+ current_class = current_namespace.SlaveDeclSpace;
+ current_container = current_class.PartialContainer; // == RootContest.ToplevelTypes
lexer = new Tokenizer (reader, file, defines);
}
Console.WriteLine (e);
}
- RootContext.ToplevelTypes.NamespaceEntry = null;
+ if (RootContext.ToplevelTypes.NamespaceEntry != null)
+ throw new InternalErrorException ("who set it?");
}
static void CheckToken (int error, int yyToken, string msg, Location loc)