ghciwatch icon indicating copy to clipboard operation
ghciwatch copied to clipboard

Parse single-quoted GHC output more reliably

Open 9999years opened this issue 8 months ago • 1 comments

GHC output contains quoted fragments:

Module graph contains a cycle:
        module ‘C’ (./C.hs)
        imports module ‘A’ (A.hs)
  which imports module ‘B’ (./B.hs)
  which imports module ‘C’ (./C.hs)

When Unicode output is not available, the Unicode quotes are substituted for GNU-style ASCII quotes:

module `C' (./C.hs)

However, when the quoted text starts or ends with a single quote, ASCII quotes are omitted. This leads to ambiguous output:

A   → `A'
A'  → A'
`A' → `A'
'A  → 'A
'A' → 'A'

Correctly parsing this is challenging.

This probably increases the amount of backtracking and lookahead required for these parsers. Not sure if that's significant or how concerning it is...

Split off of #297

9999years avatar Jun 21 '24 20:06 9999years