123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154(**************************************************************************)(* *)(* Copyright 2012-2020 OCamlPro *)(* Copyright 2012 INRIA *)(* *)(* All rights reserved. This file is distributed under the terms of the *)(* GNU Lesser General Public License version 2.1, with the special *)(* exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(** Defines the types for the opam format lexer and parser *)(** Type definitions used by the legacy and the new full position modules *)(** Relational operators *)typerelop=[`Eq(** [=] *)|`Neq(** [!=] *)|`Geq(** [>=] *)|`Gt(** [>] *)|`Leq(** [<=] *)|`Lt(** [<] *)](** Logical operators *)typelogop=[`And(** [&] *)|`Or(** [|] *)](** Prefix operators *)typepfxop=[`Not(** [!] *)|`Defined(** [?] *)]typefile_name=string(** Source file positions: [(filename, line, column)] *)typepos=file_name*int*int(** Environment variable update operators *)typeenv_update_op=Eq(** [=] *)|PlusEq(** [+=] *)|EqPlus(** [=+] *)|ColonEq(** [:=] *)|EqColon(** [=:] *)|EqPlusEq(** [=+=] *)(** [OpamParserTypes] transitional module with full position types *)moduleFullPos=struct(** Source file positions *)typefile_name=string(** Full position *)typepos={filename:file_name;start:int*int;(* line, column *)stop:int*int;(* line, column *)}(** [with_pos] type, used for all units, embedding the element [pelem] ans
its position [pos] *)type'awith_pos={pelem:'a;pos:pos}typerelop_kind=reloptyperelop=relop_kindwith_postypelogop_kind=logoptypelogop=logop_kindwith_postypepfxop_kind=pfxoptypepfxop=pfxop_kindwith_postypeenv_update_op_kind=env_update_optypeenv_update_op=env_update_op_kindwith_pos(** Base values *)typevalue_kind=|Boolofbool(** [bool] atoms *)|Intofint(** [int] atoms *)|Stringofstring(** [string] atoms *)|Relopofrelop*value*value(** Relational operators with two values (e.g. [os != "win32"]) *)|Prefix_relopofrelop*value(** Relational operators in prefix position (e.g. [< "4.07.0"]) *)|Logopoflogop*value*value(** Logical operators *)|Pfxopofpfxop*value(** Prefix operators *)|Identofstring(** Identifiers *)|Listofvaluelistwith_pos(** Lists of values ([[x1 x2 ... x3]]) *)|Groupofvaluelistwith_pos(** Groups of values ([(x1 x2 ... x3)]) *)|Optionofvalue*valuelistwith_pos(** Value with optional list ([x1 {x2 x3 x4}]) *)|Env_bindingofvalue*env_update_op*value(** Environment variable binding ([FOO += "bar"]) *)andvalue=value_kindwith_pos(** An opamfile section *)typeopamfile_section={section_kind:stringwith_pos;(** Section kind
(e.g. [extra-source]) *)section_name:stringwith_posoption;(** Section name
(e.g. ["myfork.patch"]) *)section_items:opamfile_itemlistwith_pos;(** Content of the section *)}(** An opamfile is composed of sections and variable definitions *)andopamfile_item_kind=|Sectionofopamfile_section(** e.g. [kind ["name"] { ... }] *)|Variableofstringwith_pos*value(** e.g. [opam-version: "2.0"] *)andopamfile_item=opamfile_item_kindwith_pos(** A file is a list of items and the filename *)typeopamfile={file_contents:opamfile_itemlist;(** Content of the file *)file_name:file_name;(** Name of the disk file this record was
loaded from *)}endtypevalue=|Boolofpos*bool|Intofpos*int|Stringofpos*string|Relopofpos*relop*value*value|Prefix_relopofpos*relop*value|Logopofpos*logop*value*value|Pfxopofpos*pfxop*value|Identofpos*string|Listofpos*valuelist|Groupofpos*valuelist|Optionofpos*value*valuelist|Env_bindingofpos*value*env_update_op*valuetypeopamfile_section={section_kind:string;section_name:stringoption;section_items:opamfile_itemlist}andopamfile_item=|Sectionofpos*opamfile_section|Variableofpos*string*valuetypeopamfile={file_contents:opamfile_itemlist;file_name:file_name;}