Skip to content

Get Started

This guide covers installation and basic usage of MathScript.

Installation

  1. Download the Installer
  2. Run the Installer
    • Run the downloaded installer
    • Follow the installation wizard prompts
    • Choose your installation directory and your installation options (add to PATH, install MathGet, ...)
  3. Verify Installation
    • Open your terminal or command prompt
    • Run the following command:
      mathscript --version
      

Basic Usage

Your first program

Create a file named hello.mscr:

print("Hello, MathScript!");

Run it:

mathscript hello.mscr

Command-Line Options

Description:
  MathScript Interpreter & Compiler

Usage:
  mathscript [<Program>] [options]

Arguments:
  <Program>  The MathScript program (.mscr file) to compile/execute

Options:
  -o, --Output, --output <Output>    Compile the MathScript program into the `<Output>` executable
  -d, --Debug, --debug <DebugLevel>  Set the debug level (Parser, Lexer, ParserLexer, All)
  -?, -h, --help                     Show help and usage information
  --version                          Show version information
  -v, --Version                      Print version information

Examples

int a = 3;
int b = 2;
int result = a + b;
print(result); // Output: 5

Functions

func int add(int x, int y) {
    return x + y;
}

print(add(5, 3)); // Output: 8

Debug Levels

Set the debug level to inspect parser, lexer and interpreter behavior:

mathscript -d Parser program.mscr
mathscript -d Lexer program.mscr
mathscript -d ParserLexer program.mscr
mathscript -d All program.mscr

Use debug levels to troubleshoot parsing and execution of your programs.