Skip to content

raahii/monkey-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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言語でつくるインタプリタ入門

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages