## Generic This interpreter allows you to support virtually any language, provided it's not to strange, at up to bloc-level If you're trying to override an already-supported language, add Generic to the list of selected interpreters: ``` require'sniprun'.setup({ selected_interpreters = { 'Generic' }, }) ``` to add support for, let's say, python2 ``` require'sniprun'.setup({ interpreter_options = { Generic = { error_truncate="long", -- strongly recommended to figure out what's going on MyPython2Config = { -- any key name is ok supported_filetypes = {"python2"}, -- mandatory extension = ".py", -- recommended, but not mandatory. Sniprun use this to create temporary files interpreter = "python2", -- interpreter or compiler (+ options if any) compiler = "", -- one of those MUST be non-empty } } } } }) ``` to also add support for, let's suppose it wasn't officially supported, C ``` require'sniprun'.setup({ interpreter_options = { Generic = { error_truncate="long", MyPython2Config = { supported_filetypes = {"python2"}, extension = ".py", interpreter = "python2", compiler = "", exe_name = "", boilerplate_pre = "" boilerplate_post = "" }, my_super_c_config = { supported_filetypes = {"c", "mysupercfiletype}, extension = ".c", interpreter = "", compiler = "gcc -o my_main -O3", -- compiler (+ options if necessary) (current working directory is sniprun's work directory) exe_name = "my_main", -- executable name, by default a.out (always in sniprun's work directory) boilerplate_pre = "#include \nint main () {" -- include this before code snippets boilerplate_post = "}" -- include this after code snippets } } }, -- other sniprun options, for example: selected_interpreters = {"Generic"} }) ``` ### How the generic interpreter works #### For interpreted languages ("interpreter" is set) 1. Sniprun receive a snippet of code to run 2. The snippet gets surrounded by boilerplate_pre and boilerplate_post 3. The whole thing is written to a file with the given extension, named `_src.` 4. Sniprun runs ` .` and displays the stdout/stderr #### For compiled languages ("compiler" is set) 1. Sniprun receive a snippet of code to run 2. The snippet gets surrounded by boilerplate_pre and boilerplate_post 3. The whole thing is written to a temporary file with the given extension, named `_src.` 4. Sniprun runs ` _src.` , and if this has a non-success status, displays the stderr 5. Sniprun runs `./` and displays the stdout/stderr ### Community examples for non-officially supported languages (contribute here)