Skip to content

Draft: Try error resumption mode for `happy`

Sebastian Graf requested to merge wip/sgraf-resumable-parser into master

See https://github.com/haskellfoundation/tech-proposals/pull/63#issuecomment-1908919179.

I haven't tweaked the CI script yet to use my development branch of happy: https://github.com/sgraf812/happy/tree/resumptive. So CI will fail, but I uploaded the patch that made it through a bootstrap locally.

I only added one catch production to the parser so far, for local decls. Resumption can be witnessed in the following example:

module Test where

f :: Int -> Int
f x = y + z
  where
    y = [
    z = ]
    w = )
    v = Ok

g :: Int
g = True
[1 of 1] Compiling Lib              ( test.hs, test.o ) [Source file changed]

test.hs:7:5: error: [GHC-58481]
    Parse error (possibly incorrect indentation or mismatched brackets).
    Expected one of '_', 'as', 'case', 'hiding', 'if', 'let',
                    'qualified', 'type', 'export', 'label', ...
  |
7 |     z = ]
  |     ^

test.hs:7:9: error: [GHC-58481]
    Parse error on input ‘]’.
    Expected one of '_', 'as', 'case', 'hiding', 'if', 'let',
                    'qualified', 'type', 'export', 'label', ...
  |
7 |     z = ]
  |         ^

test.hs:8:9: error: [GHC-58481]
    Parse error on input ‘)’.
    Expected one of '_', 'as', 'case', 'hiding', 'if', 'let',
                    'qualified', 'type', 'export', 'label', ...
  |
8 |     w = )
  |         ^

Sadly no name and type errors in v and g yet, but that is orthogonal.

Edited by Sebastian Graf

Merge request reports