MercuryTechnologies / ghciwatch

Load a GHCi session for a Haskell project and reload it when source files change
https://mercurytechnologies.github.io/ghciwatch/
MIT License
111 stars 10 forks source link

Parse single-quoted GHC output more reliably #301

Open 9999years opened 4 months ago

9999years commented 4 months ago

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

linear[bot] commented 4 months ago

DUX-2348 Fix single quoted GHC output parser