https://github.com/valsov/go-interpreter
Study on interpreters, implemented in Go
https://github.com/valsov/go-interpreter
ast dynamically-typed repl
Last synced: 3 months ago
JSON representation
Study on interpreters, implemented in Go
- Host: GitHub
- URL: https://github.com/valsov/go-interpreter
- Owner: valsov
- Created: 2023-09-15T08:18:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-14T20:33:22.000Z (about 1 year ago)
- Last Synced: 2025-01-26T05:41:33.572Z (4 months ago)
- Topics: ast, dynamically-typed, repl
- Language: Go
- Homepage:
- Size: 51.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Interpreter implemented in Go
Study on interpreters, featuring a complete dynamically-typed language. This work is based on the book [Writing An Interpreter In Go, by Thorsten Ball](https://interpreterbook.com/). The project is fully unit-tested.## Structure of the project
- `/ast` All available data structures representing the evaluated program
- `/evaluator` Navigates through the AST in order to evaluate its nodes
- `/lexer` Produces tokens from chars, it is responsible of syntax checking
- `/object` Data structures representing the execution results of the AST by the evaluator
- `/parser` The role of the parser is to produce an AST of the program from tokens
- `/repl` Read-Eval-Print Loop, which enables direct development in this language
- `/token` Base representation of the code: a collection of tokens**Execution flow of the interpreter**:
`string` =[`lexer`]=> `[]token` =[`parser`]=> `ast` =[`evaluator`]=> `stream of objects`
## List of additional features to implement
### Lexer
- [x] Support UNICODE + UFT8 encoding instead of only ASCII. This requires switching from `byte` to `rune` reading
- [x] Allow integers as part of a variable or function name (but only if not solely composed of int chars)
- [ ] Support ++, --, +=, -=, *=, /=, %=
- [x] Support modulo
- [ ] Allow ternary operators### Parser
- [ ] indicate source line and col when reporting errors (impacts lexer)
- [ ] Support else if(...)