Example #1
0
 def ___parse___(self, parser):
   # x << y << z << value
   y = parser.parse(self.y)
   if isinstance(self.x, _VarSymbol):
     return special.set(varcache(self.x.name), y)
   if isinstance(self.x, _lshift): 
     vars = _get_assign_vars_chain(self.x)
     i = len(vars)-1
     set_stmts = [special.set(vars[i], y)]
     while i>0:
       i -= 1
       set_stmts.append(special.set(vars[i], vars[i+1]))
     return special.begin(*set_stmts)
   elif isinstance(self.x, tuple) or isinstance(self.x, list):
     vars = self.x
   elif isinstance(self.x, _div):
     vars = _get_assign_vars_list(self.x)
   else: raise DinpySyntaxError()
   return special.set_list(vars, y)
Example #2
0
 def ___parse___(self, parser):
   # x << y << z << value
   y = parser.parse(self.y)
   if isinstance(self.x, _VarSymbol):
     return special.set(varcache(self.x.name), y)
   if isinstance(self.x, _lshift): 
     vars = _get_assign_vars_chain(self.x)
     i = len(vars)-1
     set_stmts = [special.set(vars[i], y)]
     while i>0:
       i -= 1
       set_stmts.append(special.set(vars[i], vars[i+1]))
     return special.begin(*set_stmts)
   elif isinstance(self.x, tuple) or isinstance(self.x, list):
     vars = self.x
   elif isinstance(self.x, _div):
     vars = _get_assign_vars_list(self.x)
   else: raise DinpySyntaxError()
   return special.set_list(vars, y)
Example #3
0
 def test_assign3(self):
     eq_(preparse_to_sexpression(put.i.j << (1, 2)),
         preparse_to_sexpression(special.set_list([i, j], (1, 2))))
Example #4
0
 def test_assign2(self):
     eq_(preparse_to_sexpression(put.i.j << v.i + 1),
         preparse_to_sexpression(special.set_list([i, j], arith.add(i, 1))))
Example #5
0
 def test_assign3(self):
   eq_(preparse_to_sexpression(put.i.j<<(1,2)), preparse_to_sexpression(special.set_list([i,j], (1,2))))
Example #6
0
 def test_assign2(self):
   eq_(preparse_to_sexpression(put.i.j<<v.i+1), preparse_to_sexpression(special.set_list([i,j], arith.add(i, 1))))