module OpamFormat: sig
.. end
Format of OPAM configuration files.
val empty : OpamTypes.file
The empty file
val map : (string -> OpamTypes.value -> (string * OpamTypes.value) option) ->
OpamTypes.file -> OpamTypes.file
map a file
val variables : OpamTypes.file_item list -> (string * OpamTypes.value) list
Get all the variable definitions from a list of items
val sections : OpamTypes.file_item list -> (string * OpamTypes.file_section) list
Get all the sections from a list of items
val is_valid : OpamTypes.file_item list -> string list -> bool
Check whether a list of items contains only valid variable definitions
val invalid_fields : OpamTypes.file_item list -> string list -> string list
Find all the invalid fields
Parsing functions
exception Bad_format of string
All the following parsing function raise Bad_format
in case the
input does not have the right format.
val bad_format : ('a, unit, string, 'b) Pervasives.format4 -> 'a
Raise Bad_format
.
val parse_bool : OpamTypes.value -> bool
Parse a boolean
val parse_int : OpamTypes.value -> int
Parse an integer
val parse_ident : OpamTypes.value -> string
Parse an ident
val parse_symbol : OpamTypes.value -> string
Parse a symbol
val parse_string : OpamTypes.value -> string
Parse a string
val parse_list : (OpamTypes.value -> 'a) -> OpamTypes.value -> 'a list
Parse a list of 'things'
val parse_list_list : (OpamTypes.value -> 'a) -> OpamTypes.value -> 'a list
Parse a list of list of 'things'
val parse_group : (OpamTypes.value -> 'a) -> OpamTypes.value -> 'a list
Parse a group of 'things'
val parse_option : (OpamTypes.value -> 'a) ->
(OpamTypes.value list -> 'b) -> OpamTypes.value -> 'a * 'b option
Parse a value and its option of 'things'
val parse_single_option : (OpamTypes.value -> 'a) ->
(OpamTypes.value -> 'b) -> OpamTypes.value -> 'a * 'b option
Parse a value and a single optional value
val parse_string_option : (OpamTypes.value list -> 'a) -> OpamTypes.value -> string * 'a option
Parse a string with an optional argument
val parse_string_list : OpamTypes.value -> string list
Parse a list of strings
val parse_single_string : OpamTypes.value list -> string
Parse a single string
val parse_pair : (OpamTypes.value -> 'a) ->
(OpamTypes.value -> 'b) -> OpamTypes.value -> 'a * 'b
Parse a pair of strings
val parse_or : (string * (OpamTypes.value -> 'a)) list -> OpamTypes.value -> 'a
Try to parse the value using function from the list. All the
parsing functions are tried until one succeeds. The first argument
is a debug message.
val parse_sequence : (string * (OpamTypes.value -> 'a)) list -> OpamTypes.value -> 'a list
Parse a sequence of values
Creation functions
val make_bool : bool -> OpamTypes.value
Create a boolean
val make_int : int -> OpamTypes.value
Create an integer
val make_ident : string -> OpamTypes.value
Create an ident
val make_symbol : string -> OpamTypes.value
Create a symbol
val make_string : string -> OpamTypes.value
Create a string
val make_list : ('a -> OpamTypes.value) -> 'a list -> OpamTypes.value
Create a list of 'things'
val make_string_list : string list -> OpamTypes.value
Create a list of strings
val make_group : ('a -> OpamTypes.value) -> 'a list -> OpamTypes.value
Create a group of 'things'
val make_option : ('a -> OpamTypes.value) ->
('b -> OpamTypes.value list) -> 'a * 'b option -> OpamTypes.value
Create a value and its optional arguments
val make_pair : ('a -> OpamTypes.value) ->
('b -> OpamTypes.value) -> 'a * 'b -> OpamTypes.value
Create a pair
val make_string_pair : string * string -> OpamTypes.value
Create a pair of strings
Printing functions
val string_of_value : OpamTypes.value -> string
Print a value
val string_of_values : OpamTypes.value list -> string
Print a list of values
type
indent_variable = string -> bool
When folding recursively a value Variable (s, v)
for printing,
we check if we indent the first encountered list below v
(i.e. in case indent_variable s
is true
).
val string_of_item : simplify:bool ->
?indent_variable:indent_variable ->
OpamTypes.file_item -> string option
Print an file_item
val string_of_items : simplify:bool ->
?indent_variable:indent_variable ->
OpamTypes.file_item list -> string
Print a list of items
val string_of_file : simplify:bool ->
?indent_variable:indent_variable -> OpamTypes.file -> string
Print a file
Finding functions
val assoc : OpamTypes.file_item list -> string -> (OpamTypes.value -> 'a) -> 'a
Get the value of a field
val assoc_option : OpamTypes.file_item list -> string -> (OpamTypes.value -> 'a) -> 'a option
Get the value of a field. If the field does not exist, return
None
val assoc_default : 'a -> OpamTypes.file_item list -> string -> (OpamTypes.value -> 'a) -> 'a
Get the value of a field. If the variable does not exist, return a
default value
val assoc_list : OpamTypes.file_item list -> string -> (OpamTypes.value -> 'a list) -> 'a list
Get the value associated to a variable. If the variable does not
exists, return []
val assoc_string_list : OpamTypes.file_item list -> string -> string list
Get the string list associated to a variable. If the variable does
not exist, return []
val get_section_by_kind : OpamTypes.file_item list -> string -> OpamTypes.file_section
Get one section of a certain kind
val get_all_section_by_kind : OpamTypes.file_item list -> string -> OpamTypes.file_section list
Get all the sections of a certain kind
val assoc_sections : OpamTypes.file_item list ->
string -> (OpamTypes.file_section -> 'a) -> 'a list
Get sections
This section is dedicated to the parsing and creatin of dependency
and conflict formaulas. It's maybe easier to do that directly in
the parser ...
val parse_formula : OpamTypes.value -> OpamTypes.formula
Parse package formula where AND are implicit: x y -> x & y
val make_formula : OpamTypes.formula -> OpamTypes.value
Build a formula where AND are implicit.
val parse_opt_formula : OpamTypes.value -> OpamTypes.formula
Parse optional package formula where OR are implicit: x y -> x | y
val make_opt_formula : OpamTypes.formula -> OpamTypes.value
Build a formula where OR are implicit.
val parse_compiler_constraint : OpamTypes.value -> OpamTypes.compiler_constraint
Parse compiler constraints
val make_compiler_constraint : OpamTypes.compiler_constraint -> OpamTypes.value
Build a compiler constraint
val parse_os_constraint : OpamTypes.value -> (bool * string) OpamTypes.generic_formula
Parse an OS constraint
val make_os_constraint : (bool * string) OpamTypes.generic_formula -> OpamTypes.value
Build an OS constraint
Environment variables
val parse_env_variable : OpamTypes.value -> string * string * string
Parsing
val make_env_variable : string * string * string -> OpamTypes.value
Making
filter expressions
val parse_filter : OpamTypes.value list -> OpamTypes.filter
Parsing
val make_filter : OpamTypes.filter -> OpamTypes.value list
Creation
val parse_command : OpamTypes.value -> OpamTypes.command
Parse a command
val make_command : OpamTypes.command -> OpamTypes.value
Create a command
val parse_commands : OpamTypes.value -> OpamTypes.command list
Parse a list of commands
val make_commands : OpamTypes.command list -> OpamTypes.value
Create a list of commands
val parse_messages : OpamTypes.value -> (string * OpamTypes.filter option) list
Parse a list of commands
val parse_tags : OpamTypes.value -> OpamTypes.tags
Parse tags
val make_tags : OpamTypes.tags -> OpamTypes.value
Make tags