Skip to content

Added position to infinite loop exception #3

Merged
merged 1 commit into from Jun 19, 2012
View
4 src/Parsley.Test/GrammarTests.cs
@@ -99,7 +99,7 @@ public void ApplyingARuleZeroOrMoreTimes()
Parser<Token> succeedWithoutConsuming = new LambdaParser<Token>(tokens => new Parsed<Token>(null, tokens));
Action infiniteLoop = () => ZeroOrMore(succeedWithoutConsuming).Parse(new TokenStream(Tokenize("")));
- infiniteLoop.ShouldThrow<Exception>("Parser encountered a potential infinite loop.");
+ infiniteLoop.ShouldThrow<Exception>("Parser encountered a potential infinite loop at position (1, 1).");
}
[Fact]
@@ -123,7 +123,7 @@ public void ApplyingARuleOneOrMoreTimes()
Parser<Token> succeedWithoutConsuming = new LambdaParser<Token>(tokens => new Parsed<Token>(null, tokens));
Action infiniteLoop = () => OneOrMore(succeedWithoutConsuming).Parse(new TokenStream(Tokenize("")));
- infiniteLoop.ShouldThrow<Exception>("Parser encountered a potential infinite loop.");
+ infiniteLoop.ShouldThrow<Exception>("Parser encountered a potential infinite loop at position (1, 1).");
}
[Fact]
View
2 src/Parsley/Primitives/ZeroOrMoreParser.cs
@@ -23,7 +23,7 @@ public Reply<IEnumerable<T>> Parse(TokenStream tokens)
while (reply.Success)
{
if (oldPosition == newPosition)
- throw new Exception("Parser encountered a potential infinite loop.");
+ throw new Exception(string.Format("Parser encountered a potential infinite loop at position {0}.", newPosition));
list.Add(reply.Value);
oldPosition = newPosition;
Something went wrong with that request. Please try again.