This commit is contained in:
Vítor Santos Costa 2016-01-31 19:41:10 +00:00
parent 3de5b2c2de
commit 7aba41e7c2
17 changed files with 249 additions and 247 deletions

View File

@ -1,2 +1,2 @@
#define GIT_SHA1 "713e9dc9d83c385f5bdd57c8cfa4c7771a6cdb12"
#define GIT_SHA1 "703ac357357858351b27cb33b12830193e591282"
const char g_GIT_SHA1[] = GIT_SHA1;

View File

@ -8,9 +8,9 @@
#
# All text after a single hash (#) is considered a comment and will be ignored.
# The format is:
# TAG = value [value, ...]
# TAG = value [value, file.]
# For lists, items can also be appended using:
# TAG += value [value, ...]
# TAG += value [value, file.]
# Values that contain spaces should be placed between quotes (\" \").
#---------------------------------------------------------------------------
@ -407,7 +407,7 @@ TYPEDEF_HIDES_STRUCT = NO
# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
# doxygen will become slower. If the cache is too large, memory is wasted. The
# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
# is 0file9, the default is 0, corresponding to a cache size of 2^16=65536
# symbols. At the end of a run doxygen will report the cache usage and suggest
# the optimal cache size from a speed point of view.
# Minimum value: 0, maximum value: 9, default value: 0.
@ -636,8 +636,8 @@ GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
# The ENABLED_SECTIONS tag can be used to enable conditional documentation
# sections, marked by \if <section_label> ... \endif and \cond <section_label>
# ... \endcond blocks.
# sections, marked by \if <section_label> file. \endif and \cond <section_label>
# file. \endcond blocks.
ENABLED_SECTIONS =
@ -1094,6 +1094,7 @@ HTML_FILE_EXTENSION = .html
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_HEADER =
#/Users/vsc/git/yap-6.3/docs/web/bootstrap/header.html
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
@ -1105,6 +1106,7 @@ HTML_HEADER =
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_FOOTER =
#/Users/vsc/git/yap-6.3/docs/web/bootstrap/footer.html
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
@ -1118,6 +1120,7 @@ HTML_FOOTER =
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_STYLESHEET =
#/Users/vsc/git/yap-6.3/docs/web/bootstrap/customdoxygen.css
# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
@ -1131,7 +1134,9 @@ HTML_STYLESHEET =
# list). For an example see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_STYLESHEET = /Users/vsc/git/yap-6.3/docs/solarized-light.css
HTML_EXTRA_STYLESHEET =
# /Users/vsc/git/yap-6.3/docs/solarized-light.css
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
@ -1142,6 +1147,7 @@ HTML_EXTRA_STYLESHEET = /Users/vsc/git/yap-6.3/docs/solarized-light.css
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_FILES =
#/Users/vsc/git/yap-6.3/docs/web/bootstrap/doxy-boot.js
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
@ -1489,7 +1495,7 @@ MATHJAX_FORMAT = HTML-CSS
# output directory using the MATHJAX_RELPATH option. The destination directory
# should contain the MathJax.js script. For instance, if the mathjax directory
# is located at the same level as the HTML output directory, then
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
# MATHJAX_RELPATH should be file/mathjax. The default value points to the MathJax
# Content Delivery Network so you can quickly see the result without installing
# MathJax. However, it is strongly recommended to install a local copy of
# MathJax from http://www.mathjax.org before deployment.
@ -1886,7 +1892,7 @@ MAN_LINKS = NO
# captures the structure of the code including all documentation.
# The default value is: NO.
GENERATE_XML = NO
GENERATE_XML = YES
# 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
@ -2069,7 +2075,7 @@ SKIP_FUNCTION_MACROS = YES
# a tag file without this location is as follows:
# TAGFILES = file1 file2 ...
# Adding location for the tag files is done as follows:
# TAGFILES = file1=loc1 "file2 = loc2" ...
# TAGFILES = file1=loc1 "file2 = loc2" file.
# where loc1 and loc2 can be relative or absolute paths or URLs. See the
# section "Linking to external documentation" for more information about the use
# of tag files.

View File

@ -1820,80 +1820,10 @@ Given the packaged stream position term _StreamPosition_, unify
*/
/** @pred tell(+ _S_)
If _S_ is a currently opened stream for output, it becomes the
current output stream. If _S_ is an atom it is taken to be a
filename. If there is no output stream currently associated with it,
then it is opened for output, and the new output stream created becomes
the current output stream. If it is not possible to open the file, an
error occurs. If there is a single opened output stream currently
associated with the file, then it becomes the current output stream; if
there are more than one in that condition, one of them is chosen.
Whenever _S_ is a stream not currently opened for output, an error
may be reported, depending on the state of the file_errors flag. The
predicate just fails, if _S_ is neither a stream nor an atom.
*/
/** @pred telling(- _S_)
The current output stream is unified with _S_.
*/
/** @pred told
Closes the current output stream, and the user's terminal becomes again
the current output stream. It is important to remember to close streams
after having finished using them, as the maximum number of
simultaneously opened streams is 17.
*/
/** @pred see(+ _S_)
If _S_ is a currently opened input stream then it is assumed to be
the current input stream. If _S_ is an atom it is taken as a
filename. If there is no input stream currently associated with it, then
it is opened for input, and the new input stream thus created becomes
the current input stream. If it is not possible to open the file, an
error occurs. If there is a single opened input stream currently
associated with the file, it becomes the current input stream; if there
are more than one in that condition, then one of them is chosen.
When _S_ is a stream not currently opened for input, an error may be
reported, depending on the state of the `file_errors` flag. If
_S_ is neither a stream nor an atom the predicates just fails.
*/
/** @pred seeing(- _S_)
The current input stream is unified with _S_.
*/
/** @pred seen
Closes the current input stream (see 6.7.).
*/
/** @defgroup InputOutput_of_Terms Handling Input/Output of Terms
@ingroup YAPBuiltins
@ -4244,7 +4174,7 @@ is sometimes useful. As in other Prolog systems, YAP has
several primitives that allow updating Prolog terms. Note that these
primitives are also backtrackable.
The `setarg/3` primitive allows updating any argument of a Prolog
The setarg/3 primitive allows updating any argument of a Prolog
compound terms. The `mutable` family of predicates provides
<em>mutable variables</em>. They should be used instead of `setarg/3`,
as they allow the encapsulation of accesses to updatable

View File

@ -8,7 +8,7 @@
*
*/
:- module(line_utils,
:- module(lineutils,
[search_for/2,
search_for/3,
scan_natural/3,
@ -244,7 +244,8 @@ split_unquoted(_, [], []) --> [].
split_quoted( [0'"], More) --> %0'"
"\"".
split_quoted( [0'\\ ,C|New], More) --> %0'"
split_quoted( [0'\\ ,C|New], More) -->
%0'"
"\\",
[C],
split_quoted(New, More).

View File

@ -449,8 +449,8 @@ Legal values:
"use_module" "volatile"))
(yap
("block" "char_conversion" "discontiguous" "dynamic" "encoding"
"ensure_loaded" "export" "expects_dialect" "export_list" "import"
"meta_predicate" "module" "module_transparent" "multifile" "require"
"ensure_loaded" "export" "expects_dialect" "meta_predicate" "module"
"module_transparent" "multifile" "reexport"
"table" "thread_local" "use_module" "wait"))
(gnu
("built_in" "char_conversion" "discontiguous" "dynamic" "ensure_linked"
@ -652,7 +652,7 @@ nil means send actual operating system end of file."
'((eclipse "^[a-zA-Z0-9()]* *\\?- \\|^\\[[a-zA-Z]* [0-9]*\\]:")
(sicstus "| [ ?][- ] *")
(swi "^\\(\\[[a-zA-Z]*\\] \\)?[1-9]?[0-9]*[ ]?\\?- \\|^| +")
(yap "^\\(\\[[a-zA-Z]*\\] \\)?[1-9]?[0-9]*[ ]?\\?- \\|^| +")
(yap "| [ ?][- ] *")
(t "^ *\\?-"))
"*Alist of prompts of the prolog system command line."
:group 'prolog-inferior

View File

@ -598,10 +598,14 @@ warn_singletons(FEnv *fe, TokEntry *tokstart)
singls[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomSingleton, 1), 1, &v);
singls[1] = MkIntegerTerm(LOCAL_SourceFileLineno);
singls[2] = MkAtomTerm(LOCAL_SourceFileName);
singls[3] = v;
if (fe->t)
singls[3] = fe->t;
else
singls[1] = TermTrue;
Term t = Yap_MkApplTerm(Yap_MkFunctor(AtomStyleCheck, 4), 4, singls);
singls[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomStyleCheck, 1), 1, &t);
singls[1] = TermNil;
singls[1] = v;
Yap_PrintWarning(Yap_MkApplTerm(FunctorError, 2, singls));
}
}
@ -683,7 +687,7 @@ static bool complete_clause_processing(FEnv *fe, TokEntry
v_vnames = get_varnames(fe, tokstart);
else
v_vnames = 0L;
if (trueGlobalPrologFlag(SINGLE_VAR_WARNINGS_FLAG)) {
if (trueLocalPrologFlag(SINGLE_VAR_WARNINGS_FLAG)) {
warn_singletons(fe, tokstart);
}
if (fe->tcomms)
@ -900,12 +904,6 @@ static parser_state_t parse(REnv *re, FEnv *fe, int inp_stream) {
fe->toklast = LOCAL_tokptr;
LOCAL_tokptr = tokstart;
TR = (tr_fr_ptr)tokstart;
if (fe->t == 0)
return YAP_PARSING_ERROR;
if (fe->reading_clause && !complete_clause_processing(fe, tokstart))
fe->t = 0;
else if (!fe->reading_clause && !complete_processing(fe, tokstart))
fe->t = 0;
#if EMACS
first_char = tokstart->TokPos;
#endif /* EMACS */

View File

@ -2,10 +2,11 @@
macro_optional_find_package(Java ON)
find_package(Java COMPONENTS Runtime Development)
#find_package(Java COMPONENTS Runtime)
macro_log_feature (Java_Development_FOUND "Java"
#find_package(Java)
find_package(Java COMPONENTS Runtime Development)
find_package(JNI)
macro_log_feature (Java_FOUND "Java"
"Use Java System"
"http://www.java.org" FALSE)
macro_optional_find_package(JNI ON)
@ -14,7 +15,7 @@ macro_optional_find_package(JNI ON)
"http://www.java.org" FALSE)
if (Java_Development_FOUND)
if (Java_FOUND AND JNI_FOUND)
include ( UseJava )
include ( UseSWIG )
@ -91,4 +92,4 @@ install_jar(JavaYAP ${libpl})
Endif (Java_Development_FOUND)
Endif (Java_FOUND AND JNI_FOUND)

View File

@ -1050,7 +1050,7 @@ be lost.
G =.. [F|BGs],
'$ldebugger_process_meta_args'(BGs, M, BMs, BG1s),
G1 =.. [F|BG1s].
'$debugger_process_meta_arguments'(G, M, G).
'$debugger_process_meta_arguments'(G, _M, G).
'$ldebugger_process_meta_args'([], _, [], []).
'$ldebugger_process_meta_args'([G|BGs], M, [N|BMs], ['$spy'([M1|G1])|BG1s]) :-

View File

@ -63,7 +63,7 @@ system_error(Type,Goal) :-
'$do_error'(Type,Goal) :-
% format('~w~n', [Type]),
% format('~w~n', [Type]),
ancestor_location(Call, Caller),
throw(error(Type, [
[g|g(Goal)],

View File

@ -278,14 +278,14 @@ prolog:'$goal_expansion_allowed'.
'$c_built_in_phrase'(NT, Xs0, Xs, Mod, NewGoal) :-
catch(prolog:'$translate_rule'(
(pseudo_nt --> Mod:NT), Rule),
(pseudo_nt --> Mod:NT), Rule),
error(Pat,ImplDep),
( \+ '$harmless_dcgexception'(Pat),
throw(error(Pat,ImplDep))
)
),
Rule = (pseudo_nt(Xs0c,Xsc) :- NewGoal0),
Goal \== NewGoal0,
Mod:NT \== NewGoal0,
% apply translation only if we are safe
\+ '$contains_illegal_dcgnt'(NT),
!,
@ -310,14 +310,12 @@ allowed_module(phrase(_,_),_).
allowed_module(phrase(_,_,_),_).
system:goal_expansion(Mod:phrase(NT,Xs, Xs),Mod:NewGoal) :-
source_module(M),
nonvar(NT), nonvar(Mod),
system:goal_expansion(Mod:phrase(NT,Xs0, Xs),Mod:NewGoal) :-
nonvar(NT), nonvar(Mod), !,
'$goal_expansion_allowed',
'$c_built_in_phrase'(NT, Xs0, Xs, Mod, NewGoal).
system:goal_expansion(Mod:phrase(NT,Xs0),Mod:NewGoal) :-
source_module(M),
system:goal_expansion(Mod:phrase(NT,Xs),Mod:NewGoal) :-
nonvar(NT), nonvar(Mod),
'$goal_expansion_allowed',
'$c_built_in_phrase'(NT, [], Xs, Mod, NewGoal).

View File

@ -113,10 +113,10 @@ otherwise.
format(user_error, X, Y), nl(user_error).
'$early_print_message'(_, loading( C, F)) :- !,
'$show_consult_level'(LC),
format(user_error, '~*|% ~a ~a...~n', [LC,C,F]).
'$early_print_message'(_, loaded(F,C,_M,T,H)) :- !,
format(user_error, '~*|% ~a ~w...~n', [LC,C,F]).
'$early_print_message'(_, loaded(F,C,M,T,H)) :- !,
'$show_consult_level'(LC),
format(user_error, '~*|% ~a ~a ~d bytes in ~d seconds...~n', [LC, F ,C, H, T]).
format(user_error, '~*|% ~a:~w ~a ~d bytes in ~d seconds...~n', [LC, M, F ,C, H, T]).
'$early_print_message'(Level, Msg) :-
source_location(F0, L),
!,
@ -146,7 +146,7 @@ print_message(Level, Msg) :-
:- bootstrap('atoms.yap').
:- bootstrap('os.yap').
:- bootstrap('absf.yap').
:-set_prolog_flag(verbose, normal).
:- set_prolog_flag(verbose, normal).
%:-set_prolog_flag(gc_trace, verbose).
%:- set_prolog_flag( verbose_file_search, true ).
@ -166,10 +166,10 @@ print_message(Level, Msg) :-
:- [
'errors.yap',
'utils.yap',
'control.yap',
'flags.yap'
'errors.yap',
'utils.yap',
'control.yap',
'flags.yap'
].
@ -246,7 +246,7 @@ rules.
:- dynamic user:goal_expansion/3.
:- multifile user:goal_expansion/2.
:- dynamic user:goal_expansion/2.
:- multifile system:goal_expansion/2.
@ -265,11 +265,7 @@ rules.
:- use_module('attributes.yap').
:- use_module('corout.yap').
:- use_module('dialect.yap').
:- use_module('history.pl').
:- use_module('dbload.yap').
:- use_module('swi.yap').
:- use_module('../swi/library/predopts.pl').
:- use_module('../swi/library/menu.pl').
:- use_module('../library/ypp.yap').
:- use_module('../os/chartypes.yap').
:- ensure_loaded('../os/edio.yap').

View File

@ -274,7 +274,7 @@ main_message(error(system_error(Who), _What), _Source) -->
main_message(error(uninstantiation_error(T),_), _Source) -->
[ '~*|!!! found ~q, expected unbound variable ' - [8,T], nl ].
display_consulting(Level) -->
display_consulting(_Level) -->
{ source_location(F0, L),
stream_property(_Stream, alias(loop_stream)) }, !,
[ '~a:~d:0 found while compiling this file.'-[F0,L], nl ].

View File

@ -347,7 +347,7 @@ system_module(Mod) :-
% be careful here not to generate an undefined exception.
'$imported_predicate'(G, ImportingMod, G, prolog) :-
'$imported_predicate'(G, _ImportingMod, G, prolog) :-
nonvar(G), '$is_system_predicate'(G, prolog), !.
'$imported_predicate'(G, ImportingMod, G0, ExportingMod) :-
( var(G) -> true ;
@ -766,7 +766,7 @@ unload_module(Mod) :-
module_state :-
recorded('$module','$module'(HostF,HostM,SourceF, Everything, Line),_),
format('HostF ~a, HostM ~a, SourceF ~w, Line ~d,~n Everything ~w.~n', [HostF,HostM,SourceF, Line, Everything]),
recorded('$import','$import'(HostM,M,G0,G,_N,_K),R),
recorded('$import','$import'(HostM,M,G0,G,_N,_K),_R),
format(' ~w:~w :- ~w:~w.~n',[M,G,HostM,G0]),
fail.
module_state.

View File

@ -117,7 +117,7 @@ Adds clause _C_ as the first clause for a static procedure.
*/
asserta_static(CI) :-
asserta_static(C) :-
'$assert'(C , asserta_static, _ ).
@ -137,7 +137,7 @@ static predicates, if source mode was on when they were compiled:
*/
assertz_static(CI) :-
assertz_static(C) :-
'$assert'(C , assertz_static, _ ).
/** @pred clause(+ _H_, _B_) is iso

View File

@ -762,7 +762,7 @@ qload_file( F0 ) :-
user:'$file_property'( '$lf_loaded'( F, Age, _ ) ),
recordaifnot('$source_file','$source_file'( F, Age, SourceModule), _),
fail.
'$qload_file'(_S, _SourceModule, File, FilePl, F0, _ImportList, _TOpts) :-
'$qload_file'(_S, _SourceModule, _File, FilePl, F0, _ImportList, _TOpts) :-
b_setval('$user_source_file', F0 ),
'$process_directives'( FilePl ),
fail.

View File

@ -625,3 +625,91 @@ sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.
sys //2.

View File

@ -11,6 +11,7 @@
:- use_module(library(lists)).
:- use_module(library(maplist)).
:- use_module(library(system)).
:- use_module(library(hacks)).
:- use_module(library(analysis/graphs)).
:- use_module(library(analysis/load)).
@ -29,7 +30,8 @@
private/2,
module_on/3,
exported/1,
dir/2,
dir/1,
sub_dir/2,
consulted/2,
op_export/3,
library/1,
@ -38,8 +40,9 @@
do_comment/5,
module_file/2.
% @short node(?Module:module, ?Predicate:pred_indicator, ?File:file, ?Generator:atom) is nondet
%% @pred node(?Module:module, ?Predicate:pred_indicator, ?File:file, ?Generator:atom) is nondet, dynamic.
%
% graph nodes
inline( !/0 ).
@ -66,7 +69,8 @@ main :-
% 'swi/console'-user
'packages'-user
],
% maplist(distribute(D), Dirs, Paths),
% maplist(distribute(D), Dirs, Paths),
assert(root(D)),
load( D, Dirs ),
maplist( pl_graphs, Dirs ),
fail.
@ -87,7 +91,8 @@ distribute( Root, File-Class, Path-Class) :-
atom_concat([Root, /, File], Path ).
init :-
retractall(dir(_)),
retractall(dir(_)),
retractall(s8Sadir(_)),
retractall(edge(_)),
retractall(private(_,_)),
retractall(public(_,_)),
@ -127,7 +132,6 @@ doubles :-
doubles.
undefs :-
trace,
format('UNDEFINED procedure calls:~n',[]),
setof(M, Target^F^Line^NA^undef( ( Target :- F-M:NA ), Line ), Ms ),
member( Mod, Ms ),
@ -201,13 +205,8 @@ remove_escapes([A|Cs], [A|NCs]) :-
remove_escapes(Cs, NCs).
remove_escapes( [], [] ).
always_strip_module(V, M, V1) :- var(V), !,
V = M:call(V1).
always_strip_module(M0:A, M0, call(A)) :- var(A), !.
always_strip_module(_:M0:A, M1, B) :- !,
always_strip_module(M0:A, M1, B).
always_strip_module(M0:A, M0, call(A)) :- var(A),!.
always_strip_module(M0:A, M0, A).
always_strip_module(V, M, V1) :-
fully_strip_module(V, M, V1).
c_links :-
open('tmp/foreigns.yap', write, S),
@ -293,108 +292,97 @@ doc( Comment, N ) :-
%
%
% Directories into atoms
search_file( Loc , F, Type, FN ) :-
search_file0( Loc , F, Type, FN ),
!.
search_file( Loc , F, _FN ) :-
format('~n~n~n###############~n~n FAILED TO FIND ~w when at ~a~n~n###############~n~n~n', [Loc, F ]),
fail.
:- dynamic library/1.
library('..').
:- multifile user:prolog_file_type/2.
:- dynamic user:prolog_file_type/2.
prolog_file_type(c, '.c').
prolog_file_type(c, '.h').
prolog_file_type(c, '.h.cmake').
prolog_file_type(c, '.i').
%
% handle some special cases.
%
search_file0( F, _, _Type, FN ) :-
doexpand(F, FN), !.
search_file0( A/B, F, Type, FN ) :- !,
term_to_atom(A/B, AB),
search_file0( AB, F, Type, FN ).
% libraries can be anywhere in the source.
search_file0( LibLoc, F, Type, FN ) :-
LibLoc =.. [Dir,File],
!,
( term_to_atom( Dir/File, Full ) ; Full = File ),
search_file0( Full, F, Type, FN ).
search_file( library(boot/F) , LocF, Type, FN ) :- !,
search_file( '..'/pl/F , LocF, Type, FN ).
%try to use your base
search_file0( Loc , F, c, FN ) :-
atom_concat( D, '.yap', F),
atom_concat( [ D, '/', Loc], F1),
check_suffix( F1 , c, NLoc ),
absolute_file_name( NLoc, FN),
file_base_name( FN, LocNam),
file_directory_name( FN, D),
dir( D, LocNam ).
search_file0( Loc , F, Type, FN ) :-
file_directory_name( F, FD),
check_suffix( Loc , Type, LocS ),
atom_concat( [ FD, '/', LocS], NLoc),
absolute_file_name( NLoc, FN),
file_base_name( FN, LocNam),
file_directory_name( FN, D),
dir( D, LocNam).
search_file0( Loc , _F, Type, FN ) :-
file_base_name( Loc, Loc0),
file_directory_name( Loc, LocD),
check_suffix( Loc0 , Type, LocS ),
dir( D, LocS),
sub_dir( D, DD),
atom_concat( [ DD, '/', LocD], NLoc),
absolute_file_name( NLoc, D),
atom_concat( [D,'/', LocS], FN).
search_file0( Loc , _F, Type, FN ) :-
file_base_name( Loc, Loc0),
check_suffix( Loc0 , Type, LocS ),
dir( D, LocS),
atom_concat( [D,'/', LocS], FN).
% you try using the parent
search_file( F0, LocF, Type, FN ) :-
filename(F0, F),
file_directory_name(LocF, LOC),
file_directory_name(F, D),
file_base_name(F, F1),
candidate_dir(LOC, '/', D, Left),
absolute_file_name(F1, [
relative_to(Left),
file_type(Type),file_errors(fail),
access(read) ], NF ).
search_file( Loc , F, _FN ) :-
format('~n~n~n###############~n~n FAILED TO FIND ~w when at ~a~n~n###############~n~n~n', [Loc, F ]),
fail.
sub_dir( D, D ).
sub_dir( D, DD) :-
D \= '/',
atom_concat( D, '/..', DD0),
absolute_file_name( DD0, DDA),
sub_dir( DDA, DD).
candidate_dir( Loc, _, D, Loc) :-
% ensure that the prefix of F, D, is a suffix of Loc
match(D, Loc).
% next, try going down in the current subroot
candidate_dir( Loc, _Source, D, OLoc) :-
sub_dir(Loc, NLoc),
NLoc \= Source,
candidate_dir_down(NLoc, Source, D, OLoc).
% if that fails, go up
candidate_dir( Loc, _Source, D, OLoc) :-
sub_dir(NLoc, Loc),
candidate_dir( NLoc, Loc, D, OLoc).
candidate_dir( Loc, _Source, D, OLoc) :-
root(Loc),
root(NLoc),
NLoc \= Loc,
candidate_dir( NLoc, Loc, D, OLoc).
candidate_dir_down(Loc, Source, D, Loc) :-
% ensure that the prefix of F, D, is a suffix of Loc
match(D, Loc).
% next, try going down in the current subroot
candidate_dir( Loc, _Source, D, OLoc) :-
sub_dir(NLoc, Loc),
candidate_dir_down(NLoc, Source, D, OLoc).
match('.', Loc) :- !.
match(D, Loc) :-
file_base_name( D, B),
file_base_name( Loc, B),
file_directory_name( D, ND),
file_directory_name( D, NLoc),
match(ND, NLoc).
filename(A, A) :- atom(A), !.
filename(A/B, NAB) :-
filename(A, NA),
filename(B, NB),
atom_concat([NA,'/', NB], NAB).
filename( library(A), NAB ) :-
!,
filename(A, NA),
(
library(L),
atom_concat( [L, '/', NA], NAB)
;
NAB = NA
).
filename( S, NAB ) :-
arg(1, S, A),
!,
NAB = NA.
% files must be called .yap or .pl
% if it is .yap...
check_suffix( Loc , pl, Loc ) :-
atom_concat( _, '.yap', Loc ), !.
%, otherwise, .pl
check_suffix( Loc , pl, Loc ) :-
atom_concat( _, '.pl', Loc ), !.
%, otherwise, .prolog
check_suffix( Loc , pl, Loc ) :-
atom_concat( _, '.prolog', Loc ), !.
%, otherwise, .P
% try adding suffix
check_suffix( Loc0 , pl, Loc ) :-
member( Suf , ['.yap', '.ypp', '.pl' , '.prolog']),
atom_concat( Loc0, Suf, Loc ).
check_suffix( Loc , c, Loc ) :-
atom_concat( _, '.c', Loc ), !.
%, otherwise, .pl
check_suffix( Loc , c, Loc ) :-
atom_concat( _, '.icc', Loc ), !.
%, otherwise, .prolog
check_suffix( Loc , c, Loc ) :-
atom_concat( _, '.cpp', Loc ), !.
%, otherwise, .P
% try adding suffix
check_suffix( Loc0 , c, Loc ) :-
member( Suf , ['.c', '.icc' , '.cpp']),
atom_concat( Loc0, Suf, Loc ).
match_file( LocD, Loc0, Type, FN ) :-
var(LocD), !,
dir( LocD, Loc0 ),
atom_concat( [LocD, '/', Loc0], F ),
absolute_file_name( F, Type, FN ),
exists( FN ).
match_file( SufLocD, Loc0, Type, FN ) :-
dir( LocD, Loc0 ),
atom_concat(_, SufLocD, LocD ),
atom_concat( [LocD, '/', Loc0], Type, FN ).
new_op( F, M, op(X,Y,Z) ) :-
@ -406,9 +394,9 @@ new_op( F, M, op( X, Y, Z) ) :-
public( F, M, op( X, Y, Z) ).
ypp(F, error(syntax_error(syntax_error),[syntax_error(read(_228515),between(K,L,M),_,_L,_)-_]) ) :-
format('SYNTAX ERROR at file ~a, line ~d (~d - ~d).~n', [F,L,K,M] ),
break.
error(F, Error) :-
print_message( error, Error ),
fail.
preprocess_file(F,NF) :-
atom_concat(_, '.ypp', F ), !,
@ -419,18 +407,14 @@ preprocess_file(F,F).
%%%%%%%
%% declare a concept export1able
public( F, M, op(X,Y,Z) ) :-
retract( private( F, M:op(X,Y,Z) ) ),
fail.
public( F, M, op(X,Y,Z) ) :- !,
assert( op_export(F, _M, op(X,Y,Z) ) ),
assert_new( public( F, M:op(X,Y,Z) ) ),
(
( M == user ; M == prolog )
->
op( X, Y, prolog:Z )
;
op( X, Y, M:Z )
assert_new( public( F, op(X,Y,Z) ) ),
directive( op(X,Y,M:Z), F, M ),
retract( private( F, op(X,Y,Z)) ),
fail
;
true
).
public( F, M, M:N/Ar ) :-
retract( private( F, M:N/Ar ) ),