public override void EnterCobolProgram(ProgramClassParser.CobolProgramContext context) { if (Program == null) { Program = new SourceProgram(TableOfGlobals); programsStack = new Stack<CodeModel.Program>(); CurrentProgram = Program; } else { var enclosing = CurrentProgram; CurrentProgram = new NestedProgram(enclosing); Enter(CurrentProgram.SyntaxTree.Root, context, new SymbolTable(TableOfGlobals)); } var terminal = context.ProgramIdentification(); CurrentProgram.Identification = terminal != null? (ProgramIdentification)terminal.Symbol : null; Enter(new Nodes.Program(CurrentProgram.Identification), context, CurrentProgram.SymbolTable); }