Print Boolean values with lowercase intitial letters.
This commit is contained in:
parent
14c16d469f
commit
b2c449dd66
|
|
@ -72,7 +72,6 @@ printed left-to-right. These functions are written to support :doc:`../pretty`.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
from builtins import map
|
|
||||||
def list_to_stack(el, stack=()):
|
def list_to_stack(el, stack=()):
|
||||||
'''Convert a Python list (or other sequence) to a Joy stack::
|
'''Convert a Python list (or other sequence) to a Joy stack::
|
||||||
|
|
||||||
|
|
@ -129,15 +128,25 @@ def expression_to_string(expression):
|
||||||
return _to_string(expression, iter_stack)
|
return _to_string(expression, iter_stack)
|
||||||
|
|
||||||
|
|
||||||
|
_JOY_BOOL_LITS = 'false', 'true'
|
||||||
|
|
||||||
|
|
||||||
|
def _joy_repr(thing):
|
||||||
|
if isinstance(thing, bool):
|
||||||
|
return _JOY_BOOL_LITS[thing]
|
||||||
|
return repr(thing)
|
||||||
|
|
||||||
|
|
||||||
def _to_string(stack, f):
|
def _to_string(stack, f):
|
||||||
if not isinstance(stack, tuple): return repr(stack)
|
if not isinstance(stack, tuple): return _joy_repr(stack)
|
||||||
if not stack: return '' # shortcut
|
if not stack: return '' # shortcut
|
||||||
return ' '.join(map(_s, f(stack)))
|
return ' '.join(map(_s, f(stack)))
|
||||||
|
|
||||||
|
|
||||||
_s = lambda s: (
|
_s = lambda s: (
|
||||||
'[%s]' % expression_to_string(s) if isinstance(s, tuple)
|
'[%s]' % expression_to_string(s)
|
||||||
else repr(s)
|
if isinstance(s, tuple)
|
||||||
|
else _joy_repr(s)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue