Catalog · How the catalog works
Projet_fin_module_compilateurs
This project uses a very original approach to parse a subset of the Pascal language, and covers all the aspects necessary for generating an X86 assembly program. The project is a bit 'dated', but the way recursive descent parsing was implemented is worth a look.
- ★ 8 on GitHub
Anyone may press Interesting, signed in or not. It helps others find this project.
README
Pascal to x86 Assembly Compiler (1994) – an original trick for ε-rules
Author: mzeus65
Year: 1994, republished 2026
License: GPL v3
The short story
In 1994, I wrote a Pascal compiler for my "Languages and Compilers" class.
My teacher gave me the highest grade, but dismissed it with: "We can also read books" – implying I had just copied a textbook.
He never really looked at my code.
The truth: my recursive descent parser handles empty derivations (ε-rules) using two booleans per function:
check_ok: the rule succeeded (even with zero tokens consumed)check_e: the rule derived empty
This makes the grammar extremely easy to modify. No FIRST/FOLLOW, no left factoring, no complicated lookahead.
I've never seen this trick in any book – then or since.
To this day, no one else in that institute ever completed a working compiler to this level.
What's inside
pro2asm.pas– the main compiler (Turbo Pascal)fact.lex– example Pascal program (factorial)pro2asm.exe– precompiled DOS executable
Quick test (if you have Free Pascal or DosBox)
fpc pro2asm.pas
./pro2asm fact.lex
## What I'm asking
I have ADHD and I'm retired. My memory of the details is fading.
I just want people who know compilers to take a quick look at pro2asm.pas and tell me: is this two-boolean trick known, or is it genuinely original?
Any honest feedback is welcome.
– mzeus65
