Today when we use menhir's compile_errors option to generate error messages table in ocaml, the only input is the error state. It generates something like:
let message =
fun s->
match s with
| 0 ->
"syntax error blah blah blah"
...
But sometimes for the same state, we want to have different error messages for different lookahead token. I'm thinking maybe we can use lookahead token as another input to error messages. So the generated ocaml error table file would look like this:
let message =
fun s token ->
match (s, token) with
| (0, MINUSGREATER) ->
"Doesn't expect '->' here! Maybe you mean '=>' ?"
| (0, DIV) ->
...
| (0, _) ->
...
Today when we use menhir's compile_errors option to generate error messages table in ocaml, the only input is the error state. It generates something like:
But sometimes for the same state, we want to have different error messages for different lookahead token. I'm thinking maybe we can use lookahead token as another input to error messages. So the generated ocaml error table file would look like this: