Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Candle REPL fixes #903

Closed
wants to merge 149 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
b0aa65e
Give names to rules in proves relation
oskarabrahamsson May 2, 2022
7133ed3
Add first version of compute syntax (with cheats)
oskarabrahamsson May 2, 2022
31b7328
Prove all theorems in computeSyntax
oskarabrahamsson May 2, 2022
701e62c
Move candle_kernel and computeSyntax
oskarabrahamsson May 3, 2022
17ff675
Update READMEs
oskarabrahamsson May 3, 2022
ab76610
Add lists+overloads to compute syntax
oskarabrahamsson May 3, 2022
8826164
Add functions for inserting :thm checks
oskarabrahamsson May 3, 2022
e2bbfe3
Comment about term_ok
oskarabrahamsson May 4, 2022
ef52b57
Add some boolean syntax
oskarabrahamsson May 5, 2022
761b96c
Use the BIT1 equation with addition
oskarabrahamsson May 5, 2022
d88c827
Un-local a few theorems
oskarabrahamsson May 5, 2022
d87d926
Sketch compute_add and its correctness
oskarabrahamsson May 5, 2022
aa3aecd
Derive term_ok from proves
oskarabrahamsson May 5, 2022
e39717b
Move overloads to top
oskarabrahamsson May 6, 2022
96d93ba
Use quantifier-free theorems (and the real BIT1)
oskarabrahamsson May 6, 2022
93c15cf
Derive term_ok for bool_thy_ok
oskarabrahamsson May 6, 2022
4b9906c
Update num2bit _0-case
oskarabrahamsson May 6, 2022
28377fb
Set up the necessary cheats for compute_add_thm
oskarabrahamsson May 6, 2022
69f2343
Un-local theorems and prove BIT0 equation
oskarabrahamsson May 6, 2022
e3b6b31
Prove compute_add correctness
oskarabrahamsson May 6, 2022
3a329ec
Rename num_ths
oskarabrahamsson May 6, 2022
084be7c
Update README
oskarabrahamsson May 6, 2022
d883b53
Translate compute_add
oskarabrahamsson May 6, 2022
48d24d2
Make sure candle_kernelProg builds
oskarabrahamsson May 6, 2022
3332755
Lift runtime typechecking code into its own lib/thy
oskarabrahamsson May 9, 2022
ee572d1
Add PMATCH definitions for compute functions
oskarabrahamsson May 9, 2022
3a8825b
Add thm list check
oskarabrahamsson May 9, 2022
52b9bf6
Add checks to compute_add translation
oskarabrahamsson May 9, 2022
2d56371
Update kernel_vals with compute_add and check_thm{_list}
oskarabrahamsson May 9, 2022
4c3b33a
Prove perms theorems for new functions
oskarabrahamsson May 9, 2022
aafd54e
Fix grammar ancestry
oskarabrahamsson May 9, 2022
cfc399e
Add no-clash clause to compute_add_thm
oskarabrahamsson May 9, 2022
f87b1ec
Add THM theorems to prover_inv
oskarabrahamsson May 9, 2022
185781e
Simplify proof about num_thms_v
oskarabrahamsson May 9, 2022
96d03d8
Update kernel_vals_ok proof with compute_add
oskarabrahamsson May 9, 2022
cd51bab
EVAL the num_thms list before translating
oskarabrahamsson May 10, 2022
92eb065
Fix prover_semantics proof
oskarabrahamsson May 10, 2022
c342289
Add some syntax for num-pairs
oskarabrahamsson May 10, 2022
49d1eb1
Add operations to deep embedding
oskarabrahamsson May 10, 2022
7f01c05
Add an npr_eval function and un-local theorems
oskarabrahamsson May 10, 2022
2978a8e
Change some variable names
oskarabrahamsson May 10, 2022
83ab3fb
Add npr_compute and sketch theorems
oskarabrahamsson May 10, 2022
ddd3676
Move npr_eval_thm and prove add case
oskarabrahamsson May 10, 2022
c7909a8
Prove some lemmas and npr_eval_thm
oskarabrahamsson May 11, 2022
48cf2b1
Update theorem list with _NUMERAL _0
oskarabrahamsson May 11, 2022
0fae304
Remove the last cheat in computeScript
oskarabrahamsson May 11, 2022
ebccffe
Add npr_compute to kernel and update prover soundness
oskarabrahamsson May 11, 2022
ea24dbc
Rename NPR and num_pair types/values/defs
oskarabrahamsson May 11, 2022
37a757c
Add some PMATCH definitions (and get them translated)
oskarabrahamsson May 11, 2022
2171d0b
Updates to compute theorem statements + fixes
oskarabrahamsson May 13, 2022
ee05dc9
Use the correct type in T_DEF
oskarabrahamsson May 13, 2022
0f41e06
Add overloads for new constants
oskarabrahamsson May 16, 2022
0c41f09
Add syntax for bools, chars and strings
oskarabrahamsson May 16, 2022
13b0571
Start sketching interpreter function in monadic style
oskarabrahamsson May 16, 2022
2e5c2de
Adjust if-then-else equations
oskarabrahamsson May 16, 2022
2419200
Remove bools/chars/strings and restore part of proof
oskarabrahamsson May 16, 2022
775464f
Start work on adapting computeScript for compute-v3
oskarabrahamsson May 17, 2022
f34951e
Fix dest_cval_def
oskarabrahamsson May 17, 2022
65d336e
Remove redundant PMATCH definition
oskarabrahamsson May 17, 2022
4760cf7
Fix equations for IF and prove if-case
oskarabrahamsson May 17, 2022
02d29c9
Update compute_eval_thm statement
oskarabrahamsson May 17, 2022
75dcc42
Move run/default state defs to computeSyntaxScript
oskarabrahamsson May 17, 2022
537c05b
Change compute_def
oskarabrahamsson May 17, 2022
12a4cb2
Prove theorem about list_dest_comb
oskarabrahamsson May 18, 2022
f828dd0
Remove some redundant theorems
oskarabrahamsson May 18, 2022
6f75af4
Prove some theorems about cval2term
oskarabrahamsson May 18, 2022
d8b7fec
Prove correctness of dest_cval
oskarabrahamsson May 18, 2022
c3945e1
Perform more checks in compute_def
oskarabrahamsson May 18, 2022
9d2c558
Cheat a theorem and work on compute_thm
oskarabrahamsson May 18, 2022
dd22320
Change hypotheses in dest_cval_thm
oskarabrahamsson May 18, 2022
9fceacb
Prove cheat in computeScript
oskarabrahamsson May 18, 2022
eadaa2a
Move defs/theorems around and push cheats backwards
oskarabrahamsson May 19, 2022
63a0aed
Make compute_eval_thm probably provable
oskarabrahamsson May 19, 2022
d292ff0
Prove more bits in compute_eval_thm
oskarabrahamsson May 19, 2022
d65b407
Move to substitution semantics
oskarabrahamsson May 23, 2022
08601c8
Reduce compute proof to plausible cheat
oskarabrahamsson May 24, 2022
da6b933
Fix renaming mistake
oskarabrahamsson May 24, 2022
268586f
Remove cheats from computeScript
oskarabrahamsson May 24, 2022
595a951
Remove last cheat (with Magnus)
oskarabrahamsson May 24, 2022
a56dea0
Reintroduce fst, snd and support multiple binops
oskarabrahamsson May 25, 2022
518b4c0
Split theories into several files
oskarabrahamsson May 25, 2022
5405706
Use snake_case in theory names consistently
oskarabrahamsson May 25, 2022
d2a1982
Add subtraction to compute
oskarabrahamsson May 26, 2022
91cea73
Add less-than (<) for numbers
oskarabrahamsson May 26, 2022
d2094e5
Add multiplication (and fix subtraction)
oskarabrahamsson May 26, 2022
5ba8c82
Add DIV,MOD (with cheats) and fix multiplication
oskarabrahamsson May 28, 2022
92fd6c1
Prove most of the MOD equation
oskarabrahamsson May 31, 2022
9467172
Prove MOD_num2term
oskarabrahamsson May 31, 2022
42fbbcc
Remove NOT, NOT_TM (for now)
oskarabrahamsson May 31, 2022
db5d36a
Update compute theorem list
oskarabrahamsson May 31, 2022
3887375
Prove DIV_num2term
oskarabrahamsson May 31, 2022
b43d684
Remove some empty lines
oskarabrahamsson May 31, 2022
54bc892
Add an ISPAIR operation
oskarabrahamsson Jun 1, 2022
0b8c978
Load new theory names in translation
oskarabrahamsson Jun 1, 2022
17c02ee
Update semantics to use mut-rec function for lists
oskarabrahamsson Jun 2, 2022
f0c9fbd
Remove unused deps.
oskarabrahamsson Jun 2, 2022
bd96374
Move compute expressions + semantics into own dir
oskarabrahamsson Jun 2, 2022
3b99573
Translate compute_eval
oskarabrahamsson Jun 2, 2022
58c1e9e
Fix termination proof
oskarabrahamsson Jun 2, 2022
59a750b
Translate compute_eval before Candle
oskarabrahamsson Jun 2, 2022
814627e
Do not register_type on type,term,thm in Candle translation
oskarabrahamsson Jun 2, 2022
dfd069e
Translate compute with Candle
oskarabrahamsson Jun 2, 2022
45b63b1
Update generated README
oskarabrahamsson Jun 2, 2022
4864a7d
Translate more functions
oskarabrahamsson Jun 2, 2022
e81c3dc
Wrap run functionin option-monad
oskarabrahamsson Jun 2, 2022
d27b0a7
Add missing FOLDL translation
oskarabrahamsson Jun 2, 2022
65c4804
Update local README
oskarabrahamsson Jun 2, 2022
ebb1abe
Fix translation (re-translate map_def and inline C_DEF)
oskarabrahamsson Jun 2, 2022
8aacc52
Rename compute_val -> compute_exp
oskarabrahamsson Jun 2, 2022
3e2adcf
Tuple thm-arguments to compute
oskarabrahamsson Jun 3, 2022
ed92896
Rename compute_syntax/ to compute_exp/
oskarabrahamsson Jun 3, 2022
e042535
Don't simp_conv away type check
oskarabrahamsson Jun 3, 2022
dad7808
Update generated README
oskarabrahamsson Jun 3, 2022
33b7857
Update compute_v type in candle_kernel_vals
oskarabrahamsson Jun 3, 2022
1f2b566
Stop translator from forgetting v_thms
oskarabrahamsson Jun 3, 2022
de48b88
Fix an import
oskarabrahamsson Jun 3, 2022
926148d
Prove some perms_ok theorems
oskarabrahamsson Jun 3, 2022
c2b96e4
Save accidentally discarded theorem
oskarabrahamsson Jun 3, 2022
82c8324
Use tupled call in proofs
oskarabrahamsson Jun 3, 2022
fbcc09d
Move to using Candle monad in compute_eval
oskarabrahamsson Jun 3, 2022
237b7f3
Fix translation order
oskarabrahamsson Jun 3, 2022
5efea5a
Updates to compute permissions
oskarabrahamsson Jun 3, 2022
ed5e154
Update kernel_vals_ok proof
oskarabrahamsson Jun 3, 2022
f647fe2
Hide some overloads in prover_evaluate
oskarabrahamsson Jun 3, 2022
fc3e665
Hide some overloads in basis_evaluate
oskarabrahamsson Jun 3, 2022
b67a3a7
Fix prover_semantics
oskarabrahamsson Jun 3, 2022
e2b5bf7
Prove compute_eval always succeeds or diverges
oskarabrahamsson Jun 4, 2022
06f0fa9
Qualify :asm$binop to avoid translation issues
oskarabrahamsson Jun 7, 2022
3f2a93b
Implement equality for :compute_exp
oskarabrahamsson Jun 8, 2022
dcfd05c
Gather all compute files under the same directory
oskarabrahamsson Jun 8, 2022
fb4a1d9
Update generated READMEs
oskarabrahamsson Jun 8, 2022
a9ce89a
Collect 1-ary ops in one datatype
oskarabrahamsson Jun 8, 2022
18d4960
Merge remote-tracking branch 'origin/master' into candle-compute-v4
myreen Jul 7, 2022
e6644ca
Merge remote-tracking branch 'origin/master' into candle-compute-v4
myreen Aug 5, 2022
c92d5fd
Add LET to compute_syntax
oskarabrahamsson Aug 12, 2022
aaf0500
Update compute_syntaxProof with LET
oskarabrahamsson Aug 12, 2022
5668ba7
Update compute_evalScript
oskarabrahamsson Aug 12, 2022
3d1a916
Fix main eval theorem but cheat two lemmas
oskarabrahamsson Aug 13, 2022
71d1c3c
Add the LET equation to the init thms
oskarabrahamsson Aug 13, 2022
ae34144
Update const_list and var_list
oskarabrahamsson Aug 13, 2022
1c9c588
Update check_cexp_closed
oskarabrahamsson Aug 13, 2022
166f04c
Update translation
oskarabrahamsson Aug 13, 2022
c7735b9
Fix how candle_kernel_vals finds v_defs
oskarabrahamsson Aug 13, 2022
bb348b2
Hide compute_exp "Let" constructor
oskarabrahamsson Aug 13, 2022
47ee756
Remove VFREE_IN cheat
oskarabrahamsson Aug 13, 2022
1fe70b1
Remove the last cheat in compute_evalProof
oskarabrahamsson Aug 13, 2022
ac36a04
Treat type variables more robustly in REPL
oskarabrahamsson Aug 16, 2022
8ba7d44
Various fixes to Candle REPL
oskarabrahamsson Aug 16, 2022
e6dce39
Use loads/needs instead of #load/#need in REPL
oskarabrahamsson Aug 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion candle/prover/Holmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ INCLUDES = ../../developers \
../standard/ml_kernel \
../standard/monadic \
../standard/semantics \
../standard/syntax
../standard/syntax \
compute

all: $(DEFAULT_TARGETS) README.md
.PHONY: all
Expand Down
6 changes: 6 additions & 0 deletions candle/prover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Useful predicates on the CakeML ast.
[candle_basis_evaluateScript.sml](candle_basis_evaluateScript.sml):
Proving that the basis program only produces v_ok values.

[candle_kernelProgScript.sml](candle_kernelProgScript.sml):
Adds Candle specific functions to the kernel module from ml_hol_kernel_funsProg

[candle_kernel_funsScript.sml](candle_kernel_funsScript.sml):
Prove that kernel functions maintain Candle prover's invariants

Expand All @@ -25,5 +28,8 @@ evaluate of Candle prover
[candle_prover_semanticsScript.sml](candle_prover_semanticsScript.sml):
Top-level soundness theorem for the Candle theorem prover.

[compute](compute):
A verified Candle compute primitive.

[permsScript.sml](permsScript.sml):
Permissions for CakeML values.
5 changes: 5 additions & 0 deletions candle/prover/candle_basis_evaluateScript.sml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ val _ = set_grammar_ancestry [
"candle_prover_inv", "ast_extras", "evaluate", "namespaceProps", "perms",
"semanticPrimitivesProps", "misc"];

val _ = temp_send_to_back_overload "If" {Name="If",Thy="compute_syntax"};
val _ = temp_send_to_back_overload "App" {Name="App",Thy="compute_syntax"};
val _ = temp_send_to_back_overload "Var" {Name="Var",Thy="compute_syntax"};
val _ = temp_send_to_back_overload "Let" {Name="Let",Thy="compute_syntax"};

Definition simple_exp_def:
simple_exp = every_exp $ λx.
case x of
Expand Down
190 changes: 139 additions & 51 deletions candle/prover/candle_boot.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
* Prelude
* ------------------------------------------------------------------------- *)

(* This is pointer equality, which is missing from CakeML.
|| x = y is just to get the type variables right:
*)
let (==) x y = false || x = y;;

let ref x = Ref x;;

let (/) = div;;
Expand All @@ -12,6 +17,11 @@ let (/.) = Double.(/);;

let failwith msg = raise (Failure msg);;

(* This is the pretty printer for exceptions, and you need to update it
each time you add an exception definition if you want it to print something
informative (see e.g. exception Unchanged in lib.ml).
*)

let pp_exn e =
match e with
| Chr -> Pretty_printer.token "Chr"
Expand All @@ -22,10 +32,28 @@ let pp_exn e =
| Failure s -> Pretty_printer.app_block "Failure" [Pretty_printer.pp_string s]
| _ -> Pretty_printer.token "<exn>";;

(*CML
(* OCaml parser doesn't like the tilde *)
val rat_minus = Rat.~;
*)

(* Some conversions in OCaml style: *)

let string_of_int = Int.toString;;
let string_of_int n =
if n < 0 then "-" ^ Int.toString (-n)
else Int.toString n
;;

let pp_int n = Pretty_printer.token (string_of_int n);;

let pp_rat r =
let n = Rat.numerator r in
let d = Rat.denominator r in
Pretty_printer.token (string_of_int n ^ "/" ^ string_of_int d)
;;

let string_of_float = Double.toString;;

let int_of_string = Option.valOf o Int.fromString;;

(* Left shifting integers. HOL Light expects these to not be bigints, so I
Expand All @@ -47,6 +75,7 @@ let string_escaped =
| '\b'::l -> '\\'::'b'::escape l
| '\t'::l -> '\\'::'t'::escape l
| '\n'::l -> '\\'::'n'::escape l
| '"'::l -> '\\'::'"'::escape l
| c::l -> c::escape l in
fun s -> String.implode (escape (String.explode s));;

Expand All @@ -71,6 +100,11 @@ let abs x = if x < 0 then -x else x;;

let ignore x = x; ();;

let rec rev_append xs acc =
match xs with
| [] -> acc
| x::xs -> rev_append xs (x::acc);;

(* ------------------------------------------------------------------------- *
* Helpful banner
* ------------------------------------------------------------------------- *)
Expand Down Expand Up @@ -219,9 +253,9 @@ let string_of_directive d =

type token =
| T_begin | T_end | T_struct | T_sig | T_semis | T_newline
| T_use | T_needs | T_loads (* converted into directives *)
| T_other of string
| T_symb of string
| T_directive of directive * string
| T_comment of string
| T_string of string
| T_quote of string
Expand All @@ -247,12 +281,21 @@ let string_of_token unquote tok =
| Some f -> "(" ^ f s ^ ")"
end
| T_char s -> "'" ^ s ^ "'"
| T_directive (d, f) ->
String.concat ["#"; string_of_directive d; " "; "\""; f; "\";;"]
| T_comment s | T_other s | T_symb s | T_number s | T_spaces s -> s
| T_use -> "#use"
| T_loads -> "loads"
| T_needs -> "needs"
| T_done -> "(* shouldn't happen *)"
;;

let directive_of_token t =
match t with
| T_needs -> Some D_need
| T_loads -> Some D_load
| T_use -> Some D_use
| _ -> None
;;

let scan nextChar peekChar =
let quoteSym c = c = '`' in
let tok_from_keyword =
Expand All @@ -261,6 +304,10 @@ let scan nextChar peekChar =
"end", T_end;
"struct", T_struct;
"sig", T_sig;
(* top-level directives *)
"#use", T_use;
"needs", T_needs;
"loads", T_loads;
] in
fun s -> match Alist.lookup keywords s with
| None -> T_other s
Expand Down Expand Up @@ -335,37 +382,6 @@ let scan nextChar peekChar =
let scan_spaces c =
Option.map (fun s -> T_spaces s)
(scan_while [c] (fun c -> c <> '\n' && Char.isSpace c)) in
let dir_from_string =
let dirs = [
"load", D_load;
"need", D_need;
"use", D_use ] in
Alist.lookup dirs in
let scan_directive () = (* TODO *)
match scan_while [] (fun x -> x <> ';') with
| None -> None
| Some s ->
nextChar ();
match peekChar () with
| None -> Some (T_other ("#" ^ s ^ ";"))
| Some c ->
if c <> ';' then
Some (T_other ("#" ^ s ^ ";" ^ String.str c))
else
begin
nextChar ();
match String.fields (fun x -> x = '"') s with
| [dir; fname; rest] ->
let dir = trimRight dir in
let rest = trimLeft rest in
if rest <> "" then Some (T_other ("#" ^ s ^ ";;")) else
begin
match dir_from_string dir with
| None -> Some (T_other ("#" ^ s ^ ";;"))
| Some d -> Some (T_directive (d, fname))
end
| _ -> Some (T_other ("#" ^ s ^ ";;"))
end in
let scan_escaped ch =
let rec nom acc =
Interrupt.check ();
Expand All @@ -383,9 +399,39 @@ let scan nextChar peekChar =
let scan_strlit () =
Option.map (fun s -> T_string s)
(scan_escaped '"') in
let scan_charlit () =
Option.map (fun s -> T_char s)
(scan_escaped '\'') in
(* This code will intentionally let through some bad tokens (it doesn't check
whether escape sequences are well formed), but those will get stuck in the
real lexer. *)
let scan_charlit_or_tyvar () =
match peekChar () with
(* Escaped character literal *)
| Some '\\' ->
begin
nextChar ();
Option.map (fun s -> T_char ("\\" ^ s))
(scan_escaped '\'')
end
(* A single tick, start of a type variable, but followed by space *)
| Some ' ' | Some '\n' | Some '\t' | Some '\r' -> Some (T_other "'")
(* Regular character literal, or a type variable *)
| Some c ->
begin
nextChar ();
match peekChar () with
(* Regular character literal *)
| Some '\'' ->
begin
nextChar ();
Some (T_char (String.str c))
end
(* Type variable *)
| Some _ -> Option.map (fun s -> T_other s)
(scan_while [c; '\''] is_name_char)
| None -> Some (T_other (String.implode ['\''; c]))
end
(* Two ticks following each other: '' *)
| Some '\'' -> Some (T_symb "''")
| None -> Some (T_symb "'") in
let rec nextToken () =
match nextChar () with
| None -> None
Expand All @@ -411,12 +457,12 @@ let scan nextChar peekChar =
end
| _ -> Some (T_symb "(")
end
(* Attempt to scan char literal *)
| Some '\'' -> scan_charlit ()
(* Attempt to scan char literal or type variable *)
| Some '\'' -> scan_charlit_or_tyvar ()
(* Attempt to scan string literal *)
| Some '"' -> scan_strlit ()
(* Attempt to scan load directive *)
| Some '#' -> scan_directive ()
(* A #use directive, maybe: *)
| Some '#' -> scan_name '#'
(* Newlines *)
| Some '\n' -> Some T_newline
(* Anything else *)
Expand Down Expand Up @@ -562,20 +608,61 @@ let () =
| Some tok -> Some tok
| None -> scan1 () in
let output_buffer = (Buffer.empty () : Lexer.token Buffer.buffer) in
let rec next_nonspace () =
match next () with
| Some (Lexer.T_spaces _) -> next_nonspace ()
| res -> res in
let rec scan level =
try match next () with
| None -> None
(* Attempt to use token as part of loading directive if it sits at the
top level (i.e. not inside parenthesis). The REPL fails and reports
and error unless the token is followed by a string literal and then
double semicolons. Ideally we should also check that the token sits
at the start of the line, but we don't, so odd things such as this:
foo needs "bar.ml";;
are OK and will cause the file bar.ml to be loaded and appear
directly after 'foo' in the token stream.
*)
| Some (Lexer.T_use | Lexer.T_needs | Lexer.T_loads as tok)
when level = 0 ->
begin
let dir = Option.valOf (Lexer.directive_of_token tok) in
match next_nonspace () with
(* Attempt to convert into directive: *)
| Some (Lexer.T_string fname as tok') ->
begin
match next_nonspace () with
(* OK directive, perform load: *)
| Some (Lexer.T_semis) ->
let lines = load dir fname in
if List.null lines then scan level else
begin
userInput := false;
scan_lines lines;
scan level
end
(* Malformed *)
| _ ->
failwith
(String.concat [
"\nREPL error: ";
Lexer.string_of_directive dir;
" \"string\" should be followed by a double";
" semicolon [;;].\n"])
end
(* Malformed *)
| _ ->
failwith
(String.concat [
"\nREPL error: ";
Lexer.string_of_directive dir;
" should be followed by a \"string literal\" and then a";
" double semicolon [;;].\n"])
end
| Some (Lexer.T_done) ->
userInput := true;
scan level
| Some (Lexer.T_directive (dir, fname)) ->
let lines = load dir fname in
if List.null lines then scan level else
begin
userInput := false;
scan_lines lines;
scan level
end
| Some tok ->
Buffer.push_back output_buffer tok;
match tok with
Expand Down Expand Up @@ -612,7 +699,8 @@ let () =
if not (!userInput) then print (!prompt1);
Buffer.flush input_buffer;
Buffer.flush output_buffer;
Repl.nextString := "" in
Repl.nextString := "";
userInput := true in
Repl.readNextString := (fun () ->
print (!prompt1);
next ();
Expand Down