// TODO: structs added as requirement // TypeDeclaring (n/a only for array and struct types) private void VisitNode(ClassDeclaration node) { AbstractNode modifiers = node.Child; AbstractNode identifier = modifiers.Sib; AbstractNode classBody = identifier.Sib; ClassTypeDescriptor classDesc = new ClassTypeDescriptor(); classDesc.ClassBody = new ScopeTable(); Modifiers mods = modifiers as Modifiers; if (mods != null) { classDesc.Modifiers = mods.ModifierTokens; } else { node.TypeDescriptor = new ErrorDescriptor("Expected " + "modifier node, found: " + nameof(node)); } Attr attr = new Attr(); attr.Kind = Kind.ClassType; attr.TypeDescriptor = classDesc; string id = ((Identifier)identifier).ID; Table.enter(id, attr); CurrentClass = classDesc; node.TypeDescriptor = classDesc; node.AttributesRef = attr; // push the class body scope table onto the symbol table stack Table.openScope (((ClassTypeDescriptor)attr.TypeDescriptor).ClassBody); AbstractNode fieldDecls = classBody.Child; // grammar allows one class: if body empty, parsing complete if (fieldDecls == null) { return; } fieldDecls.Accept(this); Table.closeScope(); CurrentClass = null; }