Skip to content

ManuelGarciaF/go-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go interpreter for the "monkey" language

This is an implementation of an interpreter for the "monkey" language detailed in Writing an Interpreter in Go

Language example

let age = 1;
let name = "Monkey";
let result = 10 * (20 / 2);
let myArray = [1, 2, 3, 4, 5];
let myHash = {"key1": "lorem ipsum", "key2": 42};

let fibonacci = fn(x) { if (x < 2) { x } else { fibonacci(x - 1) + fibonacci (x - 2) }}

Complicated Hello world example:

puts(["Hello", 42][0], {"second word": "world"}["second word"], fn(b) { if (b) { "!" } else { "something else" } }(true))

Usage

The interpreter is provided as a REPL, to run it use:

go run github.com/ManuelGarciaF/go-interpreter@latest

About

Go interpreter for a toy language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages