package merlin-lib

  1. Overview
  2. Docs
Merlin's libraries

Install

Dune Dependency

Authors

Maintainers

Sources

merlin-5.3-502.tbz
sha256=2cea46f12397fa6e31ef0c0d4f5e11c1cfd916ee49420694005c95ebb3aa24bc
sha512=e94abb9ae38149245337db033e2c3891c7ec772168e99abf1bda0216a894c0854e7170b56fe88eba83ec98f2ebc0f5c7c723e8db14f59eeb6dd348bec12c6d62

doc/merlin-lib.utils/Merlin_utils/Marg/index.html

Module Merlin_utils.MargSource

Argument parsing library which fold over arguments

Specifications of arguments is split in two passes:

  • _ table for parsing global arguments (compiler flags, merlin configuration)
  • a (string * _ t) for parsing command local arguments
Sourcetype 'acc t = string list -> 'acc -> string list * 'acc

Action associated to a flag updating a state of type 'acc. It takes a list of arguments and either succeeds returning untouched arguments or fails raising an exception.

Sourcetype 'acc table = (string, 'acc t) Hashtbl.t

A table mapping a flag to the corresponding action

Combinators for building actions

Sourceval unit : ('acc -> 'acc) -> 'acc t

Action updating state and not consuming any argument

Sourceval param : string -> (string -> 'acc -> 'acc) -> 'acc t

Action consuming a single argument

Sourceval bool : (bool -> 'acc -> 'acc) -> 'acc t

Action consuming a boolean argument

Sourceval int : (int -> 'acc -> 'acc) -> 'acc t

Action consuming an integer argument

Sourceval unit_ignore : 'acc t

Action doing nothing

Sourceval param_ignore : 'acc t

Action doing nothing and dropping one argument

Parsing of argument lists

Sourcetype docstring = string
Sourcetype 'a spec = string * docstring * 'a t
Sourceval parse_one : warning:(string -> unit) -> 'global table -> 'local spec list -> string list -> 'global -> 'local -> (string list * 'global * 'local) option

Consume at most one flag from the list, returning updated state or None in case of failure. Warning function is called with an error message in case of incorrect use.

Sourceval parse_all : warning:(string -> unit) -> 'global table -> 'local spec list -> string list -> 'global -> 'local -> 'global * 'local

Consume all arguments from the input list, calling warning for incorrect ones and resuming parsing after.

OCaml

Innovation. Community. Security.