<commit_before># Kimi language interpreter in Python 3
# <NAME>
# http://www.github.com/vakila/kimi

import sys
from tokenizer import tokenize
from parser import parse
from evaluator import evaluate
from environments import standard_env
from errors import *

def execute(program):
    '''Take a Kimi program as a string. Tokenize the program, parse the tokens into a tree,
    then evaluate the tree. Return the result, or an error message.'''
    return evaluate(parse(tokenize(program)), standard_env())

def kimify(exp):
    '''Convert a Python object back into a Kimi-readable string.'''
    if exp == None:
        return "nil"
    elif type(exp) == bool:
        return {True: "true", False: "false"}[exp]
    elif type(exp) == int:
        return str(exp)
    elif type(exp) == str:
        return '"' + exp + '"'
    elif type(exp) == tuple:
        return "(list " + kimify_list(exp) + ")"

def kimify_list(tups):
    if tups[1] == None:
        return kimify(tups[0])
    else:
        return " ".join([kimify(tups[0]), kimify_list(tups[1])])


if __name__ == "__main__":
    if len(sys.argv) == 1:
        repl()<commit_msg>Put repl() function back<commit_after># Kimi language interpreter in Python 3
# <NAME>
# http://www.github.com/vakila/kimi

import sys
from tokenizer import tokenize
from parser import parse
from evaluator import evaluate
from environments import standard_env
from errors import *

def execute(program):
    '''Take a Kimi program as a string. Tokenize the program, parse the tokens into a tree,
    then evaluate the tree. Return the result, or an error message.'''
    return evaluate(parse(tokenize(program)), standard_env())

def repl():
    '''An interactive Read-Evaluate-Print Loop that takes in Kimi code from a prompt and evaluates it.'''
    quit_commands = ["exit", "quit", "q"]
    print("Welcome to Kimi!")
    print("See the README (https://github.com/vakila/kimi) for information about Kimi.")
    print('To exit the interpreter, type "' + '" or "'.join(quit_commands) + '".')
    prompt = 'kimi> '
    global_env = standard_env()
    while True:
        command = input(prompt)
        if command in quit_commands:
            return "Goodbye!"
        val = evaluate(parse(tokenize(command)), global_env)
        print(kimify(val))

def kimify(exp):
    '''Convert a Python object back into a Kimi-readable string.'''
    if exp == None:
        return "nil"
    elif type(exp) == bool:
        return {True: "true", False: "false"}[exp]
    elif type(exp) == int:
        return str(exp)
    elif type(exp) == str:
        return '"' + exp + '"'
    elif type(exp) == tuple:
        return "(list " + kimify_list(exp) + ")"

def kimify_list(tups):
    if tups[1] == None:
        return kimify(tups[0])
    else:
        return " ".join([kimify(tups[0]), kimify_list(tups[1])])


if __name__ == "__main__":
    if len(sys.argv) == 1:
        repl()
{'fraction_non_alphanumeric': 0.13340227507755947, 'fraction_numerical': 0.004136504653567736, 'mean_word_length': 3.145714285714286, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '687453', 'n_tokens_mistral': 924, 'n_tokens_neox': 909, 'n_words': 299}