Skip to content

zlw/marmoset-ml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Monkey Language but in OCaml 🐡 🐫

Installation

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

Build

Dev

faster compilation, slower runtime performance

make build

Release

slower compilation, faster runtime performance

make release

Run tests

make unit

Progress

  • Lexer
  • Parser
  • Evaluator
  • Compiler

Features

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 ❌ ❌

TODO

  • 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
  • Add system tests
    • test runner
    • test cases (maybe reuse some from Crafting Interpreters?)

Ideas

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 πŸ€”

Releases

No releases published

Packages

No packages published