コード例 #1
0
def iter_equations(test_id, suites=None):
    assert isinstance(test_id, str), test_id
    for code, comment, message in iter_test_cases(test_id, suites):
        if is_app(code) and is_app(code[1]) and code[1][1] is EQUAL:
            lhs = code[1][2]
            rhs = code[2]
            if is_quote(lhs) and is_quote(rhs):
                lhs = link(compile_(lhs[1]))
                rhs = link(compile_(rhs[1]))
                example = lhs, rhs, message
                if comment and parse_xfail(comment, test_id):
                    example = pytest.mark.xfail(example)
                yield example
コード例 #2
0
def compile(string, fmt='auto'):
    """Compile code from Bohm ABS to I,K,B,C,S form.

    Available foramts: polish, sexpr

    """
    if fmt == 'auto':
        fmt = guess_format(string)
    print('Format: {}'.format(fmt))
    print('In: {}'.format(string))
    parse, print_, simplify = FORMATS[fmt]
    code = parse(string)
    compiled = curry.compile_(code)
    result = print_(compiled)
    print('Out: {}'.format(result))
    return result