HCoop
/
jackhill
/
mal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
DISABLE FDs (REMOVE ME).
[jackhill/mal.git]
/
rpython
/
printer.py
diff --git
a/rpython/printer.py
b/rpython/printer.py
index
fc835a6
..
67b607b
100644
(file)
--- a/
rpython/printer.py
+++ b/
rpython/printer.py
@@
-7,15
+7,16
@@
else:
import re
import mal_types as types
import re
import mal_types as types
-from mal_types import (MalType, MalStr, MalSym, MalInt)
+from mal_types import (MalType, MalStr, MalSym, MalInt,
+ nil, true, false, MalAtom, MalFunc)
def _pr_a_str(s, print_readably=True):
if len(s) > 0 and s[0] == u'\u029e':
return u':' + s[1:]
elif print_readably:
def _pr_a_str(s, print_readably=True):
if len(s) > 0 and s[0] == u'\u029e':
return u':' + s[1:]
elif print_readably:
- return u'"' + types._replace(u'\
\
n', u'\\n',
+ return u'"' + types._replace(u'\n', u'\\n',
types._replace(u'\"', u'\\"',
types._replace(u'\"', u'\\"',
- types._replace(u'\\', u'\\\\', s))) + u'"'
+
types._replace(u'\\', u'\\\\', s))) + u'"'
else:
return s
else:
return s
@@
-38,24
+39,21
@@
def _pr_str(obj, print_readably=True):
ret.append(_pr_a_str(k,_r))
ret.append(_pr_str(obj.dct[k],_r))
return u"{" + u" ".join(ret) + u"}"
ret.append(_pr_a_str(k,_r))
ret.append(_pr_str(obj.dct[k],_r))
return u"{" + u" ".join(ret) + u"}"
- elif types._string_Q(obj):
- assert isinstance(obj, MalStr)
+ elif isinstance(obj, MalStr):
return _pr_a_str(obj.value,_r)
return _pr_a_str(obj.value,_r)
- elif
types._nil_Q(obj)
:
+ elif
obj is nil
:
return u"nil"
return u"nil"
- elif
types._true_Q(obj)
:
+ elif
obj is true
:
return u"true"
return u"true"
- elif
types._false_Q(obj)
:
+ elif
obj is false
:
return u"false"
return u"false"
-## elif types._atom_Q(obj):
-## return "(atom " + _pr_str(obj.val,_r) + ")"
- elif types._symbol_Q(obj):
- assert isinstance(obj, MalSym)
+ elif types._atom_Q(obj):
+ return u"(atom " + _pr_str(obj.get_value(),_r) + u")"
+ elif isinstance(obj, MalSym):
return obj.value
return obj.value
- elif types._int_Q(obj):
- assert isinstance(obj, MalInt)
+ elif isinstance(obj, MalInt):
return unicode(str(obj.value))
return unicode(str(obj.value))
- elif
types._function_Q(obj
):
+ elif
isinstance(obj, MalFunc
):
return u"#<function>"
else:
return u"unknown"
return u"#<function>"
else:
return u"unknown"