This program loops forever. Replacing sepEndBy with sepBy makes it terminate. sepEndBy1 loops, sepBy1 does not. Note that the actual input to parse doesn't matter - the issue happens whenever sepEndBy or sepEndBy1 occurs within the parser.
After consulting with some other people, our best guess is that the problem is that generating an Earley parser requires exploring the entire parse tree, broken only by explicit recursion markers. The Prod type in Earley provides implementations of some and many which creates those explicit markers, so working in terms of them will succeed. sepBy and sepBy1 are implemented in terms of many, so they work with Earley. But sepEndBy and sepEndBy1 do not use some or many, and as a result they create infinite parse trees. At least, that's the guess.
Main.hs:
sepEndBy-bugreport.cabal:
This program loops forever. Replacing
sepEndBy
withsepBy
makes it terminate.sepEndBy1
loops,sepBy1
does not. Note that the actual input to parse doesn't matter - the issue happens wheneversepEndBy
orsepEndBy1
occurs within the parser.After consulting with some other people, our best guess is that the problem is that generating an Earley parser requires exploring the entire parse tree, broken only by explicit recursion markers. The
Prod
type in Earley provides implementations ofsome
andmany
which creates those explicit markers, so working in terms of them will succeed.sepBy
andsepBy1
are implemented in terms ofmany
, so they work with Earley. ButsepEndBy
andsepEndBy1
do not usesome
ormany
, and as a result they create infinite parse trees. At least, that's the guess.