scanner-parser interface - I

This commit is contained in:
Vitor Santos Costa 2019-05-17 17:49:30 +01:00
parent 552cefbcd0
commit 0949f6b494
8 changed files with 159 additions and 102 deletions

View File

@ -890,11 +890,10 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS)
{
UInt start_growth_time, growth_time;
int gc_verbose;
char *omax = (char *)H0;
ADDR old_GlobalBase = LOCAL_GlobalBase;
UInt minimal_request = 0L;
Int size = request/sizeof(CELL);
char vb_msg1 = '\0', *vb_msg2;
char vb_msg1 = '\0', *vb_msg2 = "";
bool do_grow = true;
/*
request is the amount of memory we requesd, in bytes;
@ -1556,7 +1555,6 @@ Yap_growstack(size_t size)
int res;
LOCAL_PrologMode |= GrowStackMode;
printf("extra %dBs\n",size);
res=growstack(size PASS_REGS);
LeaveGrowMode(GrowStackMode);
return res;

View File

@ -1312,8 +1312,8 @@ static void mark_eof(struct stream_desc *st) {
#define add_ch_to_buff(ch) \
{ charp += put_utf8(charp, ch); }
TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
Term *tposp) {
TokEntry *Yap_tokenizer(struct stream_desc *st,
scanner_params *params) {
CACHE_REGS
TokEntry *t, *l, *p;
@ -1325,7 +1325,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
int sign = 1;
size_t imgsz = 1024;
char *TokImage = Malloc(imgsz PASS_REGS);
bool store_comments = params->store_comments;
InitScannerMemory();
LOCAL_VarTable = NULL;
@ -1337,7 +1337,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
och=ch;
ch = getchr(st);
}
*tposp = Yap_StreamPosition(st - GLOBAL_Stream);
params->tp = Yap_StreamPosition(st - GLOBAL_Stream);
Yap_setCurrentSourceLocation(st);
LOCAL_StartLineCount = st->linecount;
LOCAL_StartLinePos = st->linepos;
@ -1393,7 +1393,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
while (chtype(ch) == BS) {
ch = getchr(st);
}
*tposp = Yap_StreamPosition(st - GLOBAL_Stream);
params->tp = Yap_StreamPosition(st - GLOBAL_Stream);
Yap_setCurrentSourceLocation(st);
}
goto restart;
@ -1428,7 +1428,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
add_ch_to_buff(ch);
}
while (ch == '\'' && isvar &&
trueGlobalPrologFlag(VARIABLE_NAMES_MAY_END_WITH_QUOTES_FLAG)) {
params->ce) {
if (charp == (unsigned char *)AuxSp - 1024) {
pop_text_stack(lvl);
return CodeSpaceError(t, p, l);
@ -1437,7 +1437,8 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
ch = getchr(st);
}
add_ch_to_buff('\0');
if (!isvar || (ch == '(' && trueLocalPrologFlag(ALLOW_VARIABLE_NAME_AS_FUNCTOR_FLAG) ) ) {
if (!isvar || (ch == '(' && params->vn_asfl) ||
(TokImage[0] != '_' && params->vprefix)) {
Atom ae;
/* don't do this in iso */
ae = Yap_LookupAtom(TokImage);
@ -1651,9 +1652,9 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
pch = Yap_peek(st - GLOBAL_Stream);
if (chtype(pch) == EF) {
mark_eof(st);
t->TokInfo = TermEof;
} else {
t->TokInfo = TermNewLine;
if (params->get_eot_blank)
getchr(st);
}
t->TokInfo = TermEof;
pop_text_stack(lvl);
@ -1733,7 +1734,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *st, bool store_comments,
ch = getchr(st);
}
CHECK_SPACE();
*tposp = Yap_StreamPosition(st - GLOBAL_Stream);
params->tp = Yap_StreamPosition(st - GLOBAL_Stream);
Yap_setCurrentSourceLocation(st);
}
}

View File

@ -1,4 +1,3 @@
/*************************************************************************
* *
* YAP Prolog *
@ -208,8 +207,14 @@ PAR("priority", nat, READ_PRIORITY), \
PAR("variables", filler, READ_VARIABLES), \
PAR("variable_names", filler, READ_VARIABLE_NAMES), \
PAR("character_escapes", booleanFlag, READ_CHARACTER_ESCAPES), \
PAR("input_closing_blank", booleanFlag, READ_INPUT_CLOSING_BLANK), \
PAR("backquoted_string", isatom, READ_BACKQUOTED_STRING), \
PAR("cycles", ok, READ_CYCLES), PAR(NULL, ok, READ_END)
PAR("singlequoted_string", isatom, READ_SINGLEQUOTED_STRING), \
PAR("doublequoted_string", isatom, READ_DOUBLEQUOTED_STRING), \
PAR("var_prefix", isatom, READ_VAR_PREFIX), \
PAR("allow_variable_name_as_functor", isatom,READ_ALLOW_VARIABLE_NAME_AS_FUNCTOR ), \
PAR("cycles", booleanFlag, READ_CYCLES), \
PAR(NULL, ok, READ_END)
#define PAR(x, y, z) z
@ -342,7 +347,9 @@ static Term scanToList(TokEntry *tok, TokEntry *errtok)
static Int scan_to_list(USES_REGS1)
{
int inp_stream;
Term tpos, tout;
Term tout;
scanner_params params;
memset(&params,0,sizeof(params));
/* needs to change LOCAL_output_stream for write */
inp_stream = Yap_CheckTextStream(ARG1, Input_Stream_f, "read/3");
@ -351,7 +358,7 @@ static Int scan_to_list(USES_REGS1)
return false;
}
TokEntry *tok = LOCAL_tokptr = LOCAL_toktide =
Yap_tokenizer(GLOBAL_Stream + inp_stream, false, &tpos);
Yap_tokenizer(GLOBAL_Stream + inp_stream, &params);
UNLOCK(GLOBAL_Stream[inp_stream].streamlock);
tout = scanToList(tok, NULL);
if (tout == 0)
@ -510,8 +517,9 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
}
typedef struct FEnv {
Term qq, tp, sp, np, vp, ce;
Term tpos; /// initial position of the term to be read.
scanner_params scanner; /// scanner interface
Term qq, tp, sp, np, vprefix;
Term cmod; /// initial position of the term to be read.
Term t, t0; /// the output term
TokEntry *tokstart; /// the token list
TokEntry *toklast; /// the last token
@ -521,8 +529,6 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
bool reading_clause; /// read_clause
size_t nargs; /// arity of current procedure
encoding_t enc; /// encoding of the stream being read
Term tcomms; /// Access to comments
Term cmod; /// Access to comments
char *msg; /// Error Messagge
} FEnv;
@ -553,7 +559,6 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
return NULL;
}
re->bq = getReadTermBackQuotesFlag();
if (args[READ_OUTPUT].used)
{
fe->t0 = args[READ_OUTPUT].tvalue;
@ -574,11 +579,60 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
}
if (args[READ_BACKQUOTED_STRING].used)
{
if (!setReadTermBackQuotesFlag(args[READ_BACKQUOTED_STRING].tvalue))
{
return false;
}
fe->scanner.backquotes = args[READ_BACKQUOTED_STRING].tvalue;
} else {
fe->scanner.backquotes = getBackQuotesFlag(fe->cmod);
}
if (args[READ_DOUBLEQUOTED_STRING].used)
{
fe->scanner.doublequotes = args[READ_DOUBLEQUOTED_STRING].tvalue;
} else {
fe->scanner.doublequotes = getDoubleQuotesFlag(fe->cmod);
}
if (args[READ_SINGLEQUOTED_STRING].used)
{
fe->scanner.singlequotes = args[READ_SINGLEQUOTED_STRING].tvalue;
} else {
fe->scanner.singlequotes = getSingleQuotesFlag(fe->cmod);
}
if (args[READ_CHARACTER_ESCAPES].used)
{
fe->scanner.ce = args[READ_CHARACTER_ESCAPES].tvalue == TermTrue;
}
else
{
fe->scanner.ce = Yap_CharacterEscapes(fe->cmod) == TermTrue;
}
if (args[READ_VAR_PREFIX].used)
{
fe->scanner.vprefix = args[READ_VAR_PREFIX].tvalue == TermTrue;
}
else
{
fe->scanner.vprefix = false;
}
if (args[READ_INPUT_CLOSING_BLANK].used)
{
fe->scanner.get_eot_blank = args[READ_INPUT_CLOSING_BLANK].tvalue == TermTrue;
}
else
{
fe->scanner.get_eot_blank = false;
}
if (args[READ_ALLOW_VARIABLE_NAME_AS_FUNCTOR].used)
{
fe->scanner.vn_asfl = args[READ_ALLOW_VARIABLE_NAME_AS_FUNCTOR].tvalue == TermTrue;
}
else
{
fe->scanner.vn_asfl = trueLocalPrologFlag(ALLOW_VARIABLE_NAME_AS_FUNCTOR_FLAG);
}
if (args[READ_COMMENTS].used)
{
fe->scanner.store_comments = args[READ_COMMENTS].tvalue;
} else {
fe->scanner.store_comments = 0;
}
if (args[READ_QUASI_QUOTATIONS].used)
{
fe->qq = args[READ_QUASI_QUOTATIONS].tvalue;
@ -589,19 +643,19 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
}
if (args[READ_COMMENTS].used)
{
fe->tcomms = args[READ_COMMENTS].tvalue;
fe->scanner.tcomms = args[READ_COMMENTS].tvalue;
}
else
{
fe->tcomms = 0;
fe->scanner.tcomms = 0;
}
if (args[READ_TERM_POSITION].used)
{
fe->tp = args[READ_TERM_POSITION].tvalue;
fe->scanner.tpos = args[READ_TERM_POSITION].tvalue;
}
else
{
fe->tp = 0;
fe->scanner.tpos = 0;
}
if (args[READ_SINGLETONS].used)
{
@ -621,11 +675,11 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
}
if (args[READ_VARIABLES].used)
{
fe->vp = args[READ_VARIABLES].tvalue;
fe->vprefix = args[READ_VARIABLES].tvalue;
}
else
{
fe->vp = 0;
fe->vprefix = 0;
}
if (args[READ_VARIABLE_NAMES].used)
{
@ -635,14 +689,6 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
{
fe->np = 0;
}
if (args[READ_CHARACTER_ESCAPES].used || Yap_CharacterEscapes(fe->cmod))
{
fe->ce = true;
}
else
{
fe->ce = false;
}
re->seekable = (GLOBAL_Stream[inp_stream].status & Seekable_Stream_f) != 0;
if (re->seekable)
{
@ -696,8 +742,8 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
PUSHFET(tp);
PUSHFET(sp);
PUSHFET(np);
PUSHFET(vp);
PUSHFET(tpos);
PUSHFET(vprefix);
PUSHFET(scanner.tpos);
PUSHFET(t);
HR = fe->old_H;
TR = (tr_fr_ptr)LOCAL_ScannerStack;
@ -706,11 +752,10 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
LOCAL_ScannerStack = (char*)TR;
TR = fe->old_TR;
POPFET(t);
POPFET(tpos);
POPFET(vp);
POPFET(vprefix);
POPFET(np);
POPFET(sp);
POPFET(tp);
POPFET(scanner.tpos);
POPFET(qq);
}
@ -719,7 +764,7 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
CACHE_REGS
Term v;
if (fe->vp)
if (fe->vprefix)
{
while (true)
{
@ -823,7 +868,7 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
CACHE_REGS
Term v;
if (fe->tp)
if (fe->scanner.tpos)
{
while (true)
{
@ -831,7 +876,7 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
if (setjmp(LOCAL_IOBotch) == 0)
{
if ((v = CurrentPositionToTerm()))
if ((v = Currenscanner.tposositionToTerm()))
{
return v;
}
@ -853,7 +898,7 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
if (fe->t0 && fe->t && !(Yap_unify(fe->t, fe->t0)))
return false;
if (fe->t && fe->vp)
if (fe->t && fe->vprefix)
v1 = get_variables(fe, tokstart);
else
v1 = 0L;
@ -865,23 +910,23 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
v3 = get_singletons(fe, tokstart);
else
v3 = 0L;
if (fe->t && fe->tcomms)
if (fe->t && fe->scanner.tcomms)
vc = LOCAL_Comments;
else
vc = 0L;
if (fe->t && fe->tp)
tp = get_stream_position(fe, tokstart);
if (fe->t && fe->scanner.tpos)
scanner.tpos = get_stream_position(fe, tokstart);
else
tp = 0L;
scanner.tpos = 0L;
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable);
free(fe->args);
// trail must be ok by now.]
if (fe->t)
{
return (!v1 || Yap_unify(v1, fe->vp)) && (!v2 || Yap_unify(v2, fe->np)) &&
return (!v1 || Yap_unify(v1, fe->vprefix)) && (!v2 || Yap_unify(v2, fe->np)) &&
(!v3 || Yap_unify(v3, fe->sp)) && (!tp || Yap_unify(tp, fe->tp)) &&
(!vc || Yap_unify(vc, fe->tcomms));
(!vc || Yap_unify(vc, fe->scanner,tcomms));
}
return true;
}
@ -889,14 +934,14 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
static bool complete_clause_processing(FEnv *fe, TokEntry *tokstart)
{
CACHE_REGS
Term v_vp, v_vnames, v_comments, v_pos;
Term v_vprefix, v_vnames, v_comments, v_pos;
if (fe->t0 && fe->t && !Yap_unify(fe->t, fe->t0))
return false;
if (fe->t && fe->vp)
v_vp = get_variables(fe, tokstart);
if (fe->t && fe->vprefix)
v_vprefix = get_variables(fe, tokstart);
else
v_vp = 0L;
v_vprefix = 0L;
if (fe->t && fe->np)
v_vnames = get_varnames(fe, tokstart);
else
@ -905,7 +950,7 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
{
warn_singletons(fe, tokstart);
}
if (fe->t && fe->tcomms)
if (fe->t && fe->scanner.tcomms)
v_comments = LOCAL_Comments;
else
v_comments = 0L;
@ -918,15 +963,15 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
// trail must be ok by now.]
if (fe->t)
{
return (!v_vp || Yap_unify(v_vp, fe->vp)) &&
return (!v_vprefix || Yap_unify(v_vprefix, fe->vprefix)) &&
(!v_vnames || Yap_unify(v_vnames, fe->np)) &&
(!v_pos || Yap_unify(v_pos, fe->tp)) &&
(!v_comments || Yap_unify(v_comments, fe->tcomms));
(!v_comments || Yap_unify(v_comments, fe->scanner.tcomms));
}
return true;
}
static parser_state_t initParser(Term opts, FEnv *fe, REnv *re, int inp_stream,
static parser_state_t initparser(Term opts, FEnv *fe, REnv *re, int inp_stream,
bool clause);
static parser_state_t parse(REnv *re, FEnv *fe, int inp_stream);
@ -975,7 +1020,7 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
fe->t = 0;
if (fe->sp && !Yap_unify(TermNil, fe->sp))
fe->t = 0;
if (fe->vp && !Yap_unify(TermNil, fe->vp))
if (fe->vprefix && !Yap_unify(TermNil, fe->vprefix))
fe->t = 0;
if (fe->tp && !Yap_unify(fe->tp, fe->tpos))
fe->t = 0;
@ -989,7 +1034,7 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
}
}
static parser_state_t initParser(Term opts, FEnv *fe, REnv *re, int inp_stream,
static parser_state_t initparser(Term opts, FEnv *fe, REnv *re, int inp_stream,
bool clause)
{
LOCAL_ErrorMessage = NULL;
@ -1219,7 +1264,7 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
{
case YAP_START_PARSING:
opts = Yap_GetFromHandle(yopts);
state = initParser(opts, fe, re, sno, clause);
state = initparser(opts, fe, re, sno, clause);
if (state == YAP_PARSING_FINISHED)
{
Yap_PopHandle(yopts);
@ -1353,7 +1398,9 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
if (fe->cmod == TermProlog)
fe->cmod = PROLOG_MODULE;
}
re->bq = getReadTermBackQuotesFlag();
fe->scanner.backquotes = getReadTermBackQuotesFlag();
fe->scanner.quotes = getReadTermQuotesFlag();
fe->scanner.doublequotes = getReadTermDoubleQuotesFlag();
fe->enc = GLOBAL_Stream[sno].encoding;
fe->sp = 0;
fe->qq = 0;
@ -1376,11 +1423,11 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
fe->sp = 0;
if (args[READ_CLAUSE_COMMENTS].used)
{
fe->tcomms = args[READ_CLAUSE_COMMENTS].tvalue;
fe->scanner.tcomms = args[READ_CLAUSE_COMMENTS].tvalue;
}
else
{
fe->tcomms = 0L;
fe->scanner.tcomms = 0L;
}
if (args[READ_CLAUSE_SYNTAX_ERRORS].used)
{
@ -1390,7 +1437,7 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
{
re->sy = TermDec10;
}
fe->vp = 0;
fe->vprefix = 0;
if (args[READ_CLAUSE_VARIABLE_NAMES].used)
{
fe->np = args[READ_CLAUSE_VARIABLE_NAMES].tvalue;
@ -1401,13 +1448,13 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
}
if (args[READ_CLAUSE_VARIABLES].used)
{
fe->vp = args[READ_CLAUSE_VARIABLES].tvalue;
fe->vprefix = args[READ_CLAUSE_VARIABLES].tvalue;
}
else
{
fe->vp = 0;
fe->vprefix = 0;
}
fe->ce = Yap_CharacterEscapes(fe->cmod);
fe->scanner.ce = Yap_CharacterEscapes(fe->cmod);
re->seekable = (GLOBAL_Stream[sno].status & Seekable_Stream_f) != 0;
if (re->seekable)
{
@ -1504,11 +1551,11 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
bool start = true;
while ((tokptr = next->TokNext))
{
if (IsAtomOrIntTerm(t = *tp))
if (IsAtomOrIntTerm(t = fe->tp))
{
ip->opc = Yap_opcode(get_atom);
ip->y_u.x_c.c = t.
ip->y_u.x_c.x = tp++; / ()c * /
ip->y_u.x_c.x = fe->tp++; / ()c * /
}
else if (IsAtomOrIntTerm(t = *tp))
{

View File

@ -46,6 +46,16 @@ typedef struct AliasDescS {
/* parser stack, used to be AuxSp, now is ASP */
#define ParserAuxSp LOCAL_ScannerStack
typedef struct scanner_extra_params {
Term tpos;
Term backquotes, singlequotes, doublequotes;
bool ce, vprefix, vn_asfl;
Term tcomms; /// Access to comments
Term cmod; /// Access to commen
bool store_comments; //
bool get_eot_blank;
} scanner_params;
/**
*
* @return a new VFS that will support /assets
@ -60,7 +70,7 @@ extern Term Yap_Variables(VarEntry *, Term);
extern Term Yap_Singletons(VarEntry *, Term);
/* routines in scanner.c */
extern TokEntry *Yap_tokenizer(struct stream_desc *, bool, Term *d);
extern TokEntry *Yap_tokenizer(struct stream_desc *, scanner_params *sp);
extern void Yap_clean_tokenizer(TokEntry *, VarEntry *, VarEntry *);
extern char *Yap_AllocScannerMemory(unsigned int);
@ -123,6 +133,7 @@ extern int Yap_open_buf_read_stream(const char *buf, size_t nchars,
Atom name, Term uname);
extern int Yap_open_buf_write_stream(encoding_t enc, memBufSource src);
extern Term Yap_BufferToTerm(const char *s, Term opts);
extern X_API Term Yap_BufferToTermWithPrioBindings(const char *s, Term opts,
Term bindings, size_t sz,
int prio);

View File

@ -458,8 +458,7 @@ be lost.
!,
gated_call(
'$start_user_code',
% try creeping
'$execute_nonstop'(G,M),
'$execute'(G,M),
Port,
'$reenter_debugger'(Port)
).
@ -671,7 +670,7 @@ be lost.
Goal.
'$port'(_P, _G, _M,GoalNumber,_Determinic, _Info ) :- %%> leap
'__NB_getval__'('$debug_status',state(leap,Border,_,_), fail),
'__NB_getval__'('$debug_state',state(leap,Border,_,_), fail),
GoalNumber < Border,
!.
'$port'(P,G,Module,L,Deterministic, Info) :-
@ -727,7 +726,7 @@ be lost.
'$action'(C,P,CallNumber,G,Module,H).
'$action'('\n',_,_,_,_,_) :- !, % newline creep
'__NB_getval__'('$trace',Trace,fail),
'__NB_setval__'('$debug_status', state(creep, 0, stop, Trace)).
'__NB_setval__'('$debug_state', state(creep, 0, stop, Trace)).
'$action'(!,_,_,_,_,_) :- !, % ! 'g execute
read(debugger_input, G),
% don't allow yourself to be caught by creep.
@ -744,7 +743,7 @@ be lost.
!, % <'Depth
skip( debugger_input, 10),
'__NB_getval__'('$trace',Trace,fail),
'__NB_setval__'('$debug_status', state(creep, 0, stop,Trace)).
'__NB_setval__'('$debug_state', state(creep, 0, stop,Trace)).
'$action'(^,_,_,G,_,_) :- !, % '
'$print_deb_sterm'(G),
skip( debugger_input, 10),
@ -765,7 +764,7 @@ be lost.
'$action'(c,_,_,_,_,_) :- !, % 'c creep
skip( debugger_input, 10),
'__NB_getval__'('$trace',Trace,fail),
'__NB_setval__'('$debug_status',status(creep,0,stop,Trace)).
'__NB_setval__'('$debug_state',status(creep,0,stop,Trace)).
'$action'(e,_,_,_,_,_) :- !, % 'e exit
halt.
'$action'(f,_,CallNumber,_,_,_) :- !, % 'f fail
@ -800,22 +799,22 @@ be lost.
'$scan_number'(ScanNumber),
( ScanNumber == 0 -> Goal = CallNumber ; Goal = ScanNumber ),
'__NB_getval__'('$trace',Trace,fail),
'__NB_setval__'('$debug_status', state(leap, Goal, stop,Trace)).
'__NB_setval__'('$debug_state', state(leap, Goal, stop,Trace)).
'$action'(z,_,_allNumber,_,_,_H) :- !, % 'z zip, fast leap
'__NB_getval__'('$trace',Trace,fail),
'__NB_setval__'('$debug_status', state(zip, 0, stop, Trace)).
'__NB_setval__'('$debug_state', state(zip, 0, stop, Trace)).
% skip first call (for current goal),
% stop next time.
'$action'(k,_,_CallNumber,_,_,_) :- !, % 'k zip, fast leap
'__NB_getval__'('$trace',Trace,fail),
'__NB_setval__'('$debug_status', state(zip, 0, stop, Trace)).
'__NB_setval__'('$debug_state', state(zip, 0, stop, Trace)).
% skip first call (for current goal),
% stop next time.
'$action'(n,_,_,_,_,_) :- !, % 'n nodebug
skip( debugger_input, 10), % '
% tell debugger never to stop.
'__NB_getval__'('$trace',Trace,fail),
'__NB_setval__'('$debug_status', state(zip, 0, ignore, Trace)),
'__NB_setval__'('$debug_state', state(zip, 0, ignore, Trace)),
nodebug.
'$action'(r,_,CallNumber,_,_,_) :- !, % r retry
'$scan_number'(ScanNumber),
@ -826,7 +825,7 @@ be lost.
( ScanNumber == 0 -> Goal = CallNumber ; Goal = ScanNumber ),
( (P==call; P==redo) ->
'__NB_getval__'('$trace',Trace,fail),
'__NB_setval__'('$debug_status', state(leap, Goal, ignore,Trace) ) ;
'__NB_setval__'('$debug_state', state(leap, Goal, ignore,Trace) ) ;
'$ilgl'(s) % '
).
'$action'(t,P,CallNumber,_,_,_) :- !, % 't fast skip
@ -834,7 +833,7 @@ be lost.
( ScanNumber == 0 -> Goal = CallNumber ; Goal = ScanNumber ),
( (P=call; P=redo) ->
'__NB_getval__'('$trace',Trace,fail),
'__NB_setval__'('$debug_status', state(zip, Goal, ignore,Trace)) ;
'__NB_setval__'('$debug_state', state(zip, Goal, ignore,Trace)) ;
'$ilgl'(t) % '
).
'$action'(q,P,CallNumber,_,_,_) :- !, % 'qst skip
@ -842,7 +841,7 @@ be lost.
( ScanNumber == 0 -> Goal = CallNumber ; Goal = ScanNumber ),
( (P=call; P=redo) ->
'__NB_getval__'('$trace',Trace,fail),
'__NB_setval__'('$debug_status', state(leap, Goal, stop, Trace)) ;
'__NB_setval__'('$debug_state', state(leap, Goal, stop, Trace)) ;
'$ilgl'(t) % '
).
'$action'(+,_,_,G,M,_) :- !, %% spy this

View File

@ -248,7 +248,7 @@ top_query(G) :-
nb_setval('$debug_run',off),
nb_setval('$debug_jump',off),
'__NB_setval__'('$trace',off),
nb_setval('$debug_status', state(zip, 0, stop,off)),
nb_setval('$debug_state', state(zip, 0, stop,off)),
set_prolog_flag(break_level, 0),
catch(user:G, Error, '$Error'(Error)).

View File

@ -400,10 +400,10 @@ notrace(G) :-
'$init_debugger_trace' :-
'__NB_getval__'('$trace',on,fail),
!,
nb_setval('$debug_status', state(creep, 0, stop, on)).
nb_setval('$debug_state', state(creep, 0, stop, on)).
'$init_debugger_trace' :-
'__NB_setval__'('$trace',off),
nb_setval('$debug_status', state(zip, 0, stop, off)).
nb_setval('$debug_state', state(zip, 0, stop, off)).
%% @pred $enter_debugging(G,Mod,CP,G0,NG)
%%
@ -492,7 +492,7 @@ notrace(G) :-
'$is_private'(G,Module)
-> true
;
'__NB_getval__'('$debug_status',state(zip, GN, Spy,_), fail)
'__NB_getval__'('$debug_state',state(zip, GN, Spy,_), fail)
->
true
;
@ -508,7 +508,7 @@ notrace(G) :-
).
'$creep_is_on_at_entry'(G,M,_GoalNo) :-
\+ '$system_predicate'(G,M),
'__NB_getval__'('$debug_status',state(Step, _GN, Spy,_), fail),
'__NB_getval__'('$debug_state',state(Step, _GN, Spy,_), fail),
(
Step \= zip
;
@ -518,13 +518,13 @@ notrace(G) :-
'$trace_on' :-
'__NB_getval__'('$debug_status', state(_Creep, GN, Spy,Trace), fail),
'__NB_getval__'('$debug_state', state(_Creep, GN, Spy,Trace), fail),
nb_setval('$trace',on),
nb_setval('$debug_status', state(creep, GN, Spy, Trace)).
nb_setval('$debug_state', state(creep, GN, Spy, Trace)).
'$trace_off' :-
'__NB_getval__'('$debug_status', state(_Creep, GN, Spy, Trace),fail),
nb_setval('$debug_status', state(zip, GN, Spy,Trace)).
'__NB_getval__'('$debug_state', state(_Creep, GN, Spy, Trace),fail),
nb_setval('$debug_state', state(zip, GN, Spy,Trace)).
/*

View File

@ -50,7 +50,8 @@ live :-
[ variable_names(Bindings),
syntax_errors(dec10),
term_position(Pos)
term_position(Pos),
input_closing_blank(true)
]),
E,
'$handle_toplevel_error'(E)).
@ -577,10 +578,10 @@ write_query_answer( Bindings ) :-
'$call'(G, CP, G, M).
'$user_call'(G, CP, G0, M) :-
'$trace_query'(G, M, CP, G0).
catch('$trace_query'(G, M, CP, G0), E, '$Error'(E)).
'$user_call'(G, M) :-
'$trace'(M:G).
gated_call('$start_user_code',call(M:G),Port,'$reenter_debugger'(Port)).
'$cut_by'(CP) :- '$$cut_by'(CP).
@ -1009,7 +1010,7 @@ log_event( String, Args ) :-
DBON = true
->
(
'__NB_getval__'('$debug_status',state(_, _, _, _,on), fail),
'__NB_getval__'('$debug_state',state(_, _, _, _,on), fail),
(
var(LF)
->