doc support

This commit is contained in:
Vítor Santos Costa
2014-04-21 11:14:18 +01:00
parent 83ec7d9072
commit 137f69ed22
19 changed files with 1476 additions and 647 deletions

View File

@@ -2,6 +2,8 @@
@node Built-ins, Library, Modules, Top
@chapter Built-In Predicates Library
@menu
Built-ins, Debugging, Syntax, Top
@@ -13,7 +15,7 @@ Built-ins, Debugging, Syntax, Top
* Predicates on Characters:: Manipulating Characters
* Comparing Terms:: Comparison of Terms
* Arithmetic:: Arithmetic in YAP
* I/O:: Input/Output with YAP
* Input/Output:: Input/Output with YAP
* Database:: Modifying Prolog's Database
* Sets:: Finding All Possible Solutions
* Grammars:: Grammar Rules
@@ -30,7 +32,7 @@ Built-ins, Debugging, Syntax, Top
@end menu
@node Control, Undefined Procedures, , Top
@chapter Control Predicates
@section Control Predicates
This chapter describes the predicates for controlling the execution of
@@ -696,7 +698,7 @@ Translates a message-term into a string object. Primarily intended for SWI-Prolo
@end table
@node Testing Terms, Predicates on Atoms, Messages, Top
@chapter Predicates on terms
@section Predicates on terms
@table @code
@@ -1194,8 +1196,7 @@ the call.
@item digit(@var{Weight})
@var{Char} is a digit with value
@var{Weight}. I.e. @code{char_type(X, digit(6))} yields @code{X =
'6'}. Useful for parsing numbers.
@var{Weight}. I.e. @code{char_type(X, digit(6))} yields @code{X = '6'}. Useful for parsing numbers.
@item xdigit(@var{Weight})
@var{Char} is a hexa-decimal digit with value @var{Weight}. I.e. char_type(a, xdigit(X) yields X = '10'. Useful for parsing numbers.
@@ -1412,9 +1413,21 @@ of length @var{S}.
@end table
@node Arithmetic, I/O, Comparing Terms, Top
@node Arithmetic, Input/Output, Comparing Terms, Top
@section Arithmetic
@ifplaintext
@copydoc arithmetic
See @ref arithmetic_preds for the predicates that implement arithment
See @ref arithmetic_cmps for the arithmetic comparisons supported in YAP
See @ref arithmetic_operators for how to call arithmetic operations in YAP
@end ifplaintext
@texinfo
YAP now supports several different numeric types:
@table @code
@@ -1440,7 +1453,8 @@ YAP now supports several different numeric types:
numbers that are returned from is/2 are canonical, which means M
is positive and N and M have no common divisors. Rational numbers
are introduced in the computation using the rational/1,
rationalize/1 or the rdiv/2 (rational division) function.
rationalize/1 or the
rdiv/2 (rational division) function.
@item float
Floating point numbers are represented using the C-type double. On most today platforms these are 64-bit IEEE floating point numbers.
@@ -1491,8 +1505,7 @@ Integer remainder, similar to @code{mod} but always has the same sign
@code{X}.
@item @var{X} div @var{Y} [ISO]
Integer division, as if defined by @code{(@var{X} - @var{X} mod @var{Y})
// @var{Y}}.
Integer division, as if defined by @code{(@var{X} - @var{X} mod @var{Y})// @var{Y}}.
@item exp(@var{X}) [ISO]
Natural exponential.
@@ -1767,6 +1780,7 @@ The primitive YAP predicates involving arithmetic expressions are:
@table @code
@itemize
@item @var{X} is +@var{Y} [2]
@findex is/2
@syindex is/2
@@ -1780,6 +1794,7 @@ X is 2+3*4
@end example
@noindent
succeeds with @code{X = 14}.
@end itemize
@item +@var{X} < +@var{Y} [ISO]
@findex </2
@@ -1852,7 +1867,6 @@ will be thrown back to the top-level.
The following predicates provide counting:
@table @code
@item between(+@var{Low}, +@var{High}, ?@var{Value})
@findex between/3
@syindex between/3
@@ -1907,13 +1921,16 @@ The following predicates provide counting:
@cnindex isinf/1
True if floating point expression @var{Float} evaluates to infinity.
@end table
@node I/O, Database, Arithmetic, Top
@chapter I/O Predicates
@end texinfo
Some of the I/O predicates described below will in certain conditions
@node Input/Output, Database, Arithmetic, Top
@section Input/Output Predicates
Some of the Input/Output predicates described below will in certain conditions
provide error messages and abort only if the file_errors flag is set.
If this flag is cleared the same predicates will just fail. Details on
setting and clearing this flag are given under 7.7.
@@ -1923,16 +1940,16 @@ setting and clearing this flag are given under 7.7.
Subnodes of Input/Output
* Streams and Files:: Handling Streams and Files
* C-Prolog File Handling:: C-Prolog Compatible File Handling
* I/O of Terms:: Input/Output of terms
* I/O of Characters:: Input/Output of Characters
* I/O for Streams:: Input/Output using Streams
* C-Prolog to Terminal:: C-Prolog compatible Character I/O to terminal
* I/O Control:: Controlling your Input/Output
* Input/Output of Terms:: Input/Output of terms
* Input/Output of Characters:: Input/Output of Characters
* Input/Output for Streams:: Input/Output using Streams
* C-Prolog to Terminal:: C-Prolog compatible Character Input/Output to terminal
* Input/Output Control:: Controlling your Input/Output
* Sockets:: Using Sockets from YAP
@end menu
@node Streams and Files, C-Prolog File Handling, , I/O
@node Streams and Files, C-Prolog File Handling, , Input/Output
@section Handling Streams and Files
@table @code
@@ -2002,7 +2019,7 @@ wide character and encoding issues.
@item representation_errors(+@var{Mode})
Change the behaviour when writing characters to the stream that cannot
be represented by the encoding. The behaviour is one of @code{error}
(throw and I/O error exception), @code{prolog} (write @code{\u...\}
(throw and Input/Output error exception), @code{prolog} (write @code{\u...\}
escape code or @code{xml} (write @code{&#...;} XML character entity).
The initial mode is @code{prolog} for the user streams and
@code{error} for all other streams. See also @ref{Encoding}.
@@ -2048,6 +2065,12 @@ Unify the last modification time of @var{File} with
@var{Time}. @var{Time} is a floating point number expressing the seconds
elapsed since Jan 1, 1970.
@item access_file(+@var{F},+@var{M})
@findex access_file/2
Is the file accessible?
@texinfo
@item absolute_file_name(+@var{Name},+@var{Options}, -@var{FullPath}) absolute_file_name(+@var{Name}, -@var{FullPath},+@var{Options})
@findex absolute_file_name/3
@syindex absolute_file_name/3
@@ -2111,6 +2134,7 @@ If the last argument is a list and the 2nd not, the arguments are
swapped, making the call @code{absolute_file_name}(+@var{Spec}, -@var{Path},
+@var{Options}) valid as well.
@item absolute_file_name(+@var{Name},-@var{FullPath})
@findex absolute_file_name/2
@syindex absolute_file_name/2
@@ -2119,6 +2143,8 @@ Give the path a full path @var{FullPath} YAP would use to consult a file
named @var{Name}. Unify @var{FullPath} with @code{user} if the file
name is @code{user}.
@end texinfo
@item file_base_name(+@var{Name},-@var{FileName})
@findex file_base_name/2
@snindex file_base_name/2
@@ -2223,7 +2249,7 @@ past-end-of-stream.
@cnindex at_end_of_stream/1
Succeed if the stream @var{S} has stream position end-of-stream or
past-end-of-stream. Note that @var{S} must be a readable stream.
@item set_stream_position(+@var{S}, +@var{POS}) [ISO]
@findex set_stream_position/2
@syindex set_stream_position/2
@@ -2297,7 +2323,7 @@ overview of wide character and encoding issues in YAP.
@item representation_errors(+@var{Mode})
Behaviour when writing characters to the stream that cannot be
represented by the encoding. The behaviour is one of @code{error}
(throw and I/O error exception), @code{prolog} (write @code{\u...\}
(throw and Input/Output error exception), @code{prolog} (write @code{\u...\}
escape code or @code{xml} (write @code{&#...;} XML character entity).
The initial mode is @code{prolog} for the user streams and
@code{error} for all other streams. See also @ref{Encoding} and
@@ -2355,7 +2381,7 @@ Given the packaged stream position term @var{StreamPosition}, unify
@end table
@node C-Prolog File Handling, I/O of Terms, Streams and Files, I/O
@node C-Prolog File Handling, Input/Output of Terms, Streams and Files, Input/Output
@section C-Prolog File Handling
@table @code
@@ -2423,7 +2449,8 @@ Closes the current input stream (see 6.7.).
@end table
@node I/O of Terms, I/O of Characters, C-Prolog File Handling, I/O
@node Input/Output of Terms, Input/Output of Characters, C-Prolog File Handling, Input/Output
@section Handling Input/Output of Terms
@table @code
@@ -2859,7 +2886,7 @@ X = [104, 101, 108, 108, 111]
@end table
@node I/O of Characters, I/O for Streams, I/O of Terms, I/O
@node Input/Output of Characters, Input/Output for Streams, Input/Output of Terms, Input/Output
@section Handling Input/Output of Characters
@table @code
@@ -2988,7 +3015,7 @@ Outputs a new line to the current output stream.
@end table
@node I/O for Streams, C-Prolog to Terminal, I/O of Characters, I/O
@node Input/Output for Streams, C-Prolog to Terminal, Input/Output of Characters, Input/Output
@section Input/Output Predicates applied to Streams
@table @code
@@ -3154,8 +3181,8 @@ Outputs a new line to stream @var{S}.
@end table
@node C-Prolog to Terminal, I/O Control, I/O for Streams, I/O
@section Compatible C-Prolog predicates for Terminal I/O
@node C-Prolog to Terminal, Input/Output Control, Input/Output for Streams, Input/Output
@section Compatible C-Prolog predicates for Terminal Input/Output
@table @code
@@ -3198,7 +3225,7 @@ Outputs a new line to stream @code{user_output}.
@end table
@node I/O Control, Sockets, C-Prolog to Terminal, I/O
@node Input/Output Control, Sockets, C-Prolog to Terminal, Input/Output
@section Controlling Input/Output
@table @code
@@ -3223,7 +3250,7 @@ opened or closed.
@syindex fileerrors/0
@cyindex fileerrors/0
Switches on the file_errors flag so that in certain error conditions
I/O predicates will produce an appropriated message and abort.
Input/Output predicates will produce an appropriated message and abort.
@item always_prompt_user
@findex always_prompt_user/0
@@ -3235,15 +3262,15 @@ interactive control from a pipe or a socket.
@end table
@node Sockets, , I/O Control, I/O
@node Sockets, , Input/Output Control, Input/Output
@section Using Sockets From YAP
YAP includes a SICStus Prolog compatible socket interface. In YAP-6.3
this uses the @c{clib} package to emulate the old low level interface that
this uses the @code{clib} package to emulate the old low level interface that
provides direct access to the major socket system calls. These calls
can be used both to open a new connection in the network or connect to
a networked server. Socket connections are described as read/write
streams, and standard I/O built-ins can be used to write on or read
streams, and standard Input/Output built-ins can be used to write on or read
from sockets. The following calls are available:
@table @code
@@ -3394,8 +3421,8 @@ address in number and dots notation.
@end table
@node Database, Sets, I/O, Top
@chapter Using the Clausal Data Base
@node Database, Sets, Input/Output, Top
@section Using the Clausal Data Base
Predicates in YAP may be dynamic or static. By default, when
consulting or reconsulting, predicates are assumed to be static:
@@ -4204,7 +4231,7 @@ no
@end table
@node Grammars, OS, Sets, Top
@chapter Grammar Rules
@section Grammar Rules
Grammar rules in Prolog are both a convenient way to express definite
clause grammars and an extension of the well known context-free grammars.
@@ -4319,7 +4346,7 @@ This predicate is used by the grammar rules compiler and is defined as
@end table
@node OS, Term Modification, Grammars, Top
@chapter Access to Operating System Functionality
@section Access to Operating System Functionality
The following built-in predicates allow access to underlying
Operating System functionality:
@@ -4548,7 +4575,7 @@ order of dispatch.
@end table
@node Term Modification, Global Variables, OS, Top
@chapter Term Modification
@section Term Modification
@cindex updating terms
It is sometimes useful to change the value of instantiated
@@ -4598,7 +4625,7 @@ Set the current value of mutable term @var{M} to term @var{D}.
@end table
@node Global Variables, Profiling, Term Modification, Top
@chapter Global Variables
@section Global Variables
@cindex global variables
@@ -4804,7 +4831,7 @@ compound terms.
@node Profiling, Call Counting, Global Variables, Top
@chapter Profiling Prolog Programs
@section Profiling Prolog Programs
@cindex profiling
@@ -4938,7 +4965,7 @@ Show profiling info for the top-most @var{N} predicates.
The @code{showprofres/0} and @code{showprofres/1} predicates call a user-defined multifile hook predicate, @code{user:prolog_predicate_name/2}, that can be used for converting a possibly explicitly-qualified callable term into an atom that will used when printing the profiling information.
@node Call Counting, Arrays, Profiling, Top
@chapter Counting Calls
@section Counting Calls
@cindex Counting Calls
Predicates compiled with YAP's flag @code{call_counting} set to
@@ -5014,7 +5041,7 @@ exception when @code{l/0} performs more than 10000 reductions.
@node Arrays, Preds, Call Counting , Top
@chapter Arrays
@section Arrays
The YAP system includes experimental support for arrays. The
support is enabled with the option @code{YAP_ARRAYS}.
@@ -5223,7 +5250,7 @@ terms.
@end table
@node Preds, Misc, Arrays, Top
@chapter Predicate Information
@section Predicate Information
Built-ins that return information on the current predicates and modules:
@@ -5247,7 +5274,7 @@ Succeeds if @var{M} are current modules associated to the file @var{F}.
@end table
@node Misc, , Preds, Top
@chapter Miscellaneous
@section Miscellaneous
@table @code
@@ -5322,9 +5349,8 @@ garbage collection and stack shifts time included.
Size of static code in YAP in bytes: @var{Clause Size}, the number of
bytes allocated for clauses, plus
@var{Index Size}, the number of bytes spent in the indexing code. The
indexing code is divided into main tree, @var{Tree Index
Size}, tables that implement choice-point manipulation, @var{Choice Point Instructions
Size}, tables that cache clauses for future expansion of the index
indexing code is divided into main tree, @var{Tree Index Size},
tables that implement choice-point manipulation, @var{Choice xsPoint Instructions Size}, tables that cache clauses for future expansion of the index
tree, @var{Expansion Nodes Size}, and
tables such as hash tables that select according to value, @var{Index Switch Size}.
@@ -5388,8 +5414,7 @@ available using @code{yap_flag(gc_trace,verbose)}.
Size of static code in YAP in bytes: @var{Clause Size}, the number of
bytes allocated for clauses, plus
@var{Index Size}, the number of bytes spent in the indexing code. The
indexing code is divided into a main tree, @var{Tree Index
Size}, table that cache clauses for future expansion of the index
indexing code is divided into a main tree, @var{Tree Index Size}, table that cache clauses for future expansion of the index
tree, @var{Expansion Nodes Size}, and and
tables such as hash tables that select according to value, @var{Index Switch Size}.
@@ -5902,7 +5927,6 @@ YAP is booted with the @code{-q} or @code{-L} flag.
consulting files. If @code{false} disable printing these messages. It
is @code{normal} by default except if YAP is booted with the @code{-L}
flag.
.
@item version
@findex version (yap_flag/2 option)
@@ -6058,7 +6082,7 @@ filed are ignored.
Current source module.
@item source (prolog_load_context/2 option)
@findex file_prolog_load_context/2 option
@findex source_prolog_load_context/2 option
@*
Full name for the file currently being read in, which may be consulted,
reconsulted, or included.

View File

@@ -51,14 +51,14 @@ PROJECT_BRIEF =
# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo
# to the output directory.
PROJECT_LOGO = ../misc/icons/yap_96x96x32.png
PROJECT_LOGO = misc/icons/yap_96x96x32.png
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
# into which the generated documentation will be written. If a relative path is
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.
OUTPUT_DIRECTORY = ../../doxout
OUTPUT_DIRECTORY = doxout
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
@@ -68,7 +68,7 @@ OUTPUT_DIRECTORY = ../../doxout
# performance problems for the file system.
# The default value is: NO.
CREATE_SUBDIRS = NO
CREATE_SUBDIRS = YES
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
@@ -230,7 +230,12 @@ TAB_SIZE = 4
# "Side Effects:". You can put \n's in the value part of an alias to insert
# newlines.
ALIASES =
ALIASES ="predicate=@brief" \
"doxygen=\if english" \
"endenglish=\endif" \
"dutch=\if dutch" \
"enddutch=\endif"
# This tag can be used to specify a number of word-keyword mappings (TCL only).
# A mapping has the form "name=value". For example adding "class=itcl::class"
@@ -244,7 +249,9 @@ TCL_SUBST =
# members will be omitted, etc.
# The default value is: NO.
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_FOR_PROLOG = YES
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
# Python sources only. Doxygen will then generate output that is more tailored
@@ -280,7 +287,7 @@ OPTIMIZE_OUTPUT_VHDL = NO
# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
# the files are not read by doxygen.
EXTENSION_MAPPING = md
EXTENSION_MAPPING = md pl=Prolog
# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
# according to the Markdown format, which allows for more readable
@@ -682,7 +689,7 @@ LAYOUT_FILE =
# search path. Do not use file names with spaces, bibtex cannot handle them. See
# also \cite for info how to create references.
CITE_BIB_FILES = yap.bib
CITE_BIB_FILES = docs/yap.bib
#---------------------------------------------------------------------------
# Configuration options related to warning and progress messages
@@ -753,7 +760,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.
INPUT = yap.md
INPUT = docs/yap.md pl/absf.yap C/cmppreds.c C/eval.c H/eval.h C/arith0.c C/arith1.c C/arith2.c pl/arithpreds.yap
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -788,6 +795,7 @@ FILE_PATTERNS = *.c \
*.ddl \
*.odl \
*.h \
*.h.in \
*.hh \
*.hxx \
*.hpp \
@@ -814,7 +822,9 @@ FILE_PATTERNS = *.c \
*.ucf \
*.qsf \
*.as \
*.js
*.js \
*.pl \
*.yap
# The RECURSIVE tag can be used to specify whether or not subdirectories should
# be searched for input files as well.
@@ -930,7 +940,7 @@ FILTER_SOURCE_PATTERNS =
# (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output.
USE_MDFILE_AS_MAINPAGE =
USE_MDFILE_AS_MAINPAGE = NO
#---------------------------------------------------------------------------
# Configuration options related to source browsing
@@ -949,7 +959,7 @@ SOURCE_BROWSER = YES
# classes and enums directly into the documentation.
# The default value is: NO.
INLINE_SOURCES = NO
INLINE_SOURCES = YES
# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
# special comment blocks from generated source code fragments. Normal C, C++ and
@@ -1422,7 +1432,7 @@ DISABLE_INDEX = NO
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_TREEVIEW = NO
GENERATE_TREEVIEW = YES
# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
# doxygen will group on one line in the generated HTML documentation.

View File

@@ -198,6 +198,15 @@ files specified by @var{F} into the file being currently consulted.
@end table
@node Setting the Compiler, Conditional Compilation, Compiling, Loading Programs
@section Looking for Files
@ifplaintext
@ref abs_file_name
@end ifplaintext
@section Changing the Compiler's Behavior
This section presents a set of built-ins predicates designed to set the
@@ -304,6 +313,8 @@ Puts YAP in state @var{N} (@code{on} or @code{off}) and unify
@code{do_not_compile_expressions}. This predicate was kept to maintain
compatibility with C-Prolog.
@texinfo
@item path(-@var{D})
@findex path/1
@snindex path/1
@@ -333,6 +344,8 @@ YAP, specified by @var{N}. @var{N} must be either of
@cnindex remove_from_path/1
Remove @var{D} from YAP's directory search path.
@end texinfo
@item style_check(+@var{X})
@findex style_check/1
@snindex style_check/1
@@ -414,6 +427,8 @@ Similar to @code{initialization/1}, but allows for specifying when
restoring a state (not implemented yet).
@end table
@texinfo
@item library_directory(+@var{D})
@findex library_directory/1
@snindex library_directory/1
@@ -428,7 +443,7 @@ directories are the places where files specified in the form
@findex file_search_path/2
@syindex file_search_path/2
@cnindex file_search_path/2
Allows writing file names as compound terms. The @var{NAME} and
Allows writing file names as compound terms. The @var{NAME} and
@var{DIRECTORY} must be atoms. The predicate may generate multiple
solutions. The predicate is originally defined as follows:
@@ -450,6 +465,8 @@ Thus, @code{[library(A)]} will search for a file using
Unify @var{FullPath} with the absolute path YAP would use to consult
file @var{Name}.
@end texinfo
@item prolog_to_os_filename(+@var{PrologPath},-@var{OsPath})
@findex prolog_to_os_filename/2
@snindex prolog_to_os_filename/2

View File

@@ -7,17 +7,17 @@ default in YAP. This support is loaded with the
@table @code
@item append(?@var{List1},?@var{List2},?@var{List3})
@findex append/3
@snindex append/3
@cnindex append/3
@findex swi_append/3
@snindex swi_append/3
@cnindex swi_append/3
Succeeds when @var{List3} unifies with the concatenation of @var{List1}
and @var{List2}. The predicate can be used with any instantiation
pattern (even three variables).
@item between(+@var{Low},+@var{High},?@var{Value})
@findex between/3
@snindex between/3
@cnindex between/3
@findex swi_between/3
@snindex swi_between/3
@cnindex swi_between/3
@var{Low} and @var{High} are integers, @var{High} less or equal than
@var{Low}. If @var{Value} is an integer, @var{Low} less or equal than
@@ -67,9 +67,9 @@ L = [gnu, gnat]
@end example
@item nth1(+@var{Index},?@var{List},?@var{Elem})
@findex nth1/3
@snindex nth1/3
@cnindex nth1/3
@findex swi_nth1/3
@snindex swi_nth1/3
@cnindex swi_nth1/3
Succeeds when the @var{Index}-th element of @var{List} unifies with
@var{Elem}. Counting starts at 1.
@@ -79,18 +79,18 @@ passed to @code{shell/[0-2]} and can be requested using @code{getenv/2}.
They also influence @code{expand_file_name/2}.
@item setenv(+@var{Name},+@var{Value})
@findex setenv/2
@snindex setenv/2
@cnindex setenv/2
@findex swi_setenv/2
@snindex swi_setenv/2
@cnindex swi_setenv/2
Set environment variable. @var{Name} and @var{Value} should be
instantiated to atoms or integers. The environment variable will be
passed to @code{shell/[0-2]} and can be requested using @code{getenv/2}.
They also influence @code{expand_file_name/2}.
@item term_to_atom(?@var{Term},?@var{Atom})
@findex term_to_atom/2
@snindex term_to_atom/2
@cnindex term_to_atom/2
@findex swi_term_to_atom/2
@snindex swi_term_to_atom/2
@cnindex swi_term_to_atom/2
Succeeds if @var{Atom} describes a term that unifies with @var{Term}. When
@var{Atom} is instantiated @var{Atom} is converted and then unified with
@var{Term}. If @var{Atom} has no valid syntax, a @code{syntax_error}
@@ -98,9 +98,9 @@ exception is raised. Otherwise @var{Term} is ``written'' on @var{Atom}
using @code{write/1}.
@item working_directory(-@var{Old},+@var{New})
@findex working_directory/2
@snindex working_directory/2
@cnindex working_directory/2
@findex swi_working_directory/2
@snindex swi_working_directory/2
@cnindex swi_working_directory/2
Unify @var{Old} with an absolute path to the current working directory
and change working directory to @var{New}. Use the pattern
@@ -136,26 +136,26 @@ we will phrase this as ``@var{Predicate} is applied on ...''
@table @code
@item maplist(+@var{Pred},+@var{List})
@findex maplist/2
@snindex maplist/2
@cnindex maplist/2
@findex swi_maplist/2
@snindex swi_maplist/2
@cnindex swi_maplist/2
@var{Pred} is applied successively on each element of @var{List} until
the end of the list or @var{Pred} fails. In the latter case
@code{maplist/2} fails.
@item maplist(+@var{Pred},+@var{List1},+@var{List2})
@findex maplist/3
@snindex maplist/3
@cnindex maplist/3
@findex swi_maplist/3
@snindex swi_maplist/3
@cnindex swi_maplist/3
Apply @var{Pred} on all successive pairs of elements from
@var{List1} and
@var{List2}. Fails if @var{Pred} can not be applied to a
pair. See the example above.
@item maplist(+@var{Pred},+@var{List1},+@var{List2},+@var{List4})
@findex maplist/4
@snindex maplist/4
@cnindex maplist/4
@findex swi_maplist/4
@snindex swi_maplist/4
@cnindex swi_maplist/4
Apply @var{Pred} on all successive triples of elements from @var{List1},
@var{List2} and @var{List3}. Fails if @var{Pred} can not be applied to a
triple. See the example above.
@@ -174,9 +174,10 @@ triple. See the example above.
@table @code
@item forall(+@var{Cond},+@var{Action})
@findex forall/2
@snindex forall/2
@cnindex forall/2
@findex swi_forall/2
@snindex swi_forall/2
@snindex swi_forall/2
@cnindex swi_forall/2
For all alternative bindings of @var{Cond} @var{Action} can be proven.
The next example verifies that all arithmetic statements in the list
@@ -233,9 +234,9 @@ threads that are created @emph{after} the registration.
@table @code
@item b_setval(+@var{Name},+@var{Value})
@findex b_setval/2
@snindex b_setval/2
@cnindex b_setval/2
@findex swi_b_setval/2
@snindex swi_b_setval/2
@cnindex swi_b_setval/2
Associate the term @var{Value} with the atom @var{Name} or replaces
the currently associated value with @var{Value}. If @var{Name} does
not refer to an existing global variable a variable with initial value
@@ -243,31 +244,28 @@ not refer to an existing global variable a variable with initial value
assignment is reversed.
@item b_getval(+@var{Name},-@var{Value})
@findex b_getval/2
@snindex b_getval/2
@cnindex b_getval/2
@findex swi_b_getval/2
@snindex swi_b_getval/2
@cnindex swi_b_getval/2
Get the value associated with the global variable @var{Name} and unify
it with @var{Value}. Note that this unification may further instantiate
the value of the global variable. If this is undesirable the normal
precautions (double negation or @code{copy_term/2}) must be taken. The
@code{b_getval/2} predicate generates errors if @var{Name} is not an atom or
the requested variable does not exist.
@end table
@table @code
@item nb_setval(+@var{Name},+@var{Value})
@findex nb_setval/2
@snindex nb_setval/2
@cnindex nb_setval/2
@findex swi_nb_setval/2
@snindex swi_nb_setval/2
@cnindex swi_nb_setval/2
Associates a copy of @var{Value} created with @code{duplicate_term/2}
with the atom @var{Name}. Note that this can be used to set an
initial value other than @code{[]} prior to backtrackable assignment.
@item nb_getval(+@var{Name},-@var{Value})
@findex nb_getval/2
@snindex nb_getval/2
@cnindex nb_getval/2
@findex swi_nb_getval/2
@snindex swi_nb_getval/2
@cnindex swi_nb_getval/2
The @code{nb_getval/2} predicate is a synonym for b_getval/2, introduced for
compatibility and symmetry. As most scenarios will use a particular
global variable either using non-backtrackable or backtrackable
@@ -297,9 +295,9 @@ variable is used non-backtrackable.
@c \end{code}
@item nb_current(?@var{Name},?@var{Value})
@findex nb_current/2
@snindex nb_current/2
@cnindex nb_current/2
@findex swi_nb_current/2
@snindex swi_nb_current/2
@cnindex swi_nb_current/2
Enumerate all defined variables with their value. The order of
enumeration is undefined.

View File

@@ -34,7 +34,6 @@ scan_file( Inp ) :-
repeat,
line_count( S, Lines ),
read_line_to_string(S, Line0),
%( Lines = 416 %string(Line0),sub_string( Line0,_,_,_, "\secref{unicodesyntax}") -> trace ; true ),
assert_static( source( Inp, Lines, Line0 ) ),
( Line0 == end_of_file ->
!,
@@ -131,7 +130,9 @@ out( _S ) :-
nb_setval( min, 0 ),
fail.
out( S ) :-
line( F, Pos, Line),
line( F, Pos, Line0),
%( Pos = 5770 -> trace ; true ),
jmp_blanks( Line0, Line),
b_setval( line, F:Pos:Line ),
process( Line , NewLine, F:Pos),
offset( N ),
@@ -141,8 +142,8 @@ out( S ) :-
;
NewLine == ""
->
% nb_getval( old_line, OldLine ),
% OldLine \= "",
nb_getval( old_line, OldLine ),
OldLine \= "",
format(string(SN), '~n', [])
;
NewLine == force
@@ -185,6 +186,9 @@ singleton_line(L) :- string_concat("@itemize",_R,L), !.
singleton_line(L) :- string_concat("@enumerate",_R,L), !.
singleton_line(L) :- string_concat("@table",_R,L), !.
singleton_line(L) :- string_concat("@example",_R,L), !, assert( singletons ).
singleton_line(L) :- string_concat("@ifplaintext",_R,L), !, assert( singletons ).
singleton_line(L) :- string_concat("@pl_example",_R,L), !, assert( singletons ).
singleton_line(L) :- string_concat("@c_example",_R,L), !, assert( singletons ).
singleton_line(L) :- string_concat("@simpleexample",_R,L), !, assert( singletons ).
singleton_line(L) :- string_concat("@end",R,L), !,
( sub_string(R, _, _, _, "example") -> retract( singletons ) ; true ).
@@ -200,16 +204,20 @@ process( Line , S, F:Pos ) :-
(
first_word(Line, "@end", Rest)
->
first_word(Rest, Env1, _Rest2),
(
( Env1 == "example" ; Env1 == "smallexample" )
first_word(Rest, Env1, _Rest2),
sub_string( Env1, _, _, 0, "example" )
->
( S = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
pop( skip, verbatim ), fail
)
% fail in other ends
% ;
% Env1 = "cartouche"
;
first_word(Rest, Env1, _Rest2),
sub_string( Env1, _, _, 0, "plaintext" )
->
( S = "" ;
pop( skip, verbatim ), fail
)
)
;
first_word(Line, "@cartouche", Rest)
@@ -224,8 +232,12 @@ process( Line , "", _Pos ) :-
first_word(Line, Word, Rest),
Word == "@end",
first_word(Rest, Word2, _Rest),
W2 = Word2,
pop( skip, W2 ).
( W2 = Word2
->
pop( skip, W2 )
;
true
).
% command: flush and continue
process( Command , NewLine , Pos) :-
do_buffer(Command, NewLine, Pos ).
@@ -254,36 +266,49 @@ command( Line, Word, Rest ) :-
clause( process( Word, _, _, _, _ ), _),
!.
process("@item", _Line, _Rest, NewLine , _FilePos) :-
speek( list, it(_Env, _Item, _Pos, Numb)),
Numb > 1,
NewLine = "</li>".
process("@item", Line, Rest, NewLine , FilePos) :-
pop( list, it(Env, Item, Pos, Numb)), !,
NNumb is Numb+1,
run( Text, Rest ),
jmp_blanks( Rest, First ),
item_type(Item, Numb, Marker ),
jmp_blanks( Text, First ),
Pos1 is Pos,
% item_type(Item, Numb, Marker ),
Marker = "",
(
Env = "table",
Env = "@table",
atom_string( A, Line ),
pred( _Pred, Key, A, FilePos )
->
push( list, it(Env, Item, Pos, NNumb) ),
(
% sendout the comand
format(string(NewLine), '~t~s ~*|~s @anchor ~a', [Marker, Pos, First, Key]),
format(string(NewLine), '~t~s ~*+<li>~s @anchor ~a', [Marker, Pos1, First, Key]),
push( indent, done )
;
NewLine = force
)
;
format(string(NewLine), '~t~s ~*|~s', [ Marker, Pos, First]),
format(string(NewLine), '~t~s ~*+<li>~s', [ Marker, Pos, First]),
push( list, it(Env, Item, Pos, NNumb) ),
push( indent, done )
).
). %, writeln(+FilePos:Line), listing(stack).
process("@end", _Line, _Rest, "</li>" , _Pos) :-
once( speek(list,it(_Env,_,_LL,_)) ).
process("@end", _Line, Rest, NewLine , _Pos) :-
speek(list,it(Env,_,_LL,_)),
( Env = "@enumerate" ->
NewLine = "</ol>"
;
NewLine = "</ul>"
),
sub_string( Env, 1, _, 0, Env1 ),
sub_string( Rest, _, _, _, Env1), !, % check
pop( list, it(Env, _, _, _) ),
NewLine = "".
% writeln(_Pos:_Line), listing(stack),
pop( list, it(Env, _, _, _) ).
process("@end", Line, _Rest, NewLine , _Pos) :-
sub_string(Line, _, _, 0, "ifnottex"), !, % check
NewLine = "\\endhtmlonly".
@@ -304,7 +329,11 @@ process("@end", Line, _Rest, NewLine , _Pos) :-
process("@author", _Line, Rest, NewLine , _Pos) :- !,
jmp_blanks( Rest, Firs ),
format( string( NewLine), '\\author ~s', [ Firs ] ).
process("@*", _Line, _Rest, ¨¨ , _Pos) :- !.
process("@*", _Line, _Rest, "" , _Pos).
process("@*", _Line, Rest, Line , _Pos) :-
!,
jmp_blanks( Rest, Firs ),
run( Line, Firs ).
process("@c", _Line, Rest, NewLine , _Pos) :- !,
gen_comment( Rest, NewLine ).
process("@comment", _Line, Rest, NewLine , _Pos) :- !,
@@ -320,7 +349,8 @@ process("@chapter", _Line, Rest, NewLine, _Pos ) :- !,
run( Title, Firs ),
nb_setval( level, 1 ),
title_from_words(Firs, Id, _Pos),
format(string(NewLine), '@section ~s ~s', [Id,Title]).
title( '@chapter', _, TitleDox ),
format(string(NewLine), '~a ~s ~s', [TitleDox, Id,Title]).
% ( format( string(NewLine), '~s', [Title] ) ; NewLine = "======" ).
process("@cindex", _Line, _Rest, no , _Pos) :- !.
process("@caindex", _Line, _Rest, no, _Pos ) :- !.
@@ -329,6 +359,9 @@ process("@defindex", Line, _Rest, NewLine , _Pos) :- !,
process("@direntry", Line, _Rest, NewLine, _Pos ) :- !,
gen_comment( Line, NewLine ),
push(skip, "direntry" ).
process("@texinfo", Line, _Rest, NewLine, _Pos ) :- !,
gen_comment( Line, NewLine ),
push(skip, "texinfo" ).
process("@documentencoding", _Line, _Rest, "" , _Pos) :- !.
% jmp_blanks( Rest, NewString ),
% format( string( NewLine), '<meta charset="~s">', [ NewString ] ).
@@ -340,7 +373,16 @@ process("@enumerate", _Line, _Rest, NewLine , _Pos) :-
process("@example", _Line, _Rest, "" , _Pos).
process("@example", _Line, _Rest, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" , _Pos) :- !,
push( skip, verbatim).
process("@ifplaintext", _Line, _Rest, "" , _Pos) :- !,
push( skip, verbatim).
process("@pl_example", _Line, _Rest, "" , _Pos).
process("@pl_example", _Line, _Rest, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog}" , _Pos) :- !,
push( skip, verbatim).
process("@c_example", _Line, _Rest, "" , _Pos).
process("@c_example", _Line, _Rest, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}" , _Pos) :- !,
push( skip, verbatim).
process("@format", _Line, _Rest, "", _Pos ) :- !.
process("@alias", _Line, _Rest, "", _Pos ) :- !.
process("@dircategory", _Line, _Rest, "", _Pos ) :- !.
process("@smallexample", _Line, _Rest, "" , _Pos).
process("@smallexample", _Line, _Rest, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" , _Pos) :- !,
@@ -373,8 +415,9 @@ process("@section", _Line, Rest, NewLine, Pos ) :- !,
run( NewTitle, Title ),
nb_setval( level, 2 ),
% format(string(NewLine), '# ~s #', [NewTitle]).
title( '@section', _, TitleDox ),
title_from_words(NewTitle, Id, Pos),
format(string(NewLine), '@subsection ~s ~s', [Id,NewTitle]).
format(string(NewLine), '~a ~s ~s', [TitleDox,Id,NewTitle]).
% format(string(NewLine), '# ~s #', [NewTitle]).
process("@appendix", _Line, Rest, NewLine, _Pos ) :- !,
jmp_blanks( Rest, Title ),
@@ -384,8 +427,9 @@ process("@subsection", _Line, Rest, NewLine, _Pos ) :- !,
jmp_blanks( Rest, Title ),
run( NewTitle, Title ),
nb_setval( level, 3 ),
title( '@subsection', _, TitleDox ),
title_from_words(NewTitle, Id, _Pos),
format(string(NewLine), '@subsubsection ~s ~s', [Id,NewTitle]).
format(string(NewLine), '~a ~s ~s', [TitleDox,Id,NewTitle]).
% format(string(NewLine), '## ~s ##', [NewTitle]).
process("@unnumberedsubsubsec", _Line, Rest, NewLine, _Pos ) :- !,
nb_setval( level, 4 ),
@@ -394,8 +438,9 @@ process("@subsubsection", _Line, Rest, NewLine, _Pos ) :- !,
nb_setval( level, 4 ),
jmp_blanks( Rest, Title ),
run( NewTitle, Title ),
title( '@subsubsection', _, TitleDox ),
title_from_words(NewTitle, Id, _Pos),
format(string(NewLine), '@paragraph ~s ~s', [Id,NewTitle]).
format(string(NewLine), '~a ~s', [TitleDox,Id,NewTitle]).
% format(string(NewLine), '### ~s ###', [NewTitle]).
process("@set", _Line, Rest, NewLine , _Pos) :- !,
first_word( Rest, V, SecC),
@@ -416,16 +461,7 @@ process("@setchapternewpage", Line, _Rest, NewLine, _Pos ) :- !,
gen_comment( Line, NewLine ).
process("@setfilename", Line, _Rest, NewLine, _Pos ) :- !,
gen_comment( Line, NewLine ).
process("@settitle", _Line, Rest, NewLine , _Pos) :- !,
jmp_blanks( Rest, Title ),
( format(string(NewLine), '~s {#mainpage}', [Title]) ; NewLine = "=================="; NewLine = "" ;
NewLine = "";
NewLine = "[TOC]";
NewLine = "";
NewLine = "@secreflist" ;
NewLine = "";
NewLine = "@endsecreflist"
).
process("@settitle", _Line, _Rest, "" , _Pos) :- !.
process("@subtitle", _Line, _Rest, "", _Pos ) :- !.
process("@include", _Line, _Rest, "", _Pos ) :- !.
process("@table", _Line, Rest, NewLine , _Pos) :- !,
@@ -461,21 +497,25 @@ get_second( Rest, Title ) :-
% clear the buffer first.
%
list( Env, Line, New, _Pos) :-
writeln(_Pos),
first_word( Line, V, Rest),
jmp_blanks( Rest, End ),
(
speek( list, it(_, _,Pos, _) ) ->
Pos1 is Pos + 6
speek( list, it(_, _, _Pos, _) ) ->
Pos1 is 0 % Pos + 4
;
Pos1 = 6
Pos1 = 0 %4
),
push( list, it( Env, V, Pos1, 1 ) ),
% b_getval( pos, _Pos ),
% writeln(add:_Pos:Env:Pos1:End),
% listing(stack),
run( New, End).
list( Env, _Line, NewLine, _Pos) :-
( Env = "@enumerate" ->
NewLine = "<ol>"
;
NewLine = "<ul>"
).
item_type("@bullet", _, "-" ).
item_type("@code", _, "-" ).
@@ -521,9 +561,11 @@ from_word( Line, Id ) :-
simplify( C1, C0, []),
string_codes( Id, C1 ).
simplify( [0'_|L]) --> " ", !,
simplify( [0'_|L]) --> " ", !, %'
simplify(L).
simplify( [0'a,0'A|L]) --> "@", !,
simplify( [0's,0'T|L]) --> "*", !, %'
simplify(L).
simplify( [0'a,0'A|L]) --> "@", !,
simplify(L).
simplify( [0'b,0'A|L]) --> "'", !,
simplify(L).
@@ -637,7 +679,7 @@ pop(Type, Val) :-
stack(T, V), !,
T = Type,
V = Val,
retract(stack(T,V)).
once( retract(stack(T,V)) ).
push(Type, Val) :-
asserta(stack(Type,Val)).
@@ -706,11 +748,17 @@ run( L) --> "@value{", !,
run(R).
run( L) --> "@pxref{", !,
argument(AL, 0'{, 0'}),
{ format(codes(L, R), '`see ~s`', [AL] ) }, %'
{
string_codes(S, AL),
from_word(S, Id),
format(codes(L, R), ' (see [~s](@ref ~s))', [AL,Id] ) }, %' %
run(R).
run( L) --> "@ref{", !,
argument(AL, 0'{, 0'}),
{ format(codes(L, R), '[~s](@ref ~s)', [AL,AL] ) }, %'
{
string_codes(S, AL),
from_word(S, Id),
format(codes(L, R), '[~s](@ref ~s)', [AL,Id] ) }, %'
run(R).
run( L) --> "@strong{", !,
argument(AL, 0'{, 0'}),
@@ -808,11 +856,9 @@ argument(L, _C0, _C, L, []) :-
format(user_error, 'Line ~w :-~n argument ~c~s~c does not close in same line.~n', [Line, _C0, L, _C]).
argument0([], 0, _, C ) --> [C], !.
%:- start_low_level_trace.
argument0([C|L], I0, C0, C ) --> [C], !,
{ I0 > 0, I is I0-1 },
argument0( L, I, C0, C).
%:- stop_low_level_trace.
argument0([C0|L], I0, C0, C ) --> [C0], !,
{ I is I0+1 },
argument0( L, I, C0, C).
@@ -854,11 +900,18 @@ id(X) :-
X1 is X+100,
assert(i(X1)).
title(1, page).
title(2, section).
title(3, subsection).
title(4, subsubsection).
title(5, paragraph).
title(6, paragraph).
title(TexTitle, Level, DoxTitle) :-
title( Level, TexTitle),
% Level1 is Level + 1,
title( Level, DoxTitle ), !.
title(1, '@page' ).
title(1, '@chapter' ).
title(2, '@section' ).
title(3, '@subsection' ).
title(4, '@subsubsection' ).
title(5, '@paragraph' ).
title(6, '@paragraph' ).
%:- spy title_from_words.

File diff suppressed because it is too large Load Diff