Ansified usr.bin/lex
authorNick Downing <downing.nick@gmail.com>
Tue, 31 Jan 2017 12:36:08 +0000 (23:36 +1100)
committerNick Downing <downing.nick@gmail.com>
Tue, 31 Jan 2017 12:36:08 +0000 (23:36 +1100)
usr.bin/lex/header.c
usr.bin/lex/ldefs.h
usr.bin/lex/lmain.c
usr.bin/lex/sub1.c
usr.bin/lex/sub2.c
usr.bin/lex/y.tab.c

index 8aeaf86..f7ecd8f 100644 (file)
@@ -1,12 +1,15 @@
-#ifndef lint
+/*#include <stdio.h> ldefs.h*/
+#include "ldefs.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)header.c   4.1 (Berkeley) 8/11/83";
 #endif
-# include "ldefs.h"
-phead1(){
+/*# include "ldefs.h"*/
+int phead1() {
        ratfor ? rhd1() : chd1();
        }
 
-chd1(){
+int chd1() {
        fprintf(fout,"# include \"stdio.h\"\n");
        if (ZCH>NCH)
        fprintf(fout, "# define U(x) ((x)&0377)\n");
@@ -47,7 +50,7 @@ chd1(){
        fprintf(fout,"extern struct yysvf yysvec[], *yybgin;\n");
        }
 
-rhd1(){
+int rhd1() {
        fprintf(fout,"integer function yylex(dummy)\n");
        fprintf(fout,"define YYLMAX 200\n");
        fprintf(fout,"define ECHO call yyecho(yytext,yyleng)\n");
@@ -66,24 +69,24 @@ rhd1(){
        fprintf(fout,"\t\telse goto 30998\n");
        }
 
-phead2(){
+int phead2() {
        if(!ratfor)chd2();
        }
 
-chd2(){
+int chd2() {
        fprintf(fout,"while((nstr = yylook()) >= 0)\n");
        fprintf(fout,"yyfussy: switch(nstr){\n");
        fprintf(fout,"case 0:\n");
        fprintf(fout,"if(yywrap()) return(0); break;\n");
        }
 
-ptail(){
+int ptail() {
        if(!pflag)
                ratfor ? rtail() : ctail();
        pflag = 1;
        }
 
-ctail(){
+int ctail() {
        fprintf(fout,"case -1:\nbreak;\n");             /* for reject */
        fprintf(fout,"default:\n");
        fprintf(fout,"fprintf(yyout,\"bad switch yylook %%d\",nstr);\n");
@@ -91,7 +94,7 @@ ctail(){
        fprintf(fout,"/* end of yylex */\n");
        }
 
-rtail(){
+int rtail() {
        register int i;
        fprintf(fout,"\n30998 if(nstr .lt. 0 .or. nstr .gt. %d)goto 30999\n",casecount);
        fprintf(fout,"nstr = nstr + 1\n");
@@ -102,7 +105,7 @@ rtail(){
        fprintf(fout,"30997 continue\n");
        fprintf(fout,"}\nend\n");
        }
-statistics(){
+int statistics() {
        fprintf(errorf,"%d/%d nodes(%%e), %d/%d positions(%%p), %d/%d (%%n), %ld transitions\n",
                tptr, treesize, nxtpos-positions, maxpos, stnum+1, nstates, rcount);
        fprintf(errorf, ", %d/%d packed char classes(%%k)", pcptr-pchar, pchlen);
index a5af6c4..56b9970 100644 (file)
@@ -1,6 +1,11 @@
+#ifndef _LDEFS_H_
+#define _LDEFS_H_
+
+#include <stdio.h>
+
 /*     ldefs.c 4.1     83/08/11        */
 
-# include <stdio.h>
+/*# include <stdio.h>*/
 # define PP 1
 # ifdef unix
 
@@ -29,7 +34,6 @@
 # define NCH 256
 # endif
 
-
 # define TOKENSIZE 1000
 # define DEFSIZE 40
 # define DEFCHAR 1000
@@ -160,5 +164,98 @@ extern int optim;
 extern int *verify, *advance, *stoff;
 extern int scon;
 extern char *psave;
-extern char *calloc(), *myalloc();
-extern int buserr(), segviol();
+/*extern char *calloc(), *myalloc();*/
+/*extern int buserr(), segviol();*/
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* header.c */
+int phead1 __P((void));
+int chd1 __P((void));
+int rhd1 __P((void));
+int phead2 __P((void));
+int chd2 __P((void));
+int ptail __P((void));
+int ctail __P((void));
+int rtail __P((void));
+int statistics __P((void));
+
+/* lmain.c */
+int main __P((int argc, char **argv));
+int get1core __P((void));
+int free1core __P((void));
+int get2core __P((void));
+int free2core __P((void));
+int get3core __P((void));
+int free3core __P((void));
+char *myalloc __P((int a, int b));
+int buserr __P((void));
+int segviol __P((void));
+int yyerror __P((char *s));
+
+/* sub1.c */
+char *getl __P((char *p));
+int space __P((int ch));
+int digit __P((int c));
+int error __P((char *s, ...));
+int warning __P((char *s, ...));
+int _index __P((int a, char *s));
+int alpha __P((int c));
+int printable __P((int c));
+int lgate __P((void));
+int scopy __P((char *s, char *t));
+int siconv __P((char *t));
+int slength __P((char *s));
+int scomp __P((char *x, char *y));
+int ctrans __P((char **ss));
+int cclinter __P((int sw));
+int usescape __P((int c));
+int lookup __P((char *s, char **t));
+int cpyact __P((void));
+int gch __P((void));
+int mn2 __P((int a, int d, int c));
+int mn1 __P((int a, int d));
+int mn0 __P((int a));
+int munput __P((int t, char *p));
+int dupl __P((int n));
+int allprint __P((int c));
+int strpt __P((char *s));
+int sect1dump __P((void));
+int sect2dump __P((void));
+int treedump __P((void));
+
+/* sub2.c */
+int cfoll __P((int v));
+int pfoll __P((void));
+int add __P((int **array, int n));
+int follow __P((int v));
+int first __P((int v));
+int cgoto __P((void));
+int nextstate __P((int s, int c));
+int notin __P((int n));
+int packtrans __P((int st, char *tch, int *tst, int cnt, int tryit));
+int pstate __P((int s));
+int member __P((int d, char *t));
+int stprt __P((int i));
+int acompute __P((int s));
+int pccl __P((void));
+int mkmatch __P((void));
+int layout __P((void));
+int rprint __P((int *a, char *s, int n));
+int shiftr __P((int *a, int n));
+int upone __P((int *a, int n));
+int bprint __P((char *a, char *s, int n));
+int padd __P((int **array, int n));
+
+/* y.tab.c */
+int yylex __P((void));
+int XXXfreturn __P((int i));
+int yyparse __P((void));
+
+#endif
index e9c151a..100cf05 100644 (file)
@@ -1,8 +1,13 @@
-#ifndef lint
+#include <gen.h>
+/*#include <stdio.h> ldefs.h*/
+/*#include <sys/signal.h> gen.h*/
+#include "ldefs.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)lmain.c    4.3 (Berkeley) 2/21/85";
 #endif
 
-# include "ldefs.h"
+/*# include "ldefs.h"*/
 
        /* lex [-[drcyvntf]] [file] ... [file] */
 
@@ -138,11 +143,9 @@ int pchlen = TOKENSIZE;
 int *verify, *advance, *stoff;
 int scon;
 char *psave;
-int buserr(), segviol();
+/*int buserr(), segviol();*/
 
-main(argc,argv)
-  int argc;
-  char **argv; {
+int main(argc, argv) int argc; char **argv; {
        register int i;
 # ifdef DEBUG
 #include <signal.h>
@@ -248,7 +251,7 @@ main(argc,argv)
        fclose(stderr);
        exit(0);        /* success return code */
        }
-get1core(){
+int get1core() {
        register int i, val;
        register char *p;
 ccptr =        ccl = myalloc(CCLSIZE,sizeof(*ccl));
@@ -261,12 +264,12 @@ sp =      schar = myalloc(STARTCHAR,sizeof(*schar));
        if(ccl == 0 || def == 0 || subs == 0 || dchar == 0 || sname == 0 || schar == 0)
                error("Too little core to begin");
        }
-free1core(){
+int free1core() {
        free(def);
        free(subs);
        free(dchar);
        }
-get2core(){
+int get2core() {
        register int i, val;
        register char *p;
        gotof = (int *) myalloc(nstates,sizeof(*gotof));
@@ -284,7 +287,7 @@ nxtpos = positions = (int *) myalloc(maxpos,sizeof(*positions));
                error("Too little core for state generation");
        for(i=0;i<=tptr;i++)foll[i] = 0;
        }
-free2core(){
+int free2core() {
        free(positions);
        free(tmpstat);
        free(foll);
@@ -298,7 +301,7 @@ free2core(){
        free(schar);
        free(ccl);
        }
-get3core(){
+int get3core() {
        register int i, val;
        register char *p;
        verify = (int *) myalloc(outsize,sizeof(*verify));
@@ -308,7 +311,7 @@ get3core(){
                error("Too little core for final packing");
        }
 # ifdef DEBUG
-free3core(){
+int free3core() {
        free(advance);
        free(verify);
        free(stoff);
@@ -320,8 +323,7 @@ free3core(){
        free(cpackflg);
        }
 # endif
-char *myalloc(a,b)
-  int a,b; {
+char *myalloc(a, b) int a; int b; {
        register char *i;
        i = calloc(a, b);
        if(i==0)
@@ -335,7 +337,7 @@ char *myalloc(a,b)
        return(i);
        }
 # ifdef DEBUG
-buserr(){
+int buserr() {
        fflush(errorf);
        fflush(fout);
        fflush(stdout);
@@ -343,7 +345,7 @@ buserr(){
        if(report == 1)statistics();
        fflush(errorf);
        }
-segviol(){
+int segviol() {
        fflush(errorf);
        fflush(fout);
        fflush(stdout);
@@ -353,9 +355,7 @@ segviol(){
        }
 # endif
 
-yyerror(s)
-char *s;
-{
+int yyerror(s) char *s; {
        fprintf(stderr, "\"%s\", line %d: %s\n",
                fptr > 0 ? sargv[fptr] : "<stdin>", yyline, s);
 }
index 13dd002..d73426e 100644 (file)
@@ -1,14 +1,21 @@
-#ifndef lint
+/*#include <stdio.h> ldefs.h*/
+#ifdef __STDC__
+#include <stdarg.h>
+#define _va_start(argp, arg) va_start(argp, arg)
+#else
+#include <varargs.h>
+#define _va_start(argp, arg) va_start(argp)
+#endif
+#include "ldefs.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)sub1.c     4.2 (Berkeley) 2/21/85";
 #endif
 
-# include <varargs.h>
-# include "ldefs.h"
-char *
-getl(p)        /* return next line of input, throw away trailing '\n' */
-       /* returns 0 if eof is had immediately */
-  char *p;
-       {
+/*# include <varargs.h>*/
+/*# include "ldefs.h"*/
+char *getl(p)  /* return next line of input, throw away trailing '\n' */
+       /* returns 0 if eof is had immediately */ char *p; {
        register int c;
        register char *s, *t;
        t = s = p;
@@ -20,10 +27,8 @@ getl(p)      /* return next line of input, throw away trailing '\n' */
        pres = '\n';
        return(s);
        }
-space(ch)
-       {
-       switch(ch)
-               {
+int space(ch) int ch; {
+       switch(ch) {
                case ' ':
                case '\t':
                case '\n':
@@ -32,19 +37,20 @@ space(ch)
        return(0);
        }
 
-digit(c)
-{
+int digit(c) int c; {
        return(c>='0' && c <= '9');
 }
-error(s,va_alist)
-  char *s;
-  va_dcl
-       {
+#ifdef __STDC__
+int error(char *s, ...)
+#else
+int error(s, va_alist) char *s; va_dcl
+#endif
+{
        va_list argp;
 
        fprintf(errorf,"\"%s\", line %d: (Error) ",
                fptr > 0 ? sargv[fptr] : "<stdin>", yyline);
-       va_start(argp);
+       _va_start(argp, fmt);
        vfprintf(errorf,s,argp);
        va_end(argp);
        putc('\n',errorf);
@@ -62,15 +68,17 @@ error(s,va_alist)
        exit(1);        /* error return code */
        }
 
-warning(s,va_alist)
-  char *s;
-  va_dcl
-       {
+#ifdef __STDC__
+int warning(char *s, ...)
+#else
+int warning(s, va_alist) char *s; va_dcl
+#endif
+{
        va_list argp;
 
        fprintf(errorf,"\"%s\", line %d: (Warning) ",
                fptr > 0 ? sargv[fptr] : "<stdin>", yyline);
-       va_start(argp);
+       _va_start(argp, fmt);
        vfprintf(errorf,s,argp);
        va_end(argp);
        putc('\n',errorf);
@@ -78,9 +86,7 @@ warning(s,va_alist)
        fflush(fout);
        fflush(stdout);
        }
-index(a,s)
-       char *s;
-{
+int _index(a, s) int a; char *s; {
        register int k;
        for(k=0; s[k]; k++)
                if (s[k]== a)
@@ -88,26 +94,23 @@ index(a,s)
        return(-1);
        }
 
-alpha(c)
-  int c; {
+int alpha(c) int c; {
 # ifdef ASCII
 return('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z');
 # endif
 # ifdef EBCDIC
-return(index(c,"abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") >= 0);
+return(_index(c,"abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") >= 0);
 # endif
 }
-printable(c)
-{
+int printable(c) int c; {
 # ifdef ASCII
 return( c>040 && c < 0177);
 # endif
 # ifdef EBCDIC
-return(index(c, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,;:><+*)('&%!-=\"")>=0);
+return(_index(c, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,;:><+*)('&%!-=\"")>=0);
 # endif
 }
-lgate()
-{
+int lgate() {
        char fname[20];
        if (lgatflg) return;
        lgatflg=1;
@@ -121,15 +124,13 @@ lgate()
        }
 /* scopy(ptr to str, ptr to str) - copy first arg str to second */
 /* returns ptr to second arg */
-scopy(s,t)
-  char *s, *t; {
+int scopy(s, t) char *s; char *t; {
        register char *i;
        i = t;
        while(*i++ = *s++);
        return;
        }
-siconv(t)      /* convert string t, return integer value */
-  char *t; {
+int siconv(t)  /* convert string t, return integer value */ char *t; {
        register int i,sw;
        register char *s;
        s = t;
@@ -146,8 +147,7 @@ siconv(t)   /* convert string t, return integer value */
        }
 /* slength(ptr to str) - return integer length of string arg */
 /* excludes '\0' terminator */
-slength(s)
-  char *s; {
+int slength(s) char *s; {
        register int n;
        register char *t;
        t = s;
@@ -157,8 +157,7 @@ slength(s)
 /* scomp(x,y) - return -1 if x < y,
                0 if x == y,
                return 1 if x > y, all lexicographically */
-scomp(x,y)
-  char *x,*y; {
+int scomp(x, y) char *x; char *y; {
        register char *a,*d;
        a = x;
        d = y;
@@ -172,14 +171,11 @@ scomp(x,y)
                }
        return(0);      /* equal */
        }
-ctrans(ss)
-       char **ss;
-{
+int ctrans(ss) char **ss; {
        register int c, k;
        if ((c = **ss) != '\\')
                return(c);
-       switch(c= *++*ss)
-       {
+       switch(c= *++*ss) {
        case 'n': c = '\n'; break;
        case 't': c = '\t'; break;
        case 'r': c = '\r'; break;
@@ -189,8 +185,7 @@ ctrans(ss)
        case '0': case '1': case '2': case '3':
        case '4': case '5': case '6': case '7':
                c -= '0';
-               while ((k = *(*ss+1)) >= '0' && k <= '7')
-                       {
+               while ((k = *(*ss+1)) >= '0' && k <= '7') {
                        c = c*8 + k - '0';
                        (*ss)++;
                        }
@@ -198,8 +193,7 @@ ctrans(ss)
        }
        return(c);
 }
-cclinter(sw)
-  int sw; {
+int cclinter(sw) int sw; {
                /* sw = 1 ==> ccl */
        register int i, j, k;
        int m;
@@ -253,8 +247,7 @@ cclinter(sw)
                }
        return;
        }
-usescape(c)
-  int c; {
+int usescape(c) int c; {
        register char d;
        switch(c){
        case 'n': c = '\n'; break;
@@ -273,9 +266,7 @@ usescape(c)
        }
        return(c);
        }
-lookup(s,t)
-  char *s;
-  char **t; {
+int lookup(s, t) char *s; char **t; {
        register int i;
        i = 0;
        while(*t){
@@ -286,7 +277,7 @@ lookup(s,t)
                }
        return(-1);
        }
-cpyact(){ /* copy C action to the next ; or closing } */
+int cpyact() { /* copy C action to the next ; or closing } */
        register int brac, c, mth;
        int savline, sw;
 
@@ -362,8 +353,7 @@ case '"':   /* character string */
                                }
                        else if( c==mth ) goto loop;
                        putc(c,fout);
-                       if (c == '\n')
-                               {
+                       if (c == '\n') {
                                yyline--;
                                error( "Non-terminated string or character constant");
                                }
@@ -382,7 +372,7 @@ loop:
        }
 error("Premature EOF");
 }
-gch(){
+int gch() {
        register int c;
        static int hadeof;
 
@@ -412,9 +402,7 @@ gch(){
        if(c == '\n')yyline++;
        return(c);
        }
-mn2(a,d,c)
-  int a,d,c;
-       {
+int mn2(a, d, c) int a; int d; int c; {
        name[tptr] = a;
        left[tptr] = d;
        right[tptr] = c;
@@ -448,9 +436,7 @@ mn2(a,d,c)
                error("Parse tree too big %s",(treesize == TREESIZE?"\nTry using %e num":""));
        return(tptr++);
        }
-mn1(a,d)
-  int a,d;
-       {
+int mn1(a, d) int a; int d; {
        name[tptr] = a;
        left[tptr] = d;
        parent[tptr] = 0;
@@ -486,9 +472,7 @@ mn1(a,d)
                error("Parse tree too big %s",(treesize == TREESIZE?"\nTry using %e num":""));
        return(tptr++);
        }
-mn0(a)
-  int a;
-       {
+int mn0(a) int a; {
        name[tptr] = a;
        parent[tptr] = 0;
        nullstr[tptr] = 0;
@@ -504,9 +488,7 @@ mn0(a)
                error("Parse tree too big %s",(treesize == TREESIZE?"\nTry using %e num":""));
        return(tptr++);
        }
-munput(t,p)    /* implementation dependent */
-  char *p;
-  int t; {
+int munput(t, p)       /* implementation dependent */ int t; char *p; {
        register int i,j;
        if(t == 'c'){
                *pushptr++ = peek;              /* watch out for this */
@@ -527,8 +509,7 @@ munput(t,p) /* implementation dependent */
        return;
        }
 
-dupl(n)
-  int n; {
+int dupl(n) int n; {
        /* duplicate the subtree whose root is n, return ptr to it */
        register int i;
        i = name[n];
@@ -552,8 +533,7 @@ dupl(n)
        return(0);
        }
 # ifdef DEBUG
-allprint(c)
-  char c; {
+int allprint(c) int c; {
        switch(c){
                case 014:
                        printf("\\f");
@@ -586,8 +566,7 @@ allprint(c)
        charc++;
        return;
        }
-strpt(s)
-  char *s; {
+int strpt(s) char *s; {
        charc = 0;
        while(*s){
                allprint(*s++);
@@ -598,7 +577,7 @@ strpt(s)
                }
        return;
        }
-sect1dump(){
+int sect1dump() {
        register int i;
        printf("Sect 1:\n");
        if(def[0]){
@@ -625,12 +604,11 @@ sect1dump(){
                        }
                }
        }
-sect2dump(){
+int sect2dump() {
        printf("Sect 2:\n");
        treedump();
        }
-treedump()
-       {
+int treedump() {
        register int t;
        register char *p;
        printf("treedump %d nodes:\n",tptr);
index 79bab30..dc8ac4d 100644 (file)
@@ -1,11 +1,13 @@
-#ifndef lint
+#include <gen.h>
+/*#include <stdio.h> ldefs.h*/
+#include "ldefs.h"
+
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)sub2.c     4.1 (Berkeley) 8/11/83";
 #endif
 
-# include "ldefs.h"
-cfoll(v)
-       int v;
-       {
+/*# include "ldefs.h"*/
+int cfoll(v) int v; {
        register int i,j,k;
        char *p;
        i = name[v];
@@ -74,8 +76,7 @@ cfoll(v)
        return;
        }
 # ifdef DEBUG
-pfoll()
-       {
+int pfoll() {
        register int i,k,*p;
        int j;
        /* print sets of chars which may follow positions */
@@ -93,9 +94,7 @@ pfoll()
        return;
        }
 # endif
-add(array,n)
-  int **array;
-  int n; {
+int add(array, n) int **array; int n; {
        register int i, *temp;
        register char *ctemp;
        temp = nxtpos;
@@ -110,9 +109,7 @@ add(array,n)
                error("Too many positions %s",(maxpos== MAXPOS?"\nTry using %p num":""));
        return;
        }
-follow(v)
-  int v;
-       {
+int follow(v) int v; {
        register int p;
        if(v >= tptr-1)return;
        p = parent[v];
@@ -150,8 +147,7 @@ follow(v)
                }
        return;
        }
-first(v)       /* calculate set of positions with v as root which can be active initially */
-  int v; {
+int first(v)   /* calculate set of positions with v as root which can be active initially */ int v; {
        register int i;
        register char *p;
        i = name[v];
@@ -195,7 +191,7 @@ first(v)    /* calculate set of positions with v as root which can be active initia
                }
        return;
        }
-cgoto(){
+int cgoto() {
        register int i, j, s;
        int npos, curpos, n;
        int tryit;
@@ -312,8 +308,7 @@ cgoto(){
        }
        /*      Beware -- 70% of total CPU time is spent in this subroutine -
                if you don't believe me - try it yourself ! */
-nextstate(s,c)
-  int s,c; {
+int nextstate(s, c) int s; int c; {
        register int j, *newpos;
        register char *temp, *tz;
        int *pos, i, *f, num, curpos, number;
@@ -346,8 +341,7 @@ nextstate(s,c)
        count = j;
        return;
        }
-notin(n)
-  int n;       {       /* see if tmpstat occurs previously */
+int notin(n) int n; {  /* see if tmpstat occurs previously */
        register int *j,k;
        register char *temp;
        int i;
@@ -365,12 +359,10 @@ notin(n)
                }
        return(-1);
        }
-packtrans(st,tch,tst,cnt,tryit)
-  int st, *tst, cnt,tryit;
-  char *tch; {
+int packtrans(st, tch, tst, cnt, tryit) int st; char *tch; int *tst; int cnt; int tryit; {
        /* pack transitions into nchar, nexts */
        /* nchar is terminated by '\0', nexts uses cnt, followed by elements */
-       /* gotof[st] = index into nchr, nexts for state st */
+       /* gotof[st] = _index into nchr, nexts for state st */
 
        /* sfall[st] =  t implies t is fall back state for st */
        /*              == -1 implies no fall back */
@@ -528,8 +520,7 @@ nopack:
        return;
        }
 # ifdef DEBUG
-pstate(s)
-  int s; {
+int pstate(s) int s; {
        register int *p,i,j;
        printf("State %d:\n",s);
        p = state[s];
@@ -544,9 +535,7 @@ pstate(s)
        return;
        }
 # endif
-member(d,t)
-  int d;
-  char *t;     {
+int member(d, t) int d; char *t; {
        register int c;
        register char *s;
        c = d;
@@ -557,8 +546,7 @@ member(d,t)
        return(0);
        }
 # ifdef DEBUG
-stprt(i)
-  int i; {
+int stprt(i) int i; {
        register int p, t;
        printf("State %d:",i);
        /* print actions, if any */
@@ -589,8 +577,7 @@ stprt(i)
        return;
        }
 # endif
-acompute(s)    /* compute action list = set of poss. actions */
-  int s; {
+int acompute(s)        /* compute action list = set of poss. actions */ int s; {
        register int *p, i, j;
        int cnt, m;
        int temp[300], k, neg[300], n;
@@ -655,7 +642,7 @@ acompute(s) /* compute action list = set of poss. actions */
        return;
        }
 # ifdef DEBUG
-pccl() {
+int pccl() {
        /* print character class sets */
        register int i, j;
        printf("char class intersection\n");
@@ -685,7 +672,7 @@ pccl() {
        return;
        }
 # endif
-mkmatch(){
+int mkmatch() {
        register int i;
        char tab[NCH];
        for(i=0; i<ccount; i++)
@@ -698,7 +685,7 @@ mkmatch(){
                match[i] = tab[cindex[i]];
        return;
        }
-layout(){
+int layout() {
        /* format and output final program's tables */
        register int i, j, k;
        int  top, bot, startup, omin;
@@ -717,11 +704,9 @@ layout(){
                while(nchar[j])j++;
                top = j - 1;
 # if DEBUG
-               if (debug)
-                       {
+               if (debug) {
                        printf("State %d: (layout)\n", i);
-                       for(j=bot; j<=top;j++)
-                               {
+                       for(j=bot; j<=top;j++) {
                                printf("  %o", nchar[j]);
                                if (j%10==0) putchar('\n');
                                }
@@ -836,8 +821,7 @@ layout(){
        fprintf(fout,"struct yysvf *yybgin = yysvec+1;\n");
        if(optim){
                fprintf(fout,"char yymatch[] ={\n");
-               if (chset==0) /* no chset, put out in normal order */
-                       {
+               if (chset==0) /* no chset, put out in normal order */ {
                        for(i=0; i<NCH; i+=8){
                                for(j=0; j<8; j++){
                                        int fbch;
@@ -849,8 +833,7 @@ layout(){
                                putc('\n',fout);
                                }
                        }
-               else
-                       {
+               else {
                        int *fbarr;
                        fbarr = myalloc(2*NCH, sizeof(*fbarr));
                        if (fbarr==0)
@@ -859,8 +842,7 @@ layout(){
                                fbarr[i]=0;
                        for(i=0; i<NCH; i++)
                                fbarr[ctable[i]] = ctable[match[i]];
-                       for(i=0; i<ZCH; i+=8)
-                               {
+                       for(i=0; i<ZCH; i+=8) {
                                for(j=0; j<8; j++)
                                        fprintf(fout, "0%-3o,",fbarr[i+j]);
                                putc('\n',fout);
@@ -880,39 +862,30 @@ layout(){
        fprintf(fout,"0};\n");
        return;
        }
-rprint(a,s,n)
-  char *s;
-  int *a, n; {
+int rprint(a, s, n) int *a; char *s; int n; {
        register int i;
        fprintf(fout,"block data\n");
        fprintf(fout,"common /L%s/ %s\n",s,s);
        fprintf(fout,"define S%s %d\n",s,n);
        fprintf(fout,"integer %s (S%s)\n",s,s);
-       for(i=1; i<=n; i++)
-               {
+       for(i=1; i<=n; i++) {
                if (i%8==1) fprintf(fout, "data ");
                fprintf(fout, "%s (%d)/%d/",s,i,a[i]);
                fprintf(fout, (i%8 && i<n) ? ", " : "\n");
                }
        fprintf(fout,"end\n");
        }
-shiftr(a, n)
-       int *a;
-{
+int shiftr(a, n) int *a; int n; {
 int i;
 for(i=n; i>=0; i--)
        a[i+1]=a[i];
 }
-upone(a,n)
-       int *a;
-{
+int upone(a, n) int *a; int n; {
 int i;
 for(i=0; i<=n ; i++)
        a[i]++;
 }
-bprint(a,s,n)
- char *s,  *a;
- int  n; {
+int bprint(a, s, n) char *a; char *s; int n; {
        register int i, j, k;
        fprintf(fout,"block data\n");
        fprintf(fout,"common /L%s/ %s\n",s,s);
@@ -929,9 +902,7 @@ bprint(a,s,n)
        fprintf(fout,"end\n");
        }
 # ifdef PP
-padd(array,n)
-  int **array;
-  int n; {
+int padd(array, n) int **array; int n; {
        register int i, *j, k;
        array[n] = nxtpos;
        if(count == 0){
index 65ce6f7..ff7ed7d 100644 (file)
@@ -1,3 +1,8 @@
+#include <gen.h>
+/*#include <stdio.h> ldefs.h*/
+/*#include <strings.h> gen.h*/
+#include "ldefs.h"
+
 # define CHAR 257
 # define CCL 258
 # define NCCL 259
 # define CAT 266
 
 # line 11 "parser.y"
-#ifndef lint
+#if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)parser.y   4.1 (Berkeley) 8/11/83";
 #endif
 
-# include "ldefs.h"
+/*# include "ldefs.h"*/
 #define yyclearin yychar = -1
 #define yyerrok yyerrflag = 0
 extern int yychar;
@@ -36,7 +41,7 @@ char *p;
 
 # line 215 "parser.y"
 
-yylex(){
+int yylex() {
        register char *p;
        register int c, i;
        char  *t, *xp;
@@ -151,16 +156,14 @@ yylex(){
                                                                t++;
                                                                }
                                                        p = buf;
-                                                       }
-                                               {
+                                                       } {
                                                char chused[2*NCH]; int kr;
                                                for(i=0; i<ZCH; i++)
                                                        chused[i]=0;
                                                for(i=0; i<NCH; i++)
                                                        chused[ctable[i]]=1;
                                                for(kr=i=1; i<NCH; i++)
-                                                       if (ctable[i]==0)
-                                                               {
+                                                       if (ctable[i]==0) {
                                                                while (chused[kr] == 0)
                                                                        kr++;
                                                                ctable[i]=kr;
@@ -184,12 +187,12 @@ yylex(){
                                                error("Premature eof");
                                        case 's': case 'S':             /* start conditions */
                                                lgate();
-                                               while(*p && index(*p," \t,") < 0) p++;
+                                               while(*p && _index(*p," \t,") < 0) p++;
                                                n = TRUE;
                                                while(n){
-                                                       while(*p && index(*p," \t,") >= 0) p++;
+                                                       while(*p && _index(*p," \t,") >= 0) p++;
                                                        t = p;
-                                                       while(*p && index(*p," \t,") < 0)p++;
+                                                       while(*p && _index(*p," \t,") < 0)p++;
                                                        if(!*p) n = FALSE;
                                                        *p++ = 0;
                                                        if (*t == 0) continue;
@@ -371,14 +374,12 @@ yylex(){
                                        } while(c && c != '>');
                                *slptr++ = 0;
                                /* check if previous value re-usable */
-                               for (xp=slist; xp<t; )
-                                       {
+                               for (xp=slist; xp<t; ) {
                                        if (strcmp(xp, t)==0)
                                                break;
                                        while (*xp++);
                                        }
-                               if (xp<t)
-                                       {
+                               if (xp<t) {
                                        /* re-use previous pointer to string */
                                        slptr=t;
                                        t=xp;
@@ -512,8 +513,7 @@ yylex(){
        }
 /* end of yylex */
 # ifdef DEBUG
-XXXfreturn(i)
-  int i; {
+int XXXfreturn(i) int i; {
        if(yydebug) {
                printf("now return ");
                if(i < NCH) allprint(i);
@@ -612,7 +612,7 @@ short yydef[]={
   24,   0,  26,  31,   0,  27,  25 };
 #ifndef lint
 static char yaccpar_sccsid[] = "@(#)yaccpar    4.1     (Berkeley)      2/11/83";
-#endif not lint
+#endif
 
 #
 # define YYFLAG -1000
@@ -630,7 +630,7 @@ int yychar = -1; /* current input token number */
 int yynerrs = 0;  /* number of errors */
 short yyerrflag = 0;  /* error recovery flag */
 
-yyparse() {
+int yyparse() {
 
        short yys[YYMAXDEPTH];
        short yyj, yym;
@@ -728,7 +728,6 @@ yyparse() {
        yyabort:
                        return(1);
 
-
                case 3:  /* no shift yet; clobber input char */
 
 #ifdef YYDEBUG