Nice_parser.MakePass your parser/lexer to this functor to obtain a nicer interface, without having to write boilerplate code.
module P : RAW_PARSERInherited from RAW_PARSER.
type token = P.tokentype result = P.resultNice exceptions include the location at which an error occured. A nice ParseErrror also includes the token which caused the parser to choke, which can be useful for debugging.
Registers a pretty printer for LexError and ParseError. This results in colorful error messages including the source location when errrors occur. With OCaml >= 4.08, the pretty printer will also quote the problematic location in the soure code and underline the error location, like so:
File "examples/illegal.katbb", line 1, characters 10-17:
1 | this!; is illegal!; isntit?
^^^^^^^
Error: [parser] unexpected tokenval parse_string : ?pos:Stdlib.Lexing.position -> string -> resultval parse_chan : ?pos:Stdlib.Lexing.position -> Stdlib.in_channel -> resultval parse_file : string -> result