def visitProgram(self, ctx: MPParser.ProgramContext): lst = [] for x in ctx.decl(): if type(self.visit(x)) is list: lst = lst + self.visit(x) else: lst.append(self.visit(x)) return Program(lst)
def visitProgram(self, ctx: MPParser.ProgramContext): templist = [] for decl in ctx.declaration(): if decl.varDec(): templist += self.visit(decl) else: templist += [self.visit(decl)] #templist += typeDec return Program(templist)
def visitProgram(self,ctx:MPParser.ProgramContext): lstdecl = [] for x in ctx.decl(): decl_ = self.visit(x) if type(decl_) == type([]): lstdecl = lstdecl + decl_ else: lstdecl.append(decl_) return Program(lstdecl)
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): a = [self.visit(x) for x in ctx.many_declarations().declarations()] b = [] for i in a: if type(i) is not list: b.append(i) else: for j in i: b.append(j) return Program(b)
def visitProgram(self, ctx: MPParser.ProgramContext): # ctx.decl() ==> List() = [DeclContext0, DeclContext1, DeclContext2, ...., DeclContextN] listDecl = [] for x in ctx.decl(): a = self.visit(x) # check VarDeclare will return a List or not if isinstance(a, list): for every in a: # print(type(every)) listDecl.append(every) else: listDecl.append(a) return Program(listDecl)
def visitProgram(self, ctx: MPParser.ProgramContext): lst = [] vlst = list(map(self.visit, ctx.vardec())) flst = list(map(self.visit, ctx.funcdec())) plst = list(map(self.visit, ctx.procdec())) for i in range(0, ctx.getChildCount()): if isinstance(ctx.getChild(i), MPParser.VardecContext) and vlst: lst += vlst.pop(0) elif isinstance(ctx.getChild(i), MPParser.FuncdecContext) and flst: lst.append(flst.pop(0)) elif isinstance(ctx.getChild(i), MPParser.ProcdecContext) and plst: lst.append(plst.pop(0)) return Program(lst)
def visitProgram(self, ctx: MPParser.ProgramContext): lst = [] vlist = list(map(self.visit, ctx.variable_decalation())) plist = list(map(self.visit, ctx.procedure_declaration())) flist = list(map(self.visit, ctx.function_declaration())) for i in range(0, ctx.getChildCount()): if isinstance(ctx.getChild(i), MPParser.Variable_decalationContext) and vlist: lst += vlist.pop(0) elif isinstance(ctx.getChild(i), MPParser.Function_declarationContext) and flist: lst.append(flist.pop(0)) elif isinstance(ctx.getChild(i), MPParser.Procedure_declarationContext) and plist: lst.append(plist.pop(0)) return Program(lst)
def visitProgram(self, ctx: MPParser.ProgramContext): return self.visit(ctx.exp())
def visitProgram(self, ctx: MPParser.ProgramContext): return Program([ FuncDecl(Id("main"), [], self.visit(ctx.mptype()), Block([], [self.visit(ctx.body())] if ctx.body() else [])) ])
def visitProgram(self, ctx: MPParser.ProgramContext): #return Program([self.visit(x) for x in ctx.one_Dec()]) return Program( [decl for decls in ctx.one_Dec() for decl in self.visit(decls)])
def visitProgram(self, ctx: MPParser.ProgramContext): res = [] for x in ctx.vardecl(): res += self.visit(x) return Program(res)
def visitProgram(self, ctx: MPParser.ProgramContext): return Program(flatten([self.visit(x) for x in ctx.manydeclares()]))
def visitProgram(self, ctx: MPParser.ProgramContext): return Program([self.visit(x) for x in ctx.decl()])
def visitProgram(self, ctx: MPParser.ProgramContext): return Program(reduce(lambda x, y: x + self.visit(y), ctx.declar(), []))
def visitProgram(self, ctx: MPParser.ProgramContext): listDec = [] for dec in ctx.declaration(): listDec += self.visit(dec) return Program(listDec)
def visitProgram(self, ctx: MPParser.ProgramContext): return 2 + sum(1 + self.visit(x) for x in ctx.decl())
def visitProgram(self, ctx:MPParser.ProgramContext): return Program(flat_arr([self.visit(x) for x in ctx.declaration()]))
def visitProgram(self, ctx: MPParser.ProgramContext): return Program( reduce(lambda a, x: a + x, [self.visit(x) for x in ctx.decl()], []))
def visitProgram(self, ctx: MPParser.ProgramContext): A = [] for x in ctx.body(): A += self.visit(x) return Program(A)
def visitProgram(self, ctx: MPParser.ProgramContext): return Program(list(map(lambda x: self.visit(x), ctx.declare())))
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): list_decl = [self.visit(x) for x in ctx.decl()] return Program([i for j in list_decl for i in j])
def visitProgram(self,ctx:MPParser.ProgramContext): templist = [] for decl in ctx.declaration(): templist += self.visit(decl) return Program(templist)
def visitProgram(self, ctx: MPParser.ProgramContext): return Program( list( reduce(lambda x, y: x + y, [self.visit(t) for t in ctx.declaration()], [])))
def visitProgram(self, ctx: MPParser.ProgramContext): numChild = ctx.getChildCount() - 1 return Program( flatten([self.visit(ctx.getChild(x)) for x in range(numChild)]))