Skip to content

amtoine/monkey-interpreter-rs

Repository files navigation

monkey-interpreter-rs

Writing an interpreter for Monkey in Rust.

Introduction

this project is a Rust implementation of Writing An Interpreter In Go.

see the Monkey language here.

Example

there is currently a very simple CLI in main.rs that can run with

cargo run

Note

press <c-c> to quit the REPL

then, typing Monkey code should output the resulting AST, e.g.

let f = fn(x, y) { return x + y; }; f(1, 2);

will generate the following AST

Program {
    statements: [
        Let(
            "f",
            Function(
                [ "x", "y"  ],
                [ Return(Infix(Identifier("x"), Plus, Identifier("y"))) ],
            ),
        ),
        Expression(
            Call(
                Identifier("f"),
                [ IntegerLitteral(1), IntegerLitteral(2) ],
            ),
        ),
    ],
}

Roadmap

  • lexer
  • parser
    • let statements
    • return statements
    • expressions
    • extensions
      • boolean literals
      • grouped expressions
      • if expressions
      • function literals
      • call expressions
  • evaluation
  • extensions
    • strings
    • built-in functions
    • arrays
    • hash maps
  • CLI