This commit is contained in:
Vitor Santos Costa 2018-05-01 23:25:58 +01:00
parent 44ac70d3ab
commit ef04b30d66
56 changed files with 2229 additions and 2422 deletions

View File

@ -15,7 +15,13 @@
* *
*************************************************************************/
/** @defgroup YAPArrays Named Arrays
/**
@file arrays.c
@namespace prolog
@addtogroup YAPArrays Named Arrays
@ingroup extensions
@{

View File

@ -1,4 +1,3 @@
/*************************************************************************
* *
* YAP Prolog *
@ -22,15 +21,20 @@ static char SccsId[] = "%W% %G%";
/**
* @file atomic.c
*
* @namespace prolog
*
/
/**
* @defgroup Predicates_on_Atoms Predicates on Atoms and Strings
* @ingroup builtins
* @{
@brief The following predicates are used to manipulate atoms, strings, lists of
codes and lists of chars:
\toc
*
* @brief The following predicates are used to manipulate atoms, strings, lists of
* codes and lists of chars:
*
* \toc
*
*/
#define HAS_CACHE_REGS 1

View File

@ -18,6 +18,15 @@
static char SccsId[] = "%W% %G%";
#endif
/**
* @file attvar.c
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
* @date Mon Apr 30 09:31:59 2018
*
* @brief attributed variables
* @namespace prolog
*
*/
#include "Yap.h"
#include "Yatom.h"

11
C/bb.c
View File

@ -18,6 +18,17 @@
static char SccsId[] = "%W% %G%";
#endif
/**
* @file bb.c
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
* @date Mon Apr 30 09:32:54 2018
*
* @brief blackboard
*
* @namespace prolog
*
*/
/** @defgroup BlackBoard The Blackboard
@ingroup builtins

View File

@ -17,6 +17,17 @@
#ifdef SCCS
static char SccsId[] = "%W% %G%";
#endif
/**
* @file bignum.c
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
* @date Mon Apr 30 09:34:59 2018
*
* @brief BigNums and More
* @namespace prolog
*
*
*
*/
#include "Yap.h"
#include "Yatom.h"

View File

@ -16,6 +16,18 @@
* *
*************************************************************************/
/**
* @file cmppreds.c
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
* @date Mon Apr 30 09:35:58 2018
*
* @brief comparison
*
* @namespace prolog
*
*
*
*/
/// @file cmppreds.c
/**

View File

@ -18,6 +18,20 @@
static char SccsId[] = "%W% %G%";
#endif
/**
* @file dbase.c
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
* @date Mon Apr 30 09:36:46 2018
*
* @brief record and other forms of storing terms.
*
* @namespace prolog
*
*
*
*/
/** @defgroup Internal_Database Internal Data Base
@ingroup builtins
@{

View File

@ -17,8 +17,19 @@
#ifdef SCCS
static char SccsId[] = "%W% %G%";
#endif
//! @file eval.c
/**
* @file eval.c
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
* @date Mon Apr 30 09:37:59 2018
*
* @brief is/2
*
*
* @namespace prolog
*
*
*
*/
//! @{

View File

@ -18,6 +18,19 @@
static char SccsId[] = "@(#)cdmgr.c 1.1 05/02/98";
#endif
/**
* @file exec.c
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
* @date Mon Apr 30 13:48:35 2018
*
* @brief meta-call
*
* @namespace prolog
*
*
*
*/
#include "absmi.h"
#include "attvar.h"
#include "cut_c.h"
@ -121,7 +134,8 @@ inline static bool CallMetaCall(Term t, Term mod USES_REGS) {
/**
* Transfer control to a meta-call in ARG1, cut up to B.
* @method Yap_ExecuteCallMetaCall
*
* @param g goal
* @param mod current module
* @return su
*/
@ -1574,8 +1588,8 @@ bool Yap_exec_absmi(bool top, yap_reset_t has_reset) {
/**
* Fails computation up to choice-point bb
* @method Yap_fail_all
* @param USES_REGS [description]
*
* @param USES_REGS thread support
*/
void Yap_fail_all(choiceptr bb USES_REGS) {
yamop *saved_p, *saved_cp;

View File

@ -30,6 +30,10 @@
*/
/*
* @namespace prolog
* /
// this is where we define flags
#define INIT_FLAGS 1

View File

@ -1260,19 +1260,21 @@ static Term all_calls(bool internal USES_REGS) {
return Yap_MkApplTerm(f, 6, ts);
}
/**
* report the current status of the stacks up to level $N$
*
* @param depth
*
* @return data on the current program counter
*/
Term Yap_all_calls(void) {
CACHE_REGS
return all_calls(true PASS_REGS);
}
/**
* @pred current_stack( +Depth )
*
* report the current status of the stacks up to level $N$
*
* @param Depth
*
* @return data on the current Prolog stack.
*/
static Int current_stack(USES_REGS1) {
Term t;
while ((t = all_calls(false PASS_REGS)) == 0L) {

View File

@ -1617,8 +1617,9 @@ p_term_variables( USES_REGS1 ) /* variables in term t */
/**
* Exports a nil-terminated list with all the variables in a term.
* @param[in] the term
* @param[in] the arity of the calling predicate (required for exact garbage collection).
* @param[t] the term
* @param[arity] the arity of the calling predicate (required for exact garbage collection).
* @param[USES_REGS] threading
*/
Term
Yap_TermVariables( Term t, UInt arity USES_REGS ) /* variables in term t */

View File

@ -47,11 +47,11 @@ YAP_FLAG(ALLOW_ASSERT_FOR_STATIC_PREDICATES,
NULL),
/**< `allow_variable_name_as_functor` boolean flag allows constructs such as
~~~~~~~~~~~~
~~~
Tree(Node(L,node,R)) :-
Tree(L),
Tree(R).
~~~~~~~~~~~~
~~~
*/
YAP_FLAG( ALLOW_VARIABLE_NAME_AS_FUNCTOR_FLAG, "allow_variable_name_as_functor", false, booleanFlag, "false", NULL),

View File

@ -24,11 +24,10 @@
@{
@enum LocalFlags local Flags supported by YAP
@brief local flag:
@enum local_flags flag:
*/
typedef enum {
typedef enum local_flags_enum {
/** + `autoload`: set the system to look for undefined procedures */
YAP_FLAG( AUTOLOAD_FLAG, "autoload", true, booleanFlag, "false" , NULL ),

View File

@ -241,7 +241,7 @@ void Yap_init_optyap_preds(void) {
SafePredFlag | SyncPredFlag);
Yap_InitCPred("abolish_all_tables", 0, p_abolish_all_tables,
SafePredFlag | SyncPredFlag);
/** @pred abolish_all_tables/0
/** @pred abolish_all_tables
Removes all the entries from the table space for all tabled

View File

@ -8,7 +8,9 @@ if (WITH_DOCS)
set(DOCS_SOURCE_DIR ${CMAKE_SOURCE_DIR}/docs)
SET (CMAKE_HTML_EXTRA_
SET (CMAKE_HTML_EXTRA_)
SET( EXT
${DOCS_SOURCE_DIR}/custom/application.js
${DOCS_SOURCE_DIR}/custom/assets
${DOCS_SOURCE_DIR}/custom/bootstrap.min.css
@ -84,11 +86,9 @@ endforeach(i ${DOCS_EXCLUDE_})
add_subdirectory(../packages/raptor/doc ${CMAKE_BINARY_DIR}/packages/raptor/doc)
SET(DOC_INPUT_FILES_ ${CMAKE_SOURCE_DIR}/INSTALL.md
SET(DOC_INPUT_FILES_
${CMAKE_SOURCE_DIR}/pl
${CMAKE_SOURCE_DIR}/docs/md
${CMAKE_SOURCE_DIR}/CXX
${CMAKE_SOURCE_DIR}/OPTYap
${CMAKE_SOURCE_DIR}/C
@ -97,7 +97,6 @@ SET(DOC_INPUT_FILES_ ${CMAKE_SOURCE_DIR}/INSTALL.md
${CMAKE_SOURCE_DIR}/os
${CMAKE_SOURCE_DIR}/library
${CMAKE_SOURCE_DIR}/swi/library
${CMAKE_SOURCE_DIR}/docs/md
)
foreach(i ${DOC_INPUT_FILES_})

View File

@ -68,7 +68,7 @@ OUTPUT_DIRECTORY = @PROJECT_BINARY_DIR@/docs
# performance problems for the file system.
# The default value is: NO.
CREATE_SUBDIRS = YES
CREATE_SUBDIRS = NO
# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
# characters to appear in the names of generated files. If set to NO, non-ASCII
@ -98,7 +98,7 @@ OUTPUT_LANGUAGE = English
# documentation (similar to Javadoc). Set to NO to disable this.
# The default value is: YES.
BRIEF_MEMBER_DESC = YES
BRIEF_MEMBER_DESC = NO
# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
# description of a member or function before the detailed description
@ -107,7 +107,7 @@ BRIEF_MEMBER_DESC = YES
# brief descriptions will be completely suppressed.
# The default value is: YES.
REPEAT_BRIEF = YES
REPEAT_BRIEF = NO
# This tag implements a quasi-intelligent brief description abbreviator that is
# used to form the text in various listings. Each string in this list, if found
@ -204,7 +204,7 @@ MULTILINE_CPP_IS_BRIEF = NO
# documentation from any documented member that it re-implements.
# The default value is: YES.
INHERIT_DOCS = YES
INHERIT_DOCS = NO
# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
# page for each member. If set to NO, the documentation of a member will be part
@ -277,7 +277,7 @@ OPTIMIZE_OUTPUT_VHDL = NO
# Prolog sources. Doxygen will then generate output that is tailored for Prolog.
# The default value is: NO.
OPTIMIZE_OUTPUT_FOR_PROLOG = YES
OPTIMIZE_OUTPUT_FOR_PROLOG = NO
# Doxygen selects the parser to use depending on the extension of the files it
# parses. With this tag you can assign which parser to use for a given
@ -318,7 +318,7 @@ MARKDOWN_SUPPORT = YES
# Minimum value: 0, maximum value: 99, default value: 0.
# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
TOC_INCLUDE_HEADINGS = 0
TOC_INCLUDE_HEADINGS = 99
# When enabled doxygen tries to link words that correspond to documented
# classes, or namespaces to their corresponding documentation. Such a link can
@ -711,7 +711,7 @@ FILE_VERSION_FILTER =
# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
# tag is left empty.
LAYOUT_FILE =
LAYOUT_FILE = @CMAKE_SOURCE_DIR@/docs/custom/DoxygenLayout.xml
# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
# the reference definitions. This must be a list of .bib files. The .bib
@ -748,7 +748,7 @@ WARNINGS = YES
# will automatically be disabled.
# The default value is: YES.
WARN_IF_UNDOCUMENTED = YES
WARN_IF_UNDOCUMENTED = NO
# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
# potential errors in the documentation, such as not documenting some parameters
@ -1097,7 +1097,7 @@ VERBATIM_HEADERS = YES
# classes, structs, unions or interfaces.
# The default value is: YES.
ALPHABETICAL_INDEX = YES
ALPHABETICAL_INDEX = NO
# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
# which the alphabetical index list will be split.
@ -1156,7 +1156,7 @@ HTML_FILE_EXTENSION = .html
# of the possible markers and block names see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_HEADER =
HTML_HEADER = @CMAKE_SOURCE_DIR@/docs/custom/header.html
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
# generated HTML page. If the tag is left blank doxygen will generate a standard
@ -1166,7 +1166,7 @@ HTML_HEADER =
# that doxygen normally uses.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_FOOTER =
HTML_FOOTER = @CMAKE_SOURCE_DIR@/docs/custom/footer.html
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
@ -1192,7 +1192,7 @@ HTML_STYLESHEET =
# list). For an example see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_STYLESHEET =
HTML_EXTRA_STYLESHEET = @CMAKE_SOURCE_DIR@/docs/custom/customdoxygen.css
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
@ -1203,7 +1203,7 @@ HTML_EXTRA_STYLESHEET =
# files will be copied as-is; there are no commands or markers available.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_FILES =
HTML_EXTRA_FILES = @CMAKE_SOURCE_DIR@/docs/custom/doxy-boot.js
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
# will adjust the colors in the style sheet and background images according to
@ -1958,7 +1958,7 @@ MAN_LINKS = NO
# captures the structure of the code including all documentation.
# The default value is: NO.
GENERATE_XML = YES
GENERATE_XML = NO
# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of

View File

@ -1,7 +1,5 @@
h1, .h1, h2, .h2, h3, .h3{
font-weight: 200 !important;
}
/* Custom Look and feel - Can be edited
----------------------------------- */
#navrow1, #navrow2, #navrow3, #navrow4, #navrow5{
border-bottom: 1px solid #EEEEEE;
}
@ -10,95 +8,10 @@ h1, .h1, h2, .h2, h3, .h3{
margin-left: 30px !important;
font-size: 1.15em !important;
}
.navbar{
border: 0px solid #222 !important;
}
table{
white-space:pre-wrap !important;
}
/*
===========================
*/
/* Sticky footer styles
-------------------------------------------------- */
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto;
/* Negative indent footer by its height */
margin: 0 auto -60px;
/* Pad bottom by footer height */
padding: 0 0 60px;
}
/* Set the fixed height of the footer here */
#footer {
font-size: 0.9em;
padding: 8px 0px;
background-color: #f5f5f5;
}
.footer-row {
line-height: 44px;
}
#footer > .container {
padding-left: 15px;
padding-right: 15px;
}
.footer-follow-icon {
margin-left: 3px;
text-decoration: none !important;
}
.footer-follow-icon img {
width: 20px;
}
.footer-link {
padding-top: 5px;
display: inline-block;
color: #999999;
text-decoration: none;
}
.footer-copyright {
text-align: center;
}
@media (min-width: 992px) {
.footer-row {
text-align: left;
}
.footer-icons {
text-align: right;
}
}
@media (max-width: 991px) {
.footer-row {
text-align: center;
}
.footer-icons {
text-align: center;
}
}
/* DOXYGEN Code Styles
/* DOXYGEN Code Styles - These are from doxygen but can be changed to fit the theme
----------------------------------- */
a.qindex {
font-weight: bold;
}
@ -148,8 +61,8 @@ div.fragment {
}
div.line {
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
font-size: 12px;
font-family: monospace, fixed;
font-size: 13px;
min-height: 13px;
line-height: 1.0;
text-wrap: unrestricted;
@ -157,7 +70,7 @@ div.line {
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: pre-wrap; /* CSS3 */
word-wrap: normal; /* IE 5.5+ */
word-wrap: break-word; /* IE 5.5+ */
text-indent: -53px;
padding-left: 53px;
padding-bottom: 0px;
@ -173,9 +86,6 @@ div.line {
transition-property: background-color, box-shadow;
transition-duration: 0.5s;
}
div.line:hover{
background-color: #FBFF00;
}
div.line.glow {
background-color: cyan;
@ -186,21 +96,16 @@ div.line.glow {
span.lineno {
padding-right: 4px;
text-align: right;
color:rgba(0,0,0,0.3);
border-right: 1px solid #EEE;
border-left: 1px solid #EEE;
background-color: #FFF;
border-right: 2px solid #0F0;
background-color: #E8E8E8;
white-space: pre;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace ;
}
span.lineno a {
background-color: #FAFAFA;
cursor:pointer;
background-color: #D8D8D8;
}
span.lineno a:hover {
background-color: #EFE200;
color: #1e1e1e;
background-color: #C8C8C8;
}
div.groupHeader {
@ -267,104 +172,3 @@ blockquote {
padding: 0 12px 0 16px;
}
/*---------------- Search Box */
#search-box {
margin: 10px 0px;
}
#search-box .close {
display: none;
position: absolute;
right: 0px;
padding: 6px 12px;
z-index: 5;
}
/*---------------- Search results window */
#search-results-window {
display: none;
}
iframe#MSearchResults {
width: 100%;
height: 15em;
}
.SRChildren {
padding-left: 3ex; padding-bottom: .5em
}
.SRPage .SRChildren {
display: none;
}
a.SRScope {
display: block;
}
a.SRSymbol:focus, a.SRSymbol:active,
a.SRScope:focus, a.SRScope:active {
text-decoration: underline;
}
span.SRScope {
padding-left: 4px;
}
.SRResult {
display: none;
}
/* class and file list */
.directory .icona,
.directory .arrow {
height: auto;
}
.directory .icona .icon {
height: 16px;
}
.directory .icondoc {
background-position: 0px 0px;
height: 20px;
}
.directory .iconfopen {
background-position: 0px 0px;
}
.directory td.entry {
padding: 7px 8px 6px 8px;
}
.table > tbody > tr > td.memSeparator {
line-height: 0;
.table-hover;
}
.memItemLeft, .memTemplItemLeft {
white-space: normal;
}
/* enumerations */
.panel-body thead > tr {
background-color: #e0e0e0;
}
/* todo lists */
.todoname,
.todoname a {
font-weight: bold;
}
/* Class title */
.summary {
margin-top: 25px;
}
.page-header {
margin: 20px 0px !important;
}
.page-header .title {
display: inline-block;
}
.page-header .pull-right {
margin-top: 0.3em;
margin-left: 0.5em;
}
.page-header .label {
font-size: 50%;
}

View File

@ -4,6 +4,7 @@ $( document ).ready(function() {
$("div.title").addClass("h1");
$('li > a[href="index.html"] > span').before("<i class='fa fa-cog'></i> ");
$('li > a[href="index.html"] > span').text("YAP");
$('li > a[href="modules.html"] > span').before("<i class='fa fa-square'></i> ");
$('li > a[href="namespaces.html"] > span').before("<i class='fa fa-bars'></i> ");
$('li > a[href="annotated.html"] > span').before("<i class='fa fa-list-ul'></i> ");
@ -26,7 +27,7 @@ $( document ).ready(function() {
$("#nav-path > ul").addClass("breadcrumb");
$("table.params").addClass("table");
$("div.ingroups").wrapInner("<span class='text-nowrap'></span>");
$("div.ingroups").wrapInner("<small></small>");
$("div.levels").css("margin", "0.5em");
$("div.levels > span").addClass("btn btn-default btn-xs");
$("div.levels > span").css("margin-right", "0.25em");
@ -53,8 +54,10 @@ $( document ).ready(function() {
$("div.ttname a").css("color", 'white');
$("div.ttdef,div.ttdoc,div.ttdeci").addClass("panel-body");
$('div.fragment.well div.line:first').css('margin-top', '2px');
$('div.fragment.well div.line:last').css('margin-bottom', '2px');
$('#MSearchBox').parent().remove();
$('div.fragment.well div.line:first').css('margin-top', '15px');
$('div.fragment.well div.line:last').css('margin-bottom', '15px');
$('table.doxtable').removeClass('doxtable').addClass('table table-striped table-bordered').each(function(){
$(this).prepend('<thead></thead>');
@ -77,11 +80,6 @@ $( document ).ready(function() {
$(this).siblings('.memItemLeft').attr('align', 'left');
});
$('table.memberdecls').find('.memTemplItemRight').each(function(){
$(this).contents().appendTo($(this).siblings('.memTemplItemLeft'));
$(this).siblings('.memTemplItemLeft').attr('align', 'left');
});
function getOriginalWidthOfImg(img_element) {
var t = new Image();
t.src = (img_element.getAttribute ? img_element.getAttribute("src") : false) || img_element.src;
@ -93,147 +91,6 @@ $( document ).ready(function() {
$(this).css('width', '100%');
});
/* responsive search box */
$('#MSearchBox').parent().remove();
var nav_container = $('<div class="row"></div>');
$('#navrow1').parent().prepend(nav_container);
var left_nav = $('<div class="col-md-9"></div>');
for (i = 0; i < 6; i++) {
var navrow = $('#navrow' + i + ' > ul.tablist').detach();
left_nav.append(navrow);
$('#navrow' + i).remove();
}
var right_nav = $('<div class="col-md-3"></div>').append('\
<div id="search-box" class="input-group">\
<div class="input-group-btn">\
<button aria-expanded="false" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">\
<span class="glyphicon glyphicon-search"></span> <span class="caret"></span>\
</button>\
<ul class="dropdown-menu">\
</ul>\
</div>\
<button id="search-close" type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>\
<input id="search-field" class="form-control" accesskey="S" onkeydown="searchBox.OnSearchFieldChange(event);" placeholder="Search ..." type="text">\
</div>');
$(nav_container).append(left_nav);
$(nav_container).append(right_nav);
$('#MSearchSelectWindow .SelectionMark').remove();
var search_selectors = $('#MSearchSelectWindow .SelectItem');
for (var i = 0; i < search_selectors.length; i += 1) {
var element_a = $('<a href="#"></a>').text($(search_selectors[i]).text());
element_a.click(function(){
$('#search-box .dropdown-menu li').removeClass('active');
$(this).parent().addClass('active');
searchBox.OnSelectItem($('#search-box li a').index(this));
searchBox.Search();
return false;
});
var element = $('<li></li>').append(element_a);
$('#search-box .dropdown-menu').append(element);
}
$('#MSearchSelectWindow').remove();
$('#search-box .close').click(function (){
searchBox.CloseResultsWindow();
});
$('body').append('<div id="MSearchClose"></div>');
$('body').append('<div id="MSearchBox"></div>');
$('body').append('<div id="MSearchSelectWindow"></div>');
searchBox.searchLabel = '';
searchBox.DOMSearchField = function() {
return document.getElementById("search-field");
}
searchBox.DOMSearchClose = function(){
return document.getElementById("search-close");
}
/* search results */
var results_iframe = $('#MSearchResults').detach();
$('#MSearchResultsWindow')
.attr('id', 'search-results-window')
.addClass('panel panel-default')
.append(
'<div class="panel-heading">\
<h3 class="panel-title">Search Results</h3>\
</div>\
<div class="panel-body"></div>'
);
$('#search-results-window .panel-body').append(results_iframe);
searchBox.DOMPopupSearchResultsWindow = function() {
return document.getElementById("search-results-window");
}
function update_search_results_window() {
$('#search-results-window').removeClass('panel-default panel-success panel-warning panel-danger')
var status = $('#MSearchResults').contents().find('.SRStatus:visible');
if (status.length > 0) {
switch(status.attr('id')) {
case 'Loading':
case 'Searching':
$('#search-results-window').addClass('panel-warning');
break;
case 'NoMatches':
$('#search-results-window').addClass('panel-danger');
break;
default:
$('#search-results-window').addClass('panel-default');
}
} else {
$('#search-results-window').addClass('panel-success');
}
}
$('#MSearchResults').load(function() {
$('#MSearchResults').contents().find('link[href="search.css"]').attr('href','../doxygen.css');
$('#MSearchResults').contents().find('head').append(
'<link href="../customdoxygen.css" rel="stylesheet" type="text/css">');
update_search_results_window();
// detect status changes (only for search with external search backend)
var observer = new MutationObserver(function(mutations) {
update_search_results_window();
});
var config = { attributes: true};
var targets = $('#MSearchResults').contents().find('.SRStatus');
for (i = 0; i < targets.length; i++) {
observer.observe(targets[i], config);
}
});
/* enumerations */
$('table.fieldtable').removeClass('fieldtable').addClass('table table-striped table-bordered').each(function(){
$(this).prepend('<thead></thead>');
$(this).find('tbody > tr:first').prependTo($(this).find('thead'));
$(this).find('td > span.success').parent().addClass('success');
$(this).find('td > span.warning').parent().addClass('warning');
$(this).find('td > span.danger').parent().addClass('danger');
});
/* todo list */
var todoelements = $('.contents > .textblock > dl.reflist > dt, .contents > .textblock > dl.reflist > dd');
for (var i = 0; i < todoelements.length; i += 2) {
$('.contents > .textblock').append(
'<div class="panel panel-default active">'
+ "<div class=\"panel-heading todoname\">" + $(todoelements[i]).html() + "</div>"
+ "<div class=\"panel-body\">" + $(todoelements[i+1]).html() + "</div>"
+ '</div>');
}
$('.contents > .textblock > dl').remove();
$(".memitem").removeClass('memitem');
$(".memproto").removeClass('memproto');
$(".memdoc").removeClass('memdoc');
@ -261,11 +118,4 @@ $( document ).ready(function() {
$(this).siblings('.memItemRight').remove();
}
});
$('td.memTemplItemLeft').each(function(){
if($(this).siblings('.memTemplItemRight').html()=="") {
$(this).attr('colspan', 2);
$(this).siblings('.memTemplItemRight').remove();
}
});
searchBox.CloseResultsWindow();
});

View File

@ -1,20 +1,15 @@
<!-- HTML footer for doxygen 1.8.8-->
<!-- HTML footer for doxygen 1.8.14-->
<!-- start footer part -->
<!--BEGIN GENERATE_TREEVIEW-->
<!-- <div id="nav-path" class="navpath"><\!-- id is needed for treeview function! -\-> -->
<!-- <ul> -->
<!-- $navpath -->
<!-- <li class="footer">$generatedby -->
<!-- <a href="http://www.doxygen.org/index.html"> -->
<!-- <img class="footer" src="$relpath^doxygen.png" alt="doxygen"/></a> $doxygenversion </li> -->
<!-- </ul> -->
<!-- </div> -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
$navpath
<li class="footer">$generatedby
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="$relpath^doxygen.png" alt="doxygen"/></a> $doxygenversion </li>
</ul>
</div>
<!--END GENERATE_TREEVIEW-->
</div>
</div>
</div>
</div>
</div>
<!--BEGIN !GENERATE_TREEVIEW-->
<hr class="footer"/><address class="footer"><small>
$generatedby &#160;<a href="http://www.doxygen.org/index.html">

View File

@ -1,72 +1,39 @@
<!-- HTML header for doxygen 1.8.8-->
<!-- HTML header for doxygen 1.8.14-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="$relpath^dynsections.js"></script>
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen $doxygenversion"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<!-- <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script> -->
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
<!--<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>-->
$extrastylesheet
<!-- $treeview -->
<!-- $search -->
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="$relpath^dynsections.js"></script>
$treeview
$search
$mathjax
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
<link href="http://thomasf.github.io/solarized-css/solarized-light.min.css" rel="stylesheet"></link>
$extrastylesheet
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
<script type="text/javascript" src="$relpath^doxy-boot.js"></script>
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> -->
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script> -->
<script type="text/javascript" src="doxy-boot.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<!-- this div, it is closed by doxygen! -->
<div id="titlearea">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">$projectname $projectnumber</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav> <!--BEGIN TITLEAREA-->
<!-- <\!--BEGIN TITLEAREA-\-> -->
<!-- <div id="titlearea"> -->
<!-- <table cellspacing="0" cellpadding="0"> -->
<!-- <tbody> -->
<!-- <tr style="height: 56px;"> -->
@ -90,12 +57,12 @@
<!-- <\!--END !PROJECT_NAME-\-> -->
<!-- <\!--BEGIN DISABLE_INDEX-\-> -->
<!-- <\!--BEGIN SEARCHENGINE-\-> -->
<!-- <td>$Search</td> -->
<!-- <td>$searchbox</td> -->
<!-- <\!--END SEARCHENGINE-\-> -->
<!-- <\!--END DISABLE_INDEX-\-> -->
<!-- </tr> -->
<!-- </tbody> -->
``<!-- </tbody> -->
<!-- </table> -->
</div>
<!-- </div> -->
<!--END TITLEAREA-->
<!-- end header part -->

View File

@ -1,7 +1,9 @@
Downloading and Installing YAP {#INSTALL}
===========================
This text includes instructions to download and install YAP.
Installing YAP {#INSTALL}
++++++++
[TOC]
### Downloading YAP {#Download}
@ -24,7 +26,7 @@ The first argument is the repository, the last argument is the (optional) target
There are a variety of graphical interfaces to `git`, including GitHub's own [GitHub Desktop](https://desktop.github.com/) that supports Microsoft Windows and Apple OSX. A list with GUI applications, editor integration, and much more can be found at the [git Wiki](https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools),
#### Download Options
### Download Options
It may be useful to know:
@ -40,7 +42,6 @@ It may be useful to know:
these documents.
### Compiling YAP {#CompilingYAP}
-------------
YAP-6.3.4 is a [cmake](www.cmake.org) based
system. We use `cmake` because it supports mosts popular software, can
@ -48,7 +49,7 @@ generate Makefiles, Ninja, Apple's XCode, VisualStudio and ANdroid
Studio, and because it includes packaging suppport, The steps required
to install core YAP under `cmake`:
##### `C/C++` compiler
#### The compiler
*Status as of early 2017*
@ -65,7 +66,7 @@ to install core YAP under `cmake`:
YAP compiles cleanly under cross-compilers, and we have used the
crosss-compilation system [mxe](http://mxe.cc/) system with good results.
##### `cmake`
### cmake
All Linux and BSD distributions include `cmake`, so
does [Homebrew](https://brew.sh/)
@ -80,7 +81,7 @@ the [CMake site](https://www.cmake.org).
If you have an older Linux you may need to compile from source,
available at GitHub.
##### Ensure that you have other necessary packages installed:
### Ensure that you have other necessary packages installed:
+ YAP requires [gmp]{https://gmplib.org/} for infinite precision
integer and rational. Please ensure the development pacakage
@ -101,7 +102,7 @@ available at GitHub.
+ make sure to install Python-3, and not Python-2,
##### Compile and Install
### Compile and Install
1: Create a directory, say `Build` and `cd` to the directory (`cd Build`).
*YAP should not be compiled at its rootxo directory, some packages do not allow for that.
@ -115,15 +116,14 @@ available at GitHub.
5: If you feel satisfied with the result, do `make install`.
* In most systems you will need to be superuser in order to do `make install` and `make info` on the standard directories.
Tuning the Functionality of YAP
-------------------------------
### Tuning the Functionality of YAP
By default, YAP supports tabling, depth first search, and most features found in
modern Prologs. In some cases, you may want to suport extra features, or reduce system size.
`cmake`provides an graphical interface for doing so. From the commmand line, a typical example could be:
~~~~~
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~ /users/vsc/src/yap
Cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~ /users/vsc/src/yap
~~~~~
The first argument says that this is a release, compiled with full optimisation. The second argument says YAP should install under the ~ drectory. In this case, YAP will add the binaries to /users/vsc/bin, include files to `/users/vsc/include/Yap`, Prolog files to `/users/vsc/share/Yap`, and ay DLL to `/users/vsc/lib/Yap`.
@ -177,7 +177,7 @@ You can also use `xcodebuild` from the command line.
Bext follow instructions to fully compile YAP:
#### Compilation Notes for OSX/Brew
### Compilation Notes for OSX/Brew
Next follows a detailed description of a full install of YAP, including all the packages that YAP can use:
@ -210,7 +210,7 @@ brew install cudd
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl ..
~~~~~
#### Compilation Notes for Android
### Compilation Notes for Android
Next we present the compilation process for Android. The environment is an OSX, but steps
should be similar for Linux machines. We assume you have downloaded both the Android NDK and the Android SDK.

View File

@ -1,5 +1,5 @@
Attributed Variables and Co-Routining {#attributes}
=======================================
### Attributed Variables and Co-Routining {#attributes}
@ingroup extensions
@ -26,15 +26,9 @@ work with. Most packages included in YAP that use attributed
variables, such as CHR, CLP(FD), and CLP(QR), rely on the SWI-Prolog
awi interface.
+ @ref SICS_attributes
+ @ref sicsatts
+ @ref New_Style_Attribute_Declarations
+ @ref CohYroutining
+ @ref AttributeVariables_Builtins
[TOC]
### SICStus Style attribute declarations. {#SICS_attributes}
#### SICStus Style attribute declarations. {#SICS_attributes}
The YAP library `atts` implements attribute variables in the style of
SICStus Prolog. Attributed variables work as follows:
@ -279,7 +273,7 @@ Module:get_atts/2`.
@}
@{
### hProlog and SWI-Prolog style Attribute Declarations {#New_Style_Attribute_Declarations}
#### hProlog and SWI-Prolog style Attribute Declarations {#New_Style_Attribute_Declarations}
The following documentation is taken from the SWI-Prolog manual.
@ -351,7 +345,7 @@ v put_attr(Y, domain, Domain),
@{
### Co-routining {#CohYroutining}
#### Co-routining {#CohYroutining}
Prolog uses a simple left-to-right flow of control. It is sometimes
convenient to change this control so that goals will only execute when

View File

@ -1,4 +1,5 @@
@defgroup builtins YAP Core Built-ins
YAP Core Built-ins {#builtins}
==================
@brief This chapter describes the core built-in predicates that control the execution of
Prolog programs, provide fundamental functionality such as termm manipulation or arithmetic, and support interaction with external
@ -13,3 +14,49 @@ notation will be used:
argument" - the argument is read, not written, and it cannot be a free variable at the time of the call;
+ a preceding minus sign will denote an "output argument";
+ an argument with no preceding symbol can be used in both ways.
+ @ref AbsoluteFileName
+ @ref CompilerAnalysis
+ @ref New_Style_Attribute_Declarations
+ @ref YAPControl
+ @ref Profiling
+ @ref Call_Counting
+ @ref YAPConsulting
+ @ref YAPReadFiles
+ @ref ModPreds
+ @ref Conditional_Compilation
+ @ref YAPBigLoad
+ @ref Deb_Interaction
+ @ref DepthLimited
+ @ref Dialects
+ @ref Directives
+ @ref EAM
+ @ref SWI-error
+ @ref YAPErrorHandler
+ @ref CompiledExpression
+ @ref YAPFlags
+ @ref Grammars
+ @ref Hacks
+ @ref Listing
+ @ref LoadForeign
+ @ref Messages
+ @ref YAPMetaPredicates
+ @ref ModuleBuiltins
+ @ref YAPOS
+ @ref pathconf
+ @ref YAPPredDecls
+ @ref Database
+ @ref The_Count_Profiler
+ @ref QLY
+ @ref Sets
+ @ref Deb_Preds
+ @ref Statistics
+ @ref Tabling
+ @ref Threads
+ @ref TopLevel
+ @ref Undefined_Procedures
+ @ref MixBag
+ @ref InputOutput
+ @ref IO_Sockets
+ @ref ypp

View File

@ -1,24 +0,0 @@
YAP Core Built-ins {#core}
=================
This chapter describes the core predicates that control the execution of
Prolog programs, provide fundamental functionality such as termm manipulation or arithmetic, and support interaction with external
resources, Many of the predicates described here have been standardised by the ISO. The standartised subset of Prolog also known as ISO-Prolog.
In the description of the arguments of predicates the following
notation will be used:
+ a preceding plus sign will denote an argument as an "input
argument" - it cannot be a free variable at the time of the call;
+ a preceding minus sign will denote an "output argument";
+ an argument with no preceding symbol can be used in both ways.
@copydoc builtins
@{
@defgroup builtins YAP Core Builtins:
@}

View File

@ -1,8 +1,62 @@
@page Library YAP Library
YAP Prolog Library {#library}
===================
the library_directory path (set by the
`LIBDIR` variable in the Makefile for YAP). Several files in the
library are originally from the public-domain Edinburgh Prolog library.
@tableofcontents
+ @ref apply_stub
+ @ref apply_macros
+ @ref args
+ @ref Association_Lists
+ @ref sicsatts
+ @ref avl
+ @ref bhash
+ @ref block_diagram
+ @ref c_alarms
+ @ref charsio
+ @ref clauses
+ @ref cleanup
+ @ref dbqueues
+ @ref dbusage
+ @ref dgraphs
+ @ref exo_interval
+ @ref flags
+ @ref gensym
+ @ref yap_hacks
+ @ref heaps
+ @ref lam_mpi
+ @ref line_utils
+ @ref swi_listing
+ @ref Log2MD
+ @ref mapargs
+ @ref maplist
+ @ref matlab
+ @ref matrix
+ @ref nb
+ @ref ordsets
+ @ref parameters
+ @ref queues
+ @ref random
+ @ref Pseudo_Random
+ @ref rbtrees
+ @ref readutil
+ @ref regexp
+ @ref rltrees
+ @ref Splay_Trees
+ @ref operating_system_support
+ @ref Terms
+ @ref timeout
+ @ref trees
+ @ref tries
+ @ref ugraphs
+ @ref undgraphs
+ @ref varnumbers
+ @ref wdgraphs
+ @ref wgraphs
+ @ref wundgraphs

View File

@ -1,4 +1,5 @@
@defgroup load_files Loading and Organising YAP Programs
Loading and Organising YAP Programs {#load_files}
====================================
@brief Next, we present the main predicates and directives available to load
files and to control the Prolog environment.

View File

@ -1,5 +1,5 @@
### The YAP Module system {#YAPModules}
The YAP Module system {#YAPModules}
=======================
The YAP module system is based on the Quintus/SISCtus module
system ˜\cite quintus . In this design, modules are named collections of predicates,
@ -38,6 +38,8 @@ the module/2 declaration.This declaration sets the source module when
it starts consulting a file, and resets it at the end. One can set
the type-in module permanently by using the built-in `module/1`.
[TOC]
#### Explicit Naming {#ExplicitNaming}
The module system allows one to _explicitly_ specify the source mode for

View File

@ -1,13 +1,13 @@
#### Running YAP {#run}
## Running YAP {#run}
We next describe how to invoke YAP in Unix systems.
[TOC]
##### Running YAP Interactively {#Running_YAP_Interactively}
### Running YAP Interactively {#Running_YAP_Interactively}
Most often you will want to use YAP in interactive mode. Assuming that
@ -104,7 +104,7 @@ YAP can also be used to run Prolog files as scripts, at least in
Unix-like environments. A simple example is shown next (do not forget
that the shell comments are very important):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
#!/usr/local/bin/yap -L --
#
# Hello World script file using YAP
@ -113,7 +113,7 @@ that the shell comments are very important):
:- write('Hello World'), nl.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
The `#!` characters specify that the script should call the binary
file YAP. Notice that many systems will require the complete path to the
@ -147,7 +147,7 @@ Notice that the `--` is required so that the shell passes the extra
arguments to YAP. As an example, consider the following script
`dump_args`:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
#!/usr/bin/yap -L --
#.
@ -158,13 +158,13 @@ main( [H|T] ) :-
:- unix( argv(AllArgs) ), main( AllArgs ).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
If you this run this script with the arguments:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
./dump_args -s 10000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
the script will start an YAP process with stack size `10MB`, and
the list of arguments to the process will be empty.
@ -172,7 +172,7 @@ Often one wants to run the script as any other program, and for this it
is convenient to ignore arguments to YAP. This is possible by using
`L --` as in the next version of `dump_args`:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
#!/usr/bin/yap -L --
main( [] ).
@ -182,13 +182,13 @@ main( [H|T] ) :-
:- unix( argv(AllArgs) ), main( AllArgs ).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
The `--` indicates the next arguments are not for YAP. Instead,
they must be sent directly to the argv built-in. Hence, running
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
./dump_args test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
will write `test` on the standard output.

View File

@ -67,9 +67,9 @@ assert/1, clause/1 and retract/1 are used. First
predicates which will change during execution should be declared as
`dynamic` by using commands like:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~
:- dynamic f/n.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~
where `f` is the predicate name and n is the arity of the
predicate. Note that several such predicates can be declared in a
@ -174,12 +174,9 @@ standard.
The following incompatibilities between YAP and the ISO standard are
known to still exist (please check Ulrich Neumerkel's page for more details):
<ul>
<li>Currently, YAP does not handle overflow errors in integer
+ Currently, YAP does not handle overflow errors in integer
operations, and handles floating-point errors only in some
architectures. Otherwise, YAP follows IEEE arithmetic.
<ul>
Please inform the authors on other incompatibilities that may still
exist.

View File

@ -1,6 +1,7 @@
///
/// @file YapErrors.h
/// /// @adddtogroup YapError
///
/// @addtogroup YapError
///
/// The file YapErrors.h contains a list with all the error classes known
/// internally to the YAP system.

View File

@ -11,30 +11,6 @@
:- module(apply_stub,[]).
/**
* @file apply.yap
* @defgroup apply_stub Apply Predicates
*
* @ingroup library
*
* @{
This library provides a SWI-compatible set of utilities for applying a
predicate to all elements of a list.
The apply library is a _stub_, it just forwards definitions to the
@ref maplist library. The predicates forwarded are:
- maplist/2,
- maplist/3,
- maplist/4,
- maplist/5,
- include/3,
- exclude/3,
- partition/4,
- partition/5
*/
:- reexport(library(maplist),
[maplist/2,
@ -47,6 +23,31 @@ The apply library is a _stub_, it just forwards definitions to the
partition/5
]).
/**
* @defgroup apply_stub Apply Predicates
*
* @ingroup library
*
* @{
This library provides a SWI-compatible set of utilities for applying a
predicate to all elements of a list.
The apply library is a _stub_, it just forwards definitions to the
@ref maplist library. The predicates forwarded are:
- @ref maplist/2,
- @ref maplist/3,
- @ref maplist/4,
- @ref maplist/5,
- @ref include/3,
- @ref exclude/3,
- @ref partition/4,
- @ref partition/5
*/
%% @}

View File

@ -2,8 +2,8 @@
%% @file apply_macros.yap
%% @author E. Alphonse from code by Joachim Schimpf
%% @date 15 June 2002
%% @nrief Purpose: Macros to apply a predicate to all elements
% of a list or to all sub-terms of a term.
%% @brief Purpose: Macros to apply a predicate to all elements
%% of a list or to all sub-terms of a term.
:- module(apply_macros, []).

View File

@ -2,15 +2,8 @@
* @file library/lists.yap
* @author Bob Welham, Lawrence Byrd, and R. A. O'Keefe. Contributions from Vitor Santos Costa, Jan Wielemaker and others.
* @date 1999
*
* @{
*
x * @addtogroup library The Prolog Library
*
* @brief List Manipulation Predicates
*
*
*/
% This file has been included as an YAP library by Vitor Santos Costa, 1999
:- module(lists,
@ -52,15 +45,18 @@ x * @addtogroup library The Prolog Library
]).
/** @defgroup lists List Manipulation
@ingroup library
@{
The following list manipulation routines are available once included
/**
* @{
*
* @addtogroup library The Prolog Library
*
* @brief List Manipulation Predicates
*
* The following list manipulation routines are available once included
with the `use_module(library(lists))` command.
*/
/** @pred list_concat(+ _Lists_,? _List_)

View File

@ -47,6 +47,7 @@
/**
* @defgroup maplist Map List and Term Operations
* @ingroup library
* @{
*
* This library provides a set of utilities for applying a predicate to
* all elements of a list. They allow one to easily perform the most common do-loop constructs in Prolog.
@ -56,20 +57,20 @@
* by Joachim Schimpf and on code from SWI-Prolog, and it is also inspired by the GHC
* libraries.
*
* The following routines are available once included with the
* The routines are available once included with the
* `use_module(library(apply_macros))` command.
* @author : Lawrence Byrd
* @author Richard A. O'Keefe
* @author Joachim Schimpf
* @author Jan Wielemaker
* @author E. Alphonse
* @author Vitor Santos Costa
*/
/*
Examples:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.prolog}
%given
~~~~
given the progran:
~~~~
plus(X,Y,Z) :- Z is X + Y.
plus_if_pos(X,Y,Z) :- Y > 0, Z is X + Y.
@ -82,7 +83,7 @@ trans(TermIn, TermOut) :-
TermIn =.. [p|Args],
TermOut =..[q|Args], !.
trans(X,X).
~~~~
%success
?- maplist(plus(1), [1,2,3,4], [2,3,4,5]).
@ -96,15 +97,13 @@ trans(X,X).
?- sumlist(plus, [1,2,3,4], 1, 11).
?- maplist(mapargs(number_atom),[c(1),s(1,2,3)],[c('1'),s('1','2','3')]).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@{
~~~~
*/
/** @pred maplist(+ _Pred_,+ _List1_,+ _List2_)
/** @pred maplist( 2:Pred, + _List1_,+ _List2_)
Apply _Pred_ on all successive pairs of elements from
_List1_ and
@ -113,7 +112,8 @@ pair. See the example above.
*/
/** @pred maplist(+ _Pred_,+ _List1_,+ _List2_,+ _List4_)
/** @pred maplist(3:Pred,+ List1,+ List2,+ List4)
Apply _Pred_ on all successive triples of elements from _List1_,
_List2_ and _List3_. Fails if _Pred_ can not be applied to a
@ -167,13 +167,17 @@ triple. See the example above.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/** include(+ _Pred_, + _ListIn_, ? _ListOut_)
/**
@pred include( 2:Pred, + ListIn, ? ListOut)
Same as selectlist/3.
*/
include(G,In,Out) :-
selectlist(G, In, Out).
/** selectlist(: _Pred_, + _ListIn_, ? _ListOut_))
/**
@pred selectlist(1:Pred, + ListIn, ? ListOut))
Creates _ListOut_ of all list elements of _ListIn_ that pass a given test
*/
selectlist(_, [], []).
@ -185,7 +189,9 @@ selectlist(Pred, [In|ListIn], ListOut) :-
),
selectlist(Pred, ListIn, NewListOut).
/** selectlist(: _Pred_, + _ListIn_, + _ListInAux_, ? _ListOut_, ? _ListOutAux_)
/**
@pred selectlist( 2:Pred, + ListIn, + ListInAux, ? ListOut, ? ListOutAux)
Creates _ListOut_ and _ListOutAux_ of all list elements of _ListIn_ and _ListInAux_ that
pass the given test _Pred_.
*/
@ -200,7 +206,8 @@ selectlists(Pred, [In|ListIn], [In1|ListIn1], ListOut, ListOut1) :-
),
selectlist(Pred, ListIn, ListIn1, NewListOut, NewListOut1).
/** selectlist(: _Pred_, + _ListIn_, + _ListInAux_, ? _ListOut_)
/** @pred selectlist( 2:Pred, + ListIn, + ListInAux, ? ListOut)
Creates _ListOut_ of all list elements of _ListIn_ that
pass the given test _Pred_ using + _ListInAux_ as an
auxiliary element.
@ -214,7 +221,9 @@ selectlist(Pred, [In|ListIn], [In1|ListIn1], ListOut) :-
),
selectlist(Pred, ListIn, ListIn1, NewListOut).
/** exclude(+ _Goal_, + _List1_, ? _List2_)
/**
@pred exclude( 2:Goal, + List1, ? List2)
Filter elements for which _Goal_ fails. True if _List2_ contains
those elements _Xi_ of _List1_ for which `call(Goal, Xi)` fails.
*/
@ -227,8 +236,10 @@ exclude(Pred, [In|ListIn], ListOut) :-
),
exclude(Pred, ListIn, NewListOut).
/** partition(+ _Pred_, + _List1_, ? _Included_, ? _Excluded_)
Filter elements of _List_ according to _Pred_. True if
/**
@pred partition(1:Pred, + List1, ? Included, ? Excluded)
Filter elements of _List1_ according to _Pred_. True if
_Included_ contains all elements for which `call(Pred, X)`
succeeds and _Excluded_ contains the remaining elements.
*/
@ -243,7 +254,8 @@ partition(Pred, [In|ListIn], List1, List2) :-
),
partition(Pred, ListIn, RList1, RList2).
/** partition(+ _Pred_, + _List1_, ? _Lesser_, ? _Equal_, ? _Greater_)
/**
@pred partition(2:Pred, + List1, ? Lesser, ? Equal, ? Greater)
Filter list according to _Pred_ in three sets. For each element
_Xi_ of _List_, its destination is determined by
@ -274,7 +286,9 @@ partition(Pred, [In|ListIn], List1, List2, List3) :-
),
partition(Pred, ListIn, RList1, RList2, RList3).
/** checklist(: _Pred_, + _List_)
/**
@pred checklist( 1:Pred, + List)
Succeeds if the predicate _Pred_ succeeds on all elements of _List_.
*/
checklist(_, []).
@ -282,7 +296,8 @@ checklist(Pred, [In|ListIn]) :-
call(Pred, In),
checklist(Pred, ListIn).
/** maplist(: _Pred_, ? _ListIn_)
/**
@pred maplist(: Pred, ? ListIn)
Applies predicate _Pred_( _El_ ) to all
elements _El_ of _ListIn_.
@ -294,7 +309,8 @@ maplist(Pred, [In|ListIn]) :-
maplist(Pred, ListIn).
/** maplist(: _Pred_, ? _L1_, ? _L2_ )
/**
@pred maplist(: Pred, ? L1, ? L2 )
_L1_ and _L2_ are such that
`call( _Pred_, _A1_, _A2_)` holds for every
corresponding element in lists _L1_, _L2_.
@ -308,7 +324,8 @@ maplist(Pred, [In|ListIn], [Out|ListOut]) :-
call(Pred, In, Out),
maplist(Pred, ListIn, ListOut).
/** maplist(: _Pred_, ? _L1_, ? _L2_, ? _L3_)
/**
@pred maplist(: Pred, ? L1, ? L2, ? L3)
_L1_, _L2_, and _L3_ are such that
`call( _Pred_, _A1_, _A2_, _A3_)` holds for every
corresponding element in lists _L1_, _L2_, and _L3_.
@ -319,7 +336,9 @@ maplist(Pred, [A1|L1], [A2|L2], [A3|L3]) :-
call(Pred, A1, A2, A3),
maplist(Pred, L1, L2, L3).
/** maplist(: _Pred_, ? _L1_, ? _L2_, ? _L3_, ? _L4_)
/**
@pred maplist(: Pred, ? L1, ? L2, ? L3, ? L4)
_L1_, _L2_, _L3_, and _L4_ are such that
`call( _Pred_, _A1_, _A2_, _A3_, _A4_)` holds
for every corresponding element in lists _L1_, _L2_, _L3_, and
@ -331,7 +350,7 @@ maplist(Pred, [A1|L1], [A2|L2], [A3|L3], [A4|L4]) :-
maplist(Pred, L1, L2, L3, L4).
/**
convlist(: _Pred_, + _ListIn_, ? _ListOut_) @anchor convlist3
@pred convlist(: Pred, + ListIn, ? ListOut)
A combination of maplist/3 and selectlist/3: creates _ListOut_ by
applying the predicate _Pred_ to all list elements on which
@ -355,7 +374,7 @@ convlist(Pred, [_|Olds], News) :-
convlist(Pred, Olds, News).
/**
convlist(: Pred, ? ListIn, ?ExtraList, ? ListOut) @anchor convlist5
@pred convlist(: Pred, ? ListIn, ?ExtraList, ? ListOut)
A combination of maplist/4 and selectlist/3: _ListIn_, _ListExtra_,
and _ListOut_ are the sublists so that the predicate _Pred_ succeeds.
@ -378,7 +397,7 @@ convlist(Pred, [_|Olds], News) :-
convlist(Pred, Olds, News).
/**
mapnodes(+ _Pred_, + _TermIn_, ? _TermOut_)
@pred mapnodes(+ _Pred_, + _TermIn_, ? _TermOut_)
Creates _TermOut_ by applying the predicate _Pred_
to all sub-terms of _TermIn_ (depth-first and left-to-right order).
@ -398,7 +417,7 @@ mapnodes_list(Pred, [TermIn|ArgsIn], [TermOut|ArgsOut]) :-
mapnodes_list(Pred, ArgsIn, ArgsOut).
/**
checknodes(+ _Pred_, + _Term_) @anchor checknodes
@pred checknodes(+ _Pred_, + _Term_)
Succeeds if the predicate _Pred_ succeeds on all sub-terms of
_Term_ (depth-first and left-to-right order)
@ -417,7 +436,7 @@ checknodes_list(Pred, [Term|Args]) :-
checknodes_list(Pred, Args).
/**
sumlist(: _Pred_, + _List_, ? _AccIn_, ? _AccOut_)
@pred sumlist(: _Pred_, + _List_, ? _AccIn_, ? _AccOut_)
Calls _Pred_ on all elements of List and collects a result in
_Accumulator_. Same as fold/4.
@ -428,7 +447,7 @@ sumlist(Pred, [H|T], AccIn, AccOut) :-
sumlist(Pred, T, A1, AccOut).
/**
sumnodes(+ _Pred_, + _Term_, ? _AccIn_, ? _AccOut_) @anchor sumnodes
@pred sumnodes(+ _Pred_, + _Term_, ? _AccIn_, ? _AccOut_)
Calls the predicate _Pred_ on all sub-terms of _Term_ and
collect a result in _Accumulator_ (depth-first and left-to-right
@ -457,11 +476,12 @@ sumnodes_body(Pred, Term, A1, A3, N0, Ar) :-
* FOLDL *
*******************************/
%% foldl(:Goal, +List, +V0, -V, +W0, -WN).
%%
%% @pred foldl(:Goal, +List, +V0, -V, +W0, -WN).
%
/**
foldl(: _Pred_, + _List1_, + _List2_, ? _AccIn_, ? _AccOut_)
@pred oldl(: _Pred_, + _List1_, + _List2_, ? _AccIn_, ? _AccOut_)
Calls _Pred_ on all elements of `List1` and collects a result in _Accumulator_. Same as
foldr/3.
@ -475,7 +495,7 @@ foldl_([H|T], Goal, V0, V) :-
foldl_(T, Goal, V1, V).
/**
foldl(: _Pred_, + _List1_, + _List2_, ? _AccIn_, ? _AccOut_)
@pred foldl(: _Pred_, + _List1_, + _List2_, ? _AccIn_, ? _AccOut_)
Calls _Pred_ on all elements of _List1_ and
_List2_ and collects a result in _Accumulator_. Same as
@ -522,7 +542,7 @@ foldl_([H1|T1], [H2|T2], [H3|T3], [H4|T4], Goal, V0, V) :-
/**
foldl2(: _Pred_, + _List_, ? _X0_, ? _X_, ? _Y0_, ? _Y_)
@pred foldl2(: _Pred_, + _List_, ? _X0_, ? _X_, ? _Y0_, ? _Y_)
Calls _Pred_ on all elements of `List` and collects a result in
_X_ and _Y_.
@ -537,7 +557,7 @@ foldl2_([H|T], Goal, V0, V, W0, W) :-
foldl2_(T, Goal, V1, V, W1, W).
/**
foldl2(: _Pred_, + _List_, ? _List1_, ? _X0_, ? _X_, ? _Y0_, ? _Y_)
v @pred foldl2(: _Pred_, + _List_, ? _List1_, ? _X0_, ? _X_, ? _Y0_, ? _Y_)
Calls _Pred_ on all elements of _List_ and _List1_ and collects a result in
_X_ and _Y_.
@ -551,7 +571,7 @@ foldl2_([H1|T1], [H2|T2], Goal, V0, V, W0, W) :-
foldl2_(T1, T2, Goal, V1, V, W1, W).
/**
foldl2(: _Pred_, + _List_, ? _List1_, ? _List2_, ? _X0_, ? _X_, ? _Y0_, ? _Y_)
@pred foldl2(: _Pred_, + _List_, ? _List1_, ? _List2_, ? _X0_, ? _X_, ? _Y0_, ? _Y_)
Calls _Pred_ on all elements of _List_, _List1_ and _List2_ and collects a result in
_X_ and _Y_.
@ -567,7 +587,7 @@ foldl2_([H1|T1], [H2|T2], [H3|T3], Goal, V0, V, W0, W) :-
/**
foldl3(: _Pred_, + _List1_, ? _List2_, ? _X0_, ? _X_, ? _Y0_, ? _Y_, ? _Z0_, ? _Z_)
@pred foldl3(: _Pred_, + _List1_, ? _List2_, ? _X0_, ? _X_, ? _Y0_, ? _Y_, ? _Z0_, ? _Z_)
Calls _Pred_ on all elements of `List` and collects a
@ -582,7 +602,7 @@ foldl3_([H|T], Goal, V0, V, W0, W, X0, X) :-
fold3_(T, Goal, V1, V, W1, W, X1, X).
/**
foldl4(: _Pred_, + _List1_, ? _List2_, ? _X0_, ? _X_, ? _Y0_, ? _Y_, ? _Z0_, ? _Z_, ? _W0_, ? _W_)
@pred foldl4(: _Pred_, + _List1_, ? _List2_, ? _X0_, ? _X_, ? _Y0_, ? _Y_, ? _Z0_, ? _Z_, ? _W0_, ? _W_)
Calls _Pred_ on all elements of `List` and collects a
@ -618,7 +638,6 @@ foldl4_([H|T], Goal, V0, V, W0, W, X0, X, Y0, Y) :-
% ==
/**
scanl(: _Pred_, + _List_, + _V0_, ? _Values_)
Left scan of list. The scanl family of higher order list

View File

@ -37,16 +37,35 @@
* @(#)cclass.h 8.3 (Berkeley) 3/20/94
*/
/**
* @file cclass.h
*
* @brief Regexp character classes.
*
* @namespace regexp
*
*/
typedef enum {CALNUM, CALPHA, CBLANK, CCNTRL, CDIGIT, CGRAPH,
CLOWER, CPRINT, CPUNCT, CSPACE, CUPPER, CXDIGIT} citype;
typedef enum {
CALNUM,
CALPHA,
CBLANK,
CCNTRL,
CDIGIT,
CGRAPH,
CLOWER,
CPRINT,
CPUNCT,
CSPACE,
CUPPER,
CXDIGIT
} citype;
/* character-class table */
static struct cclass {
char *name;
citype fidx;
} cclasses[] = {
{"alnum", CALNUM},
} cclasses[] = {{"alnum", CALNUM},
{"alpha", CALPHA},
{"blank", CBLANK},
{"cntrl", CCNTRL},
@ -58,5 +77,6 @@ static struct cclass {
{"space", CSPACE},
{"upper", CUPPER},
{"xdigit", CXDIGIT},
{NULL, }
};
{
NULL,
}};

View File

@ -37,12 +37,20 @@
* @(#)cname.h 8.3 (Berkeley) 3/20/94
*/
/**
* @file cname.h
*
* Vharacter names.
*
* @namespace regexp
*
*/
/* character-name table */
static struct cname {
char *name;
char code;
} cnames[] = {
{"NUL", '\0'},
} cnames[] = {{"NUL", '\0'},
{"SOH", '\001'},
{"STX", '\002'},
{"ETX", '\003'},
@ -137,5 +145,4 @@ static struct cname {
{"right-curly-bracket", '}'},
{"tilde", '~'},
{"DEL", '\177'},
{NULL, 0}
};
{NULL, 0}};

View File

@ -44,6 +44,14 @@
* of code.
*/
/**
* @file engine.c
*
* regex interpeter.
*
* @namespace regexp
*/
#include "config.h"
#ifndef HAVE_REGEXEC

View File

@ -37,17 +37,25 @@
* @(#)regcomp.c 8.5 (Berkeley) 3/20/94
*/
/**
* @file regcomp.c
*
* Regular expression compiler
*
* @namespace regexp
*
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
#endif /* LIBC_SCCS and not lint */
#include "config.h"
#include "YapInterface.h"
#include "config.h"
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#if HAVE_STRING_H
#include <string.h>
#endif
@ -64,8 +72,8 @@ static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
#include "collate.h"
#include "utils.h"
#include "regex2.h"
#include "utils.h"
#include "cclass.h"
#include "cname.h"
@ -89,8 +97,7 @@ struct collate_st_chain_pri collate_chain_pri_table[TABLE_SIZE];
* into ASCII-compatible range, it allows to handle
* "[a-z]"-type ranges with national characters.
*/
static int collate_range_cmp (int c1, int c2)
{
static int collate_range_cmp(int c1, int c2) {
static char s1[2], s2[2];
int ret;
#ifndef ASCII_COMPATIBLE_COLLATE
@ -256,8 +263,7 @@ static int never = 0; /* for use in asserts; shuts lint up */
= #define REG_DUMP 0200
*/
int /* 0 success, otherwise REG_something */
yap_regcomp(preg, pattern, cflags)
regex_t *preg;
yap_regcomp(preg, pattern, cflags) regex_t *preg;
const char *pattern;
int cflags;
{
@ -359,9 +365,7 @@ int cflags;
- p_ere - ERE parser top level, concatenation and alternation
== static void p_ere(register struct parse *p, int stop);
*/
static void
p_ere(p, stop)
register struct parse *p;
static void p_ere(p, stop) register struct parse *p;
int stop; /* character this ERE should end at */
{
register char c;
@ -405,9 +409,7 @@ int stop; /* character this ERE should end at */
- p_ere_exp - parse one subERE, an atom possibly followed by a repetition op
== static void p_ere_exp(register struct parse *p);
*/
static void
p_ere_exp(p)
register struct parse *p;
static void p_ere_exp(p) register struct parse *p;
{
register char c;
register sopno pos;
@ -554,9 +556,7 @@ register struct parse *p;
- p_str - string (no metacharacters) "parser"
== static void p_str(register struct parse *p);
*/
static void
p_str(p)
register struct parse *p;
static void p_str(p) register struct parse *p;
{
(void)REQUIRE(MORE(), REG_EMPTY);
while (MORE())
@ -575,9 +575,7 @@ register struct parse *p;
* category in such cases. This is fairly harmless; not worth fixing.
* The amount of lookahead needed to avoid this kludge is excessive.
*/
static void
p_bre(p, end1, end2)
register struct parse *p;
static void p_bre(p, end1, end2) register struct parse *p;
register int end1; /* first terminating character */
register int end2; /* second terminating character */
{
@ -609,8 +607,7 @@ register int end2; /* second terminating character */
== static int p_simp_re(register struct parse *p, int starordinary);
*/
static int /* was the simple RE an unbackslashed $? */
p_simp_re(p, starordinary)
register struct parse *p;
p_simp_re(p, starordinary) register struct parse *p;
int starordinary; /* is a leading * an ordinary character? */
{
register int c;
@ -727,8 +724,7 @@ int starordinary; /* is a leading * an ordinary character? */
== static int p_count(register struct parse *p);
*/
static int /* the value */
p_count(p)
register struct parse *p;
p_count(p) register struct parse *p;
{
register int count = 0;
register int ndigits = 0;
@ -749,9 +745,7 @@ register struct parse *p;
* Note a significant property of this code: if the allocset() did SETERROR,
* no set operations are done.
*/
static void
p_bracket(p)
register struct parse *p;
static void p_bracket(p) register struct parse *p;
{
register cset *cs = allocset(p);
register int invert = 0;
@ -823,9 +817,7 @@ register struct parse *p;
- p_b_term - parse one term of a bracketed character list
== static void p_b_term(register struct parse *p, register cset *cs);
*/
static void
p_b_term(p, cs)
register struct parse *p;
static void p_b_term(p, cs) register struct parse *p;
register cset *cs;
{
register char c;
@ -887,9 +879,8 @@ register cset *cs;
} else {
(void)REQUIRE(collate_range_cmp(start, finish) <= 0, REG_ERANGE);
for (i = CHAR_MIN; i <= CHAR_MAX; i++) {
if ( collate_range_cmp(start, i) <= 0
&& collate_range_cmp(i, finish) <= 0
)
if (collate_range_cmp(start, i) <= 0 &&
collate_range_cmp(i, finish) <= 0)
CHadd(cs, i);
}
}
@ -902,9 +893,7 @@ register cset *cs;
- p_b_cclass - parse a character-class name and deal with it
== static void p_b_cclass(register struct parse *p, register cset *cs);
*/
static void
p_b_cclass(p, cs)
register struct parse *p;
static void p_b_cclass(p, cs) register struct parse *p;
register cset *cs;
{
register int c;
@ -998,9 +987,7 @@ register cset *cs;
*
* This implementation is incomplete. xxx
*/
static void
p_b_eclass(p, cs)
register struct parse *p;
static void p_b_eclass(p, cs) register struct parse *p;
register cset *cs;
{
register char c;
@ -1014,8 +1001,7 @@ register cset *cs;
== static char p_b_symbol(register struct parse *p);
*/
static char /* value of symbol */
p_b_symbol(p)
register struct parse *p;
p_b_symbol(p) register struct parse *p;
{
register char value;
@ -1034,8 +1020,7 @@ register struct parse *p;
== static char p_b_coll_elem(register struct parse *p, int endc);
*/
static char /* value of collating element */
p_b_coll_elem(p, endc)
register struct parse *p;
p_b_coll_elem(p, endc) register struct parse *p;
int endc; /* name ended by endc,']' */
{
register char *sp = p->next;
@ -1063,8 +1048,7 @@ int endc; /* name ended by endc,']' */
== static char othercase(int ch);
*/
static char /* if no counterpart, return ch */
othercase(ch)
int ch;
othercase(ch) int ch;
{
ch = (uch)ch;
assert(isalpha(ch));
@ -1082,9 +1066,7 @@ int ch;
*
* Boy, is this implementation ever a kludge...
*/
static void
bothcases(p, ch)
register struct parse *p;
static void bothcases(p, ch) register struct parse *p;
int ch;
{
register char *oldnext = p->next;
@ -1108,9 +1090,7 @@ int ch;
- ordinary - emit an ordinary character
== static void ordinary(register struct parse *p, register int ch);
*/
static void
ordinary(p, ch)
register struct parse *p;
static void ordinary(p, ch) register struct parse *p;
register int ch;
{
register cat_t *cap = p->g->categories;
@ -1130,9 +1110,7 @@ register int ch;
*
* Boy, is this implementation ever a kludge...
*/
static void
nonnewline(p)
register struct parse *p;
static void nonnewline(p) register struct parse *p;
{
register char *oldnext = p->next;
register char *oldend = p->end;
@ -1154,9 +1132,7 @@ register struct parse *p;
- repeat - generate code for a bounded repetition, recursively if needed
== static void repeat(register struct parse *p, sopno start, int from, int to);
*/
static void
repeat(p, start, from, to)
register struct parse *p;
static void repeat(p, start, from, to) register struct parse *p;
sopno start; /* operand from here to end of strip */
int from; /* repeated from this number */
int to; /* to this number of times (maybe INFINITY) */
@ -1227,8 +1203,7 @@ int to; /* to this number of times (maybe INFINITY) */
== static int seterr(register struct parse *p, int e);
*/
static int /* useless but makes type checking happy */
seterr(p, e)
register struct parse *p;
seterr(p, e) register struct parse *p;
int e;
{
if (p->error == 0) /* keep earliest error condition */
@ -1242,9 +1217,7 @@ int e;
- allocset - allocate a set of characters for []
== static cset *allocset(register struct parse *p);
*/
static cset *
allocset(p)
register struct parse *p;
static cset *allocset(p) register struct parse *p;
{
register int no = p->g->ncsets++;
register size_t nc;
@ -1261,20 +1234,17 @@ register struct parse *p;
if (p->g->sets == NULL)
p->g->sets = (cset *)malloc(nc * sizeof(cset));
else
p->g->sets = (cset *)realloc((char *)p->g->sets,
nc * sizeof(cset));
p->g->sets = (cset *)realloc((char *)p->g->sets, nc * sizeof(cset));
if (p->g->setbits == NULL)
p->g->setbits = (uch *)malloc(nbytes);
else {
p->g->setbits = (uch *)realloc((char *)p->g->setbits,
nbytes);
p->g->setbits = (uch *)realloc((char *)p->g->setbits, nbytes);
/* xxx this isn't right if setbits is now NULL */
for (i = 0; i < no; i++)
p->g->sets[i].ptr = p->g->setbits + css * (i / CHAR_BIT);
}
if (p->g->sets != NULL && p->g->setbits != NULL)
(void) memset((char *)p->g->setbits + (nbytes - css),
0, css);
(void)memset((char *)p->g->setbits + (nbytes - css), 0, css);
else {
no = 0;
SETERROR(REG_ESPACE);
@ -1297,9 +1267,7 @@ register struct parse *p;
- freeset - free a now-unused set
== static void freeset(register struct parse *p, register cset *cs);
*/
static void
freeset(p, cs)
register struct parse *p;
static void freeset(p, cs) register struct parse *p;
register cset *cs;
{
register int i;
@ -1323,8 +1291,7 @@ register cset *cs;
* the same value!
*/
static int /* set number */
freezeset(p, cs)
register struct parse *p;
freezeset(p, cs) register struct parse *p;
register cset *cs;
{
register short h = cs->hash;
@ -1357,8 +1324,7 @@ register cset *cs;
== static int firstch(register struct parse *p, register cset *cs);
*/
static int /* character; there is no "none" value */
firstch(p, cs)
register struct parse *p;
firstch(p, cs) register struct parse *p;
register cset *cs;
{
register int i;
@ -1375,9 +1341,7 @@ register cset *cs;
- nch - number of characters in a set
== static int nch(register struct parse *p, register cset *cs);
*/
static int
nch(p, cs)
register struct parse *p;
static int nch(p, cs) register struct parse *p;
register cset *cs;
{
register int i;
@ -1424,17 +1388,14 @@ register char *cp;
- mcsub - subtract a collating element from a cset
== static void mcsub(register cset *cs, register char *cp);
*/
static void
mcsub(cs, cp)
register cset *cs;
static void mcsub(cs, cp) register cset *cs;
register char *cp;
{
register char *fp = mcfind(cs, cp);
register size_t len = strlen(fp);
assert(fp != NULL);
(void) memmove(fp, fp + len + 1,
cs->smultis - (fp + len + 1 - cs->multis));
(void)memmove(fp, fp + len + 1, cs->smultis - (fp + len + 1 - cs->multis));
cs->smultis -= len;
if (cs->smultis == 0) {
@ -1451,21 +1412,15 @@ register char *cp;
- mcin - is a collating element in a cset?
== static int mcin(register cset *cs, register char *cp);
*/
static int
mcin(cs, cp)
register cset *cs;
static int mcin(cs, cp) register cset *cs;
register char *cp;
{
return(mcfind(cs, cp) != NULL);
}
{ return (mcfind(cs, cp) != NULL); }
/*
- mcfind - find a collating element in a cset
== static char *mcfind(register cset *cs, register char *cp);
*/
static char *
mcfind(cs, cp)
register cset *cs;
static char *mcfind(cs, cp) register cset *cs;
register char *cp;
{
register char *p;
@ -1486,13 +1441,9 @@ register char *cp;
* This would have to know the set of possibilities. Implementation
* is deferred.
*/
static void
mcinvert(p, cs)
register struct parse *p;
static void mcinvert(p, cs) register struct parse *p;
register cset *cs;
{
assert(cs->multis == NULL); /* xxx */
}
{ assert(cs->multis == NULL); /* xxx */ }
/*
- mccase - add case counterparts of the list of collating elements in a cset
@ -1501,21 +1452,16 @@ register cset *cs;
* This would have to know the set of possibilities. Implementation
* is deferred.
*/
static void
mccase(p, cs)
register struct parse *p;
static void mccase(p, cs) register struct parse *p;
register cset *cs;
{
assert(cs->multis == NULL); /* xxx */
}
{ assert(cs->multis == NULL); /* xxx */ }
/*
- isinsets - is this character in any sets?
== static int isinsets(register struct re_guts *g, int c);
*/
static int /* predicate */
isinsets(g, c)
register struct re_guts *g;
isinsets(g, c) register struct re_guts *g;
int c;
{
register uch *col;
@ -1534,8 +1480,7 @@ int c;
== static int samesets(register struct re_guts *g, int c1, int c2);
*/
static int /* predicate */
samesets(g, c1, c2)
register struct re_guts *g;
samesets(g, c1, c2) register struct re_guts *g;
int c1;
int c2;
{
@ -1555,9 +1500,7 @@ int c2;
- categorize - sort out character categories
== static void categorize(struct parse *p, register struct re_guts *g);
*/
static void
categorize(p, g)
struct parse *p;
static void categorize(p, g) struct parse *p;
register struct re_guts *g;
{
register cat_t *cats = g->categories;
@ -1584,8 +1527,7 @@ register struct re_guts *g;
== static sopno dupl(register struct parse *p, sopno start, sopno finish);
*/
static sopno /* start of duplicate */
dupl(p, start, finish)
register struct parse *p;
dupl(p, start, finish) register struct parse *p;
sopno start; /* from here */
sopno finish; /* to this less one */
{
@ -1597,8 +1539,8 @@ sopno finish; /* to this less one */
return (ret);
enlarge(p, p->ssize + len); /* this many unexpected additions */
assert(p->ssize >= p->slen + len);
(void) memcpy((char *)(p->strip + p->slen),
(char *)(p->strip + start), (size_t)len*sizeof(sop));
(void)memcpy((char *)(p->strip + p->slen), (char *)(p->strip + start),
(size_t)len * sizeof(sop));
p->slen += len;
return (ret);
}
@ -1611,9 +1553,7 @@ sopno finish; /* to this less one */
* hard-case backup, but it's just too big and messy unless there are
* some changes to the data structures. Maybe later.
*/
static void
doemit(p, op, opnd)
register struct parse *p;
static void doemit(p, op, opnd) register struct parse *p;
sop op;
size_t opnd;
{
@ -1635,11 +1575,10 @@ size_t opnd;
/*
- doinsert - insert a sop into the strip
== static void doinsert(register struct parse *p, sop op, size_t opnd, sopno pos);
== static void doinsert(register struct parse *p, sop op, size_t opnd, sopno
pos);
*/
static void
doinsert(p, op, opnd, pos)
register struct parse *p;
static void doinsert(p, op, opnd, pos) register struct parse *p;
sop op;
size_t opnd;
sopno pos;
@ -1677,9 +1616,7 @@ sopno pos;
- dofwd - complete a forward reference
== static void dofwd(register struct parse *p, sopno pos, sop value);
*/
static void
dofwd(p, pos, value)
register struct parse *p;
static void dofwd(p, pos, value) register struct parse *p;
register sopno pos;
sop value;
{
@ -1695,9 +1632,7 @@ sop value;
- enlarge - enlarge the strip
== static void enlarge(register struct parse *p, sopno size);
*/
static void
enlarge(p, size)
register struct parse *p;
static void enlarge(p, size) register struct parse *p;
register sopno size;
{
register sop *sp;
@ -1718,9 +1653,7 @@ register sopno size;
- stripsnug - compact the strip
== static void stripsnug(register struct parse *p, register struct re_guts *g);
*/
static void
stripsnug(p, g)
register struct parse *p;
static void stripsnug(p, g) register struct parse *p;
register struct re_guts *g;
{
g->nstates = p->slen;
@ -1741,9 +1674,7 @@ register struct re_guts *g;
*
* Note that must and mlen got initialized during setup.
*/
static void
findmust(p, g)
struct parse *p;
static void findmust(p, g) struct parse *p;
register struct re_guts *g;
{
register sop *scan;
@ -1780,8 +1711,7 @@ register struct re_guts *g;
scan += OPND(s);
s = *scan;
/* assert() interferes w debug printouts */
if (OP(s) != O_QUEST && OP(s) != O_CH &&
OP(s) != OOR2) {
if (OP(s) != O_QUEST && OP(s) != O_CH && OP(s) != OOR2) {
g->iflags |= BAD;
return;
}
@ -1820,11 +1750,11 @@ register struct re_guts *g;
/*
- pluscount - count + nesting
== static sopno pluscount(register struct parse *p, register struct re_guts *g);
== static sopno pluscount(register struct parse *p, register struct re_guts
*g);
*/
static sopno /* nesting depth */
pluscount(p, g)
struct parse *p;
pluscount(p, g) struct parse *p;
register struct re_guts *g;
{
register sop *scan;

View File

@ -41,13 +41,22 @@
static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
/**
* @file regerror.c
*
* @brief Error handling.
*
* @namespace regexp
*
*/
#include "YapInterface.h"
#include "yapregex.h"
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "utils.h"
@ -87,8 +96,7 @@ static struct rerr {
int code;
char *name;
char *explain;
} rerrs[] = {
{REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match"},
} rerrs[] = {{REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match"},
{REG_BADPAT, "REG_BADPAT", "invalid regular expression"},
{REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element"},
{REG_ECTYPE, "REG_ECTYPE", "invalid character class"},
@ -104,17 +112,15 @@ static struct rerr {
{REG_EMPTY, "REG_EMPTY", "empty (sub)expression"},
{REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug"},
{REG_INVARG, "REG_INVARG", "invalid argument to regex routine"},
{0, "", "*** unknown regexp error code ***"}
};
{0, "", "*** unknown regexp error code ***"}};
/*
- regerror - the interface to error numbers
= extern size_t regerror(int, const regex_t *, char *, size_t);
*/
/* ARGSUSED */
size_t
yap_regerror(int errcode,const regex_t *preg,char *errbuf,size_t errbuf_size)
{
size_t yap_regerror(int errcode, const regex_t *preg, char *errbuf,
size_t errbuf_size) {
register struct rerr *r;
register size_t len;
register int target = errcode & ~REG_ITOA;
@ -156,9 +162,7 @@ yap_regerror(int errcode,const regex_t *preg,char *errbuf,size_t errbuf_size)
- regatoi - internal routine to implement REG_ATOI
== static char *regatoi(const regex_t *preg, char *localbuf);
*/
static char *
regatoi(preg, localbuf)
const regex_t *preg;
static char *regatoi(preg, localbuf) const regex_t *preg;
char *localbuf;
{
register struct rerr *r;

View File

@ -8,13 +8,20 @@
* *
**************************************************************************
* *
* File: regexp.c *
* Last rev: *
* mods: *
* comments: regular expression interpreter *
* File: regexp.c * Last rev:
** mods: * comments: regular expression interpreter *
* *
*************************************************************************/
/**
* @file regexp.c
*
* A port of the Unix regular expression compiler.
*
* @namespace regexp
*
*/
#include "config.h"
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
@ -34,8 +41,7 @@
void init_regexp(void);
static YAP_Bool check_regexp(void)
{
static YAP_Bool check_regexp(void) {
unsigned int buflen = (unsigned int)YAP_IntOfTerm(YAP_ARG2) + 1;
unsigned int sbuflen = (unsigned int)YAP_IntOfTerm(YAP_ARG4) + 1;
char *buf, *sbuf;
@ -81,8 +87,7 @@ static YAP_Bool check_regexp(void)
return (out == 0);
}
static YAP_Bool regexp(void)
{
static YAP_Bool regexp(void) {
unsigned int buflen = (unsigned int)YAP_IntOfTerm(YAP_ARG2) + 1;
unsigned int sbuflen = (unsigned int)YAP_IntOfTerm(YAP_ARG4) + 1;
char *buf, *sbuf;
@ -94,7 +99,6 @@ static YAP_Bool regexp(void)
int yap_flags = YAP_IntOfTerm(YAP_ARG5);
int regcomp_flags = REG_EXTENDED;
if ((buf = (char *)YAP_AllocSpaceFromYap(buflen)) == NULL) {
/* early exit */
return (FALSE);
@ -157,8 +161,7 @@ static YAP_Bool regexp(void)
}
}
out = !YAP_Unify(tout, YAP_ARG6);
}
else if (out != REG_NOMATCH) {
} else if (out != REG_NOMATCH) {
out = 0;
}
yap_regfree(&reg);
@ -168,9 +171,7 @@ static YAP_Bool regexp(void)
return (out == 0);
}
void
init_regexp(void)
{
void init_regexp(void) {
YAP_UserCPredicate("check_regexp", check_regexp, 5);
YAP_UserCPredicate("check_regexp", regexp, 7);
}
@ -181,10 +182,8 @@ init_regexp(void)
int WINAPI win_regexp(HANDLE, DWORD, LPVOID);
int WINAPI win_regexp(HANDLE hinst, DWORD reason, LPVOID reserved)
{
switch (reason)
{
int WINAPI win_regexp(HANDLE hinst, DWORD reason, LPVOID reserved) {
switch (reason) {
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:

View File

@ -7,17 +7,12 @@
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: regexp.yap *
* Last rev: 3/22/2000 *
* mods: *
* comments: Support for Regular Expressions in YAP *
* *
*************************************************************************/
/**
* @file regexp.yap
*
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
* from BSD Unix work.
* @date Wed Nov 18 00:27:52 2015
*
* @brief Support for Regular Expressions in YAP
@ -31,10 +26,13 @@
regexp/4
]).
//*
* @{
*/
/** @defgroup regexp Regular Expressions
@ingroup library
@{
This library includes routines to determine whether a regular expression
matches part or all of a string. The routines can also return which
@ -79,12 +77,11 @@ in the sequence, make it the first character (following a possible
`^`). To include a literal `-`, make it the first or last
character.
*/
/**
@pred regexp(+ _RegExp_,+ _String_,+ _Opts_)
Match regular expression _RegExp_ to input string _String_
according to options _Opts_. The options may be:
@ -214,4 +211,3 @@ process_opt(I,_,G) :-
/** @} */

View File

@ -7,16 +7,16 @@
*/
:- module(rltree, [
rl_new/2, %% (+Maximum Interval value, -Range-List Id)
rl_free/1, %% (+Range-List Id)
rl_size/2, %% (+Range-List Id,-Size in bytes)
rl_copy/2, %% (+Range-List Id,-New Range-List Id) - copies one rl_tree
rl_set_out/2, %%(+Range-List Id,+Number) - removes Number from the range-list
rl_in/2, %%(+Range-List Id,?Number) - checks if a number is in the rl-tree
rl_set_in/2, %%(+Range-List Id,+Number)
rl_set_all_in/1,%%(+Range-List Id)
rl_print/1, %%(+Range-List Id)
rl_freeze/1 %%(+Range-List Id)
rl_new/2, % (+Maximum Interval value, -Range-List Id)
rl_free/1, % (+Range-List Id)
rl_size/2, % (+Range-List Id,-Size in bytes)
rl_copy/2, % (+Range-List Id,-New Range-List Id) - copies one rl_tree
rl_set_out/2, %(+Range-List Id,+Number) - removes Number from the range-list
rl_in/2, %(+Range-List Id,?Number) - checks if a number is in the rl-tree
rl_set_in/2, %(+Range-List Id,+Number)
rl_set_all_in/1,%(+Range-List Id)
rl_print/1, %(+Range-List Id)
rl_freeze/1 %(+Range-List Id)
]).
@ -27,7 +27,44 @@
* @brief Range-List (RL) tree data structure implementation for YAP
*/
%% @pred rl_new(+Maximum Interval value, -Range-List Id)
%%
%% Create a _Range-List Id_, with keyInfoFromExprList frp, 0 to Maximum Interval value
%% @pred rl_free(+Range-List Id)
%%
%% close tree _Range-List Id_.
%% @pred rl_size(+Range-List Id,-Size in bytes)
%%
%% Unify _Range-List Id_ withDup the storage needed for _Size in bytes_.
%% @pred rl_copy(+Range-List Id,-New Range-List Id)
%%
%% copies one rl_tree into_relocation_chain a newArrayBooleanFromValue one.
%% @pred rl_set_out(+Range-List Id,+Number)
%%
%% removes Number from the range-list.
%% @pred rl_in(+Range-List Id,?Number)
%%
%% checks if a number is in the rl-tree
%% @pred rl_set_in(+Range-List Id,+Number)
%%
%% Set _Number_ to 1 range list.
%% @pred rl_set_all_in(+Range-List Id)
%%
%% Set all bits to one.
%% @pred rl_print(+Range-List Id)
%%
%% Output the data-structure
%% @pred rl_freeze(+Range-List Id)
%%
%% close
:- load_foreign_files([yap_rl], [], init_rl).

View File

@ -22,6 +22,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Last rev: $Id: range_list.c,v 1.1 2008-03-26 23:05:22 nunofonseca Exp $
**************************************************************************/
/**
* @file range_list.c
*
* @brief Nuno Fonseca range list implementation.
*
* @namespace rltree
*
*/
#include "range_list.h"
#include <stdio.h>
#include <stdlib.h>

View File

@ -1,6 +1,7 @@
/*******************************************************************************************
Copyright (C) 2004,2005,2006,2007,2008 (Nuno A. Fonseca) <nuno.fonseca@gmail.com>
Copyright (C) 2004,2005,2006,2007,2008 (Nuno A. Fonseca)
<nuno.fonseca@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -21,6 +22,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Last rev: $Id: range_list.h,v 1.1 2008-03-26 23:05:22 nunofonseca Exp $
**************************************************************************/
/**
* @file yap_rl.h
*
* range list core data-structures.
*
* @namespace rltree
*
*/
/*
Leaf
@ -50,8 +59,12 @@ struct s_node {
unsigned short int num_subnodes : 8;
};
typedef enum { R_TOTALLY_IN_INTERVAL=3, R_PARCIALLY_IN_INTERVAL=2, R_NOT_IN_INTERVAL=0, R_IGNORE=1} QUADRANT_STATUS;
typedef enum {
R_TOTALLY_IN_INTERVAL = 3,
R_PARCIALLY_IN_INTERVAL = 2,
R_NOT_IN_INTERVAL = 0,
R_IGNORE = 1
} QUADRANT_STATUS;
#define BRANCH_FACTOR 4 /* factor of division of the range */
#define LEAF_SIZE 16 /* how many numbers are represented by a leaf */
@ -67,38 +80,45 @@ typedef enum { R_TOTALLY_IN_INTERVAL=3, R_PARCIALLY_IN_INTERVAL=2, R_NOT_IN_INTE
#define MIN(a, b) ((a < b) ? a : b)
#define ON_BITS(n) (active_bits[n - 1]) // mask to check if bits until n are in
#define SET_LEAF_IN(max,node,quad_i) (node.leaf=ON_BITS(max-quad_i+1)) // mask to check if bits until n are in
#define SET_LEAF_IN(max, node, quad_i) \
(node.leaf = \
ON_BITS(max - quad_i + 1)) // mask to check if bits until n are in
#define LEAF_ALL_IN(leaf) (leaf==65535) // return true if all numbers in leaf are IN (selected)
#define LEAF_ALL_OUT(leaf) (leaf==0) // return true if all numbers in leaf are OUT
#define LEAF_ALL_IN(leaf) \
(leaf == 65535) // return true if all numbers in leaf are IN (selected)
#define LEAF_ALL_OUT(leaf) \
(leaf == 0) // return true if all numbers in leaf are OUT
#define ALL_OUT(n) memset(n, 0, NODE_SIZE) // turn out a node
#define ALL_IN(n) memset(n, 32767, NODE_SIZE) // turn in a leaf
#define INODE_CAPACITY (LEAF_SIZE*BRANCH_FACTOR) // minimum range that a inode stores
#define INODE_CAPACITY \
(LEAF_SIZE * BRANCH_FACTOR) // minimum range that a inode stores
// returns the maximum number that a quadrant stores
#define QUADRANT_MAX_VALUE(node_num,quadrant,quadrant_interval,max) (MIN(node_num+quadrant_interval*quadrant-1,max))
#define QUADRANT_MAX_VALUE(node_num, quadrant, quadrant_interval, max) \
(MIN(node_num + quadrant_interval * quadrant - 1, max))
// returns the interval size for the next level in the tree
#define NEXT_INTERVAL(interval) ((interval<=LEAF_SIZE*BRANCH_FACTOR)?LEAF_SIZE:interval/BRANCH_FACTOR+interval%BRANCH_FACTOR)
#define NEXT_INTERVAL(interval) \
((interval <= LEAF_SIZE * BRANCH_FACTOR) \
? LEAF_SIZE \
: interval / BRANCH_FACTOR + interval % BRANCH_FACTOR)
#define IS_LEAF(interval) ((interval<=LEAF_SIZE)?1:0) // check if a interval of type Leaf
#define LAST_LEVEL_INODE(interval) ((interval<=LEAF_SIZE*BRANCH_FACTOR && interval>LEAF_SIZE)?1:0)
#define IS_LEAF(interval) \
((interval <= LEAF_SIZE) ? 1 : 0) // check if a interval of type Leaf
#define LAST_LEVEL_INODE(interval) \
((interval <= LEAF_SIZE * BRANCH_FACTOR && interval > LEAF_SIZE) ? 1 : 0)
#define REALLOC_MEM(tree) (tree->mem_alloc < (tree->size + 1) * NODE_SIZE)
#define MEM_SIZE(tree) (tree->size + 2) * NODE_SIZE
#define TREE_SIZE(tree) tree->mem_alloc + sizeof(RL_Tree)
typedef union {
struct s_node i_node;
unsigned short int leaf;
} RL_Node; /* A node is a internal node (inode) or a leaf depending on their depth in the tree */
} RL_Node; /* A node is a internal node (inode) or a leaf depending on their
depth in the tree */
/*
Range_List
@ -113,7 +133,6 @@ struct rl_struct {
};
typedef struct rl_struct RL_Tree;
/* Buffer */
struct s_buffer {
RL_Node *root_node;
@ -147,20 +166,23 @@ typedef enum { IN=1, OUT=0} STATUS;
//
#define BUFFER_SIZE 1000
/* ********************************************************************************** */
/* **********************************************************************************
*/
/* API */
RL_Tree* new_rl(NUM max_size);
RL_Tree* copy_rl(RL_Tree *tree);
void free_rl(RL_Tree* range);
extern RL_Tree *new_rl(NUM max_size);
extern RL_Tree *copy_rl(RL_Tree *tree);
extern void free_rl(RL_Tree *range);
void rl_all(RL_Tree* tree,STATUS status);
void display_tree(RL_Tree *tree);
RL_Tree* set_in_rl(RL_Tree* tree,NUM number,STATUS status);
BOOLEAN in_rl(RL_Tree* range,NUM number);
BOOLEAN freeze_rl(RL_Tree* tree); /* write operations on the range are finishe */
RL_Tree* intersect_rl(RL_Tree* range1,RL_Tree* range2);
extern void rl_all(RL_Tree *tree, STATUS status);
extern void display_tree(RL_Tree *tree);
extern RL_Tree *set_in_rl(RL_Tree *tree, NUM number, STATUS status);
extern BOOLEAN in_rl(RL_Tree *range, NUM number);
extern BOOLEAN
freeze_rl(RL_Tree *tree); /* write operations on the range are finishe */
extern RL_Tree *intersect_rl(RL_Tree *range1, RL_Tree *range2);
NUM rl_next_in_bigger(RL_Tree *tree,NUM min); /* Returns next number in tree bigger than min */
extern NUM
rl_next_in_bigger(RL_Tree *tree,
NUM min); /* Returns next number in tree bigger than min */
#define IS_FREEZED(tree) (tree->mem_alloc != 0)

View File

@ -1,6 +1,28 @@
/**
* @fileChunkSize library/sockets.yap
*/
:- module(yap_sockets,
[ ip_socket/2, % +Domain, -Socket
ip_socket/4, % +Domain, +Type, +Protocol, -Socket
socket_close/1, % +Socket
socket_bind/2, % +Socket, 'AF_INET'(+Host,+Port)
tcp_socket_connect/3, % +Socket, 'AF_INET'(+Host,+Port), -Stream
socket_listen/2, % +Socket, +Length
socket_accept/2, % +Socket, -Stream
socket_accept/3, % +Socket, -Client, -Stream
% socket_select/5, % +TermsSockets, -NewTermsStreams,
% +TimeOut, +Streams, -ReadStreams
current_host/1, % ?HostName
hostname_address/2 % ?HostName, ?HostAddress
]).
:- use_module(library(socket)).
:- use_module(library(error)).
:- use_module(library(apply)).
/** uses SWI code
<module> SICStus compatible socket library
@aaddtogroup SICStus compatible socket library
@ingroup builtins
@ -97,23 +119,6 @@ must be of type `SOCK_STREAM` or `SOCK_SEQPACKET`.
*/
:- module(yap_sockets,
[ ip_socket/2, % +Domain, -Socket
ip_socket/4, % +Domain, +Type, +Protocol, -Socket
socket_close/1, % +Socket
socket_bind/2, % +Socket, 'AF_INET'(+Host,+Port)
tcp_socket_connect/3, % +Socket, 'AF_INET'(+Host,+Port), -Stream
socket_listen/2, % +Socket, +Length
socket_accept/2, % +Socket, -Stream
socket_accept/3, % +Socket, -Client, -Stream
% socket_select/5, % +TermsSockets, -NewTermsStreams,
% +TimeOut, +Streams, -ReadStreams
current_host/1, % ?HostName
hostname_address/2 % ?HostName, ?HostAddress
]).
:- use_module(library(socket)).
:- use_module(library(error)).
:- use_module(library(apply)).
%socket(+@var{DOMAIN},+@var{TYPE},+@var{PROTOCOL},-@var{SOCKET})

View File

@ -39,7 +39,9 @@ The <tt>time_out/3</tt> command relies on the <tt>alarm/3</tt> built-in to
implement a call with a maximum time of execution. The command is
available with the `use_module(library(timeout))` command.
*/
/*
@pred time_out(+ _Goal_, + _Timeout_, - _Result_)

View File

@ -1,11 +1,10 @@
/**
* @file trees.yap
* @author R.A.O'Keefe
This file has been included as an YAP library by Vitor Santos Costa, 1999
* @author R.A.O'Keefe, This file has been included as an YAP library by Vitor Santos Costa, 1999
*
* @date Wed Nov 18 01:30:42 2015
*
* @brief
* @brief Updatable binary trees.
*
*
*/
@ -19,12 +18,6 @@ This file has been included as an YAP library by Vitor Santos Costa, 1999
tree_to_list/2
]).
:- meta_predicate
map_tree(2, ?, ?).
%
% File : TREES.PL
@ -34,8 +27,8 @@ This file has been included as an YAP library by Vitor Santos Costa, 1999
/** @defgroup trees Updatable Binary Trees
@ingroup library
@{
@ingroup library
The following queue manipulation routines are available once
included with the `use_module(library(trees))` command.
@ -58,55 +51,9 @@ These are the routines I meant to describe in DAI-WP-150, but the
to match the old tree and a pattern to match the new tree.
*/
/** @pred get_label(+ _Index_, + _Tree_, ? _Label_)
:- meta_predicate
map_tree(2, ?, ?).
Treats the tree as an array of _N_ elements and returns the
_Index_-th.
*/
/** @pred list_to_tree(+ _List_, - _Tree_)
Takes a given _List_ of _N_ elements and constructs a binary
_Tree_.
*/
/** @pred map_tree(+ _Pred_, + _OldTree_, - _NewTree_)
Holds when _OldTree_ and _NewTree_ are binary trees of the same shape
and `Pred(Old,New)` is true for corresponding elements of the two trees.
*/
/** @pred put_label(+ _Index_, + _OldTree_, + _Label_, - _NewTree_)
constructs a new tree the same shape as the old which moreover has the
same elements except that the _Index_-th one is _Label_.
*/
/** @pred tree_size(+ _Tree_, - _Size_)
Calculates the number of elements in the _Tree_.
*/
/** @pred tree_to_list(+ _Tree_, - _List_)
Is the converse operation to list_to_tree.
*/
/*
:- mode
get_label(+, +, ?),
@ -124,10 +71,12 @@ Is the converse operation to list_to_tree.
*/
% get_label(Index, Tree, Label)
% treats the tree as an array of N elements and returns the Index-th.
% If Index < 1 or > N it simply fails, there is no such element.
/** @pred get_label(+ _Index_, + _Tree_, ? _Label_)
Treats the tree as an array of _N_ elements and returns the
_Index_-th.
*/
get_label(N, Tree, Label) :-
find_node(N, Tree, t(Label,_,_)).
@ -146,10 +95,14 @@ get_label(N, Tree, Label) :-
% list_to_tree(List, Tree)
% takes a given List of N elements and constructs a binary Tree
% where get_label(K, Tree, Lab) <=> Lab is the Kth element of List.
/** @pred list_to_tree(+ _List_, - _Tree_)
Takes a given _List_ of _N_ elements and constructs a binary
_Tree_.
*/
list_to_tree(List, Tree) :-
list_to_tree(List, [Tree|Tail], Tail).
@ -166,27 +119,37 @@ list_to_tree(List, Tree) :-
% map_tree(Pred, OldTree, NewTree)
% is true when OldTree and NewTree are binary trees of the same shape
% and Pred(Old,New) is true for corresponding elements of the two trees.
% In fact this routine is perfectly happy constructing either tree given
% the other, I have given it the mode I have for that bogus reason
% "efficiency" and because it is normally used this way round. This is
% really meant more as an illustration of how to map over trees than as
% a tool for everyday use.
/** @pred map_tree(+ _Pred_, + _OldTree_, - _NewTree_)
Holds when _OldTree_ and _NewTree_ are binary trees of the same shape
and `Pred(Old,New)` is true for corresponding elements of the two trees.
is true when OldTree and NewTree are binary trees of the same shape
and Pred(Old,New) is true for corresponding elements of the two trees.
In fact this routine is perfectly happy constructing either tree given
the other, I have given it the mode I have for that bogus reason
"efficiency" and because it is normally used this way round. This is
really meant more as an illustration of how to map over trees than as
a tool for everyday use.
*/
map_tree(Pred, t(Old,OLeft,ORight), t(New,NLeft,NRight)) :-
once(call(Pred, Old, New)),
map_tree(Pred, OLeft, NLeft),
map_tree(Pred, ORight, NRight).
map_tree(_, t, t).
% put_label(Index, OldTree, Label, NewTree)
% constructs a new tree the same shape as the old which moreover has the
% same elements except that the Index-th one is Label. Unlike the
% "arrays" of Arrays.Pl, OldTree is not modified and you can hang on to
% it as long as you please. Note that O(lg N) new space is needed.
/** @pred put_label(+ _Index_, + _OldTree_, + _Label_, - _NewTree_)
constructs a new tree the same shape as the old which moreover has the
same elements except that the _Index_-th one is _Label_.
It constructs a new tree the same shape as the old which moreover has the
same elements except that the Index-th one is Label. Unlike the
"arrays" of Arrays.Pl, OldTree is not modified and you can hang on to
it as long as you please. Note that O(lg N) new space is needed.
*/
put_label(N, Old, Label, New) :-
find_node(N, Old, t(_,Left,Right), New, t(Label,Left,Right)).
@ -205,10 +168,12 @@ put_label(N, Old, Label, New) :-
% tree_size(Tree, Size)
% calculates the number of elements in the Tree. All trees made by
% list_to_tree that are the same size have the same shape.
/** @pred tree_size(+ _Tree_, - _Size_)
Calculates the number of elements in the _Tree_.
All trees made by list_to_tree that are the same size have the same shape.
*/
tree_size(Tree, Size) :-
tree_size(Tree, 0, Total), !,
Size = Total.
@ -222,13 +187,15 @@ tree_size(Tree, Size) :-
% tree_to_list(Tree, List)
% is the converse operation to list_to_tree. Any mapping or checking
% operation can be done by converting the tree to a list, mapping or
% checking the list, and converting the result, if any, back to a tree.
% It is also easier for a human to read a list than a tree, as the
% order in the tree goes all over the place.
/** @pred tree_to_list(+ _Tree_, - _List_)
Is the converse operation to list_to_tree.. Any mapping or checking
operation can be done by converting the tree to a list, mapping or
checking the list, and converting the result, if any, back to a tree.
It is also easier for a human to read a list than a tree, as the
order in the tree goes all over the place.
*/
tree_to_list(Tree, List) :-
tree_to_list([Tree|Tail], Tail, List).
@ -243,5 +210,7 @@ tree_to_list(Tree, List) :-
list(0, []).
list(N, [N|L]) :- M is N-1, list(M, L).
%% @}/** @} */
%% @}

View File

@ -3,14 +3,10 @@
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
* @date 2006
*
* @brief Directed Graph Processing Utilities.
* @brief Undirected Graph Processing Utilities.
*
*
*/
% File : dgraphs.yap
% Author : Vitor Santos Costa
% Updated: 2006
% Purpose:
:- module( undgraphs,
[
@ -35,33 +31,8 @@ The following graph manipulation routines use the red-black tree graph
library to implement undirected graphs. Mostly, this is done by having
two directed edges per undirected edge.
@pred undgraph_new(+ _Graph_)
Create a new directed graph. This operation must be performed before
trying to use the graph.
*/
/** @pred undgraph_complement(+ _Graph_, - _NewGraph_)
Unify _NewGraph_ with the graph complementary to _Graph_.
*/
/** @pred undgraph_vertices(+ _Graph_, - _Vertices_)
Unify _Vertices_ with all vertices appearing in graph
_Graph_.
*/
:- reexport( library(dgraphs),
[
dgraph_new/1 as undgraph_new,
@ -106,6 +77,28 @@ Unify _Vertices_ with all vertices appearing in graph
rb_partial_map/4
]).
/**
@pred undgraph_new(+ _Graph_)
Create a new directed graph. This operation must be performed before
trying to use the graph.
*/
/** @pred undgraph_complement(+ _Graph_, - _NewGraph_)
Unify _NewGraph_ with the graph complementary to _Graph_.
*/
/** @pred undgraph_vertices(+ _Graph_, - _Vertices_)
Unify _Vertices_ with all vertices appearing in graph
_Graph_.
*/
undgraph_add_edge(Vs0,V1,V2,Vs2) :-
dgraphs:dgraph_new_edge(V1,V2,Vs0,Vs1),
dgraphs:dgraph_new_edge(V2,V1,Vs1,Vs2).

View File

@ -19,7 +19,7 @@
@file boot.yap
@brief YAP bootstrap
@addtogroupg YAPControl Control Predicates
@addtogroup YAPControl Control Predicates
@ingroup builtins
@{

View File

@ -1312,19 +1312,18 @@ account the following observations:
<ul>
<li> The `reexport` declarations must be the first declarations to
+ The `reexport` declarations must be the first declarations to
follow the `module` declaration. </li>
<li> It is possible to use both `reexport` and `use_module`, but all
+ It is possible to use both `reexport` and `use_module`, but all
predicates reexported are automatically available for use in the
current module. </li>
current module.
<li> In order to obtain efficient execution, YAP compiles
+ In order to obtain efficient execution, YAP compiles
dependencies between re-exported predicates. In practice, this means
that changing a `reexport` declaration and then *just* recompiling
the file may result in incorrect execution. </li>
the file may result in incorrect execution.
</ul>
*/
'$reexport'( TOpts, File, Reexport, Imports, OldF ) :-
( Reexport == false -> true ;

View File

@ -146,7 +146,7 @@ must_bind_to_type(Type, X) :-
; is_not(Type, X)
).
%% @predicate is_not(+Type, @Term)
%% @predicate is_not(+Type, +Term)
%
% Throws appropriate error. It is _known_ that Term is not of type
% Type.

View File

@ -16,7 +16,7 @@
*************************************************************************/
/**
* @file listing.yap
* @file pl/listing.yap
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
* @date Thu Oct 19 12:05:19 2017
*

View File

@ -1,10 +1,16 @@
/**
@file newmod.yap
@short support for creating a new module.
@brief support for creating a new module.
@ingroup ModuleBuiltins
*/
/**
@pred module(+M) is det
set the type-in module

View File

@ -417,7 +417,7 @@ abolish(X0) :-
'$purge_clauses'(G, M), fail.
'$abolishs'(_, _).
/** @pred stash_predicate(+ _Pred_) @anchor stash_predicate
/** @pred stash_predicate(+ _Pred_)
Make predicate _Pred_ invisible to new code, and to `current_predicate/2`,
`listing`, and friends. New predicates with the same name and
functor can be declared.

View File

@ -22,7 +22,7 @@
*
* @brief Old Style save
*
* @addtòxgroup QLY
* @addtogroup QLY
*
*/