doc_modes.pl -- Analyse PlDoc mode declarations
This module analyzes the formal part of the documentation of a predicate. The formal part is processed by read_term/3 using the operator declarations in this module.
- process_modes(+Lines:lines, +Module, +FilePos, -Modes:list, -Args:list(atom), -RestLines:lines) is det
- Process the formal header lines (upto the first blank line), returning the remaining lines and the names of the arguments used in the various header lines.
- mode_lines(+Lines, -ModeText:codes, ?ModeTail:codes, -Lines) is det[private]
- Extract the formal header. For %%/%! comments these are all
lines starting with %%/%!. For /** comments, first skip empty
lines and then take all lines upto the first blank line.
Skipping empty lines allows for comments using this style:
/** * predicate(+arg1:type1, ?arg2:type2) is det ...
- modes(+Text:codes, +Module, +FilePos, -ModeDecls) is det[private]
- Read mode declaration. This consists of a number of Prolog terms which may or may not be closed by a Prolog full-stop.
- mode_syntax_error(+ErrorTerm) is det[private]
- Print syntax errors in mode declarations. Currently, this is
suppressed unless the flag
pldoc_errors
is specified. - prepare_module_operators is det[private]
- Import operators from current source module.
- public_operators(+Module, -List:list(op(Pri,Assoc,Name))) is det[private]
- List is the list of operators exported from Module through its module header.
- extract_varnames(+Bindings, -VarNames, ?VarTail) is det[private]
- Extract the variables names.
- compile_mode(+Mode, -Compiled) is det
- Compile a PlDoc mode declararion into a term
mode(Head, Determinism)
. - mode(:Head, ?Det) is nondet
- True if there is a mode-declaration for Head with Det.
- is_mode(@Head) is semidet
- True if Head is a valid mode-term.
- mode_indicator(?Ind:atom) is nondet
- Our defined argument-mode indicators
- modes_to_predicate_indicators(+Modes:list, -PI:list) is det
- Create a list of predicate indicators represented by Modes. Each predicate indicator is of the form atom/integer for normal predicates or atom//integer for DCG rules.
- compile_clause(:Term, +FilePos) is det
- Add a clause to the compiled program. Unlike assert/1, this associates the clause with the given source-location, makes it static code and removes the clause if the file is reloaded. Finally, as we create clauses one-by-one, we define our predicates as discontiguous.