Nexus is an interpreted language whose implementation takes the form of an interpreter. The Nexus interpreter is a program that executes code written in the Nexus programming language.

The Nexus interpreter is an op-code interpreter, meaning that it interprets op-codes. Nexus op-code is a special set of instructions that is not specific to any one computer system, and is optimized for the Nexus programming language. Nexus executes code by first compiling it into op-code instructions and then executing those instructions in the Nexus Virtual Machine (NVM).

The Nexus interpreter is designed to be embedded within applications, it is implemented as a library (dynamic or static) that provides an API for interpreting, loading, and executing code. Additionally, Nexus provides a self-contained interpreter application that provide an interface for executing Nexus programs directly.

The interpreter application comes in two executable forms: console based nexus.exe, and windows based nxsw.exe.

Installation

The Nexus interpreter is usually located within InstallRoot\Nexus. The Nexus installation program automatically adds this path to the PATH environment variable, which enables the operating system to find the Nexus interpreter from any directory.

On Windows systems, the Nexus interpreter is usually installed in C:\Nexus, though this can be changed when running the installer. The following DOS command can be used to manually add this directory to the environment path variable.

set path=%path%;C:\Nexus

Configuration

The Nexus environment can be configured with an ini file. The nxs.ini file is a plain-text file that contains configuration information. This configuration information is referenced by a Nexus process during startup. Reference the Nexus Environment article for details on the Nexus initialization file.

Usage

The Nexus interpreter loads and executes Nexus programs, either in text form or in precompiled binary form. The interpreter can be used as a file interpreter or interactively. The interpreter is executed from the command line as follows:

nexus.exe [ options ] [ filename [ args ] ]

nxsw.exe [ options ] [ filename [ args ] ]

The given options are executed and then the Nexus program filename is loaded and executed. The given args are available to filename as strings in an array named varg. If these arguments contain spaces or other special characters (to the shell), then they should be quoted (but note that the quotes will be removed by the shell).

Options start with '-' and are described below. '--' signals the end of options.

If no arguments are given, then "-v -i" is assumed when the stdin is a terminal; otherwise, "-" is assumed.

Options

The following options are supported by the console-based interpreter.

- load and execute the stdin as a file.

-c filename compile and save in binary form to filename.

-e string execute segment of code. string should be quoted if it contains spaces, quotes, or other special characters (to the shell).

-i enter interactive mode after executing filename.

-o [ filename ] output bytecode to stdout or optional filename.

-v show version information.

Interactive Mode

In interactive mode, the console interpreter prompts the user, reads lines from the stdin, and executes them as they are read. The evaluation result is output to stdout as a new line.

Interactive mode is terminated by an EOF token, CTRL-Z in Windows, and CTRL-D in Linux.