def visitProgram(self, ctx: BKITParser.ProgramContext): declList = [] if ctx.var_declare(): for x in ctx.var_declare(): declList.extend(self.visitVar_declare(x)) if ctx.func_declare(): for x in ctx.func_declare(): declList.extend(self.visitFunc_declare(x)) return Program(declList)
def visitProgram(self, ctx: BKITParser.ProgramContext): # [VarDecl(a,[1].{1,2.5})] # [VarDecl(b,[],2)] var_declare_list = [] # [FuncDecl(foo,n,x[3],([VarDecl(a,[3,1].{{1},{1},{2.5}})].))] func_declare_list = [] if (ctx.var_declare(0) != None): var_declare_list = destructure_list(list( map(lambda x: x.accept(self), ctx.var_declare()))) if (ctx.func_declare(0) != None): func_declare_list = list( map(lambda x: x.accept(self), ctx.func_declare())) return Program(var_declare_list + func_declare_list)
def visitProgram(self, ctx: BKITParser.ProgramContext): var = reduce(lambda x, y: x + self.visitVar_declare(y), ctx.var_declare(), []) func = reduce(lambda x, y: x + self.visitFunc_declare(y), ctx.func_declare(), []) return Program(var + func)