Commit 6221dd41 authored by Michael Hanus's avatar Michael Hanus
Browse files

Add generic script to invoke a Curry REPL

parent a3380c1f
......@@ -11,7 +11,13 @@ The specification of the concrete compiler is provided
as an element of type `REPL.Compiler.CCDescription`.
The entry point of the REPL is the operation `mainREPL`
defined in module `REPL.Main`.
The directory `examples` contains example specifications.
The directory `examples` contains example specifications
for various Curry systems.
The directory `scripts` contains a simple shell script
to invoke a Curry REPL with appropriate path settings.
This script needs to be adapted to the actual Curry compiler.
Requirements for a Curry Compiler used by a REPL
......
#!/bin/sh
#
# A simple shell script to start interactive read-eval-print loop of
# a Curry system together with CPM to compute the actual load path
# and rlwrap to support input line editing.
###########################################################################
# Adapt the following definitions to the actual Curry system:
CURRYHOME=`echo CURRYHOME must be defined here!`
export CURRYHOME
# The directory where CPM installs the binaries:
CPMBIN="$HOME/.cpm/bin"
# The executable of the Curry REPL installed by CPM:
REPL="$CPMBIN/curry-repl"
###########################################################################
# Invoke the Curry REPL with CPM to compute CURRYPATH:
# Check whether we should call CPM to compute the correct load path:
WHICHCPM=`which cypm`
if [ ! -d "$HOME" ] ; then
USECPM=no # do not use CPM without a home directory
elif [ -x $CPMBIN/cypm ] ; then
CYPMBIN=$CPMBIN/cypm
USECPM=yes
elif [ -x "$WHICHCPM" ] ; then
CYPMBIN=$WHICHCPM
USECPM=yes
else
USECPM=no
fi
# Use readline wrapper `rlwrap` for REPL if `rlwrap` exists,
# we have tty as stdin, and we have a home dir to store rlwrap's history:
USERLWRAP=no
if tty -s ; then
RLWRAP=`which rlwrap`
if [ -x "$RLWRAP" -a -d "$HOME" ] ; then
USERLWRAP=yes
fi
fi
# check arguments for appropriate settings:
for i in $* ; do
case $i in
--help | -h | -\? ) USECPM=no ;;
--version | -V ) USECPM=no ;;
--numeric-version | --compiler-name | --base-version ) USECPM=no ;;
--nocypm ) USECPM=no ;;
--noreadline ) USERLWRAP=no
esac
done
if [ ! -x "$REPL" ] ; then
echo "ERROR: executable '$REPL' not found!" >&2
echo "Run: cd $CURRYHOME && make" >&2
exit 1
fi
if [ $USECPM = yes ] ; then
# set CURRYPATH with 'deps' command of CPM
echo "Compute CURRYPATH with '$CYPMBIN'..."
CPMPATH=`"$CYPMBIN" -v quiet -d CURRYBIN="$REPL" deps -p`
if [ $? -gt 0 ] ; then
echo $CPMPATH
exit 1
fi
if [ -n "$CURRYPATH" ] ; then
CURRYPATH=$CURRYPATH:$CPMPATH # keep existing CURRYPATH setting
else
CURRYPATH=$CPMPATH
fi
export CURRYPATH
fi
# do not use rlwrap inside emacs:
if [ "$TERM" = dumb ] ; then
USERLWRAP=no
fi
if [ $USERLWRAP = yes ] ; then
exec rlwrap -c "$REPL" ${1+"$@"}
else
exec "$REPL" ${1+"$@"}
fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment