|
| 1 | +(** Parsing error messages handler. |
| 2 | + The .ml file corresponding to this mli is generated automatically generated |
| 3 | + by menhir (check the dune file) from the [mparser.messages] file. This file |
| 4 | + is the core of parsing message handling: this is where all error messages |
| 5 | + must be added. |
| 6 | +
|
| 7 | + The structure of the [mparser.messages] strongly depends on the parser's. If |
| 8 | + the parser changes, it may be necessary to rework on it to update the error |
| 9 | + messages. Hopefully, [menhir] comes with a way to automatically update |
| 10 | + messages when the parser changes. This can be automatically done by running |
| 11 | + [dune runtest --auto-promote]. Check the [src/mlang/m_frontend/dune] file |
| 12 | + for more information. |
| 13 | +
|
| 14 | + Each possible error is mapped to a state (an integer) and a custom message |
| 15 | + in the [mparser.messages] file. When the parser raises an exception, it also |
| 16 | + raises the state where it failed. This module allows to get the |
| 17 | + corresponding error message. |
| 18 | +
|
| 19 | + There is then three possibilities: |
| 20 | + * the state has a custom error message, which can be printed; |
| 21 | + * the state has the default error message (<"YOUR SYNTAX ERROR MESSAGE HERE>"), |
| 22 | + which has not been written yet; |
| 23 | + * the state has no error message, which should not happen unless the |
| 24 | + [mparser.messages] is not sync with [mparser.mly]. |
| 25 | + *) |
| 26 | + |
| 27 | +val message : int -> string |
| 28 | +(** Returns the error message corresponding to a parser error state. |
| 29 | + Raises [Not_found] if the state has no error message. *) |
0 commit comments