An open API service indexing awesome lists of open source software.

https://github.com/kx0101/liakos-language

Writing An Interpreter (Tree-Walking) In Go from scratch, using Vaughan Pratt's Parser For Educational Purposes
https://github.com/kx0101/liakos-language

ast expressions go golang identifiers interpreter lexer parser pratt-parser repl statements tokenizer tokens vaughan-pratt

Last synced: 10 months ago
JSON representation

Writing An Interpreter (Tree-Walking) In Go from scratch, using Vaughan Pratt's Parser For Educational Purposes

Awesome Lists containing this project

README

          

- **REPL (Read-Eval-Print Loop)**
- **Primitive Types**: `int`, `bool`, `string`
- **Data Structures**: Arrays (`[]`) & Hash maps (`{}`)
- **Arithmetic Expressions**: `+`, `-`, `*`, `/`, `<`, `>`, `==`, `!=`
- **Variables & Bindings**: `let` statements
- **Control Flow**: `if-else`, `return`
- **Functions**:
- First-class & higher-order
- Closures & lexical scoping
- Recursion supported
- **Built-in Functions**: e.g. `len()`, `first()`, `last()`, `push()`, `print()`
- **Parser with Pratt Parsing** for correct operator precedence
- **Error Handling** with informative messages
- **Lexical Analyzer** (Tokenizer) and recursive descent parser

## 🚀 Getting Started

### 1. Clone the repo

```bash
git clone https://github.com/kx0101/liakos-language.git
cd liakos-language
```

## REPL
```bash
go run main.go

>> let add = fn(a, b) { return a + b; };
>> add(2, 3);
5
```

## Run a File
You can also execute `.liakos` source files:

```bash
./liakos examples/main.liakos
```