Added position to infinite loop exception #3

Merged
merged 1 commit into from Jun 19, 2012
Jump to file or symbol
Failed to load files and symbols.
+3 −3
Diff settings

Always

Just for now

@@ -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;