package opam-file-format

  1. Overview
  2. Docs

Defines the types for the opam format lexer and parser

type relop = [
  1. | `Eq
    (*

    =

    *)
  2. | `Neq
    (*

    !=

    *)
  3. | `Geq
    (*

    >=

    *)
  4. | `Gt
    (*

    >

    *)
  5. | `Leq
    (*

    <=

    *)
  6. | `Lt
    (*

    <

    *)
]

Relational operators

type logop = [
  1. | `And
    (*

    &

    *)
  2. | `Or
    (*

    |

    *)
]

Logical operators

type pfxop = [
  1. | `Not
    (*

    !

    *)
  2. | `Defined
    (*

    ?

    *)
]

Prefix operators

type file_name = string
type pos = file_name * int * int

Source file positions: (filename, line, column)

type env_update_op =
  1. | Eq
    (*

    =

    *)
  2. | PlusEq
    (*

    +=

    *)
  3. | EqPlus
    (*

    =+

    *)
  4. | ColonEq
    (*

    :=

    *)
  5. | EqColon
    (*

    =:

    *)
  6. | EqPlusEq
    (*

    =+=

    *)

Environment variable update operators

type value =
  1. | Bool of pos * bool
    (*

    bool atoms

    *)
  2. | Int of pos * int
    (*

    int atoms

    *)
  3. | String of pos * string
    (*

    string atoms

    *)
  4. | Relop of pos * relop * value * value
    (*

    Relational operators with two values (e.g. os != "win32")

    *)
  5. | Prefix_relop of pos * relop * value
    (*

    Relational operators in prefix position (e.g. < "4.07.0")

    *)
  6. | Logop of pos * logop * value * value
    (*

    Logical operators

    *)
  7. | Pfxop of pos * pfxop * value
    (*

    Prefix operators

    *)
  8. | Ident of pos * string
    (*

    Identifiers

    *)
  9. | List of pos * value list
    (*

    Lists of values ([x1 x2 ... x3])

    *)
  10. | Group of pos * value list
    (*

    Groups of values ((x1 x2 ... x3))

    *)
  11. | Option of pos * value * value list
    (*

    Value with optional list (x1 {x2 x3 x4})

    *)
  12. | Env_binding of pos * value * env_update_op * value
    (*

    Environment variable binding (FOO += "bar")

    *)

Base values

type opamfile_section = {
  1. section_kind : string;
    (*

    Section kind (e.g. extra-source)

    *)
  2. section_name : string option;
    (*

    Section name (e.g. "myfork.patch")

    *)
  3. section_items : opamfile_item list;
    (*

    Content of the section

    *)
}

An opamfile section

and opamfile_item =
  1. | Section of pos * opamfile_section
    (*

    e.g. kind ["name"] { ... }

    *)
  2. | Variable of pos * string * value
    (*

    e.g. opam-version: "2.0"

    *)

An opamfile is composed of sections and variable definitions

type opamfile = {
  1. file_contents : opamfile_item list;
    (*

    Content of the file

    *)
  2. file_name : file_name;
    (*

    Name of the disk file this record was loaded from

    *)
}

A file is a list of items and the filename

OCaml

Innovation. Community. Security.