<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">So, I think there's your answer: the last token might be ITccurly, not ITsemi. It seems that the "insert invisible curlies and semis" is taken more literally for semis than for curlies.<div class=""><br class=""></div><div class="">Richard<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 19, 2021, at 4:58 PM, Alan & Kim Zimmerman <<a href="mailto:alan.zimm@gmail.com" class="">alan.zimm@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Changing it to remove the final ';' gives a last token of ITccurly.</div><div class=""><br class=""></div><div class="">Changing it to<br class=""></div><div class=""><br class=""></div><div class="">module Bug where<br class="">
x = 5<br class="">
y = 6<br class=""></div><div class=""><br class=""></div><div class="">Gives a last token of ITsemi.</div><div class=""><br class=""></div><div class="">Alan<br class="">
</div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 19 Jan 2021 at 21:50, Richard Eisenberg <<a href="mailto:rae@richarde.dev" class="">rae@richarde.dev</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">That's bizarre. Does it still happen with explicit braces?<br class="">
<br class="">
Just to test, I tried<br class="">
<br class="">
module Bug where {<br class="">
x = 5;<br class="">
y = 6;<br class="">
};<br class="">
<br class="">
and GHC rejected because of the trailing ;.<br class="">
<br class="">
Richard<br class="">
<br class="">
> On Jan 19, 2021, at 4:35 PM, Alan & Kim Zimmerman <<a href="mailto:alan.zimm@gmail.com" target="_blank" class="">alan.zimm@gmail.com</a>> wrote:<br class="">
> <br class="">
> I am (still) working on !2418 to bring the API Annotations into the GHC ParsedSource, and making good progress.<br class="">
> <br class="">
> I am currently making a rough port of ghc-exactprint, to ensure I can get all the tests around modifying the AST to work.<br class="">
> <br class="">
> One of the last pieces is being able to capture the spacing from the last token in the file to the EOF.  I guess technically it is the second last token.<br class="">
> <br class="">
> Empirically (calling getTokenStream), it seems this is always ITsemi.  I am not sure how this comes about, as the `module` parsing rule in Parser.y ends with body or body2, and those both finish with an actual or virtual '}'.<br class="">
> <br class="">
> Can I rely on the token before ITEof always being ITsemi?<br class="">
> <br class="">
> Alan<br class="">
> _______________________________________________<br class="">
> ghc-devs mailing list<br class="">
> <a href="mailto:ghc-devs@haskell.org" target="_blank" class="">ghc-devs@haskell.org</a><br class="">
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br class="">
<br class="">
</blockquote></div>
</div></blockquote></div><br class=""></div></body></html>