@@ -45,17 +45,17 @@ export function makeLiteralRules() {
4545 // (`'\NUL'`). `\\.` takes the backslash + first escape char (covers `'\''`,
4646 // `'\n'`, `'\\'`), then `[^']*` absorbs the rest up to the closing quote.
4747 _char_lit : ( $ ) => token ( / ' ( \\ .[ ^ ' ] * | [ ^ ' \\ ] ) ' # * / ) ,
48- // A backslash escapes any char, including a newline . GHC also prints long
49- // strings with a string gap `\ <whitespace> \` (`..\n\` <newline> ` \..`),
50- // which the regex must not misread :
48+ // Backslash escapes any non-space char . GHC also emits long strings with a
49+ // gap `\ <whitespace> \`, matched as its own alternative `\\\s+\\` for two
50+ // reasons :
5151 //
52- // - The resume `\` must not pair with the following escape. `\\"` is a
53- // gap-resume then an escaped quote, not an escaped backslash then a
54- // terminating quote that would end the string early.
52+ // - The gap's trailing `\` is consumed here, so it cannot pair with a
53+ // following `"` and end the string early.
5554 //
56- // - So the gap `\\\s+\\` is its own longest-match alternative, ahead of
57- // the `\\[\s\S]` escape and the `[^"\\]` char.
58- _string_lit : ( $ ) => token ( / " ( \\ \s + \\ | \\ [ \s \S ] | [ ^ " \\ ] ) * " # * / ) ,
55+ // - The escape stays `\\\S`, disjoint from the gap. An overlapping
56+ // `\\[\s\S]` lets a `\ \ \ ..` run split many ways inside the `*`
57+ // (quadratic).
58+ _string_lit : ( $ ) => token ( / " ( \\ \s + \\ | \\ \S | [ ^ " \\ ] ) * " # * / ) ,
5959 } ;
6060}
6161
0 commit comments