https://github.com/cedrickchee/hou
Hou :monkey: programming language interpreter and compiler
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (8.6%) to scientific vocabulary
Keywords
Repository
Hou :monkey: programming language interpreter and compiler
Basic Info
Statistics
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
Hou :monkey:
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: - Thorsten Ball's writing on interpreters (https://interpreterbook.com) and compilers (https://compilerbook.com) - Bob Nystrom's Crafting Interpreters handbook for making programming languages
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:
```sh $ 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
```sh
let name = "awesome people" puts("Hello " + name) Hello awesome people null ```
- Functions and closures
```sh
let newAdder = fn(x) { fn(y) { x + y } }; let addTwo = newAdder(2); addTwo(3); 5 ```
- Arrays and hash maps
```sh
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.
sh
$ 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
- 1.2 Define token
- 1.3 Lexer (basic)
- 1.4 Lexer (extended)
- 1.5 REPL (basic)
- 2.4 Parser (basic)
- 2.4 Parser (error handling)
- 2.5 Parser (return)
- 2.6 Pratt Parser (prefix)
- 2.6 Pratt Parser (infix)
- 2.8 Parser tracing
- 2.8 Parser (extended)
- 2.9 REPL (read-parse-print-loop)
- 3.4 Evaluation (Object System)
- 3.5 Evaluate Expression (basic)
- 3.5 Complete the REPL
- 3.5 Evaluation (literals)
- 3.5 Evaluation (prefix expressions)
- 3.5 Evaluation (infix expressions)
- 3.6 Evaluation (conditionals)
- 3.7 Evaluation (return statements)
- 3.8 Evaluation (error handling)
- 3.9 Evaluation (bindings and environment)
- 3.10 Evaluation (functions and call expressions)
- 4.2 Data Types (strings)
- 4.2 Data Types (string concatentation)
- 4.3 Builtins (len)
- 4.4 Data Types (arrays)
- 4.4 Arrays (index operator expressions)
- 4.4 Arrays (evaluating array literals)
- 4.4 Arrays (indexing)
- 4.4 Arrays (more built-in functions)
- 4.5 Hash
- 4.6 Hello World
Owner
- Name: Cedric Chee
- Login: cedrickchee
- Kind: user
- Location: PID 1
- Company: InvictusByte
- Website: https://cedricchee.com
- Twitter: cedric_chee
- Repositories: 227
- Profile: https://github.com/cedrickchee
Lead Software Engineer | LLMs | full stack Go/JS dev, backend | product dev @ startups | 🧑🎓 CompSci | alumni: fast.ai, Antler.co
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: 12 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 0
proxy.golang.org: github.com/cedrickchee/hou
- Homepage: https://github.com/cedrickchee/hou
- Documentation: https://pkg.go.dev/github.com/cedrickchee/hou#section-documentation
- License: MIT