@@ -0,0 +1,2568 @@
+import function_type%0Aimport math%0Aimport random%0A%0Adef _trampoline(value):%0A    while hasattr(value, '__call__'):%0A        value = value()%0A%0A    return value%0A%0ABUILTIN_FUNCTIONS = %7B%0A    '!': function_type.make_type(%5B1%5D, handler=lambda x: not x),%0A    '&&': function_type.make_type(%5B2%5D, handler=lambda x, y: x and y),%0A    '%7C%7C': function_type.make_type(%5B2%5D, handler=lambda x, y: x or y),%0A    '==': function_type.make_type(%5B2%5D, handler=lambda x, y: x == y),%0A    '!=': function_type.make_type(%5B2%5D, handler=lambda x, y: x != y),%0A    '%3C': function_type.make_type(%5B2%5D, handler=lambda x, y: x %3C y),%0A    '%3C=': function_type.make_type(%5B2%5D, handler=lambda x, y: x %3C= y),%0A    '%3E': function_type.make_type(%5B2%5D, handler=lambda x, y: x %3E y),%0A    '%3E=': function_type.make_type(%5B2%5D, handler=lambda x, y: x %3E= y),%0A    '~': function_type.make_type(%5B1%5D, handler=lambda x: -x),%0A    '+': function_type.make_type(%5B2%5D, handler=lambda x, y: x + y),%0A    '-': function_type.make_type(%5B2%5D, handler=lambda x, y: x - y),%0A    '*': function_type.make_type(%5B2%5D, handler=lambda x, y: x * y),%0A    '/': function_type.make_type(%5B2%5D, handler=lambda x, y: x / y),%0A    '%25': function_type.make_type(%5B2%5D, handler=lambda x, y: x %25 y),%0A    'floor': function_type.make_type(%5B1%5D, handler=lambda x: math.floor(x)),%0A    'ceil': function_type.make_type(%5B1%5D, handler=lambda x: math.ceil(x)),%0A    'random': function_type.make_type(%5B%5D, handler=lambda: random.random()),%0A    '$': function_type.make_type(%5B%5D, handler=lambda: ()),%0A    ',': function_type.make_type(%5B2%5D, handler=lambda x, y: (x, y)),%0A    'head': function_type.make_type(%5B1%5D, handler=lambda x: x%5B0%5D),%0A    'tail': function_type.make_type(%5B1%5D, handler=lambda x: x%5B1%5D),%0A    'if': function_type.make_type(%5B3%5D, handler=lambda condition, true, false: true if condition else false),%0A    '@': function_type.make_type(%5B1%5D, handler=_trampoline),%0A    'out': function_type.make_type(%5B1%5D, handler=lambda x: print(x) or x)%0A%7D%0A%0Aif __name__ == '__main__':%0A    import read_code%0A    import lexer%0A    import preparser%0A    import parser%0A    import evaluate%0A%0A    code = read_code.read_code()%0A    specific_lexer = lexer.Lexer()%0A    specific_preparser = preparser.Preparser(specific_lexer)%0A    preast = specific_preparser.preparse(code)%0A    specific_parser = parser.Parser()%0A    ast = specific_parser.parse(preast, BUILTIN_FUNCTIONS)%0A    result = evaluate.evaluate(ast, BUILTIN_FUNCTIONS)%0A    print(result)%0A%0A    for some_error in specific_lexer.get_errors() + specific_preparser.get_errors() + specific_parser.get_errors():%0A        some_error.detect_position(code)%0A        print(some_error)%0A

Add built-in functions