- Writing Interpreter in Go / Writing Compiler in Go's Monkey Language but in OCaml
- Marmoset is a small monkey, sometimes called Pug Monkey, and I do like pugs π
First you need to install OCaml, opam and dune:
Then you can clone this repository and run the following commands:
git clone [email protected]:zlw/marmoset.git
And then install the dependencies:
make install
faster compilation, slower runtime performance
make build
slower compilation, faster runtime performance
make release
make unit
- Lexer
- Parser
- Evaluator
- Compiler
Feature | Interpreter | Compiler |
---|---|---|
Bindings | β | β |
Conditionals | β | β |
Strings | β | β |
Integers | β | β |
Arithmetic +-/* | β | β |
Arrays | β | β |
Indexing | β | β |
Dictionaries | β | β |
Functions | β | β |
First class functions | β | β |
Higher order functions | β | β |
Closures | β | β |
Recursion | β | β |
Built-In Functions | β | β |
Loops | β | β |
Floats | β | β |
Macros | β | β |
- Cleanup pyramid of doom in
Parser
- Propagate parsing errors instead of crashing
- Return
result
-
parse_identifier
-
parse_integerLiteral
-
parse_prefixExpression
-
parse_infixExpression
-
parse_boolean
-
parse_groupedExpression
-
parse_if_expression
-
parse_block_statement
-
parse_function_literal
-
parse_function_parameters
-
parse_call_expression
-
parse_call_arguments
-
- Return
- Add system tests
- test runner
- test cases (maybe reuse some from Crafting Interpreters?)
Monkey supports closures and first class functions. It would be interesting to add some functional programming features to it:
- immutability
- static typing with HindleyβMilner style type inference
- pattern matching
We those in place, it would be a JS-looking language with a ML core π€