# ----------------------------------------------------------------------------- #
-# $Id: Makefile,v 1.15 1999/11/01 02:41:04 andy Exp $ #
+# $Id: Makefile,v 1.16 1999/11/12 16:38:31 sewardj Exp $ #
# ----------------------------------------------------------------------------- #
TOP = ../..
LIB_DL=-ldl
endif
+ifeq "$(HaveLibReadLine)$" "YES"
+LIB_READLINE=-lreadline
+else
+LIB_READLINE=
+endif
+
YACC = bison -y
%.c: %.y
-$(YACC) $<
hugs: $(C_OBJS) ../rts/Sanity.o ../rts/Assembler.o ../rts/Disassembler.o \
../rts/Evaluator.o ../rts/ForeignCall.o ../rts/GC.o ../rts/Printer.o \
../rts/StgCRun.o
- $(CC) -o $@ $(CC_OPTS) $^ $(GHC_LIBS_NEEDED) -lbfd -liberty $(LIB_DL) -lm
+ $(CC) -o $@ $(CC_OPTS) $^ $(GHC_LIBS_NEEDED) -lreadline \
+ -lbfd -liberty $(LIB_READLINE) $(LIB_DL) -lm
nHandle.$(DYN_EXT): nHandle.c
ifeq "$(TARGETPLATFORM)" "i386-unknown-cygwin32"
* included in the distribution.
*
* $RCSfile: input.c,v $
- * $Revision: 1.10 $
- * $Date: 1999/10/26 17:27:39 $
+ * $Revision: 1.11 $
+ * $Date: 1999/11/12 16:38:31 $
* ------------------------------------------------------------------------*/
#include "prelude.h"
#include <windows.h>
#endif
-#if IS_WIN32 | HUGS_FOR_WINDOWS
+#if IS_WIN32 || HUGS_FOR_WINDOWS
#undef IN
#endif
+#if HAVE_LIBREADLINE && HAVE_READLINE_READLINE_H
+#define USE_READLINE 1
+#else
+#define USE_READLINE 0
+#endif
+
+#if USE_READLINE
+#include <readline/readline.h>
+#include <readline/history.h>
+#endif
+
+
/* --------------------------------------------------------------------------
* Global data:
* ------------------------------------------------------------------------*/
#define LARGE 0x04
#define SYMBOL 0x08
#define IDAFTER 0x10
-#define SPACE 0x20
+#define ZPACE 0x20
#define PRINT 0x40
static Void local initCharTab() { /* Initialize char decode table */
setChar (IDAFTER, '\''); /* Characters in identifier */
setCopy (IDAFTER, (DIGIT|SMALL|LARGE));
- setChar (SPACE, ' '); /* ASCII space character */
- setChar (SPACE, 160); /* ISO non breaking space */
- setRange(SPACE, 9,13); /* special whitespace: \t\n\v\f\r */
+ setChar (ZPACE, ' '); /* ASCII space character */
+ setChar (ZPACE, 160); /* ISO non breaking space */
+ setRange(ZPACE, 9,13); /* special whitespace: \t\n\v\f\r */
setChars(PRINT, "(),;[]_`{}"); /* Special characters */
setChars(PRINT, " '\""); /* Space and quotes */
static String nextChar;
#define nextConsoleChar() \
(unsigned char)(*nextChar=='\0' ? '\n' : *nextChar++)
-extern Void add_history Args((String));
-extern String readline Args((String));
#else
#define nextConsoleChar() getc(stdin)
#endif
if (s[i] != '\0') { /* check s `isPrefixOf` line */
return FALSE;
}
- while (isIn(line[i], SPACE)) { /* allow whitespace at end of line */
+ while (isIn(line[i], ZPACE)) { /* allow whitespace at end of line */
++i;
}
return (line[i] == '\0');
litLines++;
return;
}
- while (c0 != '\n' && isIn(c0,SPACE)) /* maybe line is blank? */
+ while (c0 != '\n' && isIn(c0,ZPACE)) /* maybe line is blank? */
skip();
if (c0=='\n' || c0==EOF)
thisLineIs(BLANKLINE);
ERRMSG(row) "Illegal escape sequence"
EEND;
}
- else if (isIn(c0,SPACE)) {
+ else if (isIn(c0,ZPACE)) {
if (isStrLit) {
skipGap();
return NIL;
newlineSkip();
else
skip();
- while (isISO(c0) && isIn(c0,SPACE));
+ while (isISO(c0) && isIn(c0,ZPACE));
if (c0!='\\') {
ERRMSG(row) "Missing `\\' terminating string literal gap"
EEND;
String t = s;
Char c;
while ((c = *t)!=0 && isISO(c)
- && isIn(c,PRINT) && c!='"' && !isIn(c,SPACE)) {
+ && isIn(c,PRINT) && c!='"' && !isIn(c,ZPACE)) {
t++;
}
if (*t) {
do { /* which is empty */
saveTokenChar(c0);
skip();
- } while (c0!=EOF && !isIn(c0,SPACE));
+ } while (c0!=EOF && !isIn(c0,ZPACE));
endToken();
for (; cmds->cmdString; ++cmds)
return 0;
startToken();
- while (c0!=EOF && !isIn(c0,SPACE)) {
+ while (c0!=EOF && !isIn(c0,ZPACE)) {
if (c0=='"') {
skip();
while (c0!=EOF && c0!='\"') {
return; /* report allows ... */
else if (c0=='\n')
newlineSkip();
- else if (isIn(c0,SPACE))
+ else if (isIn(c0,ZPACE))
skip();
else if (c0=='{' && c1=='-') { /* (potentially) nested comment */
Int nesting = 1;