package catala

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

File names ; equal to File.t but let's avoid cyclic dependencies

type raw_file

A file name that has not yet been resolved, options.path_rewrite must be called on it

type backend_lang =
  1. | En
  2. | Fr
  3. | Pl
type when_enum =
  1. | Auto
  2. | Always
  3. | Never

The usual auto/always/never option argument

type message_format_enum =
  1. | Human
  2. | GNU
    (*

    Format of error and warning messages output by the compiler.

    *)
type input_src =
  1. | FileName of file
    (*

    A file path to read from disk

    *)
  2. | Contents of string * file
    (*

    A raw string containing the code, and the corresponding (fake) filename

    *)
  3. | Stdin of file
    (*

    Read from stdin; the specified filename will be used for file lookups, error reportings, etc.

    *)

Sources for program input

val languages : (string * backend_lang) list
val language_code : backend_lang -> string

Returns the lowercase two-letter language code

val file_lang : file -> backend_lang

Associates a file extension with its corresponding Cli.backend_lang string representation.

val input_src_file : input_src -> file
val reverse_path : ?from_dir:file -> to_dir:file -> file -> file

If to_dir is a path to a given directory and f a path to a file as seen from absolute path from_dir, reverse_path ~from_dir ~to_dir f is a path leading to f from to_dir. The results attempts to be relative to to_dir.

Configuration globals

type options = private {
  1. mutable input_src : input_src;
  2. mutable language : backend_lang option;
  3. mutable debug : bool;
  4. mutable color : when_enum;
  5. mutable message_format : message_format_enum;
  6. mutable trace : bool;
  7. mutable plugins_dirs : string list;
  8. mutable disable_warnings : bool;
  9. mutable max_prec_digits : int;
  10. mutable path_rewrite : raw_file -> file;
}

Global options, common to all subcommands (note: the fields are internally mutable only for purposes of the globals toplevel value defined below)

val globals : options

A global definition to the global options is provided for convenience, e.g. choosing the proper output in formatting functions. Prefer the use of the options returned by the command-line parsing whenever possible.

val enforce_globals : ?input_src:input_src -> ?language:backend_lang option -> ?debug:bool -> ?color:when_enum -> ?message_format:message_format_enum -> ?trace:bool -> ?plugins_dirs:string list -> ?disable_warnings:bool -> ?max_prec_digits:int -> ?path_rewrite:(file -> file) -> unit -> options

Sets up the global options (side-effect); for specific use-cases only, this should never be called from the compiler or when going through normal command-line parsing. Proper uses include setting up the compiler library when using it directly through a specific front-end.

CLI flags and options

module Flags : sig ... end

Command-line application

val version : string
val s_plugins : string

Manpage section name for the installed plugins

exception Exit_with of int

Exit with a specific exit code (but less brutally than Sys.exit which would bypass all finalisers)