def visitProgram(self, ctx: MPParser.ProgramContext): declList = [] for x in ctx.declare(): decl = self.visitDeclare(x) if isinstance(decl, list): declList.extend(decl if decl else []) else: declList.append(decl) return Program(declList)
def visitProgram(self, ctx: MPParser.ProgramContext): return Program( reduce(lambda x, y: x + y if type(y) == list else x + [y], [self.visit(t) for t in ctx.declare()], []))
def visitProgram(self, ctx: MPParser.ProgramContext): return Program(list(map(lambda x: self.visit(x), ctx.declare())))