Skip to content

bradford-hamilton/monkey-lang

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
ast
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vm
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Build Status Go Report Card codecov GoDoc Go 1.12.9

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:

  1. 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.
  2. Both file execution and console usage respond to an --engine= flag where you can choose to use the evaluator or the VM.
  3. Logical operators && and ||
  4. Single line comments starting with //
  5. Multi line comments using /* */
  6. const variable declaration (although it only mocks let at this point until I add variable reassignment)
  7. Modulo operator %
  8. Postfix operators ++ and --
  9. Comparison operators >= and <=
  10. String comparisons using != and ==
  11. Line numbers throughout the tokens/lexer/parsing/evaluator used for better errors.
  12. Ability to have question marks in identifiers. Ex: has_attribute?
  13. Additional builtin functions:
    Type Builtin
    Array pop, join
    String split
  14. VS Code syntax highlighting extension. Not yet published, but working and provides basic syntax highlighting.
  15. Add installation support through brew
  16. 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!

About

Currently extending the Monkey programming language designed in the books "Writing An Interpreter In Go" and "Writing a Compiler in Go"

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published