Skip to content

Languages

Marcelo Fornet edited this page May 23, 2020 · 4 revisions

To execute any file (main solution, generator, brute solution, ...), acmX looks for the extension of the source code, and tries to find a definition of this extension in ~/.acmx/languages. This folder contains several json files with precise information about how to compile and run each type of extension.

Structure

Each json file contains the definition for one language. It is a dictionary with three values:

{
    "preRun": [],
    "run": [],
    "ext": ""
}
  • preRun: Command line to execute to compile the source code. If it is omitted or empty, the source code won't be compiled.
  • run: Command line to execute the source code.
  • ext: String with the extension it is giving support to.

There are available several flags that can be used on the commands:

  • $CODE: Path to the file with the source code.
  • $OUTPUT: Path to the "binary" that is going to be generated. (If any).
  • $ATTIC: Path to attic of current folder. This might be useful to generate all trash files that are generated some times.

Refer to examples below.

Note that it is possible to add different definitions for py, py2, py3 extension. It can be used to detect proper Python Interpreter to be used from the extension.

Supported Languages

This is the list of supported languages with their default compile/run command lines. They can be edited at ~/.acmx/languages

C++

{
    "preRun": [
        "g++",
        "-fdiagnostics-color=always",
        "-std=c++17",
        "-DACMX",
        "$CODE",
        "-o",
        "$OUTPUT",
        "--debug"
    ],
    "run": ["$OUTPUT"],
    "ext": "cpp"
}

Python

{
    "preRun": [],
    "run": ["python", "$CODE", "DACMX"],
    "ext": "py"
}

Java

Not supported by default yet.

Rust

Not supported by default yet.

Add new language

To give support for a new language (or for different compiler or interpreter version) create a json file in ~/.acmx/languages following the rules defined at the beginning. Define compile command (if required) and run command. Use the flags

The ext should be different to all other defined ext in that folder, to avoid collision, otherwise it is undefined which definition will be used when acmX tries to compile a run a source file.

It is possible to use languages that requires several files to be created in the workspace. Read about templates.

Path to languages

languages folder is located under homePath defined at settings acmx.configuration.homePath. Its default value is ~/.acmx. That is the reason, we use ~/.acmx/languages as the default value for the folder containing language definitions.