-
Notifications
You must be signed in to change notification settings - Fork 3
Language configuration
Thomas Rößl edited this page Oct 15, 2023
·
1 revision
The available languages are configured with JSON files. Each language has a corresponding configuration.
These configurations are found in the flowtutor directory under templates. The language configuration file is called language.json.
- lang_id: A short identifier for the language.
- name: A user-facing name of the language.
- is_compiled (optional): If this value is true, the programs have to be processed by a compiler before they can be run.
- Defaults to true.
- debugger: The compiler used for programs of this language. Values possible "gdb" or "pdb".
- file_ext: The extension of the generated source file. E.g. ".py"
- has_main_function: If this value is true, a main function is generated, otherwise the main program is directly in the source file.
- Defaults to true.
- standard_imports (optional): A list of modules that can be imported into a program.
- types (optional): A list of available data types.
- comment_specifier: The string that is used to denote a comment in the source code.
- function_declaration (optional): A Jinja template describing a function declaration. The following placeholder can be used:
- RETURN_TYPE
- FUN_NAME
- PARAMETERS
- import: A Jinja template string describing a module import. The following placeholder can be used:
- IMPORT
{
"lang_id": "python",
"name": "Python",
"is_compiled": false,
"debugger": "pdb",
"file_ext": ".py",
"has_main_function": false,
"import": "import {{IMPORT}}",
"comment_specifier": "#"
}{
"lang_id": "c",
"name": "C",
"is_compiled": true,
"debugger": "gdb",
"file_ext": ".c",
"import": "#include <{{IMPORT}}>",
"standard_imports": [
"assert.h",
"ctype.h",
"errno.h",
"error.h",
"float.h",
"signal.h",
"stdio.h",
"stdlib.h",
"string.h",
"math.h"
],
"types": [
"char",
"unsigned char",
"short",
"unsigned short",
"int",
"unsigned int",
"long",
"unsigned long",
"float",
"double",
"long double"
],
"comment_specifier": "//",
"function_declaration": "{{RETURN_TYPE}} {{FUN_NAME}}({% for p in PARAMETERS %}{{p.type}} {{p.name}}{{ \", \" if not loop.last else \"\" }}{% endfor %});"
}