-
I've found time to get working again and found myself stuck another problem. After changing the source code to work for multiple lines, I was getting an unintended panic:
I was wondering if you could let me know why this was happening |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
This panic happens because the parser matched a repeating pattern without consuming any input. This is almost always a bug in the parser (and it's common enough that I chose to add a panic for it). For example: let a_chain = just('a').repeated();
let a_chain_chain = a_chain.repeated(); This parser will loop infinitely on the input In your parser, you have |
Beta Was this translation helpful? Give feedback.
-
Makes sense! removing the
I needed there to be 2 |
Beta Was this translation helpful? Give feedback.
This panic happens because the parser matched a repeating pattern without consuming any input. This is almost always a bug in the parser (and it's common enough that I chose to add a panic for it). For example:
This parser will loop infinitely on the input
b
because the first parser,a_chain
, is permitted to consume none of the input, anda_chain_chain
looks for that input many times, leading to an infinite loop.In your parser, you have
.or_not().repeated()
. This is highly suspect:or_not
is permitted to consume no inputs (as in the example I gave) andrepeated
will look for that pattern many times. I would sugg…