package reason

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

There are three main categories of error:

  • _lexer errors_, thrown by Reason_lexer when the source **text is malformed** and no token can be produced
  • _concrete parsing errors_, thrown by the menhir parser / parsing loop when a **token is unexpected**
  • _abstract parsing errors_, thrown by hand-written semantic actions or further AST checks, when the source text was incorrect but this restriction was too fine to be captured by the grammar rules
type lexing_error =
  1. | Illegal_character of char
  2. | Illegal_escape of string
  3. | Unterminated_comment of Ppxlib.Location.t
  4. | Unterminated_string
  5. | Unterminated_string_in_comment of Ppxlib.Location.t * Ppxlib.Location.t
  6. | Keyword_as_label of string
  7. | Invalid_literal of string
type ast_error =
  1. | Not_expecting of Ppxlib.Location.t * string
  2. | Other_syntax_error of string
  3. | Variable_in_scope of Ppxlib.Location.t * string
  4. | Applicative_path of Ppxlib.Location.t
type parsing_error = string
type reason_error =
  1. | Lexing_error of lexing_error
  2. | Parsing_error of parsing_error
  3. | Ast_error of ast_error
exception Reason_error of reason_error * Ppxlib.Location.t
val raise_error : reason_error -> Ppxlib.Location.t -> unit
val raise_fatal_error : reason_error -> Ppxlib.Location.t -> 'a
val recover_non_fatal_errors : (unit -> 'a) -> ('a, exn) Stdlib.result * (reason_error * Ppxlib.Location.t) list
val recover_parser_error : (Ppxlib.Location.t -> string -> 'a) -> Ppxlib.Location.t -> string -> 'a
val report_error : Stdlib.Format.formatter -> loc:Ppxlib.Location.t -> reason_error -> unit
val error_extension_node_from_recovery : Ppxlib.Location.t -> string -> string Ppxlib.Location.loc * Ppxlib.Parsetree.payload
val error_extension_node : Ppxlib.Location.t -> string -> string Ppxlib.Location.loc * Ppxlib.Parsetree.payload
OCaml

Innovation. Community. Security.