<div dir="ltr">I like the approach from "Principled Parsing for Indentation-Sensitive Languages" (<a href="https://michaeldadams.org/papers/layout_parsing/">https://michaeldadams.org/papers/layout_parsing/</a>) <br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 1, 2023 at 8:32 AM Travis Athougies <<a href="mailto:travis@athougies.net">travis@athougies.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA512<br>
<br>
According to the Haskell report [1] (See Note 5), a virtual `}` token<br>
is inserted if parsing the next token would cause a parse error and the<br>
indentation stack is non-empty.<br>
<br>
I'm trying to lex and parse Haskell source and this sort of interplay<br>
(which requires two-way communication between lexer and parser) makes<br>
it very difficult to write a conformant implementation.<br>
<br>
I can't change the standard (obviously), but I'm wondering if this is<br>
actually what GHC (de facto the only Haskell compiler) does, or if it<br>
applies some other rule. If so, does anyone know the exact mechanism of<br>
its implementation?<br>
<br>
I've been programming Haskell for more than a decade, and while I have<br>
an intuitive understanding of the indentation rules, I would have<br>
assumed the source could be lexed without also having a parser. In<br>
particular, the note seems to imply that the main purpose of this is to<br>
properly lex `let`/`in` bindings. Perhaps there's an alternate<br>
equivalent rule?<br>
<br>
Curious to hear other's thoughts.<br>
<br>
Travis<br>
<br>
[1]<br>
<a href="https://www.haskell.org/onlinereport/haskell2010/haskellch10.html#x17-17800010.3" rel="noreferrer" target="_blank">https://www.haskell.org/onlinereport/haskell2010/haskellch10.html#x17-17800010.3</a><br>
-----BEGIN PGP SIGNATURE-----<br>
<br>
iIsEARYKADMWIQRW81c55hOCXuY5k/H+BxaRGQDTjQUCZUGARhUcdHJhdmlzQGF0<br>
aG91Z2llcy5uZXQACgkQ/gcWkRkA041W+wEA/7n5NejGTYu4O6N+Pt7Rn0bBRw6D<br>
5D96idagahXqXioA/18hxYFpY45lWwB7pKCh83xQJu2Bcwkxj1xhhCEZBcoA<br>
=FrDy<br>
-----END PGP SIGNATURE-----<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>