etorreborre/specs2 — Issue #51: Parser macher produces wrong error message (and maybe result)
Author: ziggystar
Created: 2012-01-12 10:22:53+00:00
State: open

Notice the debugging statements I have inserted. First I parse the file manually and check the parse result.

``` scala
"parse uai file" ! {
val myParse = parseAll(parseProblem, StreamReader(new FileReader("res/uai/examples/grid3x3.uai")))
println(myParse)
val source: CharSequence = myParse.next.source
println(source.length())
println(source)
parseProblem must succeedOn(StreamReader(new FileReader("res/uai/examples/grid3x3.uai")))
}
```

Here is the ouput:

```
[90.1] parsed: UAIProblem()
0

'[88.36] parsed: UAIProblem()' is a Success but the input was not completely parsed: 0.00041451 2412.5 2412.5 0.00041451
```

The pointer after the manual parse is at 90.1 and there are no bytes left as input. Also parseAll succeeds. But inside the message from specs2 you see the cursor is at 88.36, with presumably the displayed string left to parse, **although** the correct AST has been produced, which definately had to read the printed numbers.