lizziew / go_compiler

Simple interpreter & compiler written in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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


Languages

Language:Go 100.0%