package catala

  1. Overview
  2. Docs
Compiler and library for the literate programming language for tax code specification

Install

dune-project
 Dependency

Authors

Maintainers

Sources

1.0.0-alpha.tar.gz
md5=2615968670ac21b1d00386a9b04b3843
sha512=eff292fdd75012f26ce7b17020f5a8374eef37cd4dd6ba60338dfbe89fbcad3443d1b409e44c182b740da9f58dff7e76dcb8ddefe47f9b2b160666d1c6930143

doc/catala.catala_utils/Catala_utils/Message/index.html

Module Catala_utils.MessageSource

Interface for emitting compiler messages.

All messages are expected to use the Format module. Flush, "@?", "@.", "%!" etc. are not supposed to be used outside of this module.

WARNING: this module performs side-effects at load time, adding support for ocolor tags (e.g. "@{<blue>text@}") to the standard string formatter used by e.g. Format.sprintf. (In this case, the tags are ignored, for color output you should use the functions of this module that toggle support depending on cli flags and terminal support).

Message content

Sourcetype level =
  1. | Error
  2. | Warning
  3. | Debug
  4. | Log
  5. | Result
Sourcemodule Content : sig ... end

This functions emits the message according to the emission type defined by Cli.message_format_flag.

Error exceptions

Sourceexception CompilerError of Content.t
Sourceexception CompilerErrors of Content.t list
Sourcetype lsp_error_kind =
  1. | Lexing
  2. | Parsing
  3. | Typing
  4. | Generic
  5. | Warning
  6. | AssertFailure
Sourcetype lsp_error = {
  1. kind : lsp_error_kind;
  2. message : Content.message;
  3. pos : Pos.t option;
  4. suggestion : string list option;
}
Sourceval register_lsp_error_notifier : (lsp_error -> unit) -> unit
Sourceval register_lsp_error_absorber : (lsp_error -> bool) -> unit

The raised error is absorbed if the hook returns false

Some formatting helpers

Sourceval unformat : (Format.formatter -> unit) -> string

Converts f to a string, discarding formatting and skipping newlines and indents

Sourceval has_color : out_channel -> bool
Sourceval set_terminal_width_function : (unit -> int) -> unit
Sourceval terminal_columns : unit -> int
Sourceval pad : int -> string -> Format.formatter -> unit

Prints the given character the given number of times (assuming it is of width 1)

Sourceval std_ppf : unit -> Format.formatter
Sourceval err_ppf : unit -> Format.formatter
Sourceval ignore_ppf : unit -> Format.formatter
Sourceval formatter_of_out_channel : ?nocolor:bool -> out_channel -> unit -> Format.formatter

Creates a new formatter from the given out channel, with correct handling of the ocolor tags. Actual use of escape codes in the output depends on Cli.style_flag -- and wether the channel is a tty if that is set to auto.

Simple interface for various message emission

Sourcetype ('a, 'b) emitter = ?header:Content.message -> ?internal:bool -> ?pos:Pos.t -> ?pos_msg:Content.message -> ?extra_pos:(string * Pos.t) list -> ?fmt_pos:(Content.message * Pos.t) list -> ?outcome:Content.message list -> ?suggestion:string list -> ('a, Format.formatter, unit, 'b) format4 -> 'a
Sourceval log : ('a, unit) emitter
Sourceval debug : ('a, unit) emitter
Sourceval result : ('a, unit) emitter
Sourceval warning : ('a, unit) emitter
Sourceval error : ?kind:lsp_error_kind -> ('a, 'exn) emitter
Sourceval results : ?title:string -> Content.message list -> unit

Multiple errors

Sourceval with_delayed_errors : ?stop_on_error:bool -> (unit -> 'a) -> 'a

with_delayed_errors ?stop_on_error f calls f and registers each error triggered using delayed_error. stop_on_error defaults to Global.options.stop_on_error.

  • raises CompilerError

    on the first error encountered when the stop_on_error flag is set.

Sourceval delayed_error : ?kind:lsp_error_kind -> 'b -> ('a, 'b) emitter