module Cudf_parser:sig..end
Parser for CUDF related documents
type cudf_parser
a CUDF parser opened on some input source
exception Parse_error of string * Cudf_types.loc
Error during parsing (syntax error, type error, ...). Arguments are error message and error location.
val from_in_channel : ?typedecl:Cudf_conf.stanza_typedecl ->
Stdlib.in_channel -> cudf_parsercreate a CUDF parser reading data from an input channel
typedecl : (initial) per-stanza and per-property type declarations to
be used while parsing. Default: Cudf_conf.stanza_typedeclval from_IO_in_channel : ?typedecl:Cudf_conf.stanza_typedecl -> IO.input -> cudf_parsercreate a CUDF parser reading data from an Extlib input channel
typedecl : (initial) per-stanza and per-property type declarations to
be used while parsing. Default: Cudf_conf.stanza_typedeclval from_file : ?typedecl:Cudf_conf.stanza_typedecl -> string -> cudf_parsercreate a CUDF parser reading data from a file
typedecl : as per Cudf_parser.from_in_channelval close : cudf_parser -> unitDispose a CUDF parser.
Afterwards, the parser should not be used any longer
"parse_*" functions offer plain syntax parsing, with no semantic interpretation of what is being parsed. "load_*" functions offer the latter, hence also checking for semantic constraints (such as the lack of key duplication).
All full parsing function are granted to raise only
Cudf_parser.Parse_error; finer grained exception are mapped to it.
val parse : cudf_parser ->
Cudf.preamble option * Cudf.package list * Cudf.request optionparse a CUDF document (or a universe) as a whole
Parse_error when an error during parsing is encountered (might be a
syntax error, a type error, ..)preamble, packages, request where preamble and request
are returned only if actually met in the parsed document. Note that a
document with no request part is not a valid CUDF document (but might still
be used to represent solver solutions, for instance).val load : cudf_parser ->
Cudf.preamble option * Cudf.universe * Cudf.request optionsame as Cudf_parser.parse, but additionally loads the package
list as an abstract Cudf.universe.
Note: to load compact universes (i.e. only containing package names,
versions, and installed status) that will be tested as solutions you should
use Cudf_parser.load_solution instead: the present function does not
expand missing metadata with respect to the initial status.
Parse_error as Cudf_parser.parse doesCudf.Constraint_violation as Cudf.load_universe doesval load_solution : cudf_parser ->
Cudf.universe -> Cudf.preamble option * Cudf.universeLoad a solution wrt to a given CUDF document, whose universe is given.
Solution format is as per Appendix B of CUDF 2.0 spec
Parse_error as Cudf_parser.parse doesval parse_from_file : ?typedecl:Cudf_conf.stanza_typedecl ->
string -> Cudf.preamble option * Cudf.package list * Cudf.request optionShorthand: parse a file given its name
val load_from_file : ?typedecl:Cudf_conf.stanza_typedecl ->
string -> Cudf.preamble option * Cudf.universe * Cudf.request optionShorthand: load from a file given its name
val load_solution_from_file : string -> Cudf.universe -> Cudf.preamble option * Cudf.universeShorthand: load a solution from a file given its name
val parse_item : cudf_parser -> Cudf.cudf_itemParse the next information item (either a package description, a user request, or a preamble) from the given input channel.
Beware that parsing is stateful; in particular when the preamble is parsed, the list of allowed properties for future package stanzas is internally updated.
The following parsing function usually raise fine grained exceptions such
as Cudf_types.Syntax_error and Cudf_types.Type_error.
typeloc_map =(string * Cudf_types.loc) list
val parse_stanza : cudf_parser -> loc_map * string Cudf_types.stanzaParse a file stanza (i.e., a RFC822-like stanza, with the notable simplification that all field/value pairs are one-liners). Strip any heading blanks lines leading to the first available field/value pair.
End_of_file if no other stanza is available due to reached EOFCudf_types.Syntax_error when a syntax error is encounteredval type_check_stanza : ?locs:loc_map ->
string Cudf_types.stanza ->
Cudf_types.typedecl -> Cudf_types.typed_value Cudf_types.stanzaType check an untyped stanza according to a given set of type declarations. Also take care of default values, adding missing properties where needed; fail if a required property is missing.
Syntax_error if a property does not match its declared type; this
exception is also raised when an undeclared property is encounteredType_error when a property has a value of the wrong type