diff --git a/C/errors.c b/C/errors.c index 0e8e8f990..bbf42d4da 100755 --- a/C/errors.c +++ b/C/errors.c @@ -348,9 +348,10 @@ bool Yap_PrintWarning(Term twarning) { } LOCAL_PrologMode |= InErrorMode; if (pred->OpcodeOfPred == UNDEF_OPCODE || pred->OpcodeOfPred == FAIL_OPCODE) { - fprintf(stderr, "warning message:\n"); - Yap_DebugPlWrite(twarning); - fprintf(stderr, "\n"); + fprintf(stderr, "%s:%ld/* d:%d warning */:\n", + LOCAL_ActiveError->errorFile, + LOCAL_ActiveError->errorLine, 0 ); + Yap_DebugPlWriteln(twarning); LOCAL_DoingUndefp = false; LOCAL_PrologMode &= ~InErrorMode; CurrentModule = cmod; @@ -1050,7 +1051,7 @@ static Int query_exception(USES_REGS1) { if (!IsAddressTerm(Deref(ARG2))) return false; yap_error_descriptor_t *y = AddressOfTerm(Deref(ARG2)); - //if (IsVarTerm(t3)) { + // if (IsVarTerm(t3)) { Term rc = queryErr(query, y); // Yap_DebugPlWriteln(rc); return Yap_unify(ARG3, rc); @@ -1059,6 +1060,26 @@ static Int query_exception(USES_REGS1) { // } } +static Int set_exception(USES_REGS1) { + const char *query = NULL; + Term t; + + if (IsAtomTerm((t = Deref(ARG1)))) + query = RepAtom(AtomOfTerm(t))->StrOfAE; + if (IsStringTerm(t)) + query = StringOfTerm(t); + if (!IsAddressTerm(Deref(ARG2))) + return false; + yap_error_descriptor_t *y = AddressOfTerm(Deref(ARG2)); + Term t3 = Deref(ARG3); + if (IsVarTerm(t3)) { + return false; + } else { + return setErr(query, y, t3); + } +} + + static Int drop_exception(USES_REGS1) { yap_error_descriptor_t *t = AddressOfTerm(Deref(ARG1)); @@ -1270,6 +1291,7 @@ void Yap_InitErrorPreds(void) { Yap_InitCPred("$reset_exception", 1, reset_exception, 0); Yap_InitCPred("$new_exception", 1, new_exception, 0); Yap_InitCPred("$get_exception", 1, get_exception, 0); + Yap_InitCPred("$set_exception", 3, set_exception, 0); Yap_InitCPred("$read_exception", 2, read_exception, 0); Yap_InitCPred("$query_exception", 3, query_exception, 0); Yap_InitCPred("$drop_exception", 1, drop_exception, 0); diff --git a/C/flags.c b/C/flags.c index 158671cf1..fbc131f99 100644 --- a/C/flags.c +++ b/C/flags.c @@ -25,10 +25,12 @@ */ /** - @{ - @defgroup YAPFlags_Impl C-code to handle Prolog flags. + + @defgroup YAPFlags C-code to handle Prolog flags. @ingroup YAPFlags + @{ + @brief Low-level code to support flags. Prolog Flags can be: @@ -313,7 +315,7 @@ static bool mkprompt(Term inp) { CACHE_REGS if (IsVarTerm(inp)) { return Yap_unify(inp, MkAtomTerm(Yap_LookupAtom(LOCAL_Prompt))); - } + } if (IsStringTerm(inp)) { inp = MkStringTerm(RepAtom(AtomOfTerm(inp))->StrOfAE); } @@ -1797,10 +1799,6 @@ void Yap_InitFlags(bool bootstrap) { Yap_InitCPredBack("current_prolog_flag", 2, 1, current_prolog_flag, cont_yap_flag, 0); TR = tr0; - /** @pred prolog_flag( ?Flag, - Value) - - Obtain the value for a YAP Prolog flag, same as current_prolog_flag/2. - */ Yap_InitCPredBack("prolog_flag", 3, 1, prolog_flag, cont_yap_flag, 0); Yap_InitCPredBack("yap_flag", 3, 1, yap_flag, cont_yap_flag, 0); diff --git a/C/save.c b/C/save.c index 721939e9d..9d6f3afbd 100755 --- a/C/save.c +++ b/C/save.c @@ -1469,6 +1469,7 @@ int Yap_SavedInfo(const char *FileName, CELL *ATrail, mode = OpenRestore(FileName, &MyState, &MyTrail, &MyStack, &MyHeap, NULL); if (mode == FAIL_RESTORE) { + fprintf(stderr, "restore failed to open %s as a valid state\n", FileName); return -1; } close_file(); diff --git a/C/utilpreds.c b/C/utilpreds.c index 3b3c4de63..bcb42b72d 100644 --- a/C/utilpreds.c +++ b/C/utilpreds.c @@ -2643,7 +2643,7 @@ static Term free_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end clean_tr(TR0 PASS_REGS); Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); - if (HR != InitialH+1) { + if (HR != InitialH) { InitialH[0] = (CELL)Yap_MkFunctor(AtomDollar, (HR-InitialH)-1); return AbsAppl(InitialH); } else { @@ -2983,24 +2983,28 @@ static Term non_singletons_in_complex_term(register CELL *pt0, register CELL *pt } /* Do we still have compound terms to visit */ if (to_visit > to_visit0) { -#ifdef RATIONAL_TREES to_visit -= 3; pt0 = to_visit[0]; pt0_end = to_visit[1]; *pt0 = (CELL)to_visit[2]; -#else - to_visit -= 2; - pt0 = to_visit[0]; - pt0_end = to_visit[1]; -#endif goto loop; } clean_tr(TR0 PASS_REGS); if (HR != InitialH) { - /* close the list */ - RESET_VARIABLE(HR-2); - Yap_unify((CELL)(HR-2),ARG2); + CELL *pt0 = InitialH, *pt1 = pt0; + while (pt0 < InitialH) { + if(Deref(pt0[0]) == TermFoundVar) { + pt1[0] = pt0[0]; + pt1[1] = AbsAppl(pt1+2); + pt1 += 2; + } + pt0 += 2; + } + } + if (HR != InitialH) { + /* close the list */ + HR[-1] = Deref(ARG2); return output; } else { return ARG2; diff --git a/H/YapGFlagInfo.h b/H/YapGFlagInfo.h index 3e9ba6246..65f613c10 100644 --- a/H/YapGFlagInfo.h +++ b/H/YapGFlagInfo.h @@ -24,28 +24,29 @@ START_GLOBAL_FLAGS -YAP_FLAG(ADDRESS_BITS_FLAG, "address_bits", false, nat, BITNESS, NULL), /**< + /**< Number of address bits in the machine, either 64 or 32 bits. */ +YAP_FLAG(ADDRESS_BITS_FLAG, "address_bits", false, nat, BITNESS, NULL), - YAP_FLAG(AGC_MARGIN_FLAG, "agc_margin", true, nat, "10000", - agc_threshold), /**< + /**< An integer: if this amount of atoms has been created since the last atom-garbage collection, perform atom garbage collection at the first opportunity. Initial value is 10,000. May be changed. A value of 0 (zero) disables atom garbage collection. */ + YAP_FLAG(AGC_MARGIN_FLAG, "agc_margin", true, nat, "10000", + agc_threshold), - YAP_FLAG(ALLOW_ASSERT_FOR_STATIC_PREDICATES, + /**< + boolean: allow asserting and retracting clauses of static + predicates. */ + YAP_FLAG(ALLOW_ASSERT_FOR_STATIC_PREDICATES, "allow_assert_for_static_predicates", true, booleanFlag, "true", - NULL), /**< - boolean: allow asserting and retracting clauses of static - predicates. */ + NULL), - YAP_FLAG(ALLOW_VARIABLE_NAME_AS_FUNCTOR_FLAG, - "allow_variable_name_as_functor", false, booleanFlag, "false", - NULL), /**< + /**< boolean flag allows syntax such as @@ -55,27 +56,32 @@ opportunity. Initial value is 10,000. May be changed. A value of 0 Tree(R). ~~~ */ + YAP_FLAG(ALLOW_VARIABLE_NAME_AS_FUNCTOR_FLAG, + "allow_variable_name_as_functor", false, booleanFlag, "false", + NULL), + - YAP_FLAG(ANSWER_FORMAT_FLAG, "answer_format", true, isatom, "~p", NULL), /**< how to present answers, default is `~p`. */ + YAP_FLAG(ANSWER_FORMAT_FLAG, "answer_format", true, isatom, "~p", NULL), #if __ANDROID__ - YAP_FLAG(ANDROID_FLAG, "android", false, booleanFlag, "true", NULL), /**< + /**< read-only boolean, a machine running an Google's Android version of the Linux Operating System */ + YAP_FLAG(ANDROID_FLAG, "android", false, booleanFlag, "true", NULL), #endif #if __APPLE__ - YAP_FLAG(APPLE_FLAG, "apple", false, booleanFlag, "true", NULL), /**< + /**< read-only boolean, a machine running an Apple Operating System */ + YAP_FLAG(APPLE_FLAG, "apple", false, booleanFlag, "true", NULL), #endif - YAP_FLAG(ARCH_FLAG, "arch", false, isatom, YAP_ARCH, NULL), /**< + /**< read-only atom, it describes the ISA used in this version of YAP. Available from YAP_ARCH. */ + YAP_FLAG(ARCH_FLAG, "arch", false, isatom, YAP_ARCH, NULL), YAP_FLAG(ARGV_FLAG, "argv", false, argv, "@boot", NULL), - YAP_FLAG(ARITHMETIC_EXCEPTIONS_FLAG, "arithmetic_exceptions", true, - booleanFlag, "true", NULL), - /**< + /**< Read-write flag telling whether arithmetic exceptions generate Prolog exceptions. If enabled: @@ -95,86 +101,96 @@ opportunity. Initial value is 10,000. May be changed. A value of 0 It is `true` by default, but it is disabled by packages like CLP(BN) and ProbLog. */ - YAP_FLAG(BACK_QUOTES_FLAG, "back_quotes", true, isatom, "true", bqs), - /**< + YAP_FLAG(ARITHMETIC_EXCEPTIONS_FLAG, "arithmetic_exceptions", true, + booleanFlag, "true", NULL), + + /**< If _Value_ is unbound, tell whether a back quoted list of characters token is converted to a list of atoms, `chars`, to a list of integers, `codes`, or to a single atom, `atom`. If _Value_ is bound, set to the corresponding behavior. The default value is `string` */ - YAP_FLAG(BOUNDED_FLAG, "bounded", false, booleanFlag, "false", NULL), - /**< `bounded` is iso + YAP_FLAG(BACK_QUOTES_FLAG, "back_quotes", true, isatom, "true", bqs), + + /**< Read-only flag telling whether integers are bounded. The value depends on whether YAP uses the GMP library or not. */ + YAP_FLAG(BOUNDED_FLAG, "bounded", false, booleanFlag, "false", NULL), + YAP_FLAG(C_CC_FLAG, "c_cc", false, isatom, C_CC, NULL), YAP_FLAG(C_CFLAGS_FLAG, "c_cflags", false, isatom, C_CFLAGS, NULL), YAP_FLAG(C_LDFLAGS_FLAG, "c_ldflags", false, isatom, C_LDFLAGS, NULL), YAP_FLAG(C_LIBPLSO_FLAG, "c_libplso", false, isatom, C_LIBPLSO, NULL), YAP_FLAG(C_LIBS_FLAG, "c_libs", false, isatom, C_LIBS, NULL), - YAP_FLAG(CHAR_CONVERSION_FLAG, "char_conversion", true, booleanFlag, - "false", NULL), - /**< `char_conversion is iso` + /**< `char_conversion is iso` Writable flag telling whether a character conversion table is used when reading terms. The default value for this flag is `off` except in `sicstus` and `iso` language modes, where it is `on`. */ - YAP_FLAG(CHARACTER_ESCAPES_FLAG, "character_escapes", true, booleanFlag, - "true", NULL), - /**< ` + YAP_FLAG(CHAR_CONVERSION_FLAG, "char_conversion", true, booleanFlag, + "false", NULL), + + /**< ` Writable flag telling whether a character escapes are enabled, `true`, or disabled, `false`. The default value for this flag is `true`. */ - YAP_FLAG(COLON_SETS_CALLING_CONTEXT_FLAG, "colon_sets_calling_context", - true, booleanFlag, "true", NULL), - /**< `compiled_at ` + YAP_FLAG(CHARACTER_ESCAPES_FLAG, "character_escapes", true, booleanFlag, + "true", NULL), + + /**< `compiled_at ` Read-only flag that gives the time when the main YAP binary was compiled. It is obtained staight from the __TIME__ macro, as defined in the C99. */ + YAP_FLAG(COLON_SETS_CALLING_CONTEXT_FLAG, "colon_sets_calling_context", + true, booleanFlag, "true", NULL), + YAP_FLAG(COMPILED_AT_FLAG, "compiled_at", false, isatom, YAP_COMPILED_AT, NULL), - YAP_FLAG(DEBUG_FLAG, "debug", true, booleanFlag, "false", NULL), - /**< + /**< If _Value_ is unbound, tell whether debugging is `true` or `false`. If _Value_ is bound to `true` enable debugging, and if it is bound to `false` disable debugging. */ + YAP_FLAG(DEBUG_FLAG, "debug", true, booleanFlag, "false", NULL), + YAP_FLAG(DEBUG_INFO_FLAG, "debug_info", true, booleanFlag, "true", NULL), - YAP_FLAG(DEBUG_ON_ERROR_FLAG, "debug_on_error", true, booleanFlag, "true", - NULL), - /**< + /**< If bound, set the argument to the `write_term/3` options the debugger uses to write terms. If unbound, show the current options. */ + YAP_FLAG(DEBUG_ON_ERROR_FLAG, "debug_on_error", true, booleanFlag, "true", + NULL), + YAP_FLAG(DEBUGGER_PRINT_OPTIONS_FLAG, "debugger_print_options", true, list_option, "[quoted(true),numbervars(true),portrayed(true),max_depth(10)]", NULL), YAP_FLAG(DEBUGGER_SHOW_CONTEXT_FLAG, "debugger_show_context", true, booleanFlag, "false", NULL), - YAP_FLAG(DEFAULT_PARENT_MODULE_FLAG, "default_parent_module", true, isatom, - "user", NULL), - /**< + /**< * A module to be inherited by all other modules. Default is user that * reexports prolog. * * Set it to `prolog` for SICStus Prolog like resolution, to `user` for * SWI-like. */ - YAP_FLAG(DIALECT_FLAG, "dialect", false, ro, "yap", NULL), - /**< + YAP_FLAG(DEFAULT_PARENT_MODULE_FLAG, "default_parent_module", true, isatom, + "user", NULL), + + /**< Read-only flag that always returns `yap`. */ - YAP_FLAG(DISCONTIGUOUS_WARNINGS_FLAG, "discontiguous_warnings", true, - booleanFlag, "true", NULL), - /**< + YAP_FLAG(DIALECT_FLAG, "dialect", false, ro, "yap", NULL), + + /**< If `true` (default `true`) YAP checks for definitions of the same predicate that are separated by clauses for other predicates. This may indicate that @@ -184,36 +200,42 @@ opportunity. Initial value is 10,000. May be changed. A value of 0 predicates. */ - YAP_FLAG(DOLLAR_AS_LOWER_CASE_FLAG, "dollar_as_lower_case", true, - booleanFlag, "false", NULL), - /**< + YAP_FLAG(DISCONTIGUOUS_WARNINGS_FLAG, "discontiguous_warnings", true, + booleanFlag, "true", NULL), + + /**< If `off` (default) consider the character `$` a control character, if vxu `on` consider `$` a lower case character. */ - YAP_FLAG(DOUBLE_QUOTES_FLAG, "double_quotes", true, isatom, "codes", dqs), - /**< iso + YAP_FLAG(DOLLAR_AS_LOWER_CASE_FLAG, "dollar_as_lower_case", true, + booleanFlag, "false", NULL), + + /**< iso If _Value_ is unbound, tell whether a double quoted list of characters token is converted to a list of atoms, `chars`, to a list of integers, `codes`, or to a single atom, `atom`. If _Value_ is bound, set to the corresponding behavior. The default value is `codes`. */ + YAP_FLAG(DOUBLE_QUOTES_FLAG, "double_quotes", true, isatom, "codes", dqs), + YAP_FLAG(EDITOR_FLAG, "editor", true, isatom, "$EDITOR", NULL), - YAP_FLAG(EXECUTABLE_FLAG, "executable", false, executable, "@boot", NULL), - /**< + /**< Read-only flag. It unifies with an atom that gives the original program path. */ - YAP_FLAG(FAST_FLAG, "fast", true, booleanFlag, "false", NULL), - /**< + YAP_FLAG(EXECUTABLE_FLAG, "executable", false, executable, "@boot", NULL), + + /**< If `on` allow fast machine code, if `off` (default) disable it. Only available in experimental implementations. */ + YAP_FLAG(FAST_FLAG, "fast", true, booleanFlag, "false", NULL), + YAP_FLAG(FILE_NAME_VARIABLES_FLAG, "file_name_variables", true, booleanFlag, "true", NULL), - YAP_FLAG(FLOAT_FORMAT_FLAG, "float_format", true, isatom, "%.16f", NULL), - /**< + /**< C-library `printf()` format specification used by write/1 and friends to determine how floating point numbers are printed. The @@ -222,20 +244,23 @@ vxu `on` consider `$` a lower case character. printed, `%g` will print all floats using 6 digits instead of the default 15. */ - YAP_FLAG(GC_FLAG, "gc", true, booleanFlag, "on", NULL), - /**< `gc` + YAP_FLAG(FLOAT_FORMAT_FLAG, "float_format", true, isatom, "%.16f", NULL), + + /**< `gc` If `on` allow garbage collection (default), if `off` disable it. */ - YAP_FLAG(GC_MARGIN_FLAG, "gc_margin", true, nat, "0", gc_margin), - /**< `gc_margin ` + YAP_FLAG(GC_FLAG, "gc", true, booleanFlag, "on", NULL), + + /**< `gc_margin ` Set or show the minimum free stack before starting garbage collection. The default depends on total stack size. */ - YAP_FLAG(GC_TRACE_FLAG, "gc_trace", true, isatom, "off", NULL), - /**< + YAP_FLAG(GC_MARGIN_FLAG, "gc_margin", true, nat, "0", gc_margin), + + /**< * If `off` (default) do not show information on garbage collection and stack shifts, if `on` inform when a garbage collection or stack @@ -244,9 +269,9 @@ vxu `on` consider `$` a lower case character. information on data-structures found during the garbage collection process, namely, on choice-points. */ - YAP_FLAG(GENERATE_DEBUGGING_INFO_FLAG, "generate_debug_info", true, - booleanFlag, "true", NULL), - /**< ` + YAP_FLAG(GC_TRACE_FLAG, "gc_trace", true, isatom, "off", NULL), + + /**< ` If `true` (default) generate debugging information for procedures, including source mode. If `false` predicates no @@ -254,55 +279,64 @@ vxu `on` consider `$` a lower case character. source mode is disabled. */ + YAP_FLAG(GENERATE_DEBUGGING_INFO_FLAG, "generate_debug_info", true, + booleanFlag, "true", NULL), + YAP_FLAG(GMP_VERSION_FLAG, "gmp_version", false, isatom, "4.8.12", NULL), YAP_FLAG(HALT_AFTER_CONSULT_FLAG, "halt_after_consult", false, booleanFlag, "false", NULL), - YAP_FLAG(HOME_FLAG, "home", false, isatom, YAP_ROOTDIR, NULL), - /**< home ` + /**< home ` the root of the YAP installation, by default `/usr/local` in Unix or `c:\Yap` in Windows system. Can only be set at configure time */ - YAP_FLAG(HOST_TYPE_FLAG, "host_type", false, isatom, HOST_ALIAS, NULL), - /**< host_type ` + YAP_FLAG(HOME_FLAG, "home", false, isatom, YAP_ROOTDIR, NULL), + + /**< host_type ` Return `configure` system information, including the machine-id for which YAP was compiled and Operating System information. */ - YAP_FLAG(INDEX_FLAG, "index", true, indexer, "multi", NULL), - /**< `index ` + YAP_FLAG(HOST_TYPE_FLAG, "host_type", false, isatom, HOST_ALIAS, NULL), + + /**< `index ` If `on` allow indexing (default), if `off` disable it, if `single` allow on first argument only. */ - YAP_FLAG(INDEX_SUB_TERM_SEARCH_DEPTH_FLAG, "index_sub_term_search_depth", - true, nat, "0", NULL), - /**< `Index_sub_term_search_depth ` + YAP_FLAG(INDEX_FLAG, "index", true, indexer, "multi", NULL), + + /**< `Index_sub_term_search_depth ` Maximum bound on searching sub-terms for indexing, if `0` (default) no bound. */ - YAP_FLAG(INFORMATIONAL_MESSAGES_FLAG, "informational_messages", true, - isatom, "normal", NULL), - /**< `informational_messages ` + YAP_FLAG(INDEX_SUB_TERM_SEARCH_DEPTH_FLAG, "index_sub_term_search_depth", + true, nat, "0", NULL), + + /**< `informational_messages ` If `on` allow printing of informational messages, such as the ones that are printed when consulting. If `off` disable printing these messages. It is `on` by default except if YAP is booted with the `-L` flag. */ - YAP_FLAG(INTEGER_ROUNDING_FUNCTION_FLAG, "integer_rounding_function", true, - isatom, "toward_zero", NULL), - /**< `integer_rounding_function is iso ` + YAP_FLAG(INFORMATIONAL_MESSAGES_FLAG, "informational_messages", true, + isatom, "normal", NULL), + + /**< `integer_rounding_function is iso ` Read-only flag telling the rounding function used for integers. Takes the value `toward_zero` for the current version of YAP. */ + YAP_FLAG(INTEGER_ROUNDING_FUNCTION_FLAG, "integer_rounding_function", true, + isatom, "toward_zero", NULL), + YAP_FLAG(ISO_FLAG, "iso", true, booleanFlag, "false", NULL), - YAP_FLAG(JUPYTER_FLAG, "jupyter", false, booleanFlag, "true", NULL), /**< + /**< read-only boolean, a machine running Jupyter */ - YAP_FLAG(LANGUAGE_FLAG, "language", true, isatom, "yap", NULL), - /**< `language ` + YAP_FLAG(JUPYTER_FLAG, "jupyter", false, booleanFlag, "true", NULL), + /**< `language ` Choose whether YAP follows native, closer to C-Prolog, `yap`, iso-prolog, `iso` or SICStus Prolog, `sicstus`. The current default is @@ -311,21 +345,26 @@ vxu `on` consider `$` a lower case character. are interpreted, when to use dynamic, character escapes, and how files are consulted. Also check the `dialect` option. */ - YAP_FLAG(PROLOG_LIBRARY_DIRECTORY_FLAG, "prolog_library_directory", true, - isatom, "", NULL), - /**< if defined, first location where YAP expects to find the YAP Prolog + YAP_FLAG(LANGUAGE_FLAG, "language", true, isatom, "yap", NULL), + + /**< if defined, first location where YAP expects to find the YAP Prolog library. Takes precedence over library_directory */ - YAP_FLAG(PROLOG_FOREIGN_DIRECTORY_FLAG, "prolog_foreign_directory", true, + YAP_FLAG(PROLOG_LIBRARY_DIRECTORY_FLAG, "prolog_library_directory", true, isatom, "", NULL), - /**< if defined, first location where YAP expects to find the YAP Prolog + + /**< if defined, first location where YAP expects to find the YAP Prolog shared libraries (DLLS). Takes precedence over executable_directory/2. */ - - /**< `max_arity is iso ` + /**< `max_arity is iso ` YAP_FLAG(MAX_ARITY_FLAG, "max_arity", false, isatom, "unbounded", NULL), Read-only flag telling the maximum arity of a functor. Takes the value `unbounded` for the current version of YAP. */ + YAP_FLAG(PROLOG_FOREIGN_DIRECTORY_FLAG, "prolog_foreign_directory", true, + isatom, "", NULL), + + + YAP_FLAG(MAX_TAGGED_INTEGER_FLAG, "max_tagged_integer", false, at2n, "INT_MAX", NULL), YAP_FLAG(MAX_THREADS_FLAG, "max_threads", false, at2n, "MAX_THREADS", NULL), @@ -336,28 +375,31 @@ vxu `on` consider `$` a lower case character. "256", NULL), YAP_FLAG(OCCURS_CHECK_FLAG, "occurs_check", true, booleanFlag, "false", NULL), - YAP_FLAG(OPEN_EXPANDS_FILENAME_FLAG, "open_expands_filename", true, - booleanFlag, "false", NULL), - /**< `open_expands_filename ` + /**< `open_expands_filename ` If `true` the open/3 builtin performs filename-expansion before opening a file (SICStus Prolog like). If `false` it does not (SWI-Prolog like). */ - YAP_FLAG(OPEN_SHARED_OBJECT_FLAG, "open_shared_object", true, booleanFlag, - "true", NULL), - /**< `open_shared_object ` + YAP_FLAG(OPEN_EXPANDS_FILENAME_FLAG, "open_expands_filename", true, + booleanFlag, "false", NULL), + + /**< `open_shared_object ` If true, `open_shared_object/2` and friends are implemented, providing access to shared libraries (`.so` files) or to dynamic link libraries (`.DLL` files). */ - /**< `module_independent_operators ` + /**< `module_independent_operators ` If `true` an operator declaration will be valid for every module in the program. This is for compatibility with old software that might expect module-independent operators. */ + YAP_FLAG(OPEN_SHARED_OBJECT_FLAG, "open_shared_object", true, booleanFlag, + "true", NULL), + + YAP_FLAG(MODULE_INDEPENDENT_OPERATORS_FLAG, "module_independent_operators", true, booleanFlag, "false", NULL), @@ -365,17 +407,16 @@ vxu `on` consider `$` a lower case character. YAP_FLAG(OS_ARGV_FLAG, "os_argv", false, os_argv, "@boot", NULL), YAP_FLAG(PID_FLAG, "pid", false, sys_pid, "@boot", NULL), YAP_FLAG(PIPE_FLAG, "pipe", true, booleanFlag, "true", NULL), - YAP_FLAG(PROFILING_FLAG, "profiling", true, booleanFlag, "false", NULL), - /**< `profiling ` + /**< `profiling ` If `off` (default) do not compile call counting information for procedures. If `on` compile predicates so that they calls and retries to the predicate may be counted. Profiling data can be read through the call_count_data/3 built-in. */ - YAP_FLAG(PROMPT_ALTERNATIVES_ON_FLAG, "prompt_alternatives_on", true, - isatom, "determinism", NULL), - /**< `prompt_alternatives_on(atom, + YAP_FLAG(PROFILING_FLAG, "profiling", true, booleanFlag, "false", NULL), + + /**< `prompt_alternatives_on(atom, changeable) ` SWI-Compatible option, determines prompting for alternatives in the Prolog @@ -383,17 +424,20 @@ vxu `on` consider `$` a lower case character. and only if the query contains variables. The alternative, default in SWI-Prolog is determinism which implies the system prompts for alternatives if the goal succeeded while leaving choicepoints. */ + YAP_FLAG(PROMPT_ALTERNATIVES_ON_FLAG, "prompt_alternatives_on", true, + isatom, "determinism", NULL), + YAP_FLAG(QUASI_QUOTATIONS_FLAG, "quasi_quotations", true, booleanFlag, "true", NULL), - YAP_FLAG(READLINE_FLAG, "readline", true, booleanFlag, "false", - Yap_InitReadline), - /**< `readline(boolean, changeable)` + /**< `readline(boolean, changeable)` } enable the use of the readline library for console interactions, true by default if readline was found. */ - YAP_FLAG(REDEFINE_WARNINGS_FLAG, "redefine_warnings", true, booleanFlag, - "true", NULL), /**< + YAP_FLAG(READLINE_FLAG, "readline", true, booleanFlag, "false", + Yap_InitReadline), + + /**< If _Value_ is unbound, tell whether warnings for procedures defined in several different files are `on` or @@ -401,43 +445,50 @@ in several different files are `on` or and if it is bound to `off` disable them. The default for YAP is `off`, unless we are in `sicstus` or `iso` mode. */ + YAP_FLAG(REDEFINE_WARNINGS_FLAG, "redefine_warnings", true, booleanFlag, + "true", NULL), YAP_FLAG(REPORT_ERROR_FLAG, "report_error", true, booleanFlag, "true", NULL), - YAP_FLAG(RESOURCE_DATABASE_FLAG, "resource_database", false, isatom, - YAP_BOOTSTRAP, NULL), - - /**<`resource_database` + /**<`resource_database` Name of the resource file (saved-state or Prolog file) used to construct the YAP run-time environment. */ - YAP_FLAG(SAVED_PROGRAM_FLAG, "saved_program", false, booleanFlag, "false", - NULL), - /**<`saved_program` + YAP_FLAG(RESOURCE_DATABASE_FLAG, "resource_database", false, isatom, + + YAP_BOOTSTRAP, NULL), + + + /**<`saved_program` if `true` YAP booted from a `yss` file, usually `startup.yss'. If `false`, YAP booted from a Prolog file, by default `boot.yap`. */ - YAP_FLAG(SHARED_OBJECT_EXTENSION_FLAG, "shared_object_extension", false, - isatom, SO_EXT, NULL), - - /**< `shared_object_extension ` + YAP_FLAG(SAVED_PROGRAM_FLAG, "saved_program", false, booleanFlag, "false", + NULL), + + /**< `shared_object_extension ` Suffix associated with loadable code. */ - YAP_FLAG(SHARED_OBJECT_SEARCH_PATH_FLAG, "shared_object_search_path", true, - isatom, SO_PATH, NULL), - /**< `shared_object_search_path ` + YAP_FLAG(SHARED_OBJECT_EXTENSION_FLAG, "shared_object_extension", false, + isatom, SO_EXT, NULL), + + + /**< Name of the environment variable used by the system to search for shared objects. */ - YAP_FLAG(SINGLE_QUOTES_FLAG, "single_quotes", true, isatom, "atom", sqf), - /**< `single_quoted text is usuallly interpreted as atoms. This flagTerm - allows other inerpretations such as strings_contains_strings */ + YAP_FLAG(SHARED_OBJECT_SEARCH_PATH_FLAG, "shared_object_search_path", true, + isatom, SO_PATH, NULL), + + /**< single_quoted text is usuallly interpreted as atoms. This flag + allows other interpretations such as strings */ + YAP_FLAG(SINGLE_QUOTES_FLAG, "single_quotes", true, isatom, "atom", sqf), + - YAP_FLAG(SINGLE_VAR_WARNINGS_FLAG, "single_var_warnings", true, booleanFlag, - "true", NULL), /**< + /**< If `true` (default `true`) YAP checks for singleton variables when loading files. A singleton variable is a variable that appears ony once in a clause. The name @@ -445,22 +496,25 @@ and if it is bound to `off` disable them. The default for YAP is starts with underscore are never considered singleton. */ - YAP_FLAG(SIGNALS_FLAG, "signals", true, booleanFlag, "true", NULL), - /**< `signals` + YAP_FLAG(SINGLE_VAR_WARNINGS_FLAG, "single_var_warnings", true, booleanFlag, + "true", NULL), + /**< If `true` (default) YAP handles Signals such as `^C` (`SIGINT`). */ - YAP_FLAG(SOURCE_FLAG, "source", true, booleanFlag, "true", NULL), - /**< `source` + YAP_FLAG(SIGNALS_FLAG, "signals", true, booleanFlag, "true", NULL), + + /**< If `true` maintain the source for all clauses. Notice that this is trivially supported for facts, and always supported for dynamic code. */ - YAP_FLAG(STRICT_ISO_FLAG, "strict_iso", true, booleanFlag, "false", NULL), - /**< `strict_iso ` + YAP_FLAG(SOURCE_FLAG, "source", true, booleanFlag, "true", NULL), + + /**< `strict_iso ` If _Value_ is unbound, tell whether strict ISO compatibility mode is `on` or `off`. If _Value_ is bound to `on` set @@ -482,9 +536,9 @@ and if it is bound to `off` disable them. The default for YAP is depends on a Prolog's platform specific features. */ - YAP_FLAG(SYSTEM_OPTIONS_FLAG, "system_options", false, options, - SYSTEM_OPTIONS, NULL), - /**< `system_options ` + YAP_FLAG(STRICT_ISO_FLAG, "strict_iso", true, booleanFlag, "false", NULL), + + /**< `system_options ` This read only flag tells which options were used to compile YAP. Currently it informs whether the system supports `big_numbers`, @@ -492,20 +546,22 @@ and if it is bound to `off` disable them. The default for YAP is `or-parallelism`, `rational_trees`, `readline`, `tabling`, `threads`, or the `wam_profiler`. */ + YAP_FLAG(SYSTEM_OPTIONS_FLAG, "system_options", false, options, + SYSTEM_OPTIONS, NULL), + YAP_FLAG(SYSTEM_THREAD_ID_FLAG, "system_thread_id", false, sys_thread_id, "@boot", NULL), - YAP_FLAG(TABLING_MODE_FLAG, "tabling_mode", true, isatom, "[]", NULL), - /**< `tabling_mode` + /**< `tabling_mode` Sets or reads the tabling mode for all tabled predicates. Please (see Tabling) for the list of options. */ + YAP_FLAG(TABLING_MODE_FLAG, "tabling_mode", true, isatom, "[]", NULL), + YAP_FLAG(THREADS_FLAG, "threads", false, ro, "MAX_THREADS", NULL), YAP_FLAG(TIMEZONE_FLAG, "timezone", false, ro, "18000", NULL), - YAP_FLAG(TOPLEVEL_HOOK_FLAG, "toplevel_hook", true, booleanFlag, "true", - NULL), - /**< `toplevel_hook ` + /**< `toplevel_hook ` If bound, set the argument to a goal to be executed before entering the top-level. If unbound show the current goal or `true` if none is @@ -513,6 +569,9 @@ and if it is bound to `off` disable them. The default for YAP is backtracked into. */ + YAP_FLAG(TOPLEVEL_HOOK_FLAG, "toplevel_hook", true, booleanFlag, "true", + NULL), + YAP_FLAG(TOPLEVEL_PRINT_ANON_FLAG, "toplevel_print_anon", true, booleanFlag, "true", NULL), YAP_FLAG(TOPLEVEL_PRINT_OPTIONS_FLAG, "toplevel_print_options", true, @@ -521,14 +580,13 @@ and if it is bound to `off` disable them. The default for YAP is YAP_FLAG(TOPLEVEL_PROMPT_FLAG, "toplevel_prompt", true, isatom, "?- ", mkprompt), YAP_FLAG(TTY_CONTROL_FLAG, "tty_control", true, booleanFlag, "true", NULL), - YAP_FLAG(UNIX_FLAG, "unix", false, ro, "true", NULL), - /**< `unix` + /**< `unix` Read-only BooleanFlag flag that unifies with `true` if YAP is running on an Unix system. Defined if the C-compiler used to compile this version of YAP either defines `__unix__` or `unix`. */ - /**< `update_semantics ` + /**< `update_semantics ` Define whether YAP should follow `immediate` update semantics, as in C-Prolog (default), `logical` update semantics, @@ -537,10 +595,12 @@ and if it is bound to `off` disable them. The default for YAP is procedures follow logical semantics but the internal data base still follows immediate semantics. */ + YAP_FLAG(UNIX_FLAG, "unix", false, ro, "true", NULL), + + YAP_FLAG(UPDATE_SEMANTICS_FLAG, "update_semantics", true, isatom, "logical", NULL), - YAP_FLAG(USER_FLAGS_FLAG, "user_flags", true, isatom, "error", NULL), - /**< + /**< `user_flags ` Define the behaviour of set_prolog_flag/2 if the flag is not known. Values @@ -551,18 +611,20 @@ and if it is bound to `off` disable them. The default for YAP is developers are encouraged to use `create_prolog_flag/3` to create flags for their library. */ - YAP_FLAG(UNKNOWN_FLAG, "unknown", true, isatom, "error", Yap_unknown), - /**< `unknown is iso` + YAP_FLAG(USER_FLAGS_FLAG, "user_flags", true, isatom, "error", NULL), + + /**< `unknown is iso` Corresponds to calling the unknown/2 built-in. Possible ISO values are `error`, `fail`, and `warning`. Yap includes the following extensions: `fast_fail` does not invoke any handler. */ + YAP_FLAG(UNKNOWN_FLAG, "unknown", true, isatom, "error", Yap_unknown), + YAP_FLAG(VARIABLE_NAMES_MAY_END_WITH_QUOTES_FLAG, "variable_names_may_end_with_quotes", true, booleanFlag, "false", NULL), - YAP_FLAG(VERBOSE_FLAG, "verbose", true, isatom, "normal", NULL), - /**< `verbose ` + /**< If `normal` allow printing of informational and banner messages, such as the ones that are printed when consulting. If `silent` @@ -570,66 +632,75 @@ and if it is bound to `off` disable them. The default for YAP is YAP is booted with the `-q` or `-L` flag. */ - YAP_FLAG(VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, booleanFlag, - "false", NULL), - /**< `verbose_file_search ` + YAP_FLAG(VERBOSE_FLAG, "verbose", true, isatom, "normal", NULL), + + /**< If `true` allow printing of informational messages when searching for file names. If `false` disable printing these messages. It is `false` by default except if YAP is booted with the `-L` flag. */ - YAP_FLAG(VERBOSE_LOAD_FLAG, "verbose_load", true, booleanFlag, "true", NULL), - /**< `verbose_load ` + YAP_FLAG(VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, booleanFlag, + "false", NULL), + + /**< If `true` allow printing of informational messages when consulting files. If `false` disable printing these messages. It is `true` by default except if YAP is booted with the `-L` flag. */ - YAP_FLAG(VERSION_FLAG, "version", false, nat, YAP_NUMERIC_VERSION, NULL), - /**< - `version ` Read-only flag that returns a compound term with the + YAP_FLAG(VERBOSE_LOAD_FLAG, "verbose_load", true, booleanFlag, "true", NULL), + + /**< + Read-only flag that returns a compound term with the current version of YAP. The term will have the name `yap` and arity 4, the first argument will be the major version, the second the minor version, the third the patch number, and the last one is reserved. */ - YAP_FLAG(VERSION_DATA_FLAG, "version_data", false, ro, YAP_TVERSION, NULL), - /**< `version_data ` + YAP_FLAG(VERSION_FLAG, "version", false, nat, YAP_NUMERIC_VERSION, NULL), + + /**< Read-only flag that unifies with a number of the form `_Major_ * 100000 + _Minor_ *100 + _Patch_`, where _Major_ is the major version, _Minor_ is the minor version, and _Patch_ is the patch number. */ - YAP_FLAG(VERSION_GIT_FLAG, "version_git", false, isatom, YAP_GIT_HEAD, - NULL), - /**< `version_git ` + YAP_FLAG(VERSION_DATA_FLAG, "version_data", false, ro, YAP_TVERSION, NULL), + + /**< ` this is the unique identifier for the last commit of the current GIT HEAD, it xan be used to identify versions that differ on small (or large) updates. */ - YAP_FLAG(WRITE_ATTRIBUTES_FLAG, "write_attributes", true, isatom, "ignore", + YAP_FLAG(VERSION_GIT_FLAG, "version_git", false, isatom, YAP_GIT_HEAD, NULL), -#if __WINDOWS__ - /**< `windows` + + /**< Read-only booleanFlag flag that unifies with `true` if YAP is running on an Windows machine. */ + YAP_FLAG(WRITE_ATTRIBUTES_FLAG, "write_attributes", true, isatom, "ignore", + NULL), +#if __WINDOWS__ + YAP_FLAG(WINDOWS_FLAG, "windows", false, ro, "true", NULL), #endif - YAP_FLAG(WRITE_STRINGS_FLAG, "write_strings", true, booleanFlag, "false", - NULL), - - /**< `write_strings ` + /**< Writable flag telling whether the system should write lists of integers that are writable character codes using the list notation. It is `on` if enables or `off` if disabled. The default value for this flag is `off`. */ + YAP_FLAG(WRITE_STRINGS_FLAG, "write_strings", true, booleanFlag, "false", + NULL), + + END_GLOBAL_FLAGS //! @} diff --git a/H/YapLFlagInfo.h b/H/YapLFlagInfo.h index 376a4989e..9b1c5fd05 100644 --- a/H/YapLFlagInfo.h +++ b/H/YapLFlagInfo.h @@ -1,5 +1,3 @@ - - /************************************************************************* * * * YAP Prolog * @@ -28,14 +26,13 @@ START_LOCAL_FLAGS -/** + `autoload`: set the system to look for undefined procedures */ +/**< set the system to look for undefined procedures */ YAP_FLAG(AUTOLOAD_FLAG, "autoload", true, booleanFlag, "false", NULL), -/** + `read-only flag, that tells if Prolog is in an inner top-level */ +/**<`read-only flag, that tells if Prolog is in an inner top-level */ YAP_FLAG(BREAK_LEVEL_FLAG, "break_level", true, nat, "0", NULL), - /** + `call_counting` - + /**< Predicates compiled with this flag set maintain a counter on the numbers of proceduree calls and of retries. These counters are decreasing counters, and they can be used as timers. Three @@ -55,7 +52,7 @@ YAP_FLAG(AUTOLOAD_FLAG, "autoload", true, booleanFlag, "false", NULL), YAP_FLAG(CALL_COUNTING_FLAG, "call_counting", true, booleanFlag, "true", NULL), -/** + support for coding systens, YAP relies on UTF-8 internally. +/**< support for coding systens, YAP relies on UTF-8 internally. */ YAP_FLAG(ENCODING_FLAG, "encoding", true, isatom, "utf-8", getenc), @@ -63,28 +60,25 @@ YAP_FLAG(AUTOLOAD_FLAG, "autoload", true, booleanFlag, "false", NULL), */ YAP_FLAG(FILEERRORS_FLAG, "fileerrors", true, booleanFlag, "true", - NULL), /** + `fileerrors` + NULL), - If `on` `fileerrors` is `on`, if `off` (default) - `fileerrors` is disabled. - */ - /** + `language_mode` + /**< - wweter native mode or trying to emulate a different + whether native mode or trying to emulate a different Prolog. */ YAP_FLAG(LANGUAGE_MODE_FLAG, "language_mode", true, isatom, "yap", NULL), YAP_FLAG(STACK_DUMP_ON_ERROR_FLAG, "stack_dump_on_error", true, booleanFlag, - "true", NULL), /** + `stack_dump_on_error ` + "true", NULL), + /**<` -If `true` show a stack dump when YAP finds an error. The default is -`off`. -*/ - YAP_FLAG(STREAM_TYPE_CHECK_FLAG, "stream_type_check", true, isatom, "loose", + If `true` show a stack dump when YAP finds an error. The default is + `off`. + */ + YAP_FLAG(STREAM_TYPE_CHECK_FLAG, "stream_type_check", true, isatom, "loose", NULL), - YAP_FLAG(SYNTAX_ERRORS_FLAG, "syntax_errors", true, synerr, "error", - NULL), /** + `syntax_errors` + /** + `syntax_errors` Control action to be taken after syntax errors while executing read/1, `read/2`, or `read_term/3`: @@ -97,16 +91,18 @@ Report the syntax error and generate an error (default). + `quiet` Just fail */ - YAP_FLAG(TYPEIN_MODULE_FLAG, "typein_module", true, isatom, "user", - typein), /** + `typein_module ` + YAP_FLAG(SYNTAX_ERRORS_FLAG, "syntax_errors", true, synerr, "error", + NULL), + /**< + If bound, set the current working or type-in module to the argument, + which must be an atom. If unbound, unify the argument with the current + working module. -If bound, set the current working or type-in module to the argument, -which must be an atom. If unbound, unify the argument with the current -working module. - -*/ + */ + YAP_FLAG(TYPEIN_MODULE_FLAG, "typein_module", true, isatom, "user", + typein), YAP_FLAG(USER_ERROR_FLAG, "user_error", true, stream, "user_error", - set_error_stream), /** + `user_error1` + set_error_stream), /**< If the second argument is bound to a stream, set user_error to this stream. If the second argument is unbound, unify the argument with @@ -140,7 +136,7 @@ automatically redirects the user_error alias to the original YAP_FLAG(USER_INPUT_FLAG, "user_input", true, stream, "user_input", set_input_stream), YAP_FLAG(USER_OUTPUT_FLAG, "user_output", true, stream, "user_output", - set_output_stream), + set_output_stream) END_LOCAL_FLAGS diff --git a/docs/custom/DoxygenLayout.xml b/docs/custom/DoxygenLayout.xml index 1cdc7e17d..e00a18683 100644 --- a/docs/custom/DoxygenLayout.xml +++ b/docs/custom/DoxygenLayout.xml @@ -140,26 +140,12 @@ - + - - - - - - - - - - - - - - @@ -177,8 +163,24 @@ + - + + + + + + + + + + + + + + + + diff --git a/library/listing.yap b/library/listing.yap index 7c869a4db..77f6061ed 100644 --- a/library/listing.yap +++ b/library/listing.yap @@ -19,10 +19,10 @@ * @file library/listing.yap * @author VITOR SANTOS COSTA * @date Tue Nov 17 22:03:59 2015 - * + * * @brief Emulate SWI Prolog's listing. - * - * + * + * */ :- module(swi_listing, [ listing/0, @@ -31,20 +31,3 @@ portray_clause/2, % +Stream, +Clause portray_clause/3 % +Stream, +Clause, +Options ]). - - - -/* - - * @defgroup swi_listing SWI Prolog listing emulation - * @ingroup library - - emulates listing.pl, but just the interface for now. - -*/ - - -:- meta_predicate portray_clause( +, + , : ). - -portray_clause(Stream, Term, M:Options) :- - portray_clause( Stream, Term ). diff --git a/pl/listing.yap b/pl/listing.yap index 38543747f..fb10a8b86 100644 --- a/pl/listing.yap +++ b/pl/listing.yap @@ -318,7 +318,6 @@ portray_clause(Clause) :- '$beautify_vs'(T) :- '$non_singletons_in_term'(T,[],Fs), -writeln(Fs), '$vv_transform'(Fs,1), term_variables(T, NFs), '$v_transform'(NFs).