allow ins flag to change input: on -> true
This commit is contained in:
parent
c5323b2920
commit
969b022e1c
96
H/YapFlags.h
96
H/YapFlags.h
@ -48,152 +48,154 @@
|
|||||||
#define SYSTEM_OPTION_8 "tabling,"
|
#define SYSTEM_OPTION_8 "tabling,"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline bool nat(Term inp) {
|
static inline Term nat(Term inp) {
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s",
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s",
|
||||||
"bound");
|
"bound");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
if (IsIntTerm(inp)) {
|
if (IsIntTerm(inp)) {
|
||||||
Int i = IntOfTerm(inp);
|
Int i = IntOfTerm(inp);
|
||||||
if (i >= 0)
|
if (i >= 0)
|
||||||
return true;
|
return inp;
|
||||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, inp,
|
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, inp,
|
||||||
"set_prolog_flag: value must be %s", ">= 0");
|
"set_prolog_flag: value must be %s", ">= 0");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
Yap_Error(TYPE_ERROR_INTEGER, inp, "set_prolog_flag: value must be %s",
|
Yap_Error(TYPE_ERROR_INTEGER, inp, "set_prolog_flag: value must be %s",
|
||||||
"integer");
|
"integer");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool at2n(Term inp) {
|
static inline Term at2n(Term inp) {
|
||||||
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s",
|
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s",
|
||||||
"flag is read-only");
|
"flag is read-only");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool isfloat(Term inp) {
|
static inline Term isfloat(Term inp) {
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s",
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s",
|
||||||
"integer");
|
"integer");
|
||||||
|
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
if (IsFloatTerm(inp)) {
|
if (IsFloatTerm(inp)) {
|
||||||
return true;
|
return inp;
|
||||||
}
|
}
|
||||||
Yap_Error(TYPE_ERROR_FLOAT, inp, "set_prolog_flag: value must be %s",
|
Yap_Error(TYPE_ERROR_FLOAT, inp, "set_prolog_flag: value must be %s",
|
||||||
"floating-point");
|
"floating-point");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool ro(Term inp);
|
static inline Term ro(Term inp);
|
||||||
|
|
||||||
static inline bool ro(Term inp) {
|
static inline Term ro(Term inp) {
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s",
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag: value must be %s",
|
||||||
"bound");
|
"bound");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s",
|
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s",
|
||||||
"flag is read-only");
|
"flag is read-only");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN bool aro(Term inp) {
|
INLINE_ONLY inline EXTERN Term aro(Term inp) {
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s",
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s",
|
||||||
"value must be bound");
|
"value must be bound");
|
||||||
|
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s",
|
Yap_Error(PERMISSION_ERROR_READ_ONLY_FLAG, inp, "set_prolog_flag %s",
|
||||||
"flag is read-only");
|
"flag is read-only");
|
||||||
|
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INLINE_ONLY inline EXTERN bool booleanFlag( Term inp );
|
// INLINE_ONLY inline EXTERN Term booleanFlag( Term inp );
|
||||||
|
|
||||||
static inline bool booleanFlag(Term inp) {
|
static inline Term booleanFlag(Term inp) {
|
||||||
if (inp == TermTrue || inp == TermFalse || inp == TermOn || inp == TermOff)
|
if (inp == TermTrue || inp == TermOn )
|
||||||
return true;
|
return TermTrue;
|
||||||
|
if ( inp == TermFalse || inp == TermOff)
|
||||||
|
return TermFalse;
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s",
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s",
|
||||||
"value must be bound");
|
"value must be bound");
|
||||||
;
|
;
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
if (IsAtomTerm(inp)) {
|
if (IsAtomTerm(inp)) {
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp,
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp,
|
||||||
"set_prolog_flag in {true,false,on,off}");
|
"set_prolog_flag in {true,false,on,off}");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag in {true,false,on,off");
|
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag in {true,false,on,off");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool synerr(Term inp) {
|
static Term synerr(Term inp) {
|
||||||
if (inp == TermDec10 || inp == TermFail || inp == TermError ||
|
if (inp == TermDec10 || inp == TermFail || inp == TermError ||
|
||||||
inp == TermQuiet)
|
inp == TermQuiet)
|
||||||
return true;
|
return inp;
|
||||||
|
|
||||||
if (IsAtomTerm(inp)) {
|
if (IsAtomTerm(inp)) {
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp,
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp,
|
||||||
"set_prolog_flag in {dec10,error,fail,quiet}");
|
"set_prolog_flag in {dec10,error,fail,quiet}");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
Yap_Error(TYPE_ERROR_ATOM, inp,
|
Yap_Error(TYPE_ERROR_ATOM, inp,
|
||||||
"set_prolog_flag in {dec10,error,fail,quiet}");
|
"set_prolog_flag in {dec10,error,fail,quiet}");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool filler(Term inp) { return true; }
|
static inline Term filler(Term inp) { return inp; }
|
||||||
|
|
||||||
static inline bool list_filler(Term inp) {
|
static inline Term list_filler(Term inp) {
|
||||||
if (IsVarTerm(inp) ||
|
if (IsVarTerm(inp) ||
|
||||||
IsPairTerm(inp) ||
|
IsPairTerm(inp) ||
|
||||||
inp == TermNil)
|
inp == TermNil)
|
||||||
return true;
|
return inp;
|
||||||
|
|
||||||
Yap_Error(TYPE_ERROR_LIST, inp,
|
Yap_Error(TYPE_ERROR_LIST, inp,
|
||||||
"set_prolog_flag in {codes,string}");
|
"set_prolog_flag in {codes,string}");
|
||||||
|
|
||||||
return false; }
|
return TermZERO; }
|
||||||
|
|
||||||
static bool bqs(Term inp) {
|
static Term bqs(Term inp) {
|
||||||
if (inp == TermCodes || inp == TermString || inp == TermSymbolChar)
|
if (inp == TermCodes || inp == TermString || inp == TermSymbolChar)
|
||||||
return true;
|
return inp;
|
||||||
|
|
||||||
if (IsAtomTerm(inp)) {
|
if (IsAtomTerm(inp)) {
|
||||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp,
|
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, inp,
|
||||||
"set_prolog_flag in {codes,string}");
|
"set_prolog_flag in {codes,string}");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag in {codes,string}");
|
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag in {codes,string}");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INLINE_ONLY inline EXTERN bool isatom( Term inp );
|
// INLINE_ONLY inline EXTERN Term isatom( Term inp );
|
||||||
|
|
||||||
static inline bool isatom(Term inp) {
|
static inline Term isatom(Term inp) {
|
||||||
if (IsVarTerm(inp)) {
|
if (IsVarTerm(inp)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s",
|
Yap_Error(INSTANTIATION_ERROR, inp, "set_prolog_flag %s",
|
||||||
"value must be bound");
|
"value must be bound");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
if (IsAtomTerm(inp))
|
if (IsAtomTerm(inp))
|
||||||
return true;
|
return inp;
|
||||||
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag");
|
Yap_Error(TYPE_ERROR_ATOM, inp, "set_prolog_flag");
|
||||||
return false;
|
return TermZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool options(Term inp) { return Yap_IsGroundTerm(inp); }
|
static inline Term options(Term inp) { return Yap_IsGroundTerm(inp) ? inp : TermZERO; }
|
||||||
|
|
||||||
// INLINE_ONLY inline EXTERN bool ok( Term inp );
|
// INLINE_ONLY inline EXTERN Term ok( Term inp );
|
||||||
|
|
||||||
static inline bool ok(Term inp) { return true; }
|
static inline Term ok(Term inp) { return inp; }
|
||||||
|
|
||||||
// a pair, obtained from x(y) -> 1,2,y)
|
// a pair, obtained from x(y) -> 1,2,y)
|
||||||
typedef struct x_el {
|
typedef struct x_el {
|
||||||
@ -219,7 +221,7 @@ typedef struct {
|
|||||||
bool writable;
|
bool writable;
|
||||||
flag_func def;
|
flag_func def;
|
||||||
const char *init;
|
const char *init;
|
||||||
flag_func helper;
|
flag_helper_func helper;
|
||||||
} flag_info;
|
} flag_info;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -320,7 +322,7 @@ static inline void setVerbosity(Term val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline bool setSyntaxErrorsFlag(Term val) {
|
static inline bool setSyntaxErrorsFlag(Term val) {
|
||||||
if (!synerr(val))
|
if ((val = synerr(val)) == TermZERO)
|
||||||
return false;
|
return false;
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
LOCAL_Flags[SYNTAX_ERRORS_FLAG].at = val;
|
LOCAL_Flags[SYNTAX_ERRORS_FLAG].at = val;
|
||||||
|
@ -83,7 +83,7 @@ running on an Apple machine.
|
|||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
YAP_FLAG(ARCH_FLAG, "arch", false, isatom, YAP_ARCH, NULL),
|
YAP_FLAG(ARCH_FLAG, "arch", false, isatom, YAP_ARCH, NULL),
|
||||||
YAP_FLAG(ARGV_FLAG, "argv", false, argv, "?-", NULL),
|
YAP_FLAG(ARGV_FLAG, "argv", false, argv, "@boot", NULL),
|
||||||
YAP_FLAG(ARITHMETIC_EXCEPTIONS_FLAG, "arithmetic_exceptions", true, booleanFlag,
|
YAP_FLAG(ARITHMETIC_EXCEPTIONS_FLAG, "arithmetic_exceptions", true, booleanFlag,
|
||||||
"true", NULL),
|
"true", NULL),
|
||||||
YAP_FLAG(BACKQUOTED_STRING_FLAG, "backquoted_string", true, isatom,
|
YAP_FLAG(BACKQUOTED_STRING_FLAG, "backquoted_string", true, isatom,
|
||||||
@ -172,8 +172,8 @@ 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
|
`codes`, or to a single atom, `atom`. If _Value_ is bound, set to
|
||||||
the corresponding behavior. The default value is `codes`. */
|
the corresponding behavior. The default value is `codes`. */
|
||||||
YAP_FLAG(EDITOR_FLAG, "editor", true, isatom, "$EDITOR", NULL),
|
YAP_FLAG(EDITOR_FLAG, "editor", true, isatom, "$EDITOR", NULL),
|
||||||
YAP_FLAG(EXECUTABLE_FLAG, "executable", false, isatom, "yap",
|
YAP_FLAG(EXECUTABLE_FLAG, "executable", false, executable, "@boot",
|
||||||
executable), /**< `executable `
|
NULL), /**< `executable `
|
||||||
|
|
||||||
Read-only flag. It unifies with an atom that gives the
|
Read-only flag. It unifies with an atom that gives the
|
||||||
original program path.
|
original program path.
|
||||||
@ -239,7 +239,7 @@ the root of the YAP installation, by default `/usr/local` in Unix or
|
|||||||
Return `configure` system information, including the machine-id
|
Return `configure` system information, including the machine-id
|
||||||
for which YAP was compiled and Operating System information.
|
for which YAP was compiled and Operating System information.
|
||||||
*/
|
*/
|
||||||
YAP_FLAG(INDEX_FLAG, "index", true, isatom, "multi", indexer), /**< `index `
|
YAP_FLAG(INDEX_FLAG, "index", true, indexer, "multi", NULL), /**< `index `
|
||||||
|
|
||||||
If `on` allow indexing (default), if `off` disable it, if
|
If `on` allow indexing (default), if `off` disable it, if
|
||||||
`single` allow on first argument only.
|
`single` allow on first argument only.
|
||||||
@ -312,8 +312,8 @@ If `true` an operator declaration will be valid for every module in the program.
|
|||||||
might expect module-independent operators.
|
might expect module-independent operators.
|
||||||
*/
|
*/
|
||||||
YAP_FLAG(OPTIMISE_FLAG, "optimise", true, booleanFlag, "false", NULL),
|
YAP_FLAG(OPTIMISE_FLAG, "optimise", true, booleanFlag, "false", NULL),
|
||||||
YAP_FLAG(OS_ARGV_FLAG, "os_argv", false, os_argv, "?-", NULL),
|
YAP_FLAG(OS_ARGV_FLAG, "os_argv", false, os_argv, "@boot", NULL),
|
||||||
YAP_FLAG(PID_FLAG, "pid", false, ro, "0", NULL),
|
YAP_FLAG(PID_FLAG, "pid", false, sys_pid, "@boot", NULL),
|
||||||
YAP_FLAG(PIPE_FLAG, "pipe", true, booleanFlag, "true", NULL),
|
YAP_FLAG(PIPE_FLAG, "pipe", true, booleanFlag, "true", NULL),
|
||||||
YAP_FLAG(PROFILING_FLAG, "profiling", true, booleanFlag, "false",
|
YAP_FLAG(PROFILING_FLAG, "profiling", true, booleanFlag, "false",
|
||||||
NULL), /**< `profiling `
|
NULL), /**< `profiling `
|
||||||
@ -405,8 +405,8 @@ YAP. Currently it informs whether the system supports `big_numbers`,
|
|||||||
`or-parallelism`, `rational_trees`, `readline`, `tabling`,
|
`or-parallelism`, `rational_trees`, `readline`, `tabling`,
|
||||||
`threads`, or the `wam_profiler`.
|
`threads`, or the `wam_profiler`.
|
||||||
*/
|
*/
|
||||||
YAP_FLAG(SYSTEM_THREAD_ID_FLAG, "system_thread_id", false, ro, "0",
|
YAP_FLAG(SYSTEM_THREAD_ID_FLAG, "system_thread_id", false, sys_thread_id, "@boot",
|
||||||
sys_thread_id),
|
NULL),
|
||||||
YAP_FLAG(TABLING_MODE_FLAG, "tabling_mode", true, isatom, "[]",
|
YAP_FLAG(TABLING_MODE_FLAG, "tabling_mode", true, isatom, "[]",
|
||||||
NULL), /**< `tabling_mode`
|
NULL), /**< `tabling_mode`
|
||||||
|
|
||||||
|
@ -22,6 +22,19 @@
|
|||||||
|
|
||||||
YAP_FLAG( AUTOLOAD_FLAG, "autoload", true, booleanFlag, "false" , NULL ),
|
YAP_FLAG( AUTOLOAD_FLAG, "autoload", true, booleanFlag, "false" , NULL ),
|
||||||
YAP_FLAG( BREAK_LEVEL_FLAG, "break_level", true, nat, "0" , NULL ),
|
YAP_FLAG( BREAK_LEVEL_FLAG, "break_level", true, nat, "0" , NULL ),
|
||||||
|
YAP_FLAG( CALL_COUNTING_FLAG, "call_counting", true, booleanFlag, "true" , 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 counters are available:
|
||||||
|
|
||||||
|
calls: number of predicate calls since execution started or since system was reset;
|
||||||
|
retries: number of retries for predicates called since execution started or since counters were reset;
|
||||||
|
calls_and_retries: count both on predicate calls and retries.
|
||||||
|
These counters can be used to find out how many calls a certain goal takes to execute. They can also be force the computatiom yp
|
||||||
|
stopping.
|
||||||
|
|
||||||
|
If `on` `fileerrors` is `on`, if `off` (default)
|
||||||
|
`fileerrors` is disabled.
|
||||||
|
*/
|
||||||
YAP_FLAG( ENCODING_FLAG, "encoding", true, isatom, "utf-8" , getenc ),
|
YAP_FLAG( ENCODING_FLAG, "encoding", true, isatom, "utf-8" , getenc ),
|
||||||
YAP_FLAG( FILEERRORS_FLAG, "fileerrors", true, booleanFlag, "true" , NULL ), /**< `fileerrors`
|
YAP_FLAG( FILEERRORS_FLAG, "fileerrors", true, booleanFlag, "true" , NULL ), /**< `fileerrors`
|
||||||
|
|
||||||
@ -50,7 +63,7 @@ YAP_FLAG( STACK_DUMP_ON_ERROR_FLAG, "stack_dump_on_error", true, booleanFlag, "
|
|||||||
`off`.
|
`off`.
|
||||||
*/
|
*/
|
||||||
YAP_FLAG( STREAM_TYPE_CHECK_FLAG, "stream_type_check", true, isatom, "loose" , NULL ),
|
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`
|
YAP_FLAG( SYNTAX_ERRORS_FLAG, "syntax_errors", true, synerr, "error" , NULL ), /**< `syntax_errors`
|
||||||
|
|
||||||
Control action to be taken after syntax errors while executing read/1,
|
Control action to be taken after syntax errors while executing read/1,
|
||||||
`read/2`, or `read_term/3`:
|
`read/2`, or `read_term/3`:
|
||||||
|
@ -1296,7 +1296,8 @@ INLINE_ONLY inline EXTERN bool IsValProperty(PropFlags flags) {
|
|||||||
|
|
||||||
/* flag property entry structure */
|
/* flag property entry structure */
|
||||||
|
|
||||||
typedef bool (*flag_func)(Term);
|
typedef Term (*flag_func)(Term);
|
||||||
|
typedef bool (*flag_helper_func)(Term);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Prop NextOfPE; /* used to chain properties */
|
Prop NextOfPE; /* used to chain properties */
|
||||||
@ -1306,7 +1307,8 @@ typedef struct {
|
|||||||
#endif
|
#endif
|
||||||
int FlagOfVE; /* (atomic) value associated with the atom */
|
int FlagOfVE; /* (atomic) value associated with the atom */
|
||||||
bool global, atomic, rw;
|
bool global, atomic, rw;
|
||||||
flag_func type, helper;
|
flag_func type;
|
||||||
|
flag_helper_func helper;
|
||||||
} FlagEntry;
|
} FlagEntry;
|
||||||
#if USE_OFFSETS_IN_PROPS
|
#if USE_OFFSETS_IN_PROPS
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user