benjamin-hodgson / Pidgin

A lightweight and fast parsing library for C#.
https://www.benjamin.pizza/Pidgin/
MIT License
883 stars 68 forks source link

Tried to rewind past the start of the input. Please report this as a bug in Pidgin! #140

Closed PJB3005 closed 1 year ago

PJB3005 commented 1 year ago

Just tried updating all my dependencies in my project, and it seems updating Pidgin from 3.0.0 to 3.2.0 caused this to start appearing in my parser.

The parser (it's huge and a mess, sorry) Smallest input it triggers on. All the files in that directory trigger it except sliderBehav.lingo, stop.lingo and inptBox.lingo unit test that hit this

Exception:

System.InvalidOperationException : Tried to rewind past the start of the input. Please report this as a bug in Pidgin!
   at Pidgin.ParseState`1.Rewind(Int32 bookmark)
   at Pidgin.TryParser`2.TryParse(ParseState`1& state, PooledList`1& expecteds, T& result)
   at Pidgin.OneOfParser`2.TryParse(ParseState`1& state, PooledList`1& expecteds, T& result)
   at Pidgin.RecParser`2.TryParse(ParseState`1& state, PooledList`1& expecteds, T& result)
   at Pidgin.Map2Parser`4.TryParse(ParseState`1& state, PooledList`1& expecteds, R& result)
   at Pidgin.Map2Parser`4.TryParse(ParseState`1& state, PooledList`1& expecteds, R& result)
   at Pidgin.TryParser`2.TryParse(ParseState`1& state, PooledList`1& expecteds, T& result)
   at Pidgin.ChainAtLeastOnceLParser`4.TryParse(ParseState`1& state, PooledList`1& expecteds, U& result)
   at Pidgin.OneOfParser`2.TryParse(ParseState`1& state, PooledList`1& expecteds, T& result)
   at Pidgin.Map2Parser`4.TryParse(ParseState`1& state, PooledList`1& expecteds, R& result)
   at Pidgin.Map3Parser`5.TryParse(ParseState`1& state, PooledList`1& expecteds, R& result)
   at Pidgin.Map2Parser`4.TryParse(ParseState`1& state, PooledList`1& expecteds, R& result)
   at Pidgin.Map2Parser`4.TryParse(ParseState`1& state, PooledList`1& expecteds, R& result)
   at Pidgin.Map2Parser`4.TryParse(ParseState`1& state, PooledList`1& expecteds, R& result)
   at Pidgin.WithExpectedParser`2.TryParse(ParseState`1& state, PooledList`1& expecteds, T& result)
   at Pidgin.Map1Parser`3.TryParse(ParseState`1& state, PooledList`1& expecteds, R& result)
   at Pidgin.OneOfParser`2.TryParse(ParseState`1& state, PooledList`1& expecteds, T& result)
   at Pidgin.WithExpectedParser`2.TryParse(ParseState`1& state, PooledList`1& expecteds, T& result)
   at Pidgin.Map2Parser`4.TryParse(ParseState`1& state, PooledList`1& expecteds, R& result)
   at Pidgin.Map2Parser`4.TryParse(ParseState`1& state, PooledList`1& expecteds, R& result)
   at Pidgin.TryParser`2.TryParse(ParseState`1& state, PooledList`1& expecteds, T& result)
   at Pidgin.ChainAtLeastOnceLParser`4.TryParse(ParseState`1& state, PooledList`1& expecteds, U& result)
   at Pidgin.OneOfParser`2.TryParse(ParseState`1& state, PooledList`1& expecteds, T& result)
   at Pidgin.Map2Parser`4.TryParse(ParseState`1& state, PooledList`1& expecteds, R& result)
   at Pidgin.Map2Parser`4.TryParse(ParseState`1& state, PooledList`1& expecteds, R& result)
   at Pidgin.WithExpectedParser`2.TryParse(ParseState`1& state, PooledList`1& expecteds, T& result)
   at Pidgin.ParserExtensions.DoParse[TToken,T](Parser`2 parser, ParseState`1& state)
   at Pidgin.ParserExtensions.DoParse[TToken,T](Parser`2 parser, ITokenStream`1 stream, IConfiguration`1 configuration)
   at Pidgin.ParserExtensions.Parse[T](Parser`2 parser, TextReader input, IConfiguration`1 configuration)
   at Pidgin.ParserExtensions.ParseOrThrow[T](Parser`2 parser, TextReader input, IConfiguration`1 configuration)
   at Drizzle.Lingo.Tests.ParseTest.Test(String fileName) in C:\Users\Pieter-Jan Briers\Projects\Drizzle\Drizzle.Lingo.Tests\ParseTest.cs:line 28
benjamin-hodgson commented 1 year ago

Thank you for reporting this! Apologies for not getting back to you sooner (Christmas break).

I've released v3.2.1 which should contain a fix for this bug: https://www.nuget.org/packages/Pidgin/3.2.1

Thanks!