Up

module Cudf_types_pp

: sig

CUDF type library: parsing and pretty printing

Implement parsing and pretty printing of CUDF types (see CUDF spec. ยง2.2.2).

For the actual CUDF type definition see Cudf_types.

For pretty printing of macro-components see Cudf_printer.

Errors
#
exception Type_error of Cudf_types.typ * Cudf_types.typed_value
Parsers
Public types

All parsing function are granted to raise only Cudf_types_pp.Type_error, lower lever exception (e.g. syntax errors) are wrapped into it

#
val parse_int : string -> int
#
val parse_posint : string -> int
#
val parse_nat : string -> int
#
val parse_bool : string -> bool
#
val parse_string : string -> string
#
val parse_pkgname : string -> Cudf_types.pkgname
#
val parse_ident : string -> string
#
val parse_enum : enums:string list -> string -> string
#
val parse_vpkg : string -> Cudf_types.vpkg
#
val parse_vpkglist : string -> Cudf_types.vpkglist
#
val parse_vpkgformula : string -> Cudf_types.vpkgformula
#
val parse_veqpkg : string -> Cudf_types.veqpkg
#
val parse_veqpkglist : string -> Cudf_types.veqpkglist
#
val parse_typedecl : string -> Cudf_types.typedecl
Parsing of other CUDF entities

Mostly for application relying on CUDF conventions

#
val parse_qstring : string -> string

Parse a quoted string, enclosed by double quotes as it happens within the "property" property of preamble stanzas. The only place where such strings are allowed in CUDF are within type declarations; see Cudf_types_pp.parse_typedecl.

Returns the parsed string after having resolved escaping and removed surrounding double quotes
Raises Cudf_types.Syntax_error when the quoted string cannot be parsed
#
val parse_type : string -> Cudf_types.typ

Parse a CUDF type expression.

At present it can be either a typename or an enum with its values.

Raises Cudf_types.Syntax_error when the given string is not a valid type expression
#
val parse_keep : string -> Cudf_types.enum_keep

Parse the enum value corresponding to the "keep" core property of package stanzas. Shorthand to avoid parsing the corresponding `Enum and then casting to Cudf_types.enum_keep

#
val parse_value : Cudf_types.typ -> string -> Cudf_types.typed_value

generic, type-based parsing

Pretty printers
Pretty print to string
#
val string_of_int : int -> string
#
val string_of_posint : int -> string
#
val string_of_nat : int -> string
#
val string_of_bool : bool -> string
#
val string_of_keep : Cudf_types.enum_keep -> string
#
val string_of_pkgname : Cudf_types.pkgname -> string
#
val string_of_version : Cudf_types.version -> string
#
val string_of_vpkg : Cudf_types.vpkg -> string
#
val string_of_vpkglist : Cudf_types.vpkglist -> string
#
val string_of_vpkgformula : Cudf_types.vpkgformula -> string
#
val string_of_veqpkg : Cudf_types.veqpkg -> string
#
val string_of_veqpkglist : Cudf_types.veqpkglist -> string
#
val string_of_typedecl : Cudf_types.typedecl -> string
#
val string_of_type : Cudf_types.typ -> string
#
val string_of_value : Cudf_types.typed_value -> string
end