Skip to content

HTPL Compiler

Dec. 2024 – Jan. 2025

HTPL language logo

HTPL is a small teaching language whose programs are written as XML-style tags. For our compilation course at ESI, a team of five of us built a compiler front end for it in C with Flex and Bison. In a single pass it checks a program's syntax, fills a symbol table and emits intermediate code as quadruples.

What I built

I did the overall design of the project and wrote the syntax analysis: the Bison grammar the parser is generated from. That included operator precedence for arithmetic expressions. Instead of declaring it with Bison's %left and %right, I wrote it into the grammar itself, one rule per priority level, so multiplication binds tighter than addition by construction.

Later

In 2026 I came back to the repository and made it dependable. I reorganised it, wrote a language reference and an architecture note, added regression tests and CI, and fixed bugs in the compiler, such as while loops that did not recompute their condition.

What I took from it

Understanding the theory can replace a tool's shortcut. Precedence needs no special declarations: the shape of the grammar, and the automaton the parser generator builds from it, already settles it.