I’ve twice now created a parser that hangs, that is given a finite input string a call to parse_xxx it never returns and the beam.smp process is consuming ~100% of a core.
I’m usually making a small, seemingly innocuous, change to the string being parsed that causes the hang.
I have seen it hang if I wrote a parser that would infinitely recurse. Unfortunately I can’t recall the details, but I fixed it by changing my parser. If you can’t find any infinite recursion happening, it might be a bug in NimbleParsec?
Anyway, if you want to guard against the parser hanging, you might want to wrap the parsing in a Task
I had read that but hadn’t appreciated what it was saying. I do have a few cases where repeat and optional get combined and I suspect this is what is happening.
Part of the problem is that I find my error handling strategy is “fiddle with it a bit” because I find the error information difficult to work with. Any guidance about (or good examples of) that would be much appreciated.
As a further note here, in the (much simpler) parser combinator library I built called Ergo I have implemented cycle detection and the parser will automatically halt with a trace of the history of rules. A bit primitive right now but I’ve found it useful when playing with a new grammar.