#compiler #compile #bytecode #script #source #gs2 #graal

gs2compiler

Compiles GS2 source code into GS2 bytecode

2 unstable releases

new 0.2.2 Dec 18, 2024
0.1.0 Aug 14, 2024

#864 in WebAssembly

Download history 13/week @ 2024-09-16 7/week @ 2024-09-23 4/week @ 2024-09-30 3/week @ 2024-11-04 23/week @ 2024-12-02 44/week @ 2024-12-09

67 downloads per month

GPL-3.0-only

405KB
9K SLoC

Python 2.5K SLoC // 0.2% comments C++ 2.5K SLoC // 0.1% comments Bazel 2.5K SLoC // 0.1% comments Happy 398 SLoC Shell 291 SLoC // 0.2% comments PowerShell 229 SLoC // 0.1% comments Rust 115 SLoC // 0.0% comments Lex 110 SLoC // 0.1% comments Batch 66 SLoC // 0.1% comments C# 50 SLoC Visual Studio Solution 16 SLoC JavaScript 4 SLoC

gs2-parser

This is a compiler for the Graal Script 2 (GS2) language.

Prerequisites

Before building, clone the repository and recursively clone the submodules:

git clone git@github.com:xtjoeytx/gs2-parser.git --recursive

Building

You can build the project using CMake:

mkdir build
cd build
cmake ..
make -j $(nproc)

Building (Wasm)

First, ensure you have Emscripten installed. Then, you can build the project using CMake:

mkdir build
cd build
emcmake cmake ..
make -j $(nproc)

The resulting gs2test.js file can be imported into a webpage.

Running

The non-wasm build can be run using the following command:

$ ./gs2test ../scripts/asd2.txt
Argc: 2
Args: ../scripts/asd2.txt
Compiling file ../scripts/asd2.txt
Compiled in 0.001322 seconds
 -> saved to ../scripts/asd2.gs2bc
Total length of bytecode w/ headers:   160

Dependencies

~0.4–390KB