purescript-contrib/purescript-parsing

`sepEndBy` behaves incorrectly (?)

garyb opened this issue · 2 comments

garyb commented
elemA = PS.string "A"
elemB = PS.string "B"
sep = PS.string ";"
parse = flip P.runParser do Tuple <$> PC.sepEndBy elemA sep <*> elemB

This now fails:

parse "A;B"

Prior to v6 it succeeded. Copying the old implementation of sepEndBy locally and implementing parse with that restores the original behaviour.

I'd say this behaviour is wrong too, it's not just that it's different now - as far as I can tell, if there's a trailing separator, and then any other input follows, the combinator fails now.

I can reproduce this issue. I suppose it's due to #102.

I think this comes down to me not understanding the parser's Alt instance when I made that PR, and how heavily many depends on it. Specifically the detail of the second parser only being run if the first one doesn't consume any input before failing.