Embedding Generalized Parsing in Haskell
Monadic parser combinators are a domain specific language for writing parsers which can be embedded in general purpose programming languages like Haskell. Monadic parser combinators have several advantages over traditional parser generators. For example, they allow users to define their own derived combinators which can reduce duplication; the monadic structure allows for data dependent parsing, for example for length headers in (binary) data formats or for disambiguation such as layout parsing; and the embedding allows for direct semantic parsing which avoids the need for concrete syntax trees.
However, most monadic parser combinator libraries force their users to contort their grammars to avoid left-recursion and, if left-recursion is introduced accidentally, produce non-terminating programs without clear error messages. Secondly, parser combinators usually have little support for backtracking or degrade to exponential worst case complexity if backtracking is used pervasively. Finally, Ambiguities are often resolved by choosing the first successful branch which can be unpredictable.
In this talk, I show how we can distill a GLL parsing algorithm to its essence and how to embed it as a parser combinator library in Haskell. The resulting library allows for writing left recursive parsers while retaining most of the advantages of monadic parser combinators. Futhermore, I will discuss new challenges and new opportunities that this approach brings.
Embedding Generalized Parsing in Haskell slides (embedding-generalized-parsing-in-haskell.pdf) | 733KiB |
Fri 16 JunDisplayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change
11:30 - 12:30 | |||
11:30 20mTalk | Parallel Programming With An Autonomous Data Language PLNL 2023 File Attached | ||
11:50 20mTalk | Seaso: Logic Programming with Downstream Constraints for the Incremental Specification of Data-Exchange Systems PLNL 2023 Christopher Esterhuyse University of Amsterdam Media Attached File Attached | ||
12:10 20mTalk | Embedding Generalized Parsing in Haskell PLNL 2023 Jaro Reinders TU Delft File Attached |