Mint (short for Minimal Interpreter) is a stack-based programming language similar to Forth written in assembly.
- - Printing
- - Keywords
- - Math
- - Variables
Note
Syntax highlighting for Vim/Neovim is available in the editor section.
Source:
12 10 over out out out
Output:
$ ./mint example.mint
12
10
12
- Prerequisites: nasm
git clone https://github.com/kinderjosh/mint.git
cd mint
./build.sh
- Items left on the stack are automatically popped when the program exits and won't cause a segmentation fault.
Name | Purpose |
---|---|
drop |
Pop the top item off the stack and discard it. |
dup |
Copy the top item on the stack and push it to the stack. |
<variable> load |
Extracts the value within <variable> and push it to the stack. |
over |
Copy the item below the top item on the stack and push it to the stack. |
out |
Pop the top item off the stack and print it. |
<variable> store |
Pop the top item off the stack and store it into <variable> . |
swap |
Swap the top two items on the stack. |
Like Forth, Mint uses Reverse Polish notation.
Arithmetic operators pop the top two items and push the result of the operation.
10 2 / out
This program basically does:
printf("%ld\n", 10 / 2);
The characters a-k are parsed as variables.
Variables are pushed as pointers, not as values.
a b
This program pushes a pointer to a
and a pointer to b
.
Use the store
and load
keywords to access the values within variables.
An example to initialize, divide two variables and print the result:
64 a store
8 b store
a load
b load
/ out
This program basically does:
long a, b;
a = 64;
b = 8;
printf("%ld\n", a / b);
Syntax highlighting is currently only available for Vim/Neovim.
mkdir -p ~/.vim/syntax/
cp ./mint.vim ~/.vim/syntax/
Then add the following line to your vimrc:
autocmd BufNewFile,BufRead *.mint set filetype=mint
mkdir -p ~/.config/nvim/syntax/
cp ./mint.vim ~/.config/nvim/syntax/
Then add the following line to your init file:
VimScript:
autocmd BufNewFile,BufRead *.mint set filetype=mint
Lua:
vim.cmd('autocmd BufNewFile,BufRead *.mint set filetype=mint')
Mint is distributed under the MIT license. See LICENSE for details.