Awesome
Monkey Lang
Currently extending the Monkey programming language designed in Writing An Interpreter In Go and Writing a Compiler in Go by Thorsten Ball. I highly recommend picking up a copy of his books.
I'll formally document the language and it's features at some point, but for now I'm keeping a list of the additional functionality I've added on top of original design.
All additional features (where applicable) have been implemented for both the interpreter and the compiler:
- Ability to execute Monkey files (.mo file ext) in addition to the interactive console. This is now the default behavior. Add
--console
flag when executing to drop into the REPL instead. - Both file execution and console usage respond to an
--engine=
flag where you can choose to use the evaluator or the VM. - Logical operators
&&
and||
- Single line comments starting with
//
- Multi line comments using
/* */
const
variable declaration (although it only mocks let at this point until I add variable reassignment)- Modulo operator
%
- Postfix operators
++
and--
- Comparison operators
>=
and<=
- String comparisons using
!=
and==
- Line numbers throughout the tokens/lexer/parsing/evaluator used for better errors.
- Ability to have question marks in identifiers. Ex:
has_attribute?
- Additional builtin functions:
Type Builtin Array pop
,join
String split
- VS Code syntax highlighting extension. Not yet published, but working and provides basic syntax highlighting.
- Add installation support through brew
- Add roughly +20% code coverage
Installation
Option A:
brew tap bradford-hamilton/monkey
brew install bradford-hamilton/monkey/monkey
Option B:
If you mosey on over to releases, you'll find binaries for darwin, linux, windows, and amd64. You can download directly from there.
Option C:
If you have Go installed on your machine, use go install
:
go install github.com/bradford-hamilton/monkey-lang
This will place the binary in your go/bin
and is ready to use.
Usage
Build
go build -o monkey main.go
Run
./monkey [option...] filePath
Examples
Running with vm
./monkey --engine=vm examples/program.mo
Running with evaluator
./monkey --engine=eval examples/program.mo
Run interactive console
./monkey --console
Show your support
Give a ⭐ if this project was helpful in any way!