-
Notifications
You must be signed in to change notification settings - Fork 3
/
polyrepl
executable file
·63 lines (50 loc) · 1.42 KB
/
polyrepl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
#
# polyrepl - load a SML program defined in a MLB file into the Poly/ML
# interactive environment
#
# Chris Cannam, 2015-2022. MIT licence
set -e
usage() {
me=$(basename "$0")
echo 1>&2
echo "$me: Load a SML program defined in a MLB file into the Poly/ML repl" 1>&2
echo 1>&2
echo "Usage: $me [-d] file.sml" 1>&2
echo " $me [-u] [-d] file.mlb" 1>&2
echo "where" 1>&2
echo " -u: Unique: \"use\" each file only once, regardless of how many times it" 1>&2
echo " appears in the MLB file. See \"polybuild\" for discussion." 1>&2
echo " -d: Enable Poly/ML compiler debug mode before reading SML source." 1>&2
echo 1>&2
exit 2
}
unique_arg=""
if [ "$1" = "-u" ]; then
unique_arg="-u"
shift
fi
debug=no
if [ "$1" = "-d" ]; then
debug=yes
shift
fi
arg="$1"
if [ -z "$arg" ]; then
usage
fi
shift
set -u
mydir=$(dirname "$0")
. "$mydir/smlbuild-include.sh"
out=$(get_outfile "$arg") # we don't use this, but it does some arg error checking
if rlwrap -v >/dev/null 2>&1 ; then
rlwrap=rlwrap
else
rlwrap=
fi
if [ "$debug" = "yes" ]; then
$rlwrap poly --eval 'PolyML.Compiler.debug := true;' $(expand_arg $unique_arg "$arg" | sed 's/^\(.*\)$/--use \1/') --eval '"Entering trace mode; evaluate `PolyML.Debug.trace false` to leave";' --eval 'PolyML.Debug.trace true;'
else
$rlwrap poly $(expand_arg -u "$arg" | sed 's/^\(.*\)$/--use \1/')
fi