Get the latest tech news

I Wrote a Compiler


I have a Computer Science degree. I attended a whole course of lectures on compilers (and have a certain fondness for “the red dragon book” as a result). However, I had never actually written a compiler from start to finish until a rainy day last weekend.

Instead, nex takes a config file ( here’s mine) where you specify a set of regular expresions which capture all the keywords and identifiers for your language. Each regex match runs the Go code in curly braces on the right which must return a token type and fill out the per-type properties for any leaf nodes in the tree. To test it out I wrote a little BASIC program that uses every single construct in the language and made sure it works and generates the expected output.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of compiler

compiler

Related news:

News photo

AMD Makes Another Software Acquisition To Bolster Their AI & Compiler Talent

News photo

Iron Spring PL/I Compiler

News photo

GCC 14.3 Compiler Released With 200+ Bug Fixes