zesterer / chumsky

Write expressive, high-performance parsers with ease.
https://crates.io/crates/chumsky
MIT License
3.54k stars 147 forks source link

[Need help/Question] Repeated parser iteration succeeded but consumed no inputs #173

Closed TornaxO7 closed 2 years ago

TornaxO7 commented 2 years ago

Disclaimer

Hello, it's me again! I'm sorry that I'm often asking for help but I hope that it's fine... as I already said, you are always free to say that you don't want to get any questions like that again.

The problem

I'm getting the following error message:

thread 'lexer::tests::test_encoded_from_1'
panicked at 'Repeated parser iteration succeeded but consumed no inputs
(i.e: continuing iteration would likely lead to an infinite loop, if the parser is pure).
This is likely indicative of a parser bug.
Consider using a more specific error recovery strategy.',

(formatted for better readability)

if I run cargo test on my fork.

If you remember, I've already asked a similar question. I was trying to find the issue but I can't find a fix.

Where to start

This function returns the parser for the program.

What have you tried?

I'd be happy if anyone can help me here :)

zesterer commented 2 years ago

Here, you use whitespace().repeated() but the whitespace parser already accepts any number of whitespace characters, so whitespace().repeated() can accept no inputs, spinning round indefinitely. I recommend removing the .repeated().

TornaxO7 commented 2 years ago

Thank you :)

TornaxO7 commented 2 years ago

@zesterer I'm sorry that I'm pinging again ._. but I've got a (little) other problem if I remove repeated() from whitespace(). Because according to the rfc-2047 there can be any amount of whitespaces between two encoded words, which should be ignored. Here is an examle from the rfc:

(=?ISO-8859-1?Q?a?=  =?ISO-8859-1?Q?b?=)    (ab)

        Even multiple SPACEs between 'encoded-word's are ignored
        for the purpose of display.

Do you have an idea for this?

zesterer commented 2 years ago

Does this not work as-is? whitespace() will consume any amount of whitespace characters.

TornaxO7 commented 2 years ago

Oh god... I just found out that it was another issue... sorry! Yes you're right, it consumes any amount of whitespace :)