Skip to content

Commit

Permalink
zero-repl: ensure all commands in block are processed
Browse files Browse the repository at this point in the history
  • Loading branch information
digama0 authored and mn200 committed Oct 1, 2024
1 parent 202feca commit 966ae67
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
19 changes: 11 additions & 8 deletions tools-poly/holrepl.ML
Original file line number Diff line number Diff line change
Expand Up @@ -154,26 +154,29 @@ fun topLevel diag {nameSpace, exitLoop, exitOnError, isInteractive, zeroTerm,
| chunk => process chunk)
| Current chunk => process chunk

(* Returns true and moves to the next state if another statement
is ready. *)
(* Moves to the next state if another statement is ready. *)
fun finishCommand () =
case !state of
Next s => (state := Current s; true)
| _ => false
Next s => state := Current s
| _ => () (* this can only happen if endOfFile is true *)

in fn () =>
let
(* Create a new lexer for each command block. *)
val {read, ...} = QFRead.inputToReader true input
val {read, ...} = QFRead.inputToReader true input;
val endOfBlock = ref false;
fun read' () = case read () of
NONE => (endOfBlock := true; NONE)
| ch => ch;

fun readEvalPrint compileAcc runAcc =
let
val {compileTime, runTime, result} =
readEvalPrint1 read (fn () => ());
readEvalPrint1 read' (fn () => ());
val () = reportResult result;
in
if !endOfFile orelse finishCommand () then
reportTiming compileTime runTime
if !endOfBlock then
(finishCommand (); reportTiming compileTime runTime)
else
readEvalPrint (compileAcc + compileTime) (runAcc + runTime)
end;
Expand Down
7 changes: 5 additions & 2 deletions tools/Holmake/tests/repl/Holmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ HOL = $(protect $(HOLDIR)/bin/hol.bare) --zero
CMP = diff

ifdef POLY
DEPS = test1.out test2.out test3.out test4.out
DEPS = test1.out test2.out test3.out test4.out test5.out

# FIXME: % in targets doesn't work
test1.out: test1.input test1.expected
echo $(DEPS)
$(HOL) < $< | tail -n +8 > $@
$(CMP) $@ $(patsubst %.input,%.expected,$<)

Expand All @@ -27,6 +26,10 @@ test4.out: test4.input test4.expected
$(HOL) < $< | tail -n +8 > $@
$(CMP) $@ $(patsubst %.input,%.expected,$<)

test5.out: test5.input test5.expected
$(HOL) < $< | tail -n +8 > $@
$(CMP) $@ $(patsubst %.input,%.expected,$<)

endif

all: $(DEFAULT_TARGETS) $(DEPS)
Expand Down
Binary file added tools/Holmake/tests/repl/test5.expected
Binary file not shown.
Binary file added tools/Holmake/tests/repl/test5.input
Binary file not shown.

0 comments on commit 966ae67

Please sign in to comment.