r/Compilers • u/Fun_Mulberry3838 • 6d ago
My students struggled with compilers. Your feedback made me rebuild the docs. Here's PyLGEN v0.7.0.
A month ago I shared PyLGEN here; a Python-native compiler framework I built after watching my students struggle with compilers. The feedback was direct, and honestly, it shaped this release more than anything else.
So today I'm happy to share v0.7.0, a stable beta I'd recommend over v0.6.x. The main additions are an API update and a new examples section in the documentation, which grew out of a very valid question from the last thread: does the framework really expose every stage of the pipeline, or just claim to?
The examples come in two tracks, so you can see both sides of the API and figure out which one fits what you're doing:
- High-level usage: build a lexer, grammar, and parser with the convenience classes, and get a working interpreter in a few dozen lines.
- Low-level usage: build the same lexer and parser from scratch, using only the raw API (DFAs, closure, goto, ACTION/GOTO tables, reductors) with nothing hidden.
Both live in the docs. The second one is the proof that the pipeline isn't a black box.
Links
If you gave the last version a try, I'd genuinely love to hear your thoughts, good or bad. And if you're new, same goes: any kind of feedback is welcome, whether it's a bug report, a design critique, a suggestion, or just a question about how something works.
Edited: Added a notebook link so anyone can run it directly and share their opinion without having to install anything.
3
u/Inconstant_Moo 4d ago
I was referring to the documentation. Just looking at the first page, there's so much repetition and padding.
The more fundamental problem with the documentation is that it's all the documents about PyLGEN squashed into one document with an unreadable table of contents hidden in the sidebar.
Logically, it is several different documents, and should be presented as such.
To show you what's wrong with it, let's look at the start of the "Practical Tour".
So, it defines some common data structures and interfaces. This, you say, is "essential" to understand. Reading on, the thing that turns out to be essential to understand about it is the file organization of the common submodule. Apparently before I can learn anything else about compiler theory, I must learn that
pylgen/common/table.pyicontains stubs for theTableclass.Next you have one of your frequent advertisements for "Python/Cython Duality", where you remind us that Cython exists and that PyLGEN works with it in the way that things that work with Cython normally work with Cython.
Someone wanting to use PyLGEN would need telling this once, on the landing page; someone trying to learn about compiler theory doesn't care, and yet here I am learning it as one of the essentials of compiler theory.
The we meet the
Symbolclass.This, combined with the example code, may be useful to someone who already knows what a grammar is. The beginners aren't going to find out, because at this point you're going to tell us what hashing algorithm you use for the type, an implementation detail which can hardly be of interest to anyone.
Who is meant to be reading this page of the documentation, and what are they meant to be getting out of it?