package touist

  1. Overview
  2. Docs

This is where the compiler errors are managed.

We call a 'message' an error or a warning. Two cases for displaying the errors:

  • either one of the parse/eval/smt/sat function will raise the TouistFatal exception. In this case, after the exception is catched, you can run print_msgs.
  • or no fatal error has been encoundered; if you want to display the errors, you can run print_msgs.

Rules for good error or warning messages:

  • a message must always end with a newline
  • use a new line (\n) only when the line break is mandatory for understanding. The text will be wrapped automatically.
  • use indentations for pieces of code you want to show: the indentation will be kept when wrapping as long as no \n is encountered. Indented text is colored.
  • the text in simple quote '...' or backquotes `...` is colored
type msg_type =
  1. | Error
  2. | Warning
type during =
  1. | Usage
  2. | Parse
  3. | Lex
  4. | Eval
  5. | Sat
  6. | Cnf
  7. | Prenex
type loc = Stdlib.Lexing.position * Stdlib.Lexing.position
type msg = msg_type * during * string * loc option
exception TouistFatal of msg
val string_of_loc : ?fmt:string -> loc -> string
val string_of_msg : ?width:int -> ?color:bool -> ?fmt:string -> msg -> string
val string_of_type : msg_type -> string
val string_of_during : during -> string
val get_loc : loc -> int * int * int * int

get_loc translates a 'loc' to an understandable tuple that contains (num_line, num_col, token_start, token_end).

Give errors

val warn : msg -> unit
val fatal : msg -> 'a

Change the error formatting

val wrap_width : int Stdlib.ref
val format : string Stdlib.ref
val loc_format : string Stdlib.ref
val color : bool Stdlib.ref
val discard_warnings : bool Stdlib.ref
OCaml

Innovation. Community. Security.