Cpp4Web is a JavaScript library that serves as an interpreter for C++. It allows you to tokenize C++ code, parse it into an Abstract Syntax Tree (AST), and run the code to produce an output.
- To tokenize C++ code to tokens:
const stream = Cpp4Web.Tokenizer(code);
stream
will be an array of tokens.
- To parse the tokens to AST:
const AST = Cpp4Web.Parse(stream);
- To create a runtime for the AST:
const runtime = new Cpp4Web.Runtime(AST);
- To run the C++ code and output an object:
const {output} = runtime.launch();
To install Cpp4Web, run the following commands:
npm install
npm run build
The library will be bundled in the dist
directory.
This project is licensed under the MIT License - see the LICENSE file for details.
Created by philippica
Feel free to contribute by submitting a pull request or opening an issue on GitHub. Thank you for using Cpp4Web!