/bm

Stack-Based Language with Meta-Programming

Primary LanguageCMIT LicenseMIT

BM

birch

Stack-Based Language with Powerful Meta-Programming.

Build

We are using nobuild build system which requires a bootstrapping step with any relatively standard complaint C compiler.

On Linux/MacOS/FreeBSD/literally any OS on the planet Earth except Windows with MSVC:

$ cc -o nobuild nobuild.c
$ ./nobuild help

If you still want to use MSVC on Windows run vcvarsall.bat and from within the development environment of MSVC:

> cl.exe nobuild.c
> nobuild.exe help

Building the libbm Library

$ ./nobuild lib

The static library will be put into ./build/library/

Building the Toolchain

$ ./nobuild tools

The binaries of the toolchain will be placed in ./build/toolchain/.

Building and Running Examples

$ ./nobuild examples

The examples will be placed in ./build/examples/.

To run the examples use basm executable from the toolchain:

$ ./build/toolchain/bme ./build/examples/hello.bm
$ ./build/toolchain/bme ./build/examples/fib.bm
$ ./build/toolchain/bme ./build/examples/e.bm
$ ./build/toolchain/bme ./build/examples/pi.bm

Adding More Examples

nobuild examples automatically builds all the ./examples/*.basm files. So if you want to add a new example to the build just add *.basm file to ./examples/.

Running and Recoding Tests

TBD

Toolchain

basm

Assembly language for the Virtual Machine. For examples see ./examples/ folder.

bme

BM emulator. Used to run programs generated by basm.

bdb

BM debuger. Used to step debug programs generated by basm.

debasm

Disassembler for the binary files generated by basm

bmr

BM recorder. Used to record the output of binary files generated by basm and comparing those output to the expected ones. We use this tool for Integration Testing.

expr2dot

Accepts BASM TTE as a command line argument and dumps its AST in dot format that you can render later with graphviz later.

$ ./build/toolchain/expr2dot "f(a) + g(b) + 69 > 420" | dot -Tsvg > ast.svg
$ iexplore.exe ast.svg

Editor Support

Emacs

Emacs mode available in ./tools/basm-mode.el. Until the language stabilized and we upload the mode on MELPA you need to install this mode manually.

Add the following lines to your .emacs file:

(add-to-list 'load-path "/path/to/basm-mode/")
(require 'basm-mode)

Vim

Copy ./tools/basm.vim in .vim/syntax/basm.vim. Add the following line to your .vimrc file:

autocmd BufRead,BufNewFile *.basm set filetype=basm