Did you know ... Search Documentation:
prolog_format.pl -- Analyse format specifications
PublicShow source

This library parses the format specification used by format/1, format/2 and format/3. The parsed specification can be used to validate the consistency of the format string and the provided arguments. For example:

?- format_types('~d bottles of beer', Types).
Types = [integer].
author
- Michael Hendricks
See also
- http://www.swi-prolog.org/pack/list?p=format_spec
To be done
- The current implementation does not support format_predicate/2.
Source format_spec(+Format, -Spec:list) is det
Parse a format string. Each element of Spec is one of the following:
text(Text)
Text sent to the output as is
escape(Num, Colon, Action)
A format escape. Num represents the optional numeric portion of an esape. Colon represents the optional colon in an escape. Action is an atom representing the action to be take by this escape.
Source format_spec(-Spec)// is det
DCG for parsing format strings. It doesn't yet generate format strings from a spec. See format_spec/2 for details.
Source format_types(+Format:text, -Types:list) is det
True when Format requires an argument list with terms of the type specified by Types. The length of this list is the number of arguments required. Each value of Types is a type as described by has_type/2.
Source spec_types(+FormatSpec, -Types:list(type)) is det[private]
True if FormatSpec requires format/2 to have arguments of Types. Each value of Types is a type as described by has_type/2. This notion of types is compatible with library(mavis).
Source is_action(+Action:integer) is semidet[private]
is_action(-Action:integer) is multi[private]
True if Action is a valid format/2 action character. Iterates all acceptable action characters, if Action is unbound.
Source action_types(?Action:integer, ?Types:list(type))[private]
True if Action consumes arguments matching Types. An action (like ~), which consumes no arguments, has Types=[]. For example,
?- action_types(0'~, Types).
Types = [].
?- action_types(0'a, Types).
Types = [atom].