<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

from som.vm.universe import main, Exit

import os

# __________  Entry points  __________


def entry_point(argv):
    try:
        main(argv)
    except Exit, e:
        return e.code
    except Exception, e:
        os.write(2, "ERROR: %s thrown during execution.\n" % e)
        return 1
    return 1


# _____ Define and setup target ___


def target(driver, args):
    interp_type = os.getenv('SOM_INTERP', None)
    if interp_type is None or not (interp_type == 'AST' or interp_type == 'BC'):
        print("Type of interpreter not set. Please set the SOM_INTERP environment variable")
        print("\tSOM_INTERP=AST   Use an Abstract Syntax Tree interpreter")
        print("\tSOM_INTERP=BC    Use a Bytecode interpreter")
        sys.exit(1)

    exe_name = 'som-'
    if interp_type == 'AST':
        exe_name += 'ast-'
    elif interp_type == 'BC':
        exe_name += 'bc-'

    if driver.config.translation.jit:
        exe_name += 'jit'
    else:
        exe_name += 'interp'

    driver.exe_name = exe_name
    return entry_point, None


def jitpolicy(driver):
    from rpython.jit.codewriter.policy import JitPolicy
    return JitPolicy()


if __name__ == '__main__':
    from rpython.translator.driver import TranslationDriver
    f, _ = target(TranslationDriver(), sys.argv)
    sys.exit(f(sys.argv))<commit_msg>Sync main-rpython<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

from som.compiler.parse_error import ParseError
from som.interp_type import is_ast_interpreter, is_bytecode_interpreter
from som.vm.universe import main, Exit

import os

# __________  Entry points  __________


def entry_point(argv):
    try:
        main(argv)
    except Exit, e:
        return e.code
    except ParseError as e:
        os.write(2, str(e))
        return 1
    except Exception, e:
        os.write(2, "ERROR: %s thrown during execution.\n" % e)
        return 1
    return 1


# _____ Define and setup target ___


def target(driver, args):
    exe_name = 'som-'
    if is_ast_interpreter():
        exe_name += 'ast-'
    elif is_bytecode_interpreter():
        exe_name += 'bc-'

    if driver.config.translation.jit:
        exe_name += 'jit'
    else:
        exe_name += 'interp'

    driver.exe_name = exe_name
    return entry_point, None


def jitpolicy(driver):
    from rpython.jit.codewriter.policy import JitPolicy
    return JitPolicy()


if __name__ == '__main__':
    from rpython.translator.driver import TranslationDriver
    f, _ = target(TranslationDriver(), sys.argv)
    sys.exit(f(sys.argv))
{'fraction_non_alphanumeric': 0.10650437428680107, 'fraction_numerical': 0.0041841004184100415, 'mean_word_length': 2.767908309455587, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6158680', 'n_tokens_mistral': 896, 'n_tokens_neox': 848, 'n_words': 229}