def visitVardecl(self, ctx: MCParser.VardeclContext): primtype = self.visitPrimtype(ctx.primtype()) varlist = self.visitVarlist(ctx.varlist()) return [ VarDecl(x[0], ArrayType(x[1], primtype)) if isinstance(x, tuple) else VarDecl(x, primtype) for x in varlist ]
def visitVardecl(self,ctx:MCParser.VardeclContext): lst = [] for x in ctx.var(): if (x.INTLIT()): lst.append(VarDecl((x.ID().getText()),ArrayType(x.INTLIT().getText(),self.visit(ctx.pritype())))) else: lst.append(VarDecl((x.ID().getText()),self.visit(ctx.pritype()))) return lst
def visitVardecl(self,ctx:MCParser.VardeclContext): arr = [] typ = ctx.mctype().accept(self) for x in ctx.manyvar().accept(self): if len(x) == 1: arr.append(str(VarDecl(typ, x))) else: arr.append(str(VarDecl(ArrayType(typ, x[1]), x[0]))) return arr # return the list of VarDecl
def visitVardecl(self, ctx: MCParser.VardeclContext): # vardecl: primitype lstvar SM; lstVardecl = [] lstVar = self.visit(ctx.lstvar()) nameType = self.visit(ctx.primitype()) for var in lstVar: if (isinstance(var, list) == True): lstVardecl += [ VarDecl(var[0], ArrayType(int(var[1]), nameType)) ] else: lstVardecl += [VarDecl(var, nameType)] return lstVardecl
def visitVardecl(self, ctx: MCParser.VardeclContext): lst = [] for item in self.visit(ctx.variablelist()): if item[0] == 1: lst.append(VarDecl(item[1], self.visit(ctx.primitivetype()))) elif item[0] == 2: lst.append( VarDecl( item[1], ArrayType( item[2], self.visit(ctx.primitivetype()), ))) else: lst.append( VarDecl( item[1], ArrayPointerType(self.visit(ctx.primitivetype()), ))) return lst
def visitVardecl(self, ctx: MCParser.VardeclContext): def create(item): if item[0] == 1: return VarDecl( item[1], self.visit(ctx.primitivetype()) ) elif item[0] == 2: return VarDecl( item[1], ArrayType(item[2], self.visit(ctx.primitivetype()),) ) else: return VarDecl( item[1], ArrayPointerType(self.visit(ctx.primitivetype()),) ) return list(map( create, self.visit(ctx.variablelist()) ))
def visitVardecl(self, ctx:MCParser.VardeclContext): return 1 + self.visitMctype(ctx.mctype()) + self.visitIds(ctx.ids())
def visitVardecl(self, ctx: MCParser.VardeclContext): return VarDecl(ctx.mctype().accept(self), ctx.ids().accept(self))
def visitVardecl(self, ctx: MCParser.VardeclContext): return VarDecl(self.visit(ctx.mctype()), self.visit(ctx.ids())) # return VarDecl object
def visitVardecl(self, ctx: MCParser.VardeclContext): lst = ctx.ids().accept(self) typ = ctx.mctype().accept(self) return [VarDecl(typ, i) for i in lst] # return the list of VarDecl objects
def visitVardecl(self,ctx:MCParser.VardeclContext): typ = self.visit(ctx.mctype()) return None # return the list of VarDecl
def visitVardecl(self, ctx: MCParser.VardeclContext): return [ varlist(self.visit(ctx.pritype())) for varlist in self.visit(ctx.idlist()) ]