def visitAssignment_statement(self,
                               ctx: MPParser.Assignment_statementContext):
     lhsCxtList = ctx.lhs_assignment()[::-1]
     lhsCxtAndTypeList = [ctx.exp()] + lhsCxtList[:-1]
     return [
         Assign(self.visit(x), self.visit(y))
         for x, y in zip(lhsCxtList, lhsCxtAndTypeList)
     ]
Example #2
0
 def visitAssignment_statement(self,
                               ctx: MPParser.Assignment_statementContext):
     # ol = ctx.lhs_assign()[::-1] # a = b = c = 4 -> ol = [c,b,a], tl = [c,b]
     # tl = reversed(ctx.lhs_assign()[:1])
     # return [Assign(self.visit(x[0]),self.visit(x[1])) for x in zip(ol,[self.visit(ctx.exp())] + tl)]
     return reversed([
         Assign(self.visit(x), self.visit(y))
         for x, y in zip(ctx.lhs_assign(),
                         ctx.lhs_assign()[1:] + [ctx.exp()])
     ])
Example #3
0
 def visitAssignment_statement(self, ctx:MPParser.Assignment_statementContext):
     d=list(reversed(range((ctx.getChildCount()-2)//2)))
     a=self.visit(ctx.expression())
     retList=[]
     for i in d:
         q=ctx.getChild(2*i)
         q=self.visit(q)
         retList.append(Assign(q,a))
         a=q
     return retList
Example #4
0
 def visitAssignment_statement(self,ctx:MPParser.Assignment_statementContext):
     tl = ctx.lhs_assign()[::-1] #danh sach lhs_assign dao nguoc vd: a := b :=c :=4 -> tl = [c,b,a] -> zip([c,b,a],[4] + [c,b])
     ol = reversed(ctx.lhs_assign()[1:])
     return [Assign(self.visit(x),self.visit(y)) for x,y in zip(tl,[self.visit(exp)] + ol)]