Exemple #1
0
    def load(algorithm_dir):
        from turingarena.sandbox.languages.language import Language

        with open(os.path.join(algorithm_dir, "language.txt")) as f:
            language = Language(f.read().strip())

        return language.executable(
            algorithm_dir=algorithm_dir,
            language=language,
        )
Exemple #2
0
    def load(source_text, *, language, interface):
        from turingarena.sandbox.languages.language import Language

        language = Language(language)

        return language.source(
            text=source_text,
            language=language,
            interface=interface,
        )
Exemple #3
0
def load_source_file(directory, source_filename, *, interface):
    base, ext = os.path.splitext(source_filename)
    source_path = os.path.join(directory, source_filename)
    with open(source_path) as f:
        source_text = f.read()
    language = Language(ext)
    return language.source(
        interface=interface,
        language=language,
        text=source_text,
    )
Exemple #4
0
def generate_skeleton_cli(args):
    """Generate interface skeleton code (for debugging).

    Usage:
        skeleton [options]

    Options:
        -x --language=<lang>  Source language [default: c++].
        -I --interface=<file>  Interface definition file [default: interface.txt].
    """

    with open(args["--interface"]) as f:
        interface_text = f.read()

    interface = InterfaceDefinition.compile(interface_text)
    language = Language(args["--language"])
    generator = language.skeleton_generator(interface)
    generator.write_to_file(sys.stdout)
Exemple #5
0
from .executable import ElfAlgorithmExecutable
from .source import CppAlgorithmSource
from .generator import CppSkeletonCodeGen, CppTemplateCodeGen
from turingarena.sandbox.languages.language import Language

language = Language(
    name="c++",
    extension="cpp",
    source=CppAlgorithmSource,
    executable=ElfAlgorithmExecutable,
    skeleton_generator=CppSkeletonCodeGen,
    template_generator=CppTemplateCodeGen,
)
Exemple #6
0
from .executable import JavaAlgorithmExecutable
from .source import JavaAlgorithmSource
from .generator import JavaSkeletonCodeGen, JavaTemplateCodeGen
from turingarena.sandbox.languages.language import Language

language = Language(
    name="java",
    extension="java",
    source=JavaAlgorithmSource,
    executable=JavaAlgorithmExecutable,
    skeleton_generator=JavaSkeletonCodeGen,
    template_generator=JavaTemplateCodeGen,
)
from .executable import JavaScriptAlgorithmExecutableScript
from .source import JavascriptAlgorithmSource
from .generator import JavaScriptSkeletonCodeGen, JavaScriptTemplateCodeGen
from turingarena.sandbox.languages.language import Language

language = Language(
    name="javascript",
    extension="js",
    source=JavascriptAlgorithmSource,
    executable=JavaScriptAlgorithmExecutableScript,
    skeleton_generator=JavaScriptSkeletonCodeGen,
    template_generator=JavaScriptTemplateCodeGen,
)
Exemple #8
0
from .executable import PythonAlgorithmExecutableScript
from .source import PythonAlgorithmSource
from .generator import PythonSkeletonCodeGen, PythonTemplateCodeGen
from turingarena.sandbox.languages.language import Language

language = Language(
    name="python",
    extension="py",
    source=PythonAlgorithmSource,
    executable=PythonAlgorithmExecutableScript,
    skeleton_generator=PythonSkeletonCodeGen,
    template_generator=PythonTemplateCodeGen,
)