About this library

QScript has many powerful features that make it one of the best Java solutions for evaluating methematical expressions, equations and algorithms. It is the only evaluator I know that supports vectors and complex numbers out-of-the-box.


  • evaluate mathematical expressions.
  • supports integer, floating point (double), boolean, string, vector and complex number data types.
  • floating point numbers can be expressed as simple decimals (e.g. 2.59) or in exponential format (e.g. 2.3E-5).
  • handles + and - unary operators used with number literarls.
  • includes string concatenation (including with mixed types).
  • performs integer division.
  • uses standard order of precedence.
  • includes all commonly used mathematical symbols and functions that work with both real and imaginary numbers.
  • evaluates scipts with multiple expressions and over multiple lines.
  • users can include comments in the script to document their algorithm.
  • supports dynamically typed variables.
  • supports string data type and string concatenation (including with mixed types).
  • syntax checking and reporting during parsing.
  • runtime errors found during evaluation are reported.
  • user can decide how errors are handled.
  • includes simple conditional statement (IF ELSE ENDIF).
  • includes WHILE-WEND and REPEAT_UNTIL loop constructs.
  • user defined operators and functions can easily be added to those already available.
  • has a simple mechanism to enable scripts to be evaluated in a separate thread.
  • can send asynchornous scripting events as the script is being evaluated so its progress can be tracked.
  • user defined scripting events can easily be added to those already available.

This event mechanism is powered by the excellent events-on-fire library which has been embeded into this QScript library.

Bonus Features

QScript development editors

There are two editors included in the library -

  1. Java Swing version that has no dependance on Processing.
  2. Version built with Processing and the G4P GUI library

Both versions allow you to -

  • edit scripts
  • execute scripts
  • trace script evaluation
  • view curent state of variable
  • pause and resume script execution

These make it easier to getting started with learning QScript as well as developing scripts for your own purposes.

Extending the library

If the range of mathematical operators does not do everything you want then it is easy to add your own user defined functions, operators and scripting events. In version 2 this capability has been enhanced to smplify the creation of scripting objects that might for instance be used in games.

Documenting the library

This site includes detailed guides to using this library. The links on the right give direct access to all of the library guides. Apart from the Operators and Functions guide they are intended to to be read in sequence.


QScript is entirely written in Java and has no external dependancies.

Although the library is packaged as a Processing library the actual library jar does not require Processing for its functions. The examples that come with this package use the G4P and Graphica libraries and include a QScript IDE. For non-Processing users the library jar also inclues a QScript IDE using Java Swing controls.