Example #1
0
def unparse(ast):
    if is_boolean(ast):
        return "#t" if value_of(ast) else "#f"
    elif is_integer(ast):
        return str(value_of(ast))
    elif isinstance(ast, list):
        if len(ast) > 0 and ast[0] in quote_names:
            return "%s%s" % (quote_names[ast[0]], unparse(ast[1]))
        else:
            return "(%s)" % " ".join([unparse(x) for x in ast])
    else:
        return str(ast)  # string, integer or Closure
Example #2
0
def _assert_boolean(p, exp=None):
    if not is_boolean(p):
        msg = "Boolean required, got '%s'. " % unparse(p)
        if exp is not None:
            msg += "Offending expression: %s" % unparse(exp)
        raise LispTypeError(msg)