philippica / cpp4web

JavaScript Interpreter for C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cpp4Web - JavaScript Interpreter for C++

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.

Usage

  1. To tokenize C++ code to tokens:
const stream = Cpp4Web.Tokenizer(code);

stream will be an array of tokens.

  1. To parse the tokens to AST:
const AST = Cpp4Web.Parse(stream);
  1. To create a runtime for the AST:
const runtime = new Cpp4Web.Runtime(AST);
  1. To run the C++ code and output an object:
const {output} = runtime.launch();

Installation

To install Cpp4Web, run the following commands:

npm install
npm run build

The library will be bundled in the dist directory.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Created by philippica

Feel free to contribute by submitting a pull request or opening an issue on GitHub. Thank you for using Cpp4Web!

About

JavaScript Interpreter for C++

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:JavaScript 93.6%Language:HTML 6.4%