Permalink
Browse files

Merge pull request #3 from ChrisMissal/infinite

Added position to infinite loop exception.
  • Loading branch information...
2 parents 8168ee8 + 6c9a60b commit 2d113754b6e3e68a43e624987fb7ed5c4dd99870 @plioi 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
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;

0 comments on commit 2d11375

Please sign in to comment.