--- es_j.py- 2016-10-06 01:00:00.000000000 +0900 +++ es_j.py 2016-10-07 00:00:00.000000000 +0900 @@ -697,6 +697,13 @@ def do_type_arr(typ, arr_n, val, info): def try_int(typ, v): return int(v) if typ == [ 'int' ] and v is not None else v +def flat_name(a): + if a[:1] == [ 'name' ]: + return a[1:] + if a[:2] == [ 'op', '*' ]: + return [ '*' ] + flat_name( a[2] ) + err('unexpected {}'.format(a)) + def do_type_val(typ, arr_n, val, info): if arr_n is not False: return do_type_arr(typ, arr_n, val, info) @@ -814,8 +821,14 @@ def do_fcall(name, args, info): (args_info, ret_type, body) = fdef[2:] (_, _, args_lst) = args_info - types = [ e[1] for e in args_lst if e[0] == 'type' ] - names = [ e[1] for e in args_lst if e[0] == 'name' ] + + lst = zip( args_lst[::3], args_lst[1::3] ) + # [::3] is [ type, [ ... ] ] + # [1::3] is [ op, *, ... ] or [ name, xxx ] + mv_ast = lambda t, a: ( t + a[:-1], a[-1] ) + lst = [ mv_ast( t[1], flat_name(a) ) for (t, a) in lst ] + (types, names) = zip(*lst) if len(lst) > 0 else ([], []) + args = [ try_int(t, v) for (t, v) in zip(types, args) ] env = dict( zip(names, args) )