1 # include <u.h> 2 # include <libc.h> 3 # include <ctype.h> 4 # include <bio.h> 5 # define PP 1 6 7 #ifdef NOTDEF 8 # define CWIDTH 8 9 # define CMASK 0377 10 #endif 11 # define NCH 256 12 13 14 # define TOKENSIZE 1000 15 # define DEFSIZE 40 16 # define DEFCHAR 1000 17 # define STARTCHAR 100 18 # define STARTSIZE 256 19 # define CCLSIZE 1000 20 21 # define TREESIZE 1000 22 # define NSTATES 500 23 # define MAXPOS 2500 24 # define NTRANS 2000 25 # define NOUTPUT 5000 26 27 # define NACTIONS 100 28 # define ALITTLEEXTRA 30 29 30 # define RCCL NCH+90 31 # define RNCCL NCH+91 32 # define RSTR NCH+92 33 # define RSCON NCH+93 34 # define RNEWE NCH+94 35 # define FINAL NCH+95 36 # define RNULLS NCH+96 37 # define RCAT NCH+97 38 # define STAR NCH+98 39 # define PLUS NCH+99 40 # define QUEST NCH+100 41 # define DIV NCH+101 42 # define BAR NCH+102 43 # define CARAT NCH+103 44 # define S1FINAL NCH+104 45 # define S2FINAL NCH+105 46 47 # define DEFSECTION 1 48 # define RULESECTION 2 49 # define ENDSECTION 5 50 # define TRUE 1 51 # define FALSE 0 52 53 # define PC 1 54 # define PS 1 55 56 # ifdef DEBUG 57 # define LINESIZE 110 58 extern int yydebug; 59 extern int debug; /* 1 = on */ 60 extern int charc; 61 # endif 62 63 # ifdef DEBUG 64 extern int freturn(int); 65 # else 66 # define freturn(s) s 67 # endif 68 69 extern int sargc; 70 extern char **sargv; 71 extern uchar buf[520]; 72 extern int yyline; /* line number of file */ 73 extern int sect; 74 extern int eof; 75 extern int lgatflg; 76 extern int divflg; 77 extern int funcflag; 78 extern int pflag; 79 extern int casecount; 80 extern int chset; /* 1 = char set modified */ 81 extern Biobuf *fin, fout, *fother; 82 extern int foutopen; 83 extern int errorf; 84 extern int fptr; 85 extern char *cname; 86 extern int prev; /* previous input character */ 87 extern int pres; /* present input character */ 88 extern int peek; /* next input character */ 89 extern int *name; 90 extern int *left; 91 extern uintptr *right; 92 extern int *parent; 93 extern uchar **ptr; 94 extern uchar *nullstr; 95 extern int tptr; 96 extern uchar pushc[TOKENSIZE]; 97 extern uchar *pushptr; 98 extern uchar slist[STARTSIZE]; 99 extern uchar *slptr; 100 extern uchar **def, **subs, *dchar; 101 extern uchar **sname, *stchar; 102 extern uchar *ccl; 103 extern uchar *ccptr; 104 extern uchar *dp, *sp; 105 extern int dptr, sptr; 106 extern uchar *bptr; /* store input position */ 107 extern uchar *tmpstat; 108 extern int count; 109 extern int **foll; 110 extern int *nxtpos; 111 extern int *positions; 112 extern int *gotof; 113 extern int *nexts; 114 extern uchar *nchar; 115 extern int **state; 116 extern int *sfall; /* fallback state num */ 117 extern uchar *cpackflg; /* true if state has been character packed */ 118 extern int *atable, aptr; 119 extern int nptr; 120 extern uchar symbol[NCH]; 121 extern uchar cindex[NCH]; 122 extern int xstate; 123 extern int stnum; 124 extern int ccount; 125 extern uchar match[NCH]; 126 extern uchar extra[NACTIONS]; 127 extern uchar *pcptr, *pchar; 128 extern int pchlen; 129 extern int nstates, maxpos; 130 extern int yytop; 131 extern int report; 132 extern int ntrans, treesize, outsize; 133 extern long rcount; 134 extern int *verify, *advance, *stoff; 135 extern int scon; 136 extern uchar *psave; 137 138 extern void acompute(int); 139 extern void add(int **, int); 140 extern void allprint(int); 141 extern void cclinter(int); 142 extern void cgoto(void); 143 extern void cfoll(int); 144 extern int cpyact(void); 145 extern int dupl(int); 146 extern void error(char *,...); 147 extern void first(int); 148 extern void follow(int); 149 extern int gch(void); 150 extern uchar *getl(uchar *); 151 extern void layout(void); 152 extern void lgate(void); 153 extern int lookup(uchar *, uchar **); 154 extern int member(int, uchar *); 155 extern void mkmatch(void); 156 extern int mnp(int, void*); 157 extern int mn0(int); 158 extern int mn1(int, int); 159 extern int mn2(int, int, uintptr); 160 extern void munputc(int); 161 extern void munputs(uchar *); 162 extern void *myalloc(int, int); 163 extern void nextstate(int, int); 164 extern int notin(int); 165 extern void packtrans(int, uchar *, int *, int, int); 166 extern void padd(int **, int); 167 extern void pccl(void); 168 extern void pfoll(void); 169 extern void phead1(void); 170 extern void phead2(void); 171 extern void pstate(int); 172 extern void ptail(void); 173 extern void sect1dump(void); 174 extern void sect2dump(void); 175 extern void statistics(void); 176 extern void stprt(int); 177 extern void strpt(uchar *); 178 extern void treedump(void); 179 extern int usescape(int); 180 extern void warning(char *,...); 181 extern int yyparse(void); 182 extern void yyerror(char *); 183