Skip to content

CLI Reference

This document provides a comprehensive reference for the RuneScript Compiler command-line interface.

Basic Usage

The RuneScript Compiler is executed using the Java Runtime Environment:

java -jar runescript.jar [options] <script-file>

Command Options

Execution Options

  • -h, --help: Display help information and exit
  • -v, --version: Show the compiler version and exit
  • -r, --run: Execute the script after compilation (default behavior)
  • -c, --compile-only: Compile the script without executing it
  • -d, --debug: Enable debug mode with detailed compilation information
  • -t, --timing: Show timing information for compilation phases

Output Options

  • -o, --output <file>: Specify output file for compiled bytecode
  • --dump-ast: Print the Abstract Syntax Tree after parsing
  • --dump-bytecode: Print the generated bytecode instructions
  • --verbose: Enable verbose output during compilation

Configuration Options

  • --memory-limit <size>: Set memory limit for execution (e.g., 512M, 1G)
  • --stack-size <size>: Set maximum stack size (e.g., 1M, 2M)
  • --no-cache: Disable compilation caching
  • --strict: Enable strict mode with additional type checking

Examples

Running a Script

Execute a RuneScript file:

java -jar runescript.jar hello.rn

Compiling Only

Compile a script without executing it:

java -jar runescript.jar -c myscript.rn

Debug Mode

Run with debug information:

java -jar runescript.jar -d myscript.rn

Verbose Output

Get detailed compilation information:

java -jar runescript.jar --verbose myscript.rn

Dump AST

View the parsed Abstract Syntax Tree:

java -jar runescript.jar --dump-ast myscript.rn

Dump Bytecode

View the generated bytecode:

java -jar runescript.jar --dump-bytecode myscript.rn

Timing Information

Show timing for compilation phases:

java -jar runescript.jar -t myscript.rn

Memory Configuration

Set memory limits for execution:

java -jar runescript.jar --memory-limit 1G myscript.rn

Strict Mode

Enable strict type checking:

java -jar runescript.jar --strict myscript.rn

Exit Codes

The RuneScript Compiler returns the following exit codes:

  • 0: Success - script executed without errors
  • 1: Compilation error - syntax or semantic error in the script
  • 2: Runtime error - error occurred during script execution
  • 3: System error - issue with the compiler or environment
  • 4: Invalid arguments - incorrect command-line options provided

Environment Requirements

  • Java Version: Java 21 or higher is required
  • Memory: Minimum 256MB RAM recommended for compilation
  • Disk Space: At least 50MB free space for temporary files

Troubleshooting

Common Issues

"Could not find or load main class" - Ensure you're using the correct JAR filename - Check that the JAR file exists in the specified path

"Unsupported class file major version" - Update to Java 21 or higher

"Out of memory" error - Increase heap size: java -Xmx2g -jar runescript.jar script.rn - Reduce memory usage in your script

"Permission denied" - Ensure the JAR file has execute permissions - On Unix systems: chmod +x runescript.jar

Getting Help

For additional help, use the built-in help option:

java -jar runescript.jar --help

Or visit the online documentation for more detailed information.