In any event, I am proceeding with this sort of ad hoc way for now.
'''
from __future__ import print_function
+from builtins import next
+from builtins import str
+from builtins import object
from joy.parser import text_to_expression, Symbol
from joy.utils.stack import concat, iter_stack, list_to_stack
from joy.library import SimpleFunctionWrapper, YIN_STACK_EFFECTS
_NAMES = _names()
next(_NAMES)
- names = _NAMES.next
+ names = _NAMES.__next__
reset = lambda _, _n=_NAMES: _n.send(-1)
def __init__(self, code):
'''
+from builtins import map
def list_to_stack(el, stack=()):
'''Convert a Python list (or other sequence) to a Joy stack::
def _to_string(stack, f):
- if isinstance(stack, long): return str(stack).rstrip('L')
if not isinstance(stack, tuple): return repr(stack)
if not stack: return '' # shortcut
return ' '.join(map(_s, f(stack)))
_s = lambda s: (
'[%s]' % expression_to_string(s) if isinstance(s, tuple)
- else str(s).rstrip('L') if isinstance(s, long)
else repr(s)
)
# along with Thun. If not see <http://www.gnu.org/licenses/>.
#
from __future__ import print_function
+from builtins import str
+from builtins import map
+from past.builtins import basestring
+from builtins import object
from logging import getLogger, addLevelName
from functools import reduce
addLevelName(15, 'hmm')
from collections import Counter
-from itertools import imap, chain, product
+from itertools import chain, product
from inspect import stack as inspect_stack
from joy.utils.stack import (
concat,
Joy type variable. Represents any Joy value.
'''
- accept = tuple, int, float, long, complex, str, unicode, bool, Symbol
+ accept = tuple, int, float, int, complex, str, bool, Symbol
prefix = 'a'
def __init__(self, number):
class NumberJoyType(AnyJoyType):
- accept = bool, int, float, long, complex
+ accept = bool, int, float, complex
prefix = 'n'
accept = tuple
prefix = 's'
- def __nonzero__(self):
+ def __bool__(self):
# Imitate () at the end of cons list.
return False
Return True if a stack effect represents a function that can be
automatically compiled (to Python), False otherwise.
'''
- return isinstance(f, tuple) and all(imap(compilable, f)) or _stacky(f)
+ return isinstance(f, tuple) and all(map(compilable, f)) or _stacky(f)
def doc_from_stack_effect(inputs, outputs=('??', ())):
def show(DEFS):
- for name, stack_effect_comment in sorted(DEFS.iteritems()):
+ for name, stack_effect_comment in sorted(DEFS.items()):
t = ' *'[compilable(stack_effect_comment)]
print(name, '=', doc_from_stack_effect(*stack_effect_comment), t)
import sys
f = sys.stdout
print('# GENERATED FILE. DO NOT EDIT.\n', file=f)
- for name, stack_effect_comment in sorted(DEFS.iteritems()):
+ for name, stack_effect_comment in sorted(DEFS.items()):
if not compilable(stack_effect_comment):
continue
print(file=f)