def node_listmaker(self, node, cls='list'):
        items = []
        for child in node.children:
            if isinstance(child, Leaf):
                if child.value != ',':
                    items.append(self.dispatch(child))
            elif type_repr(child.type) == 'comp_for':
                # list comprehension
                # create a for_stmt lookalike
                simple_stmt = self.create_call_stmt(
                    'a.append',
                    [node.children[0]],
                    subst_base='comp$',
                )
                childs = child.children.__iter__()
                base_node = comp_node = child
                comp_node.type = sym_type('for_stmt')
                comp_node.children = []
                child = childs.next()

                try:
                    while True:
                        while isinstance(child, Leaf) or \
                              not type_repr(child.type) in ['comp_if', 'comp_for']:
                            comp_node.append_child(child)
                            child = childs.next()
                        childs = child.children.__iter__()
                        comp_node.append_child(Leaf(11, ':'))
                        comp_node.append_child(child)
                        comp_node = child
                        comp_node.children = []
                        if type_repr(comp_node.type) == 'comp_for':
                            comp_node.type = sym_type('for_stmt')
                        else:
                            comp_node.type = sym_type('if_stmt')
                        child = childs.next()
                except StopIteration:
                    pass
                comp_node.append_child(Leaf(11, ':'))
                comp_node.append_child(simple_stmt)
                lines = self.lines
                self.lines = []
                self.node_for_stmt(base_node)
                i = self.indent_level - 1
                comp = '\n'.join(["%s%s" % ('+' * (j-i), s) for j, s in self.lines])
                self.lines = lines
                jsvars = self.jsvars.copy()
                jsvars.update(locals())
                retval = 'comp$'
                if cls != 'list':
                    retval = "%(module)s['$new'](%(builtin)s['%(cls)s'], comp$)" % jsvars
                jsvars.update(locals())
                return """\
(function() {
+   var comp$ = %(module)s['$new'](%(builtin)s['list'], []);
%(comp)s
+   return %(retval)s;
})()""" % jsvars

            else:
                items.append(self.dispatch(child))
        return items
dataset/ETHPy150Open anandology/pyjamas/pyjs/src/pyjs/translator_dict.py/Translator.node_listmaker/original