[Haskell-cafe] GLR parser for Haskell?
Benjamin Redelings
benjamin.redelings at gmail.com
Thu Apr 15 14:10:56 UTC 2021
Hi,
I've been looking at the Haskell parser in ghc/compiler/GHC/Parser.y.
It relies on post-processing pretty heavily, both to determine the type
of parsed expressions (i.e. is "(x,y)" a pattern or expression?) and to
reject invalid syntax (i.e. field declarations are parsed as a type, but
this is rejected during postprocessing I think, except in constructor
declarations).
This makes the grammar rather hard to read. To quote [1]:
> Insteadof describingthe languageto be parsed,thegrammardescribes
> theprocessused to parseit; it'smore like a hand-crafted parsing
> program,butcrammed into Backus-Naur Form.
Does anybody know if there is another version of the parser generator
uses grammar rules that are closer to the grammar rules in the 2010
report? Maybe a GLR grammar?
Also, I see that Happy is able to generate GLR parsers. I'm curious if
GLR parsers aren't being used just because they are slow, or if there is
some other reason they are hard to use. I am not an expert on parsing
or grammars, so any insight would be appreciated.
Thanks!
-BenRI
[1] https://escholarship.org/uc/item/8559j464
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210415/76678289/attachment.html>
More information about the Haskell-Cafe
mailing list