There are still some known bugs in INTERCAL (and no doubt many we don't even
suspect as yet). The following list accumulates current bug reports and
-TO DO agenda items from the major INTERCAL hackers through version 0.10.
+TO DO agenda items from the major INTERCAL hackers through version 0.13.
ESR = Eric S. Raymond
SS = Steve Swales
relatively small gain, and anyone trying it should make sure
the result isn't buggier than the current version.
-5) (ESR) We can't use flex to generate the lexical analyzer. The
- frustrating thing is that it *almost* works; only some sources
- (including icat.i, pi.i and both life programs) fail. Looking
- at the parsing trace suggests that flex is returning something to
- yacc/bison that does not cause it to terminate as it should.
-
TO DO
1. (ESR) Add more optimization templates, esp. the idioms for &, |, ^, ~.
# Utility productions for the INTERCAL distribution
#
ick.tar:
- (cd ..; tar cvf ick.tar `cat intercal-0.12/MANIFEST`)
+ (cd ..; tar cvf ick.tar `cat intercal-0.13/MANIFEST`)
mv ../ick.tar .
ick.tar.Z: ick.tar
SHAROPTS = -l63 -n intercal -o intercal -a -s esr@snark.thyrsus.com
ick.shar:
- (cd ..; shar $(SHAROPTS) `cat intercal-0.12/MANIFEST` >ick.shar)
+ (cd ..; shar $(SHAROPTS) `cat intercal-0.13/MANIFEST` >ick.shar)
NEW IN THIS RELEASE
+ Release 0.13 (by Eric S. Raymond)
+
+1. I folded in patches by Brian Raiter <breadbox@muppetlabs.com> that port
+ this code to Linux and enable it to use flex. Note: This version has
+ been tested on Linux and SunOS but not yet elsewhere.
+
Release 0.12 (by Eric S. Raymond)
1. The code now compiles and runs under Linux, using bison and lex. It does
Release Notes for C-INTERCAL
- version 0.12
+ version 0.13
DISCREDITS
during a fit of lunacy from which he has since mostly recovered. It has
been considerably hacked upon and improved by Steve Swales, Michael Ernst,
Louis Howell (who wrote the array support stubbed out in Eric's original
-version), and others.
+version), and others. Brian Raiter ported it to Linux and enabled it to use
+flex.
You can surf to the latest version of this package, and related resources, from
http://www.ccil.org/~esr/home.html.
There's a -c option that leaves the generated `foo.c' in place for inspection
(suppressing compilation to machine code), a -d option that enables verbose
-parse reporting from the YACC parser, a -t option that requires strict
+parse reporting from the yacc/bison parser, a -t option that requires strict
INTERCAL-72 compliance (rejecting COME FROM and the extensions for bases other
than two) and an -O option that enables the (hah!) optimizer. Invoking ick -?
prints a usage message. Other than that, yer on yer own.
believe writing "IV" upside-down offends IVPITER and would rather
see IIII.
-Steve Swales added [+/-]help, [+/-]traditional, and [+/-]wimpmode options in
-the 0.6 release. The help option (with either + or -) triggers a 'usage'
-message.
-
-The +traditional option is presently a no-op.
+Every INTERCAL runtime also accepts certain options at runtime (code by
+Steve Swales). These include [+/-]help, [+/-]traditional, and [+/-]wimpmode.
+The help option (with either + or -) triggers a 'usage' message. The
++traditional option is presently a no-op.
Steve writes: "The wimpmode option is the most interesting. I found myself
always running my test programs with filters on both ends to work around the
SPREADING THE BLAME
The latest version of INTERCAL is kept available at the Retrocomputing Museun,
-ftp:locke.ccil.org:pub/retro.
+http://www.ccil.org/retro.
There is, in addition, an occasionally active USENET newsgroup devoted to the
language: alt.lang.intercal.
+ NOTES ON THE LINUX BUILD
+
+At the top of ick.h are two defines that you may need to remove if you
+are using lex instead of flex.
+
+Many lexes export a yylineno variable, an undocumented feature that is
+not in flex (by default). If your build fails because of redecleration
+of yylineno, comment out the define of YYLINENO_BY_HAND.
+
+Some lexes also supply a yyrestart function to begin parsing a second
+file, while others automatically restart after seeing an EOF. (This is
+the case with flex.) If your build fails at link time because
+yyrestart is not defined, comment out the define of USE_YYRESTART.
+
+If you are using gcc in an non-ANSI environment, such as SunOS, it is
+strongly recommended that you add "-Wno-unused -Wimplicit" to the gcc
+command in the makefile. If you are in an ANSI environment and are
+using the current versions of gcc, flex, and bison, C-INTERCAL should
+build with no warnings.
+
+
+
+
./sink
test:
- testcompile $(SOURCES)
+ for x in $(SOURCES); do echo "Test-compiling $$x"; ../src/ick $$x; done
lines:
wc -l $(SOURCES)
+++ /dev/null
-#
-# testcompile -- testcompile all named sources using ick:
-#
-for x in $*
-do
- echo "Test-compiling $x";
- ../src/ick $x;
-done
# all over creation behind your back.
# (/dev/null may be another good choice :-))
-DVMT=/home/esr/export/intercal-0.12
+DVMT=/home2/esr/WWW/intercal-0.13
BINDIR = $(DVMT)/bin
INCDIR = $(DVMT)/lib
#INCDIR = $(PWD)
#LIBDIR = $(PWD)
-# To cope with BSD's losing linker, comment the next line out
-NR = @echo "Real UNIXes don't need "
-
YDEBUG = -vlt
DEBUG = -g -DDEBUG
# DEBUG = -O
LDFLAGS =
# Warning: using flex does not work yet!
-LEX = lex
-#LEX = flex -l
+#LEX = lex
+LEX = flex
# However, you can use either yacc or bison
-YACC = yacc
-#YACC = bison -y
+#YACC = yacc
+YACC = bison -y
CSOURCES = ick.y lexer.l feh.c lose.c fiddle.c perpetrate.c
ISOURCES = cesspool.c arrgghh.c ick-wrap.c
-HEADERS = ick.h lose.h sizes.h
+HEADERS = ick.h lose.h sizes.h abcess.h fiddle.h feh.h
SOURCES = $(CSOURCES) $(ISOURCES) $(HEADERS)
all: ick libick.a
$(YACC) -d $(YDEBUG) ick.y
mv y.tab.c ick.c
-lexer.c: lexer.l
+lexer.c: lexer.l ick.h
$(LEX) $(LFLAGS) lexer.l
mv lex.yy.c lexer.c
lextest: y.tab.h lexer.c ick.h lose.o
$(CC) -DMAIN lexer.c lose.o $(LEXLIBS) -o lextest
-ick.o: ick.c ick.h lose.h sizes.h
-lexer.o: lexer.c y.tab.h ick.h
-feh.o: feh.c y.tab.h ick.h lose.h sizes.h
-perpetrate.o: perpetrate.c y.tab.h ick.h lose.h
-cesspool.o: cesspool.c numerals.c cesspool.h lose.h sizes.h
+ick.o: ick.c ick.h feh.h lose.h sizes.h
+lexer.o: lexer.c y.tab.h ick.h lose.h
+feh.o: feh.c feh.h y.tab.h ick.h fiddle.h lose.h sizes.h
+perpetrate.o: perpetrate.c y.tab.h ick.h lose.h sizes.h
+cesspool.o: cesspool.c numerals.c abcess.h lose.h sizes.h
lose.o: lose.h
-fiddle.o: sizes.h
+fiddle.o: fiddle.h sizes.h
libick.a: cesspool.o lose.o fiddle.o arrgghh.o
ar cr libick.a cesspool.o lose.o fiddle.o arrgghh.o
- $(NR) ranlib libick.a
+ -ranlib libick.a
install: all
cp ick $(BINDIR)
- cp lose.h cesspool.h ick-wrap.c $(INCDIR)
+ cp lose.h abcess.h fiddle.h ick-wrap.c $(INCDIR)
cp libick.a ../pit/lib/syslib.i $(LIBDIR)
- $(NR) ranlib $(LIBDIR)/libick.a
+ -ranlib $(LIBDIR)/libick.a
clean:
rm -f yacc.* y.tab.* y.output *~ *.[oa] lexer.c ick.c lextest ick
TAGS: $(SOURCES)
etags $(SOURCES)
-
--- /dev/null
+/* abcess.h -- functions used by compiled INTERCAL programs */
+
+typedef int bool;
+#define TRUE 1
+#define FALSE 0
+
+#define ONESPOT 0
+#define TWOSPOT 1
+#define TAIL 2
+#define HYBRID 3
+
+/* the following two types must both promote to unsigned int in expressions */
+
+typedef unsigned short type16;
+typedef unsigned int type32;
+
+typedef struct array_t
+{
+ unsigned int rank;
+ unsigned int *dims;
+ union
+ {
+ type16 *tail;
+ type32 *hybrid;
+ } data;
+} array;
+
+/* defined in cesspool.c */
+extern void pushnext(int n);
+extern unsigned int popnext(int n);
+extern unsigned int resume(unsigned int n);
+extern unsigned int pin(void);
+extern void clockface(bool mode);
+extern void pout(unsigned int val);
+extern void binin(unsigned int type, array *a, bool forget);
+extern void binout(unsigned int type, array *a);
+extern unsigned int assign(char *dest, unsigned int type, bool forget,
+ unsigned int value);
+extern char *aref();
+extern void resize();
+extern void stashinit(void);
+extern void stash(unsigned int type, unsigned int index, void *from);
+extern void retrieve(void *to, int type, unsigned int index, bool forget);
+extern unsigned int roll(unsigned int n);
+
+/* defined in arrgghh.c */
+extern void parseargs(int argc, char **argv);
+
+/* abcess.h ends here */
* PURPOSE: Parse arguments for INTERCAL programs.
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "abcess.h"
#include "lose.h"
-int traditional = 1;
+int traditional = 0;
int wimp_mode = 0;
void
-parseargs(argc,argv)
-int argc;
-char **argv;
+parseargs(int argc, char **argv)
{
register int i, j;
static int helpflag = -1;
&wimp_mode,
&traditional
};
- static nflags = (sizeof(flags)/sizeof(flags[0]));
+ static int nflags = (int)(sizeof(flags)/sizeof(flags[0]));
for(i = 1;i < argc;i++) {
if(argv[i][0] != '+' && argv[i][0] != '-') {
/* cesspool.c -- storage management and runtime support for INTERCAL */
/* LINTLIBRARY */
#include <stdio.h>
+#include <stdlib.h>
#include <varargs.h>
#include "sizes.h"
-#include "cesspool.h"
+#include "abcess.h"
#include "lose.h"
#include "numerals.c"
int next[MAXNEXT];
int nextindex = 0;
-void pushnext(n)
-int n;
+void pushnext(int n)
{
if (nextindex < MAXNEXT)
next[nextindex++] = n;
lose(E123, lineno, (char *)NULL);
}
-unsigned int popnext(n)
-int n;
+unsigned int popnext(int n)
{
nextindex -= n;
if (nextindex < 0) {
nextindex = 0;
- return(-1);
+ return (unsigned int)-1;
}
return(next[nextindex]);
}
-unsigned int resume(n)
-unsigned int n;
+unsigned int resume(unsigned int n)
{
if (n == 0)
+ {
lose(E621, lineno, (char *)NULL);
- else if ((n = popnext(n)) == -1)
+ return 0;
+ }
+ else if ((n = popnext(n)) == (unsigned int)-1)
+ {
lose(E632, lineno, (char *)NULL);
- else
- return(n);
+ return 0;
+ }
+ return(n);
}
/**********************************************************************
*
*********************************************************************/
-unsigned int pin()
+unsigned int pin(void)
{
char buf[BUFSIZ], *cp, *strtok();
unsigned int result = 0;
if (digit == -1)
lose(E579, lineno, cp);
- if (result < 429496729 || result == 429496729 && digit < 6)
+ if (result < 429496729 || (result == 429496729 && digit < 6))
result = result * 10 + digit;
else
lose(E533, lineno, (char *)NULL);
}
if (!n)
lose(E562, lineno, (char *)NULL);
- if (result > Max_large)
+ if (result > (unsigned int)Max_large)
lose(E533, lineno, (char *)NULL);
return(result);
}
* 11/24/91 LHH: Removed unnecessary final newline.
*/
-static void butcher(val, result)
-unsigned long val;
-char *result;
+static void butcher(unsigned long val, char *result)
{
int i, j;
int digitsig, digitval;
}
j = i;
- while (*result++ = ovb[j++])
+ while ((*result++ = ovb[j++]))
continue;
*--result = '\n';
j = i;
- while (*++result = res[j++])
+ while ((*++result = res[j++]))
continue;
/* Final newline will be added by puts.
*result++ = '\n';
}
}
-void clockface(mode)
+void clockface(bool mode)
/* enable or disable clockface mode (output IIII instead of IV) */
-bool mode;
{
if (mode)
{
}
}
-void pout(val)
+void pout(unsigned int val)
/* output in `butchered' Roman numerals; see manual, part 4.4.13 */
-unsigned int val;
{
char result[2*MAXROMANS+1];
extern int wimp_mode;
if(wimp_mode) {
- printf("%d\n",val);
+ printf("%u\n",val);
}
else {
butcher(val, result);
*
*********************************************************************/
-void binin(type,a,forget)
-unsigned int type;
-array *a;
-bool forget;
+void binin(unsigned int type, array *a, bool forget)
{
- static unsigned lastin = 0;
- int i, c, v;
+ static unsigned int lastin = 0;
+ int c, v;
+ unsigned int i;
if (a->rank != 1)
lose(E241, lineno, (char *)NULL);
}
}
-void binout(type,a)
-unsigned int type;
-array *a;
+void binout(unsigned int type, array *a)
{
- static unsigned lastout = 0;
- unsigned c;
- int i;
+ static unsigned int lastout = 0;
+ unsigned int i, c;
if (a->rank != 1)
lose(E241, lineno, (char *)NULL);
*
*********************************************************************/
-unsigned int assign(dest,type,forget,value)
-char *dest;
-unsigned int type, value;
-bool forget;
+unsigned int assign(char *dest, unsigned int type, bool forget,
+ unsigned int value)
{
unsigned int retval;
if (type == ONESPOT || type == TAIL) {
- if (value > Max_small)
+ if (value > (unsigned int)Max_small)
lose(E275, lineno, (char *)NULL);
if (forget)
retval = value;
array *a;
unsigned int v;
va_list ap;
- int i, address = 0;
+ int address = 0;
+ unsigned int i;
va_start(ap);
type = va_arg(ap, unsigned int);
unsigned int type;
array *a;
bool forget;
- unsigned int r, v;
+ unsigned int i, r, v;
va_list ap;
- int i, prod = 1;
+ int prod = 1;
va_start(ap);
type = va_arg(ap, unsigned int);
typedef struct stashbox_t /* this is a save-stack element */
{
- int type; /* variable type */
- int index; /* variable's index within the type */
+ unsigned int type; /* variable type */
+ unsigned int index; /* variable's index within the type */
union /* the data itself */
{
type16 onespot;
static stashbox *first;
-void stashinit()
+void stashinit(void)
{
first = NULL;
}
-static stashbox *fetch(type, index)
+static stashbox *fetch(unsigned int type, unsigned int index)
/* find a stashed variable in the save stack and extract it */
-unsigned int type, index;
{
stashbox **pp = &first, *sp = first;
return (sp);
}
-void stash(type, index, from)
+void stash(unsigned int type, unsigned int index, void *from)
/* stash away the variable's value */
-char *from;
-unsigned int type, index;
{
/* create a new stashbox and push it onto the stack */
stashbox *sp = (stashbox*)malloc(sizeof(stashbox));
memcpy((char *)&sp->save.onespot, from, sizeof(type16));
else if (type == TWOSPOT)
memcpy((char *)&sp->save.twospot, from, sizeof(type32));
- else if (type == TAIL | type == HYBRID) {
+ else if (type == TAIL || type == HYBRID) {
array *a = (array*)from;
- int i, prod;
+ int prod;
+ unsigned int i;
sp->save.a = (array*)malloc(sizeof(array));
if (sp->save.a == NULL) lose(E222, lineno, (char *)NULL);
sp->save.a->rank = a->rank;
return;
}
-void retrieve(to, type, index, forget)
+void retrieve(void *to, int type, unsigned int index, bool forget)
/* restore the value of a variable from the save stack */
-char *to;
-unsigned int type, index;
-bool forget;
{
stashbox *sp;
memcpy(to, (char *)&sp->save.onespot, sizeof(type16));
else if (type == TWOSPOT)
memcpy(to, (char *)&sp->save.twospot, sizeof(type32));
- else if (type == TAIL | type == HYBRID) {
+ else if (type == TAIL || type == HYBRID) {
array *a = (array*)to;
if (a->rank) {
free(a->dims);
free(sp->save.a);
}
}
- else if (type == TAIL | type == HYBRID) {
+ else if (type == TAIL || type == HYBRID) {
free(sp->save.a->dims);
if (type == TAIL)
free(sp->save.a->data.tail);
*
*********************************************************************/
-unsigned int roll(n)
+unsigned int roll(unsigned int n)
/* return TRUE on n% chance, FALSE otherwise */
-unsigned int n;
{
#ifdef USG
- return(lrand48() % 100 < n);
+ return((unsigned int)(lrand48() % 100) < n);
#else
- return(rand() % 100 < n);
+ return((unsigned int)(rand() % 100) < n);
#endif /* UNIX */
}
+++ /dev/null
-/* cesspool.h -- interface to INTERCAL storage manager and runtime support */
-
-#include <malloc.h>
-
-typedef int bool;
-#define TRUE 1
-#define FALSE 0
-
-extern char *aref();
-extern unsigned int aget(), pin(), roll(), popnext(), resume(), assign();
-extern void pushnext(), resize(), stashinit(), stash(), retrieve(), aput();
-extern void clockface(), pout();
-
-extern int lineno;
-
-#define ONESPOT 0
-#define TWOSPOT 1
-#define TAIL 2
-#define HYBRID 3
-
-/* the following two types must both promote to unsigned int in expressions */
-
-typedef unsigned short type16;
-typedef unsigned int type32;
-
-typedef struct array_t
-{
- int rank;
- unsigned int *dims;
- union
- {
- type16 *tail;
- type32 *hybrid;
- } data;
-} array;
-
-typedef struct
-{
- char *name;
- int value;
-}
-numeral;
-
-extern numeral numerals[];
-
-/* cesspool.h ends here */
****************************************************************************/
/*LINTLIBRARY */
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include "sizes.h"
#include "ick.h"
#include "y.tab.h"
+#include "fiddle.h"
#include "lose.h"
-
-int yyerror()
-{
- /* lose(E017, yylineno, (char *)NULL); */
-}
+#include "feh.h"
/*************************************************************************
*
*
**************************************************************************/
-node *newnode()
+node *newnode(void)
/* allocate and zero out a new expression node */
{
return((node *)calloc(sizeof(node), 1));
}
-node *cons(type, car, cdr)
-int type;
-node *car, *cdr;
+node *cons(int type, node *car, node *cdr)
{
node *np = newnode();
*
**************************************************************************/
-unsigned int intern(type, index)
+unsigned int intern(int type, int index)
{
atom *x;
*
**************************************************************************/
-void treset()
+void treset(void)
{
memset(tuples, '\0', sizeof(tuple) * MAXLINES);
nonespots = ntwospots = ntails = nhybrids = 0;
lineno = 0;
}
-tuple *newtuple()
+tuple *newtuple(void)
/* allocate and zero out a new expression tuple */
{
if (lineno >= MAXLINES)
+ {
lose(E666, yylineno, (char *)NULL);
+ return NULL;
+ }
else
return(tuples + lineno++);
}
*
**************************************************************************/
-void typecast(np)
-node *np;
+void typecast(node *np)
{
/* recurse so we typecast each node after all its subnodes */
if (np == (node *)NULL)
*
**************************************************************************/
-void codecheck()
+void codecheck(void)
{
tuple *tp, *up;
#define ISCONSTANT(np, v) ((np->opcode == MESH || np->opcode == MESH32) && np->constant == v)
-void rfree(np)
+static void rfree(node *np)
/* recursively free the given node and all nodes underneath */
-node *np;
{
if (np->lval != (node *)NULL)
rfree(np->lval);
free(np);
}
-int requal(mp, np)
+static int requal(node *mp, node *np)
/* do two node trees represent the same expression? */
-node *mp, *np;
{
if (mp == (node *)NULL && np == (node *)NULL)
return(TRUE);
return(TRUE);
}
-void optimize(np)
-node *np;
+void optimize(node *np)
{
/* recurse so we simplify each node after all its subnodes */
if (np == (node *)NULL)
if (np->opcode == AND && np->rval->opcode == MESH)
{
np->opcode = MESH;
- np->constant = and16(np->lval->constant, np->rval->constant);
+ np->constant = and16(np->lval->constant);
free(np->rval);
}
if (np->opcode == OR && np->rval->opcode == MESH)
{
np->opcode = MESH;
- np->constant = or16(np->lval->constant, np->rval->constant);
+ np->constant = or16(np->lval->constant);
free(np->rval);
}
if (np->opcode == XOR && np->rval->opcode == MESH)
{
np->opcode = MESH;
- np->constant = xor16(np->lval->constant, np->rval->constant);
+ np->constant = xor16(np->lval->constant);
free(np->rval);
}
}
assoc vartypes[] =
{
- ONESPOT, "ONESPOT",
- TWOSPOT, "TWOSPOT",
- TAIL, "TAIL",
- HYBRID, "HYBRID",
- 0, (char *)NULL
+ { ONESPOT, "ONESPOT" },
+ { TWOSPOT, "TWOSPOT" },
+ { TAIL, "TAIL" },
+ { HYBRID, "HYBRID" },
+ { 0, (char *)NULL }
};
-assoc forgetbits[] =
+static assoc forgetbits[] =
{
- ONESPOT, "oneforget",
- TWOSPOT, "twoforget",
- TAIL, "tailforget",
- HYBRID, "hyforget",
- 0, (char *)NULL
+ { ONESPOT, "oneforget" },
+ { TWOSPOT, "twoforget" },
+ { TAIL, "tailforget" },
+ { HYBRID, "hyforget" },
+ { 0, (char *)NULL }
};
-assoc varstores[] =
+static assoc varstores[] =
{
- ONESPOT, "onespots",
- TWOSPOT, "twospots",
- TAIL, "tails",
- HYBRID, "hybrids",
- 0, (char *)NULL
+ { ONESPOT, "onespots" },
+ { TWOSPOT, "twospots" },
+ { TAIL, "tails" },
+ { HYBRID, "hybrids" },
+ { 0, (char *)NULL }
};
-assoc typedefs[] =
+static assoc typedefs[] =
{
- ONESPOT, "type16",
- TWOSPOT, "type32",
- TAIL, "type16",
- HYBRID, "type32",
- 0, (char *)NULL
+ { ONESPOT, "type16" },
+ { TWOSPOT, "type32" },
+ { TAIL, "type16" },
+ { HYBRID, "type32" },
+ { 0, (char *)NULL }
};
-char *nameof(value, table)
+char *nameof(int value, assoc table[])
/* return string corresponding to value in table */
-int value;
-assoc table[];
{
assoc *ap;
return((char *)NULL);
}
-void prvar(np, fp)
+static void prexpr(node *np, FILE *fp);
+
+static void prvar(node *np, FILE *fp)
/* print out args to pass to storage manager for reference */
-node *np;
-FILE *fp;
{
node *sp;
int dim;
switch (np->opcode)
{
case ONESPOT:
- (void) fprintf(fp, "onespots[%d]", np->constant);
+ (void) fprintf(fp, "onespots[%lu]", np->constant);
break;
case TWOSPOT:
- (void) fprintf(fp, "twospots[%d]", np->constant);
+ (void) fprintf(fp, "twospots[%lu]", np->constant);
break;
case TAIL:
- (void) fprintf(fp, "TAIL, &tails[%d]", np->constant);
+ (void) fprintf(fp, "TAIL, &tails[%lu]", np->constant);
break;
case HYBRID:
- (void) fprintf(fp, "HYBRID, &hybrids[%d]", np->constant);
+ (void) fprintf(fp, "HYBRID, &hybrids[%lu]", np->constant);
break;
case SUB:
{
- void prexpr();
- node *sp;
-
(void) fprintf(fp, "aref(");
prvar(np->lval, fp);
}
}
-void prexpr(np, fp)
+static void prexpr(node *np, FILE *fp)
/* print out C-function equivalent of an expression */
-FILE *fp;
-node *np;
{
switch (np->opcode)
{
break;
case MESH:
- (void) fprintf(fp, "0x%x", np->constant);
+ (void) fprintf(fp, "0x%lx", np->constant);
break;
case MESH32:
(void) free(np);
}
-char *nice_text(text)
-char *text;
+static char *nice_text(char *text)
{
#define MAXNICEBUF 512
static char buf[MAXNICEBUF];
return buf;
}
-void emit(tn, fp)
+void emit(tuple *tn, FILE *fp)
/* emit code for the given tuple */
-tuple *tn;
-FILE *fp;
{
node *np, *sp;
int dim;
- char *name;
static int make_cf_target = 0;
if (yydebug || compile_only)
}
prvar(np->lval, fp);
(void) fprintf(fp,", %s", nameof(sp->opcode, vartypes));
- (void) fprintf(fp,", %s[%d], ", nameof(sp->opcode, forgetbits),
+ (void) fprintf(fp,", %s[%lu], ", nameof(sp->opcode, forgetbits),
sp->constant);
prexpr(np->rval, fp);
(void) fprintf(fp,");\n");
dim++;
(void) fprintf(fp, "\tresize(");
prvar(np->lval, fp);
- (void) fprintf(fp, ", %s[%d]", nameof(np->lval->opcode, forgetbits),
+ (void) fprintf(fp, ", %s[%lu]", nameof(np->lval->opcode, forgetbits),
np->lval->constant);
(void) fprintf(fp, ", %d", dim);
for (sp = np->rval; sp; sp = sp->rval) {
case STASH:
for (np = tn->u.node; np; np = np->rval)
- (void) fprintf(fp, "\tstash(%s, %d, %s+%d);\n",
+ (void) fprintf(fp, "\tstash(%s, %lu, %s+%lu);\n",
nameof(np->opcode, vartypes),
np->constant,
nameof(np->opcode, varstores), np->constant);
case RETRIEVE:
for (np = tn->u.node; np; np = np->rval)
- (void) fprintf(fp, "\tretrieve(%s+%d, %s, %d, %s[%d]);\n",
+ (void) fprintf(fp, "\tretrieve(%s+%lu, %s, %lu, %s[%lu]);\n",
nameof(np->opcode, varstores), np->constant,
nameof(np->opcode, vartypes),
np->constant,
case IGNORE:
for (np = tn->u.node; np; np = np->rval)
- (void) fprintf(fp,"\t%s[%d] = TRUE;\n",
+ (void) fprintf(fp,"\t%s[%lu] = TRUE;\n",
nameof(np->opcode, forgetbits),
np->constant);
break;
case REMEMBER:
for (np = tn->u.node; np; np = np->rval)
- (void) fprintf(fp,"\t%s[%d] = FALSE;\n",
+ (void) fprintf(fp,"\t%s[%lu] = FALSE;\n",
nameof(np->opcode, forgetbits),
np->constant);
break;
for (np = tn->u.node; np; np = np->rval)
{
(void) fprintf(fp,
- "\tint i;\n\n\tfor (i = 0; i < sizeof(linetype)/sizeof(int); i++)\n");
+ "\tint i;\n\n\tfor (i = 0; i < (int)(sizeof(linetype)/sizeof(int)); i++)\n");
(void) fprintf(fp,
"\t if (linetype[i] == %s)\n", enablers[np->constant-GETS]);
(void) fprintf(fp,
for (np = tn->u.node; np; np = np->rval)
{
(void) fprintf(fp,
- "\tint i;\n\n\tfor (i = 0; i < sizeof(linetype)/sizeof(int); i++)\n");
+ "\tint i;\n\n\tfor (i = 0; i < (int)(sizeof(linetype)/sizeof(int)); i++)\n");
(void) fprintf(fp,
"\t if (linetype[i] == %s)\n", enablers[np->constant-GETS]);
(void) fprintf(fp,
if (np->lval->opcode == TAIL || np->lval->opcode == HYBRID) {
(void) fprintf(fp,"\tbinin(");
prvar(np->lval, fp);
- (void) fprintf(fp, ", %s[%d]",
+ (void) fprintf(fp, ", %s[%lu]",
nameof(np->lval->opcode, forgetbits),
np->lval->constant);
(void) fprintf(fp,");\n");
}
prvar(np->lval, fp);
(void) fprintf(fp,", %s", nameof(sp->opcode, vartypes));
- (void) fprintf(fp,", %s[%d]", nameof(sp->opcode, forgetbits),
+ (void) fprintf(fp,", %s[%lu]", nameof(sp->opcode, forgetbits),
sp->constant);
(void) fprintf(fp,", pin());\n");
}
fprintf(stderr,"compiling a splat... line = %d (%s)\n",
tn->lineno,textlines[tn->lineno]);
*/
- (void) fprintf(fp,"\t(void) puts(\"%s\");\n",
+ (void) fprintf(fp,"\t(void) puts(\"*%s\");\n",
nice_text(textlines[tn->lineno]));
(void) fprintf(fp,
"\texit(%d);\n", tn->lineno);
--- /dev/null
+/* feh.h -- compilation functions used by perpetrate.c and ick.y */
+
+extern node *newnode(void);
+extern node *cons(int type, node *car, node *cdr);
+extern unsigned int intern(int type, int index);
+extern void treset(void);
+extern tuple *newtuple(void);
+extern void typecast(node *np);
+extern void codecheck(void);
+extern void optimize(node *np);
+extern char *nameof(int value, assoc table[]);
+extern void emit(tuple *tn, FILE *fp);
+
+extern char *enablers[MAXTYPES];
+extern assoc vartypes[];
+
+/* feh.h ends here */
* We link these to the compiler, too, in order to do constant folding
*/
+#include "fiddle.h"
#include "sizes.h"
-unsigned int mingle(r, s)
-register unsigned int r, s;
+unsigned int mingle(register unsigned int r, register unsigned int s)
{
if (Base == 2) {
r = ((r & 0x0000ff00) << 8) | (r & 0x000000ff);
return (r << 1) | s;
}
else {
- unsigned int i, result = 0, fac = 1;
+ unsigned int result = 0, fac = 1;
+ int i;
for (i = 0 ; i < Small_digits ; i++) {
result += fac * (s % Base);
s /= Base;
}
}
-unsigned int iselect(r, s)
-register unsigned int r, s;
+unsigned int iselect(register unsigned int r, register unsigned int s)
{
if (Base == 2) {
register unsigned int i = 1, t = 0;
return(t);
}
else {
- unsigned int i, j, result = 0, fac, digit, ofac = 1;
+ unsigned int j, result = 0, fac, digit, ofac = 1;
for (j = Base - 1 ; j > 0 ; j--) {
+ int i;
fac = 1;
for (i = 0; i < Large_digits ; i++) {
if ((s / fac) % Base == j) {
}
}
-unsigned int whirl(len,p,n)
-unsigned int len,p,n;
+static unsigned int whirl(unsigned int len, unsigned int p, unsigned int n)
{
unsigned int i, fac = 1, result = 0, d1, d2, dsave;
d1 = n % Base;
return result;
}
-unsigned int and16(n)
-unsigned int n;
+unsigned int and16(unsigned int n)
{
if (Base == 2) {
unsigned int m = (n >> 1);
}
}
-unsigned int or16(n)
-unsigned int n;
+unsigned int or16(unsigned int n)
{
if (Base == 2) {
unsigned int m = (n >> 1);
}
}
-unsigned int whirl16(p,n)
-unsigned int p,n;
+unsigned int whirl16(unsigned int p, unsigned int n)
{
return whirl(Small_digits,p,n);
}
-unsigned int and32(n)
-unsigned int n;
+unsigned int and32(unsigned int n)
{
if (Base == 2) {
unsigned int m = (n >> 1);
}
}
-unsigned int or32(n)
-unsigned int n;
+unsigned int or32(unsigned int n)
{
if (Base == 2) {
unsigned int m = (n >> 1);
}
}
-unsigned int whirl32(p,n)
-unsigned int p,n;
+unsigned int whirl32(unsigned int p, unsigned int n)
{
return whirl(Large_digits,p,n);
}
-unsigned int xor(len,n)
-unsigned int len,n;
+unsigned int xor(unsigned int len, unsigned int n)
{
unsigned int i, fac = 1, result = 0, d1, d2, dsave;
d1 = n % Base;
return result;
}
-unsigned int xor16(n)
-unsigned int n;
+unsigned int xor16(unsigned int n)
{
if (Base == 2) {
unsigned int m = (n >> 1);
}
}
-unsigned int xor32(n)
-unsigned int n;
+unsigned int xor32(unsigned int n)
{
if (Base == 2) {
unsigned int m = (n >> 1);
}
}
-unsigned int fin(len,n)
-unsigned int len,n;
+static unsigned int fin(unsigned int len, unsigned int n)
{
unsigned int i, fac = 1, result = 0, d1, d2, dsave;
d1 = n % Base;
return result;
}
-unsigned int fin16(n)
-unsigned int n;
+unsigned int fin16(unsigned int n)
{
if (Base == 2) {
unsigned int m = (n >> 1);
}
}
-unsigned int fin32(n)
-unsigned int n;
+unsigned int fin32(unsigned int n)
{
if (Base == 2) {
unsigned int m = (n >> 1);
--- /dev/null
+/* fiddle.h -- functions implementing intercal's operators */
+
+extern unsigned int mingle(register unsigned int r, register unsigned int s);
+extern unsigned int iselect(register unsigned int r, register unsigned int s);
+extern unsigned int and16(unsigned int n), or16(unsigned int n),
+ xor16(unsigned int n), fin16(unsigned int n);
+extern unsigned int whirl16(unsigned int p, unsigned int n);
+extern unsigned int and32(unsigned int n), or32(unsigned int n),
+ xor32(unsigned int n), fin32(unsigned int n);
+extern unsigned int whirl32(unsigned int p, unsigned int n);
+
+/* fiddle.h ends here */
/* $A.c -- generated C-code file for INTERCAL program $A.i */
-#include <cesspool.h>
-#include <lose.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
-extern unsigned int mingle(), iselect();
-extern unsigned int and16(), or16(), xor16(), and32(), or32(), xor32();
-extern unsigned int whirl16(), whirl32(), fin16(), fin32();
+#include <fiddle.h>
+#include <abcess.h>
+#include <lose.h>
int lineno;
$D
$E
-main(argc,argv)
-int argc;
-char **argv;
+int main(int argc, char *argv[])
{
int skipto = 0;
{
$H
}
+
+ return 0;
}
/* Generated code for $A.i ends here */
/* ick.h -- compilation types for intercal parser */
+/* Comment this out if your version of lex automatically supplies yylineno. */
+#define YYLINENO_BY_HAND
+
+/* Comment this out if your version of lex doesn't use yyrestart(). */
+#define USE_YYRESTART
+
typedef int bool;
#define TRUE 1
#define FALSE 0
extern char *textlines[MAXLINES];
extern int yylineno;
-extern unsigned int mingle(), iselect();
-extern unsigned int and16(), or16(), xor16(), and32(), or32(), xor32();
-extern unsigned int whirl16(), whirl32(), fin16(), fin32();
-
-extern int yydebug;
-extern int yylineno;
-extern int politesse;
-
/* compilation options */
extern bool compile_only; /* just compile into C, don't run the linker */
+extern int yydebug; /* print debugging information while parsing */
+extern int traditional; /* compile as INTERCAL-72 */
-extern int lineno; /* current source line number; lose() uses it */
+extern int politesse;
/* ick.h ends here */
#include <stdio.h>
#include "sizes.h"
#include "ick.h"
+#include "feh.h"
#include "lose.h"
-#define yylex() lexer()
+extern int yyerror(char*);
-extern node *newnode(), *cons();
-extern tuple *newtuple();
-extern unsigned int intern();
-extern int yylineno, traditional;
+/* Intervene our first-stage lexer. */
+extern int lexer(void);
+#define yylex() lexer()
static node *rlist; /* pointer to current right-hand node list */
-static node *llist; /* pointer to current left-hand node list */
+/* static node *llist; */ /* pointer to current left-hand node list */
static node *np; /* variable for building node lists */
#define ACTION(x, nt, nn) {x = newtuple(); x->type = nt; x->u.node=nn;}
#define TARGET(x, nt, nn) {x = newtuple(); x->type = nt; x->u.target=nn;}
#define NEWFANGLED if (traditional) lose(E111,yylineno,(char*)NULL); else
+
+static tuple *splat(void);
+
%}
%start program
constant: MESH NUMBER
{
/* enforce the 16-bit constant constraint */
- if ($2 > Max_small)
+ if ((unsigned int)$2 > Max_small)
lose(E017, yylineno, (char *)NULL);
$$ = newnode();
$$->opcode = MESH;
$$->rval->opcode = $1;
if($1 == MESH) {
/* enforce the 16-bit constant constraint */
- if ($3 > Max_small)
+ if ((unsigned int)$3 > Max_small)
lose(E017, yylineno, (char *)NULL);
$$->rval->constant = $3;
}
%%
-tuple *splat()
+static tuple *splat(void)
/* try to recover from an invalid statement. */
{
- extern FILE *yyin;
- tuple *sp;
+ tuple *sp;
int tok, i, lineno;
extern bool re_send_token;
%{
#include <stdio.h>
+#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <memory.h>
#include "y.tab.h"
#include "lose.h"
-#ifdef YYLINENO_BY_HAND
-int yylineno = 1;
-#endif /* YYLINENO_BY_HAND */
+#define YY_NO_UNPUT
+
+#ifndef yywrap
+static int yywrap(void)
+{
+ return 1;
+}
+#endif /* yywrap */
+
+#ifdef YYLINENO_BY_HAND
+int yylineno = 1;
+#endif /* YYLINENO_BY_HAND */
#ifdef MAIN
YYSTYPE yylval;
char *textlines[MAXLINES];
int politesse = 0;
+#ifdef FLEX_SCANNER
+static char linebuf[YY_BUF_SIZE];
+#else /* FLEX_SCANNER */
static char linebuf[YYLMAX];
+#endif /* FLEX_SCANNER */
+
static char *lineptr = linebuf;
bool re_send_token = FALSE;
-int lexer()
-{
- static int tok = BADCHAR;
-
- if (re_send_token)
- re_send_token = FALSE;
- else
- {
- tok = yylex();
-#ifdef YYDEBUG
- if (yydebug)
- (void) (void) fprintf(stdout, "yylex: returning token %d\n", tok);
-#endif /* YYDEBUG */
- }
-
-#ifdef YYDEBUG
- if (yydebug)
- (void) (void) fprintf(stdout, "lexer: returning token %d\n", tok);
-#endif /* YYDEBUG */
- return(tok);
-}
-
-int myatoi(text)
-char *text;
-{
-#define MAXTEXT 100
- static char buf[MAXTEXT];
- register int i;
-
- for(buf[i = 0] = '\0';*text && i < MAXTEXT;text++) {
- if(isdigit(*text)) {
- buf[i++] = *text;
- }
- }
- buf[i] = '\0';
- return atoi(buf);
-}
+int lexer(void);
+static int myatoi(char *text);
/*
* The spectacular ugliness of INTERCAL syntax requires that the lexical
*/
#undef getc
-int getc(fp)
-FILE *fp;
+int getc(FILE *fp)
{
+ extern FILE* yyin;
+
static bool bangflag = FALSE;
static bool backflag = FALSE;
}
else
{
+#ifdef ACCEPT_LOWERCASE
if (islower(c))
c = toupper(c);
+#endif /* ACCEPT_LOWERCASE */
return(*lineptr++ = c);
}
}
}
+/* replace YY_INPUT so that it uses our getc function. */
+#undef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ { \
+ int c = getc(yyin); \
+ if (c == EOF) { \
+ if (ferror(yyin)) \
+ YY_FATAL_ERROR("input in flex scanner failed"); \
+ result = YY_NULL; \
+ } else { \
+ buf[0] = c; \
+ result = 1; \
+ } \
+ }
+
%}
W [\ \t\n]*
%%
-#ifdef MAIN
-int yyerror()
+int lexer(void)
+{
+ static int tok = BADCHAR;
+
+ if (re_send_token)
+ re_send_token = FALSE;
+ else
+ {
+ tok = yylex();
+#ifdef YYDEBUG
+ if (yydebug)
+ (void) fprintf(stdout, "yylex: returning token %d\n", tok);
+#endif /* YYDEBUG */
+ }
+
+#ifdef YYDEBUG
+ if (yydebug)
+ (void) fprintf(stdout, "lexer: returning token %d\n", tok);
+#endif /* YYDEBUG */
+ return(tok);
+}
+
+static int myatoi(char *text)
{
- (void) printf("lextest: lexer error.\n");
+#define MAXTEXT 100
+ static char buf[MAXTEXT];
+ register int i;
+
+ for(buf[i = 0] = '\0';*text && i < MAXTEXT;text++) {
+ if(isdigit(*text)) {
+ buf[i++] = *text;
+ }
+ }
+ buf[i] = '\0';
+ return atoi(buf);
+}
+
+void yyerror(char *errtype)
+{
+#ifdef MAIN
+ (void) printf("lextest: lexer error: %s.\n", errtype);
+#else /* MAIN */
+ /* lose(E017, yylineno, (char *)NULL); */
+ (void) errtype;
+#endif /* MAIN */
}
-main()
+#ifdef MAIN
+int main(void)
{
int t;
(void) printf("%03d %09d\n", t, yylval.numval);
yylval.numval = 0;
}
+ return 0;
}
#endif /* MAIN */
-
-int yywrap()
-{
- return(EOF);
-}
*/
/*LINTLIBRARY*/
#include <stdio.h>
+#include <stdlib.h>
+#include "lose.h"
-void lose(m, n, s)
-char *m;
-int n;
-char *s;
+void lose(char *m, int n, char *s)
{
(void) fprintf(stderr,
"ICL%c%c%cI\t",
-/* lose.h --- error message strings
+/* lose.h --- error message strings */
/*
* Note: these error message texts, with one exception, are direct from
#define E997 "997 ILLEGAL POSSESSION OF A CONTROLLED UNARY OPERATOR.\n\
ON THE WAY TO %d\n"
-extern void lose();
+extern int lineno;
+
+extern void lose(char *m, int n, char *s);
/* lose.h ends here */
* Nahuatl, Tagalog, Sanskrit, Basque, Georgian, Kwakiutl, and
* Volap\"uk are now supported in addition to English. */
-numeral numerals[] =
+typedef struct
+{
+ char *name;
+ int value;
+}
+numeral;
+
+static numeral numerals[] =
{
/* English */
- "OH", 0,
- "ZERO", 0,
- "ONE", 1,
- "TWO", 2,
- "THREE", 3,
- "FOUR", 4,
- "FIVE", 5,
- "SIX", 6,
- "SEVEN", 7,
- "EIGHT", 8,
- "NINE", 9,
- "NINER", 9, /* For all you junior birdmen */
+ { "OH", 0 },
+ { "ZERO", 0 },
+ { "ONE", 1 },
+ { "TWO", 2 },
+ { "THREE", 3 },
+ { "FOUR", 4 },
+ { "FIVE", 5 },
+ { "SIX", 6 },
+ { "SEVEN", 7 },
+ { "EIGHT", 8 },
+ { "NINE", 9 },
+ { "NINER", 9 }, /* For all you junior birdmen */
/* Sanskrit */
- "SUTYA", 0, /* Retroflex s, pronounced halfway to sh */
- "SHUTYA", 0,
- "EKA", 1,
- "DVI", 2,
- "TRI", 3,
- "CHATUR", 4,
- "PANCHAN", 5,
- "SHASH", 6,
- "SAPTAM", 7,
- "ASHTAN", 8,
- "NAVAN", 9,
+ { "SUTYA", 0 }, /* Retroflex s, pronounced halfway to sh */
+ { "SHUTYA", 0 },
+ { "EKA", 1 },
+ { "DVI", 2 },
+ { "TRI", 3 },
+ { "CHATUR", 4 },
+ { "PANCHAN", 5 },
+ { "SHASH", 6 },
+ { "SAPTAM", 7 },
+ { "ASHTAN", 8 },
+ { "NAVAN", 9 },
/* Basque */
- "ZEROA", 0,
- "BAT", 1,
- "BI", 2,
- "HIRO", 3,
- "LAU", 4,
- "BORTZ", 5,
- "SEI", 6,
- "ZAZPI", 7,
- "ZORTZI", 8,
- "BEDERATZI", 9,
+ { "ZEROA", 0 },
+ { "BAT", 1 },
+ { "BI", 2 },
+ { "HIRO", 3 },
+ { "LAU", 4 },
+ { "BORTZ", 5 },
+ { "SEI", 6 },
+ { "ZAZPI", 7 },
+ { "ZORTZI", 8 },
+ { "BEDERATZI", 9 },
/* Tagalog */
- "WALA", 0,
- "ISA", 1,
- "DALAWA", 2,
- "TATLO", 3,
- "APAT", 4,
- "LIMA", 5,
- "ANIM", 6,
- "PITO", 7,
- "WALO", 8,
- "SIYAM", 9,
+ { "WALA", 0 },
+ { "ISA", 1 },
+ { "DALAWA", 2 },
+ { "TATLO", 3 },
+ { "APAT", 4 },
+ { "LIMA", 5 },
+ { "ANIM", 6 },
+ { "PITO", 7 },
+ { "WALO", 8 },
+ { "SIYAM", 9 },
/* Classical Nahuatl */
- "AHTLE", 0, /* Actually `nothing'; no separate zero word is known */
- "CE", 1,
- "OME", 2,
- "IEI", 3,
- "NAUI", 4,
- "NACUILI", 5,
- "CHIQUACE", 6,
- "CHICOME", 7,
- "CHICUE", 8,
- "CHICUNAUI", 9,
+ { "AHTLE", 0 }, /* Actually `nothing'; no separate zero word is known */
+ { "CE", 1 },
+ { "OME", 2 },
+ { "IEI", 3 },
+ { "NAUI", 4 },
+ { "NACUILI", 5 },
+ { "CHIQUACE", 6 },
+ { "CHICOME", 7 },
+ { "CHICUE", 8 },
+ { "CHICUNAUI", 9 },
/* Georgian */
- "NULI", 0,
- "ERTI", 1,
- "ORI", 2,
- "SAMI", 3,
- "OTXI", 4,
- "XUTI", 5,
- "EKSVI", 6,
- "SHVIDI", 7,
- "RVA", 8,
- "CXRA", 9,
+ { "NULI", 0 },
+ { "ERTI", 1 },
+ { "ORI", 2 },
+ { "SAMI", 3 },
+ { "OTXI", 4 },
+ { "XUTI", 5 },
+ { "EKSVI", 6 },
+ { "SHVIDI", 7 },
+ { "RVA", 8 },
+ { "CXRA", 9 },
/* Kwakiutl (technically, Kwak'wala) */
- "KE'YOS", 0, /* Actually `nothing'; no separate zero word is known */
- "'NEM", 1,
- "MAL'H", 2,
- "YUDEXW", 3,
- "MU", 4,
- "SEK'A", 5,
- "Q'ETL'A", 6,
- "ETLEBU", 7,
- "MALHGWENALH", 8,
- "'NA'NE'MA", 9,
+ { "KE'YOS", 0 }, /* Actually `nothing'; no separate zero word is known */
+ { "'NEM", 1 },
+ { "MAL'H", 2 },
+ { "YUDEXW", 3 },
+ { "MU", 4 },
+ { "SEK'A", 5 },
+ { "Q'ETL'A", 6 },
+ { "ETLEBU", 7 },
+ { "MALHGWENALH", 8 },
+ { "'NA'NE'MA", 9 },
/* Volap\"uk */
- "NOS", 0,
- "BAL", 1,
- "TEL", 2,
- "KIL", 3,
- "FOL", 4,
- "LUL", 5,
- "M\\\"AL", 6,
- "VEL", 7,
- "J\\\"OL", 8,
- "Z\\\"UL", 9,
+ { "NOS", 0 },
+ { "BAL", 1 },
+ { "TEL", 2 },
+ { "KIL", 3 },
+ { "FOL", 4 },
+ { "LUL", 5 },
+ { "M\\\"AL", 6 },
+ { "VEL", 7 },
+ { "J\\\"OL", 8 },
+ { "Z\\\"UL", 9 },
};
/* numeral.c ends here */
****************************************************************************/
/*LINTLIBRARY */
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
#include <signal.h>
#include "ick.h"
+#include "feh.h"
#include "y.tab.h"
+#include "sizes.h"
#include "lose.h"
#ifndef ICKINCLUDEDIR
#define ICKLIBDIR "/usr/local/lib"
#endif
#ifndef CC
-#define CC "cc"
+#define CC "gcc"
#endif
+#ifdef USE_YYRESTART
+/* function supplied by lex */
+extern void yyrestart(FILE*);
+#endif /* USE_YYRESTART */
+
+/* function created by yacc */
+extern int yyparse(void);
+
/* compilation options */
-bool dooptimize; /* do optimizations? (controlled by -O) */
-bool clockface; /* set up output to do IIII for IV */
bool compile_only; /* just compile into C, don't run the linker */
-bool traditional; /* insist on strict INTERCAL-72 conformance */
+bool traditional; /* insist on strict INTERCAL-72 conformance */
+
+static bool dooptimize; /* do optimizations? (controlled by -O) */
+static bool clockface; /* set up output to do IIII for IV */
#define SKELETON "ick-wrap.c"
#define SYSLIB "syslib.i"
static void abend(int signim)
{
lose(E778, yylineno, (char *)NULL);
+ (void) signim;
}
-main(argc, argv)
-int argc;
-char *argv[];
+static void print_usage(char *prog, char *options)
+{
+ fprintf(stderr,"Usage: %s [-%s] <file> [<file> ... ]\n",prog,options);
+ fprintf(stderr,"\t-c\t:compile INTERCAL to C, but don't compile C\n");
+ fprintf(stderr,"\t-d\t:print debugging information (implies -c)\n");
+ fprintf(stderr,"\t-t\t:traditional mode, accept only INTERCAL-72\n");
+ fprintf(stderr,"\t-C\t:clockface output (e.g. use IIII instead of IV)\n");
+ fprintf(stderr,"\t-O\t:attempt to optimize generated code\n");
+ fprintf(stderr,"\t<file>\tINTERCAL source file(s) (use extension .i)\n");
+ fprintf(stderr,"\t\teach file produces a separate output program.\n");
+}
+
+int main(int argc, char *argv[])
{
- extern char *optarg; /* set by getopt */
extern int optind; /* set by getopt */
char buf[BUFSIZ], buf2[BUFSIZ], *chp, *strrchr();
tuple *tp;
FILE *ifp, *ofp;
int maxabstain;
bool needsyslib;
- void print_usage();
if (!(includedir = getenv("ICKINCLUDEDIR")))
includedir = ICKINCLUDEDIR;
switch (c)
{
case 'c':
- compile_only = 1;
+ compile_only = TRUE;
break;
case 'd':
- yydebug = compile_only = 1;
+ yydebug = compile_only = TRUE;
break;
case 'C':
break;
case 't':
- traditional = 1;
+ traditional = TRUE;
break;
case 'O':
}
(void) signal(SIGSEGV, abend);
-#ifdef SIGBUS
+#ifdef SIGBUS
(void) signal(SIGBUS, abend);
-#endif /* SIGBUS */
+#endif /* SIGBUS */
(void) sprintf(buf2,"%s/%s",includedir,SKELETON);
if ( freopen(buf2, "r", stdin) == (FILE*) NULL ) {
lose(E127, 0, (char*) NULL);
}
+#ifdef USE_YYRESTART
+ yyrestart(stdin);
+#endif /* USE_YYRESTART */
yyparse();
}
maxabstain++;
if (maxabstain)
{
- int i;
+ int i;
(void) fprintf(ofp, "#define UNKNOWN\t\t0\n");
- for (i = 0; i < sizeof(enablers)/sizeof(char *); i++)
+ i = 0;
+ for (; i < (int)(sizeof(enablers)/sizeof(char *)); i++)
(void) fprintf(ofp,
"#define %s\t%d\n",
enablers[i], i+1);
"static bool hyforget[%d];\n",
nhybrids);
}
- if (yydebug | compile_only)
+ if (yydebug || compile_only)
for (op = oblist; op < obdex; op++)
(void) fprintf(ofp, " /* %s %d -> %d */\n",
nameof(op->type, vartypes),
}
}
(void) fclose(ifp);
-}
-
-void print_usage(prog,options)
-char *prog, *options;
-{
- fprintf(stderr,"Usage: %s [-%s] <file> [<file> ... ]\n",prog,options);
- fprintf(stderr,"\t-c\t:compile INTERCAL to C, but don't compile C\n");
- fprintf(stderr,"\t-d\t:print debugging information (implies -c)\n");
- fprintf(stderr,"\t-t\t:traditional mode, accept only INTERCAL-72\n");
- fprintf(stderr,"\t-C\t:clockface output (e.g. use IIII instead of IV)\n");
- fprintf(stderr,"\t-O\t:attempt to optimize generated code\n");
- fprintf(stderr,"\t<file>\tINTERCAL source file(s) (use extension .i)\n");
- fprintf(stderr,"\t\teach file produces a separate output program.\n");
+ return 0;
}
/* perpetrate.c ends here */
extern int Large_digits;
extern unsigned int Max_small;
extern unsigned int Max_large;
+
+/* sizes.h ends here */