Hello Richard, Just FYI `gather` doesn't work with `readS_to_P` (throws an error), so you'll have to stick to ReadP parsers but, hopefully, that's OK.
-Iavor On Tue, Apr 27, 2021 at 7:14 PM Richard Eisenberg <r...@richarde.dev> wrote: > > > > On Apr 27, 2021, at 3:32 PM, Sebastian Graf <sgraf1...@gmail.com> wrote: > > > > Hi Richard, > > > > Maybe I lack a bit of context, but I don't see why you wouldn't choose > (3). > > Extending the lexer/parser will yield a declarative specification of > what exactly constitutes a GHC_OPTIONS pragma (albeit in a language that > isn't Haskell) and should be more efficient than `reads`, even if you fix > it to scale linearly. Plus, it seems that's what we do for other pragmas > such as RULE already. > > (3) is tempting indeed. There are two problems: > > A. The code that parses strings isn't actually declarative. See > https://gitlab.haskell.org/ghc/ghc/-/blob/d2399a46a01a6e46c831c19e797e656a0b8ca16d/compiler/GHC/Parser/Lexer.x#L1965. > In particular note the comment: "This stuff is horrible. I hates it." > Evidently written by Simon M in 2003 with the introduction of alex. > > B. We need this code outside the lexer, to deal with e.g. :set in GHCi. > > > On Apr 27, 2021, at 4:28 PM, Iavor Diatchki <iavor.diatc...@gmail.com> > wrote: > > > > ... gather ... > > Aha! That was the magic incantation I needed but did not have. Many > thanks, Iavor. > > The curious can see > https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5509/diffs?commit_id=a560fcbbc7d4e37c4909385c55839f793b570e68#c1078a9741c11d1e15d4c678b107092790295bb3_308_317 > for the final result. > > Thanks! > Richard > _______________________________________________ > ghc-devs mailing list > ghc-devs@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs >
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs