Hawk-lang: A practice project for beginners interested in lang-dev and compilers!

I haven’t posted here in a long time but I’ve been so caught up with life and work that I haven’t had the chance to make any updates. This is only one thing I’m going to post here that I just did for fun. Took me a few days and I hope it proves useful to new people in compiler development.

I was talking to my co-working about compilers and programming languages and I got him interested in the topic. That inspired me to make a practice playground with a realistic pipeline implementation. I call this Hawk.

Hawk is a very simple language with only variables, scopes/blocks, integers, and the four basic binary operators (+, -, *, /). Its interpreter is a very simple bytecode executing VM. Hawk is meant to act as a very simple starter project for anyone new in the game and doesn’t know exactly how to get started.

Hawk currently has a tokenizer, parser, symbol resolution pass, type checking and inference (using Hindley-Milner/depth-first search inference), and, last but not least, stack emulation and bytecode generation.

The last expression in the code is printed out to the console. The syntax is kinda wonky but that’s okay. It’s meant to act as a starter language to be modified and improved.

let
    a = 5
    b = 3
    c = 8
do
    a + b * c

This will print out 29 in the console!

4 Likes

I think this could be very useful for people getting started. Thank you for sharing it!