Installation and Start-Up


See Getting Started for instructions on downloading JS/CC from source or via the npm or bower package managers.

After downloading or building JS/CC, the command-line runners for each platform are in the bin directory. If you installed JS/CC from npm, there may also be runners in the node_modules/.bin directory of the project where you installed from npm.

In addition to use from the command line, JS/CC may be used as a module from other JavaScript code as shown below.

Use As a Module

This section presumes the use of Node.js to run your JavaScript code and the use of the npm download of JS/CC, but other platforms should be similar.

To use the module itself:

              // Import the JS/CC module
              var jscc = require("jscc-parser");
              // Compile your grammar with the default template
                  src_file: "path/to/grammar.par",
                  out_file: "path/to/output.js"

For all options that may be passed to the compiler, see Compiler Options.

Use from the Command Line

Use the batch file (.bat) on Windows or the shell script (.sh) on *nix for your desired platform, and pass options as command-line arguments. For example, to run using the Nashorn engine on Linux:

              ./bin/ --src_file "path/to/grammar.par" --out_file "path/to/output.js"

Or on Windows:

              .\bin\jscc-nashorn.bat --src_file "path\to\grammar.par" --out_file "path\to\output.js"

Again, see Compiler Options for a complete list of options on the command line.