Skip to content

Commit ec2580f

Browse files
committed
Sketch implementation of facility to handle script chunks
This should let various editor modes share standard facilities for loading dependencies etc. Work for github issue #1767
1 parent aaef121 commit ec2580f

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

src/parse/ReplCommands.sig

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
signature ReplCommands =
2+
sig
3+
4+
(* Facilities for turning chunks of script file text into commands that can
5+
be fed to running REPL instances.
6+
7+
Editor is responsible for detecting/selecting the relevant text but does
8+
not need to examine it further. Instead, it can feed, for example
9+
10+
ReplCommands.execute_command (sml_text (...,{filename=...,text =...}));
11+
12+
to the running session. The ...s above correspond solely to trivially
13+
derived information about where and what the text is. The editor needs to
14+
know to use temporary files to stash particularly huge bits of text, using
15+
the ViaFile constructor to the string_src type rather than writing huge
16+
string literals into the REPL.
17+
18+
If the parsing of text into commands fails, the functions will put their
19+
errors into the Failure constructor and the execute_command can then get the
20+
REPL to emit the appropriate diagnostics.
21+
22+
*)
23+
24+
datatype string_src = Direct of string | ViaFile of {proxy_filename : string}
25+
type script_text = locn.locn * {filename : string option, text : string_src}
26+
27+
datatype repl_command = Success of string | Failure of string
28+
29+
val sml_text : script_text -> repl_command
30+
val set_initial_goal : script_text -> repl_command
31+
val set_by_subgoal : script_text -> repl_command
32+
val set_suffices_by_subgoal : script_text -> repl_command
33+
val apply_tactic : script_text -> repl_command
34+
val apply_tactic_pattern : script_text -> repl_command
35+
(* tactic patterns as per the second argument to the >~ operator *)
36+
val load_dependencies : script_text -> repl_command
37+
38+
val execute_command : repl_command -> unit
39+
40+
end

src/parse/ReplCommands.sml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
structure ReplCommands :> ReplCommands =
2+
struct
3+
4+
5+
datatype string_src = Direct of string | ViaFile of {proxy_filename : string}
6+
type script_text = locn.locn * {filename : string option, text : string_src}
7+
8+
datatype repl_command = Success of string | Failure of string
9+
10+
fun sml_text s = Failure "Unimplemented"
11+
fun set_initial_goal s = Failure "Unimplemented"
12+
fun set_by_subgoal s = Failure "Unimplemented"
13+
fun set_suffices_by_subgoal s = Failure "Unimplemented"
14+
fun apply_tactic s = Failure "Unimplemented"
15+
fun apply_tactic_pattern s = Failure "Unimplemented"
16+
fun load_dependencies s = Failure "Unimplemented"
17+
18+
(* Under Moscow ML, handling a Success will require writing the string to a
19+
file and then use-ing it. Error-reporting will be poor; under Poly/ML the
20+
compiler can be invoked more directly, with line-numbers set up
21+
appropriately. *)
22+
fun execute_command rc =
23+
case rc of
24+
Failure s => print s
25+
| Success s => print "Can't do anything yet"
26+
27+
28+
end

0 commit comments

Comments
 (0)