Skip to content

cedrickchee/hou

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
ast
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Hou 🐒

The Hou programming language based on Monkey, but with a little twist on the syntax and features.

Hou ("Monkey" in Chinese).

About this Project

My go-to project for practicing a new programming language is:

I reimplemented Monkey tree-walking interpreter in Go as a learning exercise. The code in this repository closely resembles that presented in Thorsten's book. The interpreter is fully working.

Don't miss out the step-by-step walk-through in this project, where each commit is a fully working part. Read the books and follow along with the commit history.

Quick start

Start the REPL:

$ go get github.com/cedrickchee/hou
$ hou
This is the Hou programming language!
Feel free to type in commands
>>

Then entering some Hou code:

  • Variable bindings
>> let name = "awesome people"
>> puts("Hello " + name)
Hello awesome people
null
  • Functions and closures
>> let newAdder = fn(x) { fn(y) { x + y } };
>> let addTwo = newAdder(2);
>> addTwo(3);
5
  • Arrays and hash maps
>> let music = [{"song": "We are the World", "singer": "Michael Jackson", "year": 1985}, {"song": "Help!", "singer": "The Beatles", "year": 1965}]
>> music[0]
{song: We are the World, singer: Michael Jackson, year: 1985}
>> music[1]["song"]
Help!
  • Errors
>> color = "green"
            __,__
   .--.  .-"     "-.  .--.
  / .. \/  .-. .-.  \/ .. \
 | |  '|  /   Y   \  |'  | |
 | \   \  \ 0 | 0 /  /   / |
  \ '- ,\.-"""""""-./, -' /
   ''-' /_   ^ ^   _\ '-''
       |  \._   _./  |
       \   \ '~' /   /
        '._ '-=-' _.'
           '-----'
Woops! We ran into some monkey business here!
parser errors:
	no prefix parse function for = found

Development

To build, run make.

$ git clone https://github.com/cedrickchee/hou
$ cd hou
$ make

To run the tests, run make test.

Step-by-step walk-through

Writing an Interpreter

Releases

No releases published

Packages

No packages published