@@ -484,8 +484,14 @@ def _transform_mpi_call(
484484 def _assignment (self , node : ET .Element ):
485485 target = self .transform_all_subnodes (node .find ('./target' ))
486486 value = self .transform_all_subnodes (node .find ('./value' ))
487- assert len (target ) == 1 , (ET .tostring (node ).decode ().rstrip (), target )
488- assert len (value ) == 1 , (ET .tostring (node ).decode ().rstrip (), value )
487+ if len (target ) != 1 :
488+ raise SyntaxError (
489+ 'exactly 1 target expected but {} given {} in:\n {}'
490+ .format (len (target ), target , ET .tostring (node ).decode ().rstrip ()))
491+ if len (value ) != 1 :
492+ raise SyntaxError (
493+ 'exactly 1 value expected but {} given {} in:\n {}'
494+ .format (len (value ), value , ET .tostring (node ).decode ().rstrip ()))
489495 return typed_ast3 .Assign (targets = [target ], value = value , type_comment = None )
490496
491497 def _operation (self , node : ET .Element ) -> typed_ast3 .AST :
@@ -646,6 +652,31 @@ def _operator(
646652 # Invert: (typed_ast3.UnaryOp, typed_ast3.Invert)
647653 }[node .attrib ['operator' ].lower ()]
648654
655+ def _array_constructor (self , node : ET .Element ) -> typed_ast3 .ListComp :
656+ values = node .findall ('./value' )
657+ if len (values ) != 2 :
658+ raise NotImplementedError ('not implemented handling of:\n {}' .format (ET .tostring (node ).decode ().rstrip ()))
659+ value = values [0 ]
660+ sub_values = value .find ('./array-constructor-values' )
661+ header_node = value .find ('./header' )
662+ header = self .transform_all_subnodes (header_node , warn = False )
663+ assert len (header ) == 1
664+ comp_target , comp_iter = header [0 ]
665+ return typed_ast3 .ListComp (
666+ elt = typed_ast3 .Call (
667+ func = typed_ast3 .Name (id = 'do_nothing' , ctx = typed_ast3 .Load ()),
668+ args = [], keywords = [], starargs = None , kwargs = None ),
669+ generators = [
670+ typed_ast3 .comprehension (target = comp_target , iter = comp_iter , ifs = [], is_async = 0 )])
671+
672+ # "[ord(c) for line in file for c in line]"
673+ #_(elt=Call(func=Name(id='ord', ctx=Load()), args=[
674+ # Name(id='c', ctx=Load()),
675+ #], keywords=[], starargs=None, kwargs=None), generators=[
676+ # comprehension(target=Name(id='line', ctx=Store()), iter=Name(id='file', ctx=Load()), ifs=[], is_async=0),
677+ # comprehension(target=Name(id='c', ctx=Store()), iter=Name(id='line', ctx=Load()), ifs=[], is_async=0),
678+ #])
679+
649680 def _dimension (self , node : ET .Element ) -> t .Union [typed_ast3 .Num , typed_ast3 .Index ]:
650681 dim_type = node .attrib ['type' ]
651682 if dim_type == 'simple' :
0 commit comments