haskell-suite / haskell-src-exts

Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer
Other
193 stars 94 forks source link

self-delimiting parseExp (and others)? #449

Open jwaldmann opened 4 years ago

jwaldmann commented 4 years ago

can we make parseExp self-delimiting? The type is

parseExp :: String -> ParseResult (Exp SrcSpanInfo)

but I'd want "maximum munch" and the part that was not eaten, as in :: String -> ParseResult (.. , String)

I tried

  parseExp "x } foo bar"
ParseFailed (SrcLoc "<unknown>.hs" 1 3) "Unexpected }"

so I could extract the error location, and then re-parse that prefix. That's feels a bit strange.

(cf. https://mail.haskell.org/pipermail/haskell-cafe/2020-April/132124.html)