Skip to content

Bite CLI

Maximilian Winter edited this page Apr 11, 2022 · 8 revisions

While BiteVM is a library intended for use as an embedded virtual machine in a Unity or C# application, we have made a command line interface available for playing around with the language and executing your own programs without needing to compile a C# application.

You can download the Bite CLI bitevm here.

You will need .NET 4.6.2, which should already be available on all Windows 10 and 11 machines. bitevm is also available in Linux-x64 and OSX-x64!

The CLI has two modes, REPL mode and Compile and Interpret mode

REPL mode

The easiest way to get up and running is to use the REPL (Read Evaluate Print Loop) in the Bite CLI. Start bitevm without command line arguments. A main module is already created for you, so you can start writing actual code. Whenever you press enter it will immediately execute the statement and compile it into the module.

You can exit your REPL session by typing exit or pressing CTRL+Z

Bite Programming Langauge v0.1 (c) 2022

Bite REPL(Read Evaluate Print Loop)

type 'declare' to declare functions, structs and classes
type 'reset' to reset the module
type 'help' for help.
type 'exit' or ^Z to quit. type 'help' for help.
> var a = 5;
> var b = 42;
> PrintLine(5 + 42);
47
> exit

!!! Goodbye !!!

Executing multi-statement code in bitevm

You can declare classes and functions in the CLI. Enter declare at the command prompt and you will be greeted with this message:

-- DECLARE START --
You are now declaring. Press ^Z to stop and compile your declaration.

You can now declare a multi-statement code such as a function. Pressing enter will allow you continue editing instead of immediately executing the statement.

Press CTRL+Z to complete the declaration and return to normal (evaluation) mode.

function foo() {
   PrintLine("Hello World!");
}
^z
-- DECLARE END --

If all went well there should be no errors. Now you can call your function from the command prompt:

> foo();
Hello World!

Resetting the module

All code in the REPL is written to a predefined module where your variables, functions and classes are declared. To start over, enter reset at the command prompt to start with a fresh module. Just remember that all your declarations will be lost!

Compile and Interpret mode

If you'd like to build full programs, create modules with the .bite extension and save them to a folder, then run them with bitevm using the command line arguments -p or -i

Compile Path

You can point bitevm at a path and it will compile all .bite files in the folder and all subfolders, recursively.

-p - specify the path containing all the .bite modules to be included in your program

The following command will compile the bite modules in the folder .\TestProgram and start execution.

  bitevm -p .\TestProgram

Compile specific modules

-i - specify individual .bite modules to be included in your program

The following command will compile the bite modules main.bite and hello.bite in the current folder and start execution.

  bitevm -i main.bite hello.bite

Compiling the Bite CLI

If you want to compile bitevm yourself, the Bite.Cli project outputs a self-contained executable in bin\<Configuration>\net462\ILMerge\bitevm.exe where <Configuration> is your current configuration, i.e. either Debug or Release.