Tutorial
This page will walk you through some basics to get up and running with Tomo.
Installing Tomo
First, clone the repository:
git clone https://code.bruce-hill.com/Bruce/tomo
cd tomo
Dependencies
Tomo has a few dependencies:
- The Boehm-Demers-Weiser garbage collector
- libunistring
- binutils
- patchelf
- The GNU Multiple Precision Arithmetic Library
- Either Clang or GCC
However, to make it easy to install these dependencies from most common package managers, Tomo comes with an install script that will try to figure out your package manager and use it to install the necessary dependencies:
./install_dependencies.sh
Note: Tomo has been tested on Arch Linux, Raspbian, MacOSX, and OpenBSD. Any other operating system is not guaranteed to work.
Installing
Once you have the dependencies, you can build and install the compiler:
make -j install
By default, this will install Tomo to ~/.local/bin/tomo
and
this does not require sudo permissions. However, you’ll get a warning if
~/.local/bin/
is not part of your $PATH
variable. To
make sure you can run executables from this location, you can put the
following line in your .profile
or .bashrc
:
export PATH="$HOME/.local/bin:$PATH"
Or, alternatively, you can run
sudo make PREFIX=/usr/local install
to install to
/usr/local/bin
or your directory of choice.
Language Plugins
To install the Tomo Vim syntax plugin, run
git clone --depth=1 'https://code.bruce-hill.com/Bruce/vim-tomo' ~/.vim/pack/syntax/start/vim-tomo
or use your plugin manager of choice to install https://code.bruce-hill.com/Bruce/vim-tomo
For Emacs, use the tomo-mode emacs plugin.
Your First Program
Open a new file called hello.tm
(.tm
is the file
extension for Tomo files) and add the following code:
func main()
say("Hello world!")
You can run this file directly like this:
$ tomo hello.tm
Hello world!
Alternatively, you can compile your program into an executable binary file like this:
$ tomo -e hello.tm
$ ls
hello.tm hello$ ./hello
Hello world!
Next Steps
Now that the Tomo compiler is installed, you can:
- Run the interactive Tomo Koans language tutorial
- Head to the learning page for more resources on Tomo