Permalink
Browse files

Added position to infinite loop exception

  • Loading branch information...
1 parent 8168ee8 commit 6c9a60bc77ef229f32b4d25a65741bc78de42204 @ChrisMissal committed Jun 19, 2012
Showing with 3 additions and 3 deletions.
  1. +2 −2 src/Parsley.Test/GrammarTests.cs
  2. +1 −1 src/Parsley/Primitives/ZeroOrMoreParser.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]
@@ -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;

0 comments on commit 6c9a60b

Please sign in to comment.