Example #1
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 #2
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)]