Desugarging the Relationship Between Concrete and Abstract Syntax
thunderseethe.dev·5d·
🔍Parser Design
Preview
Report Post

Previously, we, begrudgingly, parsed some syntax into a Concrete Syntax Tree (CST) . With that tarpit deftly dodged, we can proceed to our next pass desugaring. Desugaring removes syntax sugar and maps our CST onto our Abstract Syntax Tree (AST). Our CST leaves us with a lot of cruft, such as | or =. This stuff was important for telling head from tail in our initial source file, and we’ll want to have it around when we’re reporting diagnostics, but the rest of the compiler doesn’t really care about such mundane affairs. Desugaring helps us strip away all the syntax and focus in on what’s important, lightening the cognitive load for following compiler passes.

But… do we really gotta? It seems like a pain. Can’t the later passes …

Similar Posts

Loading similar posts...