raahii / monkey-interpreter

🐵 Go言語でつくるインタプリタ入門

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The Monkey Language Interpreter

Go言語でつくるインタプリタ

This is an interpreter for the Monkey language. Try REPL.

$ go get -u github.com/raahii/monkey-interpreter
❯ monkey
Hello, ${username}! This is the Monkey programming language!
Feel free to type in commands
>> 5
5
>> -5
-5
>> 2 * (3 + 2) / 3
3
>> let x = 3
>> if ( x > 5 ) { true } else { false }
false
>> let add = fn(x, y) { return x + y; };
>> add(x, 5)
8
>> let newAdder = fn(x) { fn(y) { return x + y } };
>> let addTwo = newAdder(2);
>> addTwo(x);
5

Monkey Language

  • integer, boolean, string, array, hash
  • +, -. *, /, (, )
  • puts(<string>), len(<array>), first(<array>), last(array), rest(<array>)

Lexer (chapter1)

lexer

Parser (chapter2)

parser

Evaluator (chapter3)

evaluator

Updated interpreter (chapter4)

  • Add support for new literals and builtin functions.

    • String (litral, +)
    • Array (literal, indexing, len(), push(), first(), rest(), last())
    • Hash (literal, indexing)
    • puts()

updated

About

🐵 Go言語でつくるインタプリタ入門


Languages

Language:Go 100.0%