Skip to content

lizziew/go_compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Interpreter and compiler for toy language

Written in Go

See http://datasieve.blogspot.com/2018/08/building-toy-language-interpreter-in-go.html and http://datasieve.blogspot.com/2018/08/building-toy-language-compiler-in-go.html for more details

Based on https://interpreterbook.com/

Features

Supports:

  • integers, booleans, strings, arrays, hashmaps
  • prefix, infix operators
  • index operators
  • conditionals
  • global and local bindings
  • first class functions
  • return statements
  • closures

How to Run

Build:

➜ go build -o toy

Run in interpreter mode:

➜ ./toy -engine=eval
`Welcome to the Monkey programming language, elizabethwei!`
`Feel free to type in commands. Engine = eval`
>> 

Run in compiler mode:

➜ ./toy -engine=vm
Welcome to the Monkey programming language, elizabethwei!
Feel free to type in commands. Engine = vm
>> 

Logging

Run with or without intermediate print statements:

alt text

alt text

About

Simple interpreter & compiler written in Go

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages