ollef / Earley

Parsing all context-free grammars using Earley's algorithm in Haskell.
BSD 3-Clause "New" or "Revised" License
361 stars 24 forks source link

Something like Ruby Slippers parsing #64

Closed expipiplus1 closed 1 year ago

expipiplus1 commented 1 year ago

Terminology from the Marpa parser.

I have no idea what Marpa's implementation is, but perhaps this would work for this package:

In the same way that names are specified for tokens at specific positions, we could maintain a set of slippers, which are utilized when no terminals match in order to rescue the parse.

expipiplus1 commented 1 year ago

Actually, perhaps this is:

terminal t `slipper` s == disambiguate (minimumBy fst) ((0,) <$> terminal t <|> (1,) <$> pure s)

i.e. a slipper is just the same as a pure value over which the terminal is prioritized