<div dir="ltr"><div><div>As part of my ongoing efforts to round-trip source code, I have bumped into an issue around file header pragmas, e.g.<br><br></div><div>    {-# LANGUAGE PatternSynonyms #-}<br>    {-# Language DeriveFoldable #-}<br>    {-# options_ghc -w #-}<br><br></div><div><br></div>In normal mode, when not called from headerInfo, the file header pragmas are lexed enough to generate a warning about an invalid pragma if enabled, and then lexed to completion and returned as an `ITblockComment` if `Opt_KeepRawTokenStream` is enabled.<br><br></div>The relevant Alex rule is<br><br><div>    <0> {<br>      -- In the "0" mode we ignore these pragmas<br>      "{-#"  $whitechar* $pragmachar+ / { known_pragma fileHeaderPrags }<br>                         { nested_comment lexToken }<br>    }<br><br></div><div>The problem is that the tokens returned are <br>    <br>    ITblockComment " PatternSynonyms #"<br>    ITblockComment " DeriveFoldable #"<br>    ITblockComment " -w #"<br><br></div><div>It is not possible to reproduce the original comment from these.<br><br><br></div><div>It looks like nested comment ignores what has been lexed so far<br><br>    nested_comment :: P (RealLocated Token) -> Action<br>    nested_comment cont span _str _len = do<br>    ...<br><br></div><div>So my question is, is there any way to make the returned comment include the prefix part? Perhaps be a specific variation of nested_comment that uses str and len.<br><br></div><div>Alan<br></div></div>