# Module OpamFormat

    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 OpamTypes.pos option * string list * string

All the following parsing function raise `Bad_format` in case the input does not have the right format.

    val bad_format : ?pos:OpamTypes.pos -> ('a, unit, string, 'b) Pervasives.format4 -> 'a

Raise `Bad_format`.

    val add_pos : OpamTypes.pos -> exn -> exn

Adds a position to a Bad_format exception if it doesn't have one yet

    val value_pos : OpamTypes.value -> OpamTypes.pos

Get the position out of a value

    val values_pos : OpamTypes.value list -> OpamTypes.pos option

Get the position of the first element out of a value list

    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_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.

## 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_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

    val make_section : OpamTypes.file_section -> OpamTypes.file_item

Create a file section

    val make_variable : string * OpamTypes.value -> OpamTypes.file_item

Create a variable

## 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

    val string_of_file : simplify:bool ->
           indent:bool -> ?ignore:string list -> 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

## Formula

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_package_name : OpamTypes.value -> OpamTypes.name

    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_ext_formula : OpamTypes.value -> OpamTypes.ext_formula

Parse an AND formula where constraints are extended with leading keywords

    val make_ext_formula : OpamTypes.ext_formula -> OpamTypes.value

Make an AND formula where constraints are extended with leading keywords

    val parse_opt_formula : OpamTypes.value -> OpamTypes.ext_formula

Parse optional package formula where OR are implicit: `x y -> x | y`

    val make_opt_formula : OpamTypes.ext_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 make_libraries : (string * OpamTypes.filter option) list -> OpamTypes.value

Create a list of libraries/syntax

    val parse_libraries : OpamTypes.value -> (string * OpamTypes.filter option) list

Parse a list of libraries/syntax

    val make_flag : OpamTypes.package_flag -> OpamTypes.value

Create a package flag

    val parse_flag : OpamTypes.value -> OpamTypes.package_flag option

Parse a package flag

## Tags

    val parse_tags : OpamTypes.value -> OpamTypes.tags

Parse tags

    val make_tags : OpamTypes.tags -> OpamTypes.value

Make tags