https://github.com/liatemplates/jscpp
Template for integrating the JavaScript C++ interpreter JSCPP into LiaScript
https://github.com/liatemplates/jscpp
cplusplus cplusplus-tutorial jscpp liascript liascript-template online-compiler template
Last synced: 12 months ago
JSON representation
Template for integrating the JavaScript C++ interpreter JSCPP into LiaScript
- Host: GitHub
- URL: https://github.com/liatemplates/jscpp
- Owner: LiaTemplates
- Created: 2018-03-17T21:39:00.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-11-24T22:38:51.000Z (over 6 years ago)
- Last Synced: 2025-01-17T12:16:34.436Z (about 1 year ago)
- Topics: cplusplus, cplusplus-tutorial, jscpp, liascript, liascript-template, online-compiler, template
- Homepage: https://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/jscpp/master/README.md
- Size: 469 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSCPP - Template
--{{0}}--
This document defines some basic macros for applying the JavaScript C++
interpreter [JSCPP](https://felixhao28.github.io/JSCPP) in
[LiaScript](https://LiaScript.github.io) to make Markdown code-blocks
executable.
__Try it on LiaScript:__

https://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/JSCPP/master/README.md
__See the project on Github:__
https://github.com/liaTemplates/JSCPP
--{{1}}--
There are three ways to use this template. The easiest way is to use the
`import` statement and the url of the raw text-file of the master branch or any
other branch or version. But you can also copy the required functionionality
directly into the header of your Markdown document, see therefor the
[last slide](#4). And of course, you could also clone this project and change
it, as you wish.
{{1}}
1. Load the macros via
`import: https://raw.githubusercontent.com/liaTemplates/JSCPP/master/README.md`
2. Copy the definitions into your Project
3. Clone this repository on GitHub
## `@JSCPP.eval`
--{{0}}--
Add the macro `@JSCPP.eval` to the end a single C++ code-block to make it
executable and editable in LiaScript. The current code gets evaluate by the
JSCPP interpreter and the result is shown in a console below.
``` c
#include
using namespace std;
int main() {
int a = 12;
int rslt = 0;
for(int i=1; i { output += s }}});
output;
} catch (msg) {
var error = new LiaError(msg, 1);
try {
var log = msg.match(/(.*)\nline (\d+) \(column (\d+)\):.*\n.*\n(.*)/);
var info = log[1] + " " + log[4];
if (info.length > 80)
info = info.substring(0,76) + "..."
error.add_detail(0, info, "error", log[2]-1, log[3]);
} catch(e) {}
throw error;
}
@end
```
--{{1}}--
If you want to minimize loading effort in your LiaScript project, you can also
copy this code and paste it into your main comment header, see the code in the
raw file of this document.
{{1}} https://raw.githubusercontent.com/liaTemplates/JSCPP/master/README.md