Taming Context-Sensitive Languages with Principled Stateful Parsing
Nicolas Laurent, Kim Mens

TL;DR
This paper introduces a novel approach called principled stateful parsing, enabling context-sensitive features in programming languages through mutable parse state, implemented in the Autumn library, improving grammar expressiveness and maintainability.
Contribution
It presents a formal, transactional discipline for stateful parsing that handles context-sensitive features more transparently and modularly than previous ad-hoc methods.
Findings
Successfully implemented context-sensitive features like whitespace and namespace handling.
Enables more maintainable and expressive grammars for complex language features.
Provides a practical library, Autumn, demonstrating the approach.
Abstract
Historically, true context-sensitive parsing has seldom been applied to programming languages, due to its inherent complexity. However, many mainstream programming and markup languages (C, Haskell, Python, XML, and more) possess context-sensitive features. These features are traditionally handled with ad-hoc code (e.g., custom lexers), outside of the scope of parsing theory. Current grammar formalisms struggle to express context-sensitive features. Most solutions lack context transparency: they make grammars hard to write, maintain and compose by hardwiring context through the entire grammar. Instead, we approach context-sensitive parsing through the idea that parsers may recall previously matched input (or data derived therefrom) in order to make parsing decisions. We make use of mutable parse state to enable this form of recall. We introduce principled stateful parsing as a new…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Testing and Debugging Techniques · Distributed systems and fault tolerance · Formal Methods in Verification
