<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,</p>
<p>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).<br>
</p>
<p>This makes the grammar rather hard to read. To quote [1]:<br>
</p>
<p><span style="left: 703.925px; top: 1263.19px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.864458);" dir="ltr">
<blockquote type="cite"><span style="left: 703.925px; top:
1263.19px; font-size: 21.2536px; font-family: sans-serif;
transform: scaleX(0.864458);" dir="ltr">Instead</span><span
style="left: 780.15px; top: 1263.19px; font-size: 21.2536px;
font-family: sans-serif; transform: scaleX(0.865052);"
dir="ltr"> of describing</span><span style="left: 907.286px;
top: 1263.19px; font-size: 21.2536px; font-family:
sans-serif; transform: scaleX(0.843643);" dir="ltr"> the </span><span
style="left: 944.893px; top: 1263.19px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.803942);" dir="ltr">language</span><span
style="left: 287.483px; top: 1288.79px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.863609);" dir="ltr"> to be parsed,</span><span
style="left: 416.406px; top: 1288.79px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.843643);" dir="ltr"> the</span><span style="left:
453.245px; top: 1288.79px; font-size: 21.2536px;
font-family: sans-serif; transform: scaleX(0.85785);"
dir="ltr"> grammar</span><span style="left: 544.555px; top:
1288.79px; font-size: 21.2536px; font-family: sans-serif;
transform: scaleX(0.84255);" dir="ltr"> describ</span><span
style="left: 610.294px; top: 1288.79px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.82857);" dir="ltr">es the</span><span style="left:
672.197px; top: 1288.79px; font-size: 21.2536px;
font-family: sans-serif; transform: scaleX(0.785871);"
dir="ltr"> process</span><span style="left: 745.31px; top:
1288.79px; font-size: 21.2536px; font-family: sans-serif;
transform: scaleX(0.811313);" dir="ltr"> used </span><span
style="left: 794.178px; top: 1288.79px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.856769);" dir="ltr">to parse</span><span
style="left: 876.271px; top: 1288.79px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.940573);" dir="ltr"> it; it's</span><span
style="left: 939.47px; top: 1288.79px; font-size: 21.2536px;
font-family: sans-serif; transform: scaleX(0.841134);"
dir="ltr"> more </span><span style="left: 992.673px; top:
1288.79px; font-size: 21.2536px; font-family: sans-serif;
transform: scaleX(0.87732);" dir="ltr">like </span><span
style="left: 287.488px; top: 251.994px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.868952);" dir="ltr">a hand-crafted </span><span
style="left: 430.473px; top: 251.994px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.856321);" dir="ltr">parsing </span><span
style="left: 505.419px; top: 251.994px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.866215);" dir="ltr">program,</span><span
style="left: 596.985px; top: 251.994px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.899339);" dir="ltr"> but</span><span style="left:
636.14px; top: 251.994px; font-size: 21.2536px; font-family:
sans-serif; transform: scaleX(0.840223);" dir="ltr"> crammed
</span><span style="left: 728.749px; top: 251.994px;
font-size: 21.2536px; font-family: sans-serif; transform:
scaleX(0.908191);" dir="ltr">into Bac</span><span
style="left: 807.007px; top: 251.994px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.899456);" dir="ltr">kus-Naur </span><span
style="left: 899.337px; top: 251.994px; font-size:
21.2536px; font-family: sans-serif; transform:
scaleX(0.90809);" dir="ltr">Form.</span></blockquote>
</span>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?<br>
</p>
<p>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.</p>
<p>Thanks!<br>
</p>
<p>-BenRI</p>
<p>[1] <a class="moz-txt-link-freetext" href="https://escholarship.org/uc/item/8559j464">https://escholarship.org/uc/item/8559j464</a><br>
</p>
</body>
</html>