{"id":20660991,"url":"https://github.com/liatemplates/jscpp","last_synced_at":"2025-03-10T04:25:12.327Z","repository":{"id":107256836,"uuid":"125671062","full_name":"LiaTemplates/JSCPP","owner":"LiaTemplates","description":"Template for integrating the JavaScript C++ interpreter JSCPP into LiaScript","archived":false,"fork":false,"pushed_at":"2019-11-24T22:38:51.000Z","size":480,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T12:16:34.436Z","etag":null,"topics":["cplusplus","cplusplus-tutorial","jscpp","liascript","liascript-template","online-compiler","template"],"latest_commit_sha":null,"homepage":"https://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/jscpp/master/README.md","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiaTemplates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-17T21:39:00.000Z","updated_at":"2022-02-22T12:40:32.000Z","dependencies_parsed_at":"2024-06-29T05:35:31.168Z","dependency_job_id":null,"html_url":"https://github.com/LiaTemplates/JSCPP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FJSCPP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FJSCPP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FJSCPP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaTemplates%2FJSCPP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiaTemplates","download_url":"https://codeload.github.com/LiaTemplates/JSCPP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242788037,"owners_count":20185205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cplusplus","cplusplus-tutorial","jscpp","liascript","liascript-template","online-compiler","template"],"created_at":"2024-11-16T19:06:44.466Z","updated_at":"2025-03-10T04:25:12.319Z","avatar_url":"https://github.com/LiaTemplates.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nauthor:   André Dietrich\n\nemail:    andre.dietrich@ovgu.de\n\nversion:  0.3.1\n\nlanguage: en\n\nnarrator: US English Female\n\nlogo:     demo.gif\n\ncomment:  Two macros that can be used to execute C++ snippets with the JSCCP\n          interpreter in LiaScript.\n\n\nscript:   https://felixhao28.github.io/JSCPP/dist/JSCPP.es5.min.js\n\n@JSCPP.__eval\n\u003cscript\u003e\n  try {\n    var output = \"\";\n    JSCPP.run(`@0`, `@1`, {stdio: {write: s =\u003e { output += s }}});\n    output;\n  } catch (msg) {\n    var error = new LiaError(msg, 1);\n    try {\n        var log = msg.match(/(.*)\\nline (\\d+) \\(column (\\d+)\\):.*\\n.*\\n(.*)/);\n        var info = log[1] + \" \" + log[4];\n        if (info.length \u003e 80)\n          info = info.substring(0,76) + \"...\"\n        error.add_detail(0, info, \"error\", log[2]-1, log[3]);\n    } catch(e) {}\n    throw error;\n    }\n\u003c/script\u003e\n@end\n\n@JSCPP.eval: @JSCPP.__eval(@input, )\n\n@JSCPP.evalWithStdin: @JSCPP.__eval(@input,`@input(1)`)\n\n--\u003e\n\n# JSCPP - Template\n\n\n                         --{{0}}--\nThis document defines some basic macros for applying the JavaScript C++\ninterpreter [JSCPP](https://felixhao28.github.io/JSCPP) in\n[LiaScript](https://LiaScript.github.io) to make Markdown code-blocks\nexecutable.\n\n__Try it on LiaScript:__\n\n\u003c!-- hidden = \"true\" --\u003e\n![demo](demo.gif)\n\nhttps://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/JSCPP/master/README.md\n\n__See the project on Github:__\n\nhttps://github.com/liaTemplates/JSCPP\n\n                         --{{1}}--\nThere are three ways to use this template. The easiest way is to use the\n`import` statement and the url of the raw text-file of the master branch or any\nother branch or version. But you can also copy the required functionionality\ndirectly into the header of your Markdown document, see therefor the\n[last slide](#4). And of course, you could also clone this project and change\nit, as you wish.\n\n                           {{1}}\n1. Load the macros via\n\n   `import: https://raw.githubusercontent.com/liaTemplates/JSCPP/master/README.md`\n\n2. Copy the definitions into your Project\n\n3. Clone this repository on GitHub\n\n\n## `@JSCPP.eval`\n\n\n                         --{{0}}--\nAdd the macro `@JSCPP.eval` to the end a single C++ code-block to make it\nexecutable and editable in LiaScript. The current code gets evaluate by the\nJSCPP interpreter and the result is shown in a console below.\n\n\n``` c\n#include \u003ciostream\u003e\nusing namespace std;\n\nint main() {\n    int a = 12;\n    int rslt = 0;\n    for(int i=1; i\u003ca; ++i) {\n        rslt += i;\n        cout \u003c\u003c \"rslt: \" \u003c\u003c rslt \u003c\u003c endl;\n    }\n    cout \u003c\u003c \"final result = \" \u003c\u003c rslt \u003c\u003c endl;\n    return 0;\n}\n```\n@JSCPP.eval\n\n\n\n## `@JSCPP.evalWithStdin`\n\n                         --{{0}}--\nYou can add stdin inputs via a second code-block and add the macro\n`@JSCPP.evalWithStdin` to the end of this project, in order to pass these\nstrings to the interpreter.\n\n\n```c\n#include \u003ciostream\u003e\nusing namespace std;\n\nint main() {\n    int a;\n\n    cin \u003e\u003e a;\n\n    int rslt = 0;\n    for(int i=1; i\u003ca; ++i) {\n        rslt += i;\n        cout \u003c\u003c \"rslt: \" \u003c\u003c rslt \u003c\u003c endl;\n    }\n    cout \u003c\u003c \"final result = \" \u003c\u003c rslt \u003c\u003c endl;\n    return 0;\n}\n```\n``` text +stdin\n5\n```\n@JSCPP.evalWithStdin\n\n\n## Implementation\n\n                         --{{0}}--\nThe code shows how the macros were implemented by calling the macro\n`@JSCPP.__eval` with different default parameters. The script command at the top\ndefines the reference to the JSCPP javascript implementation that needs to be\ncalled to load the interpreter.\n\n``` js\nscript: https://felixhao28.github.io/JSCPP/dist/JSCPP.es5.min.js\n\n@JSCPP.eval: @JSCPP.__eval(@input, )\n\n@JSCPP.evalWithStdin: @JSCPP.__eval(@input,`@input(1)`)\n\n@JSCPP.__eval\n\u003cscript\u003e\n  try {\n    var output = \"\";\n    JSCPP.run(`@0`, `@1`, {stdio: {write: s =\u003e { output += s }}});\n    output;\n  } catch (msg) {\n    var error = new LiaError(msg, 1);\n\n    try {\n        var log = msg.match(/(.*)\\nline (\\d+) \\(column (\\d+)\\):.*\\n.*\\n(.*)/);\n        var info = log[1] + \" \" + log[4];\n\n        if (info.length \u003e 80)\n          info = info.substring(0,76) + \"...\"\n\n        error.add_detail(0, info, \"error\", log[2]-1, log[3]);\n    } catch(e) {}\n\n    throw error;\n    }\n\u003c/script\u003e\n@end\n```\n\n                         --{{1}}--\nIf you want to minimize loading effort in your LiaScript project, you can also\ncopy this code and paste it into your main comment header, see the code in the\nraw file of this document.\n\n{{1}} https://raw.githubusercontent.com/liaTemplates/JSCPP/master/README.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliatemplates%2Fjscpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliatemplates%2Fjscpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliatemplates%2Fjscpp/lists"}