<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>FYI I did the horrible thing for now, optimisations welcome.</div><div><br></div><div>The change is at [1]</div><div><br></div><div>Alan</div><div><br></div><div>[1] <a href="https://gitlab.haskell.org/ghc/ghc/-/commit/742273a94c187f51e3b143f9c206c42024486ecf?merge_request_iid=2418">https://gitlab.haskell.org/ghc/ghc/-/commit/742273a94c187f51e3b143f9c206c42024486ecf?merge_request_iid=2418</a></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 19 Jan 2021 at 22:04, Alan & Kim Zimmerman <<a href="mailto:alan.zimm@gmail.com">alan.zimm@gmail.com</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"><div dir="ltr"><div>And if there is a comment after the '}' and then more blank lines, the last token is a comment.</div><div><br></div><div>If no curlies, it is a ITsemi for the last location, after the comment.</div><div><br></div><div>So my hacky scheme of using ITsemi as the means to track the last gap is not viable.<br></div><div><br></div><div>And I don't want to put extra housekeeping on every token to track two tokens back, not just one. Back to the drawing board.</div><div><br></div><div>Thanks</div><div>  Alan<br></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 19 Jan 2021 at 21:59, Richard Eisenberg <<a href="mailto:rae@richarde.dev" target="_blank">rae@richarde.dev</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"><div>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><br></div><div>Richard<br><div><br><blockquote type="cite"><div>On Jan 19, 2021, at 4:58 PM, Alan & Kim Zimmerman <<a href="mailto:alan.zimm@gmail.com" target="_blank">alan.zimm@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div>Changing it to remove the final ';' gives a last token of ITccurly.</div><div><br></div><div>Changing it to<br></div><div><br></div><div>module Bug where<br>
x = 5<br>
y = 6<br></div><div><br></div><div>Gives a last token of ITsemi.</div><div><br></div><div>Alan<br>
</div></div><br><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" target="_blank">rae@richarde.dev</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">That's bizarre. Does it still happen with explicit braces?<br>
<br>
Just to test, I tried<br>
<br>
module Bug where {<br>
x = 5;<br>
y = 6;<br>
};<br>
<br>
and GHC rejected because of the trailing ;.<br>
<br>
Richard<br>
<br>
> On Jan 19, 2021, at 4:35 PM, Alan & Kim Zimmerman <<a href="mailto:alan.zimm@gmail.com" target="_blank">alan.zimm@gmail.com</a>> wrote:<br>
> <br>
> I am (still) working on !2418 to bring the API Annotations into the GHC ParsedSource, and making good progress.<br>
> <br>
> 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>
> <br>
> 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>
> <br>
> 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>
> <br>
> Can I rely on the token before ITEof always being ITsemi?<br>
> <br>
> Alan<br>
> _______________________________________________<br>
> ghc-devs mailing list<br>
> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
<br>
</blockquote></div>
</div></blockquote></div><br></div></div></blockquote></div>
</blockquote></div>