From f92fa69eab4f9280e89f2e9b98750e819fe08b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Wed, 23 Feb 2011 17:46:50 +0000 Subject: [PATCH] more PLStream stuff. --- C/tracer.c | 4 ---- Makefile.in | 1 + packages/PLStream/pl-file.c | 2 ++ packages/PLStream/pl-read.c | 8 ++++---- pl/boot.yap | 12 ++++++++++++ pl/flags.yap | 10 ++++++++++ pl/init.yap | 4 ++++ 7 files changed, 33 insertions(+), 8 deletions(-) diff --git a/C/tracer.c b/C/tracer.c index 7f9aa73c0..bf05d1bc5 100755 --- a/C/tracer.c +++ b/C/tracer.c @@ -172,10 +172,6 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) LOCK(Yap_heap_regs->low_level_trace_lock); sc = Yap_heap_regs; vsc_count++; - if (vsc_count == 471321) - jmp_deb(1); - if (vsc_count < 471300) - return; #ifdef THREADS MY_ThreadHandle.thread_inst_count++; #endif diff --git a/Makefile.in b/Makefile.in index 5b1ee7759..278c7361b 100755 --- a/Makefile.in +++ b/Makefile.in @@ -315,6 +315,7 @@ PL_SOURCES= \ $(srcdir)/pl/tabling.yap $(srcdir)/pl/threads.yap \ $(srcdir)/pl/udi.yap \ $(srcdir)/pl/utils.yap \ + $(srcdir)/LGPL/history.pl \ $(srcdir)/pl/yapor.yap $(srcdir)/pl/yio.yap YAPDOCS=$(srcdir)/docs/yap.tex $(srcdir)/docs/chr.tex \ diff --git a/packages/PLStream/pl-file.c b/packages/PLStream/pl-file.c index e3203229d..fcddcdf7f 100755 --- a/packages/PLStream/pl-file.c +++ b/packages/PLStream/pl-file.c @@ -4681,6 +4681,8 @@ static const PL_extension foreigns[] = { FRG("format_predicate", 2, pl_format_predicate, META), FRG("current_format_predicate", 2, pl_current_format_predicate, META|NDET), + FRG("$raw_read", 1, pl_raw_read, 0), + FRG("$raw_read", 2, pl_raw_read2, 0), /* DO NOT ADD ENTRIES BELOW THIS ONE */ LFRG((char *)NULL, 0, NULL, 0) }; diff --git a/packages/PLStream/pl-read.c b/packages/PLStream/pl-read.c index 4f0c9b7ba..ff25bfa93 100644 --- a/packages/PLStream/pl-read.c +++ b/packages/PLStream/pl-read.c @@ -28,7 +28,6 @@ typedef struct unsigned char *base; /* base of clause */ unsigned char *end; /* end of the clause */ unsigned char *token_start; /* start of most recent read token */ - IOSTREAM *stream; int has_exception; /* exception is raised */ unsigned char *posp; /* position pointer */ @@ -37,6 +36,7 @@ typedef struct unsigned int flags; /* Module syntax flags */ int styleCheck; /* style-checking mask */ bool backquoted_string; /* Read `hello` as string */ + int *char_conversion_table; /* active conversion table */ term_t exception; /* raised exception */ @@ -70,7 +70,7 @@ init_read_data(ReadData _PL_rd, IOSTREAM *in ARG_LD) { memset(_PL_rd, 0, sizeof(*_PL_rd)); /* optimise! */ _PL_rd->varnames = 0; - _PL_rd->stream = in; + rb.stream = in; _PL_rd->has_exception = 0; _PL_rd->exception = 0; } @@ -81,9 +81,9 @@ free_read_data(ReadData _PL_rd) } static int -read_term(term_t t, ReadData rd ARG_LD) +read_term(term_t t, ReadData _PL_rd ARG_LD) { - return Yap_read_term(t, rd->stream, rd->varnames); + return Yap_read_term(t, rb.stream, _PL_rd->varnames); } diff --git a/pl/boot.yap b/pl/boot.yap index e9c9e82ba..554b9a93e 100755 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -144,6 +144,15 @@ true :- true. */ /* main execution loop */ +'$read_vars'(user_input, Goal, Mod, Pos, Binding) :- + read_history(h, '!h', + [trace, end_of_file], + Prompt, Goal, Bindings), + (nonvar(Err) -> + print_message(error,Err), fail + ; + true + ). '$read_vars'(Stream,T,Mod,Pos,V) :- '$read'(true,T,Mod,V,Pos,Err,Stream), (nonvar(Err) -> @@ -1562,3 +1571,6 @@ format(Stream, Command, Args) :- is_stream(Stream) :- swi_is_stream(Stream). +'$raw_read'(Stream, String) :- + 'swi_$raw_read'(Stream, String). + diff --git a/pl/flags.yap b/pl/flags.yap index 7e9a88425..4f5254a4f 100644 --- a/pl/flags.yap +++ b/pl/flags.yap @@ -205,6 +205,16 @@ yap_flag(home,X) :- '$transl_to_index_mode'(3, on). % default is multi argument indexing '$transl_to_index_mode'(4, max). +yap_flag(readline,X) :- + var(X), !, + get_value('$readline',X1). + '$transl_to_true_false'(X1,X). +yap_flag(readline,X) :- + '$transl_to_true_false'(X1,X), !, + set_value('$readline',X1). +yap_flag(bounded,X) :- + '$do_error'(domain_error(flag_value,readline+X),yap_flag(bounded,X)). + % tabling mode yap_flag(tabling_mode,Options) :- var(Options), !, diff --git a/pl/init.yap b/pl/init.yap index fdb32373f..d1652a0d6 100644 --- a/pl/init.yap +++ b/pl/init.yap @@ -113,11 +113,15 @@ system_mode(verbose,off) :- set_value('$verbose',off). :- use_module('attributes.yap'). :- use_module('corout.yap'). :- use_module('dialect.yap'). +%:- use_module('../LGPL/history.pl'). + +%:- set_prolog_flag(readline, true). '$system_module'('$messages'). '$system_module'('$hacks'). '$system_module'('$attributes'). '$system_module'('$coroutining'). +'$system_module'('$history'). yap_hacks:cut_by(CP) :- '$$cut_by'(CP).