diff --git a/src/Parlot/Fluent/ListOfCharsLiteral.cs b/src/Parlot/Fluent/ListOfCharsLiteral.cs index 66c537af..1d2b79e4 100644 --- a/src/Parlot/Fluent/ListOfCharsLiteral.cs +++ b/src/Parlot/Fluent/ListOfCharsLiteral.cs @@ -30,7 +30,7 @@ public ListOfChars(string values, int minSize = 1, int maxSize = 0, bool negate } } - if (_minSize > 0) + if (_minSize > 0 && !_negate) { ExpectedChars = values.ToCharArray(); CanSeek = true; diff --git a/src/Parlot/Fluent/SearchValuesCharLiteral.cs b/src/Parlot/Fluent/SearchValuesCharLiteral.cs index 7f88b262..d1c7e108 100644 --- a/src/Parlot/Fluent/SearchValuesCharLiteral.cs +++ b/src/Parlot/Fluent/SearchValuesCharLiteral.cs @@ -33,7 +33,7 @@ public SearchValuesCharLiteral(ReadOnlySpan searchValues, int minSize = 1, _maxSize = maxSize; _negate = negate; - if (minSize > 0) + if (minSize > 0 && !_negate) { CanSeek = true; ExpectedChars = searchValues.ToArray(); diff --git a/test/Parlot.Tests/FluentTests.cs b/test/Parlot.Tests/FluentTests.cs index d8666e19..33b71a6c 100644 --- a/test/Parlot.Tests/FluentTests.cs +++ b/test/Parlot.Tests/FluentTests.cs @@ -1249,6 +1249,15 @@ public void NoneOfShouldResetPositionWhenFalse() .TryParse("aaaZZ", out _)); } + [Fact] + public void NoneOfShouldNotBeSeekable() + { + var parser = Literals.NoneOf("Z", minSize: 3); + + Assert.True(parser is ISeekable); + Assert.False(((ISeekable)parser).CanSeek); + } + [Fact] public void ElseErrorShouldNotBeSeekable() {