Toolchain & Build
Rouge is designed to run client-side in the browser as well as a standalone application on desktop platforms. The project makes use of the following tech stack that supports both use cases. The interpreter is written in Typescript. The only two dependencies used during runtime are called typescript-parsec and yargs. typescript-parsec is a parser combinator library that Rouge uses as the foundation for its parser. yargs is used to build the command line interface for the standalone application. For local execution, both in development and production, the JavaScript runtime and toolchain Deno is used because of its simplicity and because its compile feature allows building standalone executables. To be able to run in the browser, Rouge can be bundled into a library in the form of an ES-Module with the help of Vite running on Node.js.
In the following segment, the basic steps required to build and run the interpreter for all intended target platforms are shown. It is assumed that the current working directory is set to the root of the Rouge repository. It is also important to mention that, while likely possible, the build has only been tested on Linux. Building the standalone application for other platforms is still possible through cross-compilation, however.
Building the Standalone Application
Deno can run the interpreter directly without the need to build an executable first. This option can be helpful for testing or debugging. Deno is the only required tool for this option. The following command starts the interpreter with its command line interface as the entrypoint.
A manual for using the interpreter's CLI can be found in the user documentation.
Building the self-contained executable works in a similar way.
Building the Library
To bundle the interpreter into a single ES-Module, NPM and Node.js need to be installed on the system.
The following command installs all further dependencies (such as Vite).
Now the library can be built. The output can be found in dist/ after bundling.
The module can now be submitted to any NPM-compatible package registry. However, this process is not subject of this documentation as this is not considered to be knowledge that is specific to Rouge.
Using the library
The final step shows how to use the library in a Node.js environment after it has been built. It is assumed that the library is available at an NPM registry and the local system has been configured so that the registry can be accessed.
First, the package needs to be added.
Now, the ES Modules import syntax can be used to access the entry point of the library. The following snippet runs a sample program on the interpreter and saves a list of findings from the static analysis.