How can I display the location information when a Stream.Error occurs inside a parser? For example:
let p = parser
| [< '1; '2 ?? "1 expected at line L, column C" >] -> ()
how to get the location in the stream? Is there a way to use Stream.count without having to count the newline characters manually?
You have to build the position manually (represented with
Lexing.positionfor example). I wouldn't touch the lexer/parser itself, though, but rather write a simple function that will translate a file offset (represented withStream.count) into the (line, column) coordinate system.