new flag system

This commit is contained in:
Vítor Santos Costa 2015-06-18 01:59:07 +01:00
parent c755a6d4e5
commit 8fc4dc2219
4 changed files with 2237 additions and 0 deletions

1397
C/flags.c Normal file

File diff suppressed because it is too large Load Diff

329
H/YapFlags.h Normal file
View File

@ -0,0 +1,329 @@
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 2015- *
* *
**************************************************************************
* *
* File: YapFlags.h *
* Last rev: *
* mods: *
* comments: flag system interface. *
* *
*************************************************************************/
/** @file YapFlags.h
@ingroup Flags
*/
#ifndef YAP_FLAGS_H
#define YAP_FLAGS_H 1
//INLINE_ONLY inline EXTERN bool nat( Term inp );
static inline bool nat( Term inp ) {
if (IsVarTerm(inp)) {
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag in 0...");
return false;
}
if (IsIntTerm(inp)) {
Int i = IntOfTerm(inp);
if (i >= 0) return true;
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, inp, "set_prolog_flag in 0...");
return false;
}
Yap_Error(TYPE_ERROR_INTEGER, inp, "set_prolog_flag in 0...");
return false;
}
static inline bool at2n( Term inp ) {
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag.");
return false;
}
static inline bool isfloat( Term inp ) {
if (IsVarTerm(inp)) {
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag in 0.0.");
return false;
}
if (IsFloatTerm(inp)) {
return true;
}
Yap_Error(TYPE_ERROR_FLOAT, inp, "set_prolog_flag in 0...");
return false;
}
INLINE_ONLY inline EXTERN bool ro( Term inp );
INLINE_ONLY inline EXTERN bool ro( Term inp ) {
if (IsVarTerm(inp)) {
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag in 0...");
return false;
}
Yap_Error( PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag.");
return false;
}
//INLINE_ONLY inline EXTERN bool boolean( Term inp );
static inline bool boolean( Term inp ) {
if (inp == TermTrue ||
inp == TermFalse||
inp == TermOn||
inp == TermOff )
return true;
if (IsVarTerm(inp)) {
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag in {true,false,on,off");
return false;
}
if (IsAtomTerm(inp)) {
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, "set_prolog_flag in {true,false,on,off}");
return false;
}
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag in {true,false,on,off");
return false;
}
static bool synerr( Term inp ) {
if (inp == TermDec10 ||
inp == TermFail||
inp == TermError||
inp == TermQuiet )
return true;
if (IsAtomTerm(inp)) {
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, "set_prolog_flag in {dec10,error,fail,quiet}");
return false;
}
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag in {dec10,error,fail,quiet}");
return false;
}
static inline bool filler( Term inp )
{
return true;
}
static bool bqs( Term inp ) {
if (inp == TermCodes ||
inp == TermString||
inp == TermSymbolChar )
return true;
if (IsAtomTerm(inp)) {
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp, "set_prolog_flag in {codes,string}");
return false;
}
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag in {codes,string}");
return false;
}
//INLINE_ONLY inline EXTERN bool isatom( Term inp );
static inline bool isatom( Term inp ) {
if (IsVarTerm(inp)) {
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag");
return false;
}
if (IsAtomTerm(inp) )
return true;
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flagm");
return false;
}
// INLINE_ONLY inline EXTERN bool ok( Term inp );
static inline bool ok( Term inp ) {
return true;
}
// a pair, obtained from x(y) -> 1,2,y)
typedef struct x_el {
bool used;
Term tvalue;
} xarg;
typedef struct struct_param {
char *name;
flag_func type;
int id;
} param_t;
typedef struct struct_param2 {
char *name;
flag_func type;
int id;
const char *scope;
} param2_t;
typedef struct {
const char *name;
bool writable;
flag_func def;
const char *init;
flag_func helper;
} flag_info;
typedef struct {
const char *name;
flag_func def;
const char *init;
} arg_info;
typedef union flagTerm {
Term at;
struct DB_TERM *DBT;
} flag_term;
void Yap_InitFlags( bool );
#define YAP_FLAG( x, NAME, WRITABLE, DEF, INIT, HELPER ) x
typedef enum {
#include "YapGFlagInfo.h"
} global_flag_t;
typedef enum {
#include "YapLFlagInfo.h"
} local_flag_t;
#undef YAP_FLAG
bool setYapFlag( Term tflag, Term t2 );
Term getYapFlag( Term tflag );
static inline bool check_refs_to_ltable( void ) {
return true;
}
static inline void setAtomicGlobalPrologFlag(int id, Term v)
{
GLOBAL_Flags[id].at = v;
}
static inline void setAtomicLocalPrologFlag(int id, Term v)
{
CACHE_REGS
check_refs_to_ltable();
LOCAL_Flags[id].at = v;
}
static inline void setBooleanLocalPrologFlag(int id, bool v)
{
CACHE_REGS
check_refs_to_ltable();
if (v) {
LOCAL_Flags[id].at = TermTrue;
} else {
LOCAL_Flags[-id].at = TermFalse;
}
}
static inline void setBooleanGlobalPrologFlag(int id, bool v)
{
if (v) {
GLOBAL_Flags[id].at = TermTrue;
} else {
GLOBAL_Flags[id].at = TermFalse;
}
}
static inline bool trueGlobalPrologFlag(int id)
{
return GLOBAL_Flags[id].at == TermTrue;
}
static inline bool falseGlobalPrologFlag(int id)
{
return GLOBAL_Flags[id].at == TermFalse;
}
static inline bool trueLocalPrologFlag(int id)
{
CACHE_REGS
return LOCAL_Flags[id].at == TermTrue;
}
static inline bool falsePrologFlag(int id)
{
CACHE_REGS
return LOCAL_Flags[id].at == TermFalse;
}
static inline bool isoLanguageFlag(void){
return GLOBAL_Flags[ISO_FLAG].at == TermTrue;
}
static inline bool strictISOFlag(void){
return GLOBAL_Flags[STRICT_ISO_FLAG].at == TermTrue;
}
static inline bool silentMode(void) {
CACHE_REGS
return GLOBAL_Flags[VERBOSE_FLAG].at == TermSilent;
}
static inline void setVerbosity(Term val) {
CACHE_REGS
GLOBAL_Flags[VERBOSE_FLAG].at = val;
}
static inline bool setSyntaxErrorsFlag(Term val) {
if (!synerr( val ))
return false;
CACHE_REGS
LOCAL_Flags[SYNTAX_ERRORS_FLAG].at = val;
return true;
}
static inline Term getSyntaxErrorsFlag(void) {
CACHE_REGS
return LOCAL_Flags[SYNTAX_ERRORS_FLAG].at;
}
static inline bool setBackQuotesFlag(Term val) {
if (!bqs( val ))
return false;
if (val == TermSymbolChar)
val = TermString;
CACHE_REGS
GLOBAL_Flags[BACKQUOTED_STRING_FLAG].at = val;
return true;
}
static inline Term getBackQuotesFlag(void) {
CACHE_REGS
return GLOBAL_Flags[BACKQUOTED_STRING_FLAG].at;
}
static inline int indexingMode(void) {
CACHE_REGS
return GLOBAL_Flags[INDEX_FLAG].at;
}
static inline const char *floatFormat(void) {
CACHE_REGS
return RepAtom(AtomOfTerm(GLOBAL_Flags[FLOAT_FORMAT_FLAG].at))->StrOfAE;
}
static inline size_t indexingDepth(void) {
CACHE_REGS
return IntOfTerm(GLOBAL_Flags[INDEX_SUB_TERM_SEARCH_DEPTH_FLAG].at);
}
bool rmdot(Term inp);
xarg * Yap_ArgListToVector (Term listl, const param_t *def, int n);
xarg * Yap_ArgList2ToVector (Term listl, const param2_t *def, int n);
#endif // YAP_FLAGS_H

410
H/YapGFlagInfo.h Normal file
View File

@ -0,0 +1,410 @@
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 2015- *
* *
**************************************************************************
* *
* File: YapGFlagInfo.h *
* Last rev: *
* mods: *
* comments: global flag enumeration. *
* *
*************************************************************************/
/** @file YapGFlagInfo.h
@ingroup Flags
*/
/** @pred yap_flag(? _Param_,? _Value_)
Set or read system properties for _Param_:
*/
/// `address_bits`
///
/// Number of address bits in the machine, either 64 or 32 bits.
YAP_FLAG( ADDRESS_BITS_FLAG, "address_bits", false, nat, BITNESS , NULL ), /** `address_bits`
Number of address bits in the machine, either 64 or 32 bits */
YAP_FLAG( AGC_MARGIN_FLAG, "agc_margin", true, nat, "10000" , agc_threshold ), /**`agc_margin `
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( ALLOW_ASSERT_FOR_STATIC_PREDICATES, "allow_assert_for_static_predicates", true, boolean, "true" , NULL ), /**< `allow asserting and retracting clauses of static predicates. */
/* YAP_FLAG( ALLOW_VARIABLE_NAME_AS_FUNCTOR_FLAG, "allow_variable_name_as_functor", true, boolean, "false" , NULL ), /\**< `allow_variable_name_as_functor` */
/* allow A(X) *\/ */
YAP_FLAG( ANSWER_FORMAT_FLAG, "answer_format", true, isatom, "~p" , NULL ), /** `arithmetic_exceptions `
Read-write flag telling whether arithmetic exceptions generate
Prolog exceptions. If enabled:
~~~~
?- X is 2/0.
ERROR!!
ZERO DIVISOR ERROR- X is Exp
~~~~
If disabled:
~~~~
?- X is 2/0.
X = (+inf).
~~~~
It is `true` by default, but it is disabled by packages like CLP(BN) and ProbLog.
*/
#if __APPLE__
YAP_FLAG( APPLE_FLAG, "apple", false, boolean, "true" , NULL ), /**< `apple`
Read-only boolean flag that unifies with `true` if YAP is
running on an Apple machine.
*/
#endif
YAP_FLAG( ARCH_FLAG, "arch", false, isatom, YAP_ARCH , NULL ),
YAP_FLAG( ARGV_FLAG, "argv", false, isatom, "[]" , argv ),
YAP_FLAG( ARITHMETIC_EXCEPTIONS_FLAG, "arithmetic_exceptions", true, boolean, "true" , NULL ),
YAP_FLAG( BACKQUOTED_STRING_FLAG, "backquoted_string", true, isatom, "string" , ),
YAP_FLAG( BOUNDED_FLAG, "bounded", false, boolean, "false" , NULL ), /**< `bounded` is iso
Read-only flag telling whether integers are bounded. The value depends
on whether YAP uses the GMP library or not.
*/
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, boolean, "false" , NULL ), /**< `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, boolean, "true" , NULL ), /**< `character_escapes is iso `
Writable flag telling whether a character escapes are enables,
`true`, or disabled, `false`. The default value for this flag is
`true`. */
YAP_FLAG( COLON_SETS_CALLING_CONTEXT_FLAG, "colon_sets_calling_context", true, boolean, "true" , NULL ),
YAP_FLAG( COMPILED_AT_FLAG, "compiled_at", false, isatom, YAP_COMPILED_AT , 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( DEBUG_FLAG, "debug", true, boolean, "false" , NULL ), /**< `debug is iso `
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_INFO_FLAG, "debug_info", true, boolean, "true" , NULL ),
YAP_FLAG( DEBUG_ON_ERROR_FLAG, "debug_on_error", true, boolean, "true" , NULL ),
YAP_FLAG( DEBUGGER_PRINT_OPTIONS_FLAG, "debugger_print_options", true, list_option, "[quoted(true),numbervars(true),portrayed(true),max_depth(10)]" , NULL ), /**< `debugger_print_options `
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( DEBUGGER_SHOW_CONTEXT_FLAG, "debugger_show_context", true, boolean, "false" , NULL ),
YAP_FLAG( DIALECT_FLAG, "dialect", true, ro, "yap" , NULL ), /**< `dialect `
Read-only flag that always returns `yap`.
*/
YAP_FLAG( DISCONTIGUOUS_WARNINGS_FLAG, "discontiguous_warnings", true, boolean, "true" , NULL ), /**< `discontiguous_warnings `
If `true` (default `true`) YAP checks for definitions of the same predicate that are separated by clauses for other predicates. This may indicate that different procedures have the sam*e name.
*/
YAP_FLAG( DOLLAR_AS_LOWER_CASE_FLAG, "dollar_as_lower_case", true, boolean, "false" , NULL ), /**< `dollar_as_lower_case `
If `off` (default) consider the character `$` a control character, if
`on` consider `$` a lower case character.
*/
YAP_FLAG( DOUBLE_QUOTES_FLAG, "double_quotes", true, isatom, "codes" , NULL ), /**< `double_quotes is 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( EDITOR_FLAG, "editor", true, isatom, "$EDITOR" , NULL ),
YAP_FLAG( EXECUTABLE_FLAG, "executable", false, isatom, "yap" , executable ), /**< `executable `
Read-only flag. It unifies with an atom that gives the
original program path.
*/
YAP_FLAG( FAST_FLAG, "fast", true, boolean, "false" , NULL ), /**< `fast `
If `on` allow fast machine code, if `off` (default) disable it. Only
available in experimental implementations.
*/
YAP_FLAG( FILE_NAME_VARIABLES_FLAG, "file_name_variables", true, boolean, "true" , NULL ),
YAP_FLAG( FLOAT_FORMAT_FLAG, "float_format", true, isatom, "%.15g" , NULL ), /**< + `float_format `
C-library `printf()` format specification used by write/1 and
friends to determine how floating point numbers are printed. The
default is `%.15g`. The specified value is passed to `printf()`
without further checking. For example, if you want less digits
printed, `%g` will print all floats using 6 digits instead of the
default 15.
*/
YAP_FLAG( GC_FLAG, "gc", true, boolean, "on" , 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 `
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, boolean, "off" , NULL ), /**< `gc_trace `
If `off` (default) do not show information on garbage collection
and stack shifts, if `on` inform when a garbage collection or stack
shift happened, if verbose give detailed information on garbage
collection and stack shifts. Last, if `very_verbose` give detailed
information on data-structures found during the garbage collection
process, namely, on choice-points.
*/
YAP_FLAG( GENERATE_DEBUGGING_INFO_FLAG, "generate_debug_info", true, boolean, "true" , NULL ), /**< `generate_debug_info `
If `true` (default) generate debugging information for
procedures, including source mode. If `false` predicates no
information is generated, although debugging is still possible, and
source mode is disabled.
*/
YAP_FLAG( GMP_VERSION_FLAG, "gmp_version", false, isatom, "4.8.12" , NULL ),
YAP_FLAG( HALT_AFTER_CONSULT_FLAG, "halt_after_consult", false, boolean, "false" , NULL ),
YAP_FLAG( HOME_FLAG, "home", false, isatom, YAP_ROOTDIR , NULL ), /**< 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 tien
*/
YAP_FLAG( HOST_TYPE_FLAG, "host_type", false, isatom, HOST_ALIAS , 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, isatom, "multi" , indexer ), /**< `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 `
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 `
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 `
Read-only flag telling the rounding function used for integers. Takes the value
`toward_zero` for the current version of YAP.
*/
YAP_FLAG( ISO_FLAG, "iso", true, boolean, "false" , NULL ),
YAP_FLAG( LANGUAGE_FLAG, "language", true, isatom, "yap" , NULL ), /**< `language `
Choose whether YAP follows native, closer to C-Prolog, `yap`, iso-prolog,
`iso` or SICStus Prolog, `sicstus`. The current default is
`cprolog`. This flag affects update semantics, leashing mode,
style checking, handling calls to undefined procedures, how directives
are interpreted, when to use dynamic, character escapes, and how files
are consulted. Also check the `dialect` option.
*/
YAP_FLAG( MAX_ARITY_FLAG, "max_arity", false, isatom, "unbounded" , NULL ), /**< `max_arity is iso `
Read-only flag telling the maximum arity of a functor. Takes the value
`unbounded` for the current version of YAP.
*/
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 ),
YAP_FLAG( MAX_WORKERS_FLAG, "max_workers", false, at2n, "MAX_WORKERS" , NULL ),
YAP_FLAG( MIN_TAGGED_INTEGER_FLAG, "min_tagged_integer", false, at2n, "INT_MIN" , NULL ),
YAP_FLAG( N_OF_INTEGER_KEYS_IN_DB_FLAG, "n_of_integer_keys_in_db", false, ro, "256" , NULL ),
YAP_FLAG( OCCURS_CHECK_FLAG, "occurs_check", true, boolean, "false" , NULL ),
YAP_FLAG( OPEN_EXPANDS_FILENAME_FLAG, "open_expands_filename", true, boolean, "true" , NULL ), /**< `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, boolean, "true" , 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).
*/
YAP_FLAG( OPTIMISE_FLAG, "optimise", true, boolean, "false" , NULL ),
YAP_FLAG( OS_ARGV_FLAG, "os_argv", false, ro, "[]" , os_argv ),
YAP_FLAG( PID_FLAG, "pid", false, ro, "0" , NULL ),
YAP_FLAG( PIPE_FLAG, "pipe", true, boolean, "true" , NULL ),
YAP_FLAG( PROFILING_FLAG, "profiling", true, boolean, "false" , NULL ), /**< `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, changeable) `
SWI-Compatible option, determines prompting for alternatives in the Prolog toplevel. Default is <tt>groundness</tt>, YAP prompts for alternatives if and only if the query contains variables. The alternative, default in SWI-Prolog is <tt>determinism</tt> which implies the system prompts for alternatives if the goal succeeded while leaving choicepoints. */
YAP_FLAG( QUASI_QUOTATIONS_FLAG, "quasi_quotations", true, boolean, "true" , NULL ),
YAP_FLAG( READLINE_FLAG, "readline", true, boolean, "true" , NULL ),
YAP_FLAG( REPORT_ERROR_FLAG, "report_error", true, boolean, "true" , NULL ),
YAP_FLAG( SHARED_OBJECT_EXTENSION_FLAG, "shared_object_extension", false, isatom, SO_EXT ,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 `
Name of the environment variable used by the system to search for shared
objects.
*/
YAP_FLAG( SIGNALS_FLAG, "signals", true, boolean, "true" , NULL ), /**< `signals`
If `true` (default) YAP handles Signals such as `^C` (`SIGINT`).
*/
YAP_FLAG( SOURCE_FLAG, "source", true, boolean, "true" , NULL ), /**< `source`
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, boolean, "false" , NULL ), /**< `strict_iso `
If _Value_ is unbound, tell whether strict ISO compatibility mode
is `on` or `off`. If _Value_ is bound to `on` set
language mode to `iso` and enable strict mode. If _Value_ is
bound to `off` disable strict mode, and keep the current language
mode. The default for YAP is `off`.
Under strict ISO Prolog mode all calls to non-ISO built-ins generate an
error. Compilation of clauses that would call non-ISO built-ins will
§§also generate errors. Pre-processing for grammar rules is also
disabled. Module expansion is still performed.
Arguably, ISO Prolog does not provide all the functionality required
from a modern Prolog system. Moreover, because most Prolog
implementations do not fully implement the standard and because the
standard itself gives the implementor latitude in a few important
questions, such as the unification algorithm and maximum size for
numbers there is no guarantee that programs compliant with this mode
will work the same way in every Prolog and in every platform. We thus
believe this mode is mostly useful when investigating how a program
depends on a Prolog's platform specific features.
*/
YAP_FLAG( SYSTEM_OPTIONS_FLAG, "system_options", false, ro, "[big_numbers,coroutining,depth_limit,low_level_tracer,rational_trees,threads,tabling]" , NULL ), /**< `system_options `
This read only flag tells which options were used to compile
YAP. Currently it informs whether the system supports `big_numbers`,
`coroutining`, `depth_limit`, `low_level_tracer`,
`or-parallelism`, `rational_trees`, `readline`, `tabling`,
`threads`, or the `wam_profiler`.
*/
YAP_FLAG( SYSTEM_THREAD_ID_FLAG, "system_thread_id", false, ro, "0", sys_thread_id ),
YAP_FLAG( TABLING_MODE_FLAG, "tabling_mode", true, isatom, "[]" , NULL ), /**< `tabling_mode`
Sets or reads the tabling mode for all tabled predicates. Please
(see Tabling) for the list of options.
*/
YAP_FLAG( THREADS_FLAG, "threads", false, ro, "MAX_THREADS" , NULL ),
YAP_FLAG( TIMEZONE_FLAG, "timezone", false, ro, "18000" , NULL ),
YAP_FLAG( TOPLEVEL_PRINT_ANON_FLAG, "toplevel_print_anon", true, boolean, "true" , NULL ),
YAP_FLAG( TOPLEVEL_PRINT_OPTIONS_FLAG, "toplevel_print_options", true, list_option, "[quoted(true),numbervars(true),portrayed(true)]" , NULL ), /**< `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
presented. Only the first solution is considered and the goal is not
backtracked into.
*/
YAP_FLAG( TOPLEVEL_PROMPT_FLAG, "toplevel_prompt", true, isatom, "~m~d~l~! ?- " , mkprompt ),
YAP_FLAG( TTY_CONTROL_FLAG, "tty_control", true, boolean, "true" , NULL ),
YAP_FLAG( UNIX_FLAG, "unix", false, ro, "true" , NULL ), /**< `unix`
Read-only Boolean 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`.
*/
YAP_FLAG( UPDATE_SEMANTICS_FLAG, "update_semantics", false, ro, "logical" , NULL ), /**< `update_semantics `
Define whether YAP should follow `immediate` update
semantics, as in C-Prolog (default), `logical` update semantics,
as in Quintus Prolog, SICStus Prolog, or in the ISO standard. There is
also an intermediate mode, `logical_assert`, where dynamic
procedures follow logical semantics but the internal data base still
follows immediate semantics.
*/
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 are `silent`, `warning` and `error`. The first two create the flag on-the-fly, with `warning` printing a message. The value `error` is consistent with ISO: it raises an existence error and does not create the flag. See also `create_prolog_flag/3`. The default is`error`, and developers are encouraged to use `create_prolog_flag/3` to create flags for their library.
*/
YAP_FLAG( UNKNOWN_FLAG, "unknown", true, isatom, "error" , NULL ), /**< `unknown is iso`
Corresponds to calling the unknown/2 built-in. Possible values
are `error`, `fail`, and `warning`.
*/
YAP_FLAG( VARIABLE_NAMES_MAY_END_WITH_QUOTES_FLAG, "variable_names_may_end_with_quotes", true, boolean, "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`
disable printing these messages. It is `normal` by default except if
YAP is booted with the `-q` or `-L` flag.
*/
YAP_FLAG( VERBOSE_AUTOLOAD_FLAG, "verbose_autoload", true, boolean, "false" , NULL ),
YAP_FLAG( VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, boolean, "false" , NULL ),
YAP_FLAG( VERBOSE_LOAD_FLAG, "verbose_load", true, isatom, "normal" , NULL ), /**< `verbose_load `
If `true` allow printing of informational messages when
consulting files. If `false` disable printing these messages. It
is `normal` by default except if YAP is booted with the `-L`
flag.
*/
YAP_FLAG( VERSION_FLAG, "version", false, nat, YAP_NUMERIC_VERSION , NULL ), /**< `version_data `
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_DATA_FLAG, "version_data", false, ro, YAP_TVERSION , NULL ), /**<
`version ` Read-only flag that returns an 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_GIT_FLAG, "version_git", false, isatom, YAP_GIT_HEAD , NULL ), /**< `version_git `
`
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" , NULL ),
#if __WINDOWS__
YAP_FLAG( WINDOWS_FLAG, "windows", false, ro, "true" , NULL ), /**< `windows `
Read-only boolean flag that unifies with `true` if YAP is
running on an Windows machine.
*/
#endif
YAP_FLAG( WRITE_STRINGS_FLAG, "write_strings", true, boolean, "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`.
*/

101
H/YapLFlagInfo.h Normal file
View File

@ -0,0 +1,101 @@
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 2015- *
* *
**************************************************************************
* *
* File: YapLFlagInfo.h *
* Last rev: *
* mods: *
* comments: local flag enumeration. *
* *
*************************************************************************/
/** @file YapLFlagInfo.h
@ingroup Flags
*/
YAP_FLAG( AUTOLOAD_FLAG, "autoload", true, boolean, "false" , NULL ),
YAP_FLAG( BREAK_LEVEL_FLAG, "break_level", true, nat, "0" , NULL ),
YAP_FLAG( ENCODING_FLAG, "encoding", true, isatom, "text" , getenc ),
YAP_FLAG( FILEERRORS_FLAG, "fileerrors", true, boolean, "true" , NULL ), /**< `fileerrors`
If `on` `fileerrors` is `on`, if `off` (default)
`fileerrors` is disabled.
*/
YAP_FLAG( REDEFINE_WARNINGS_FLAG, "redefine_warnings", true, boolean, "true" , NULL ), /**< `redefine_warnings `
If _Value_ is unbound, tell whether warnings for procedures defined
in several different files are `on` or
`off`. If _Value_ is bound to `on` enable these warnings,
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( SINGLE_VAR_WARNINGS_FLAG, "single_var_warnings", true, boolean, "true" , NULL ), /**< `single_var_warnings`
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 must start with a capital letter, variables whose name starts with underscore are never considered singleton.
*/
YAP_FLAG( STACK_DUMP_ON_ERROR_FLAG, "stack_dump_on_error", true, boolean, "false" , NULL ), /**< `stack_dump_on_error `
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, isatom, "error" , synerr ), /**< `syntax_errors`
Control action to be taken after syntax errors while executing read/1,
`read/2`, or `read_term/3`:
+ `dec10`
Report the syntax error and retry reading the term.
+ `fail`
Report the syntax error and fail (default).
+ `error`
Report the syntax error and generate an error.
+ `quiet`
Just fail
*/
YAP_FLAG( TYPEIN_MODULE_FLAG, "typein_module", true, isatom, "user" , typein ), /**< `typein_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( USER_ERROR_FLAG, "user_error", true, isatom, "user_error" , NULL ), /**< `user_error1`
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
the current user_error stream.
By default, the user_error stream is set to a stream
corresponding to the Unix `stderr` stream.
The next example shows how to use this flag:
~~~{.prolog}
?- open( '/dev/null', append, Error,
[alias(mauri_tripa)] ).
Error = '$stream'(3) ? ;
no
?- set_prolog_flag(user_error, mauri_tripa).
close(mauri_tripa).
yes
?-
~~~
We execute three commands. First, we open a stream in write mode and
give it an alias, in this case `mauri_tripa`. Next, we set
user_error to the stream via the alias. Note that after we did so
prompts from the system were redirected to the stream
`mauri_tripa`. Last, we close the stream. At this point, YAP
automatically redirects the user_error alias to the original
`stderr`.
*/
YAP_FLAG( USER_INPUT_FLAG, "user_input", true, isatom, "user_input" , NULL ),
YAP_FLAG( USER_OUTPUT_FLAG, "user_output", true, isatom, "user_output" , NULL ),