|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1980 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)yy.h 5.2 (Berkeley) 6/21/85 ! 7: */ ! 8: ! 9: #include "y.tab.h" ! 10: #undef CBSIZE /* from paramsys/param.h */ ! 11: /* ! 12: * INPUT/OUTPUT ! 13: */ ! 14: ! 15: /* ! 16: * The buffer for the input file is normally "ibuf". ! 17: * When files are included, however, this may be ! 18: * pushed down in the stack of currently active ! 19: * files. For this reason, the pointer ibp always ! 20: * references the i/o buffer of the current input file. ! 21: */ ! 22: FILE *ibuf, *ibp; ! 23: ! 24: /* ! 25: * Line and token buffers. Charbuf is the character buffer for ! 26: * input lines, token the buffer for tokens returned ! 27: * by the scanner. CBSIZE defines the maximum line ! 28: * length allowed on input and is doubtless too small. ! 29: * The token buffer should be a local array in yylex. ! 30: */ ! 31: #ifdef ADDR16 ! 32: #define CBSIZE 161 ! 33: #endif ADDR16 ! 34: #ifdef ADDR32 ! 35: #define CBSIZE 1024 ! 36: #endif ADDR32 ! 37: ! 38: char charbuf[CBSIZE], *bufp, token[CBSIZE]; ! 39: ! 40: #define digit(c) (c >= '0' && c <= '9') ! 41: #define alph(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) ! 42: ! 43: /* ! 44: * Flag to prevent reprinting current line after ! 45: * an error. ! 46: */ ! 47: char yyprtd; ! 48: ! 49: /* ! 50: * The following variables are maintained by ! 51: * the scanner in the file lex and used in scanning ! 52: * and in parsing. ! 53: * ! 54: * The variable yychar is the current scanner character. ! 55: * Currently, the scanner must be called as ! 56: * yychar = yylex() ! 57: * even though it should set yychar itself. ! 58: * Yychar has value YEOF at end of file, and negative value if ! 59: * there is no yychar, e.g. after a shift in the parser. ! 60: * ! 61: * The variable yycol is the current column in the line whose number ! 62: * is given by yyline. Yyecol and yyeline give the position for an ! 63: * error message to flag, usually the start of an input token. ! 64: * Yylval is the semantic return from the scanner. ! 65: * ! 66: * In fact all of these variables are "per token". ! 67: * In the usual case, only the copies in the scanner token structure ! 68: * 'Y' are used, and the #defines below serve to make them look ! 69: * like variables. ! 70: * ! 71: * For the purposes of the error recovery, however, they are copied ! 72: * and restored quite freely. For the error recovery also, the ! 73: * file name which the input line this token is on and the seek ! 74: * pointer of this line in its source file are saved as yyefile ! 75: * and yyseekp. The global variable yylinpt is the seek pointer ! 76: * of the current input line. ! 77: */ ! 78: int yycol; ! 79: int yyline; ! 80: int yyseqid; ! 81: int yysavc; ! 82: int yylinpt; ! 83: ! 84: /* *** NOTE *** ! 85: * It would be much better to not have the Yyeline and Yyefile ! 86: * in the scanner structure and to have a mechanism for mapping ! 87: * seqid's to these globally. ! 88: */ ! 89: struct yytok { ! 90: int Yychar; ! 91: int Yylval; ! 92: int Yyecol; ! 93: int Yyeline; ! 94: int Yyseekp; ! 95: char *Yyefile; ! 96: int Yyeseqid; ! 97: } Y, OY; ! 98: ! 99: #define yychar Y.Yychar ! 100: #define yylval Y.Yylval ! 101: #define yyecol Y.Yyecol ! 102: #define yyeline Y.Yyeline ! 103: #define yyseekp Y.Yyseekp ! 104: #define yyefile Y.Yyefile ! 105: #define yyeseqid Y.Yyeseqid ! 106: ! 107: /* Semantic Stack so that y.tab.c will lint */ ! 108: ! 109: union semstack ! 110: { ! 111: int i_entry; ! 112: struct nl *nl_entry; ! 113: struct tnode *tr_entry; ! 114: char *cptr; ! 115: } yyval; ! 116: ! 117: /* ! 118: * Yyval is the semantic value returned by a reduction. ! 119: * It is what "$$" is expanded to by yacc. ! 120: */ ! 121: ! 122: int *Ps; ! 123: ! 124: /* ! 125: * N is the length of a reduction. ! 126: * Used externally by "lineof" to get the left and ! 127: * right margins for a reduction. ! 128: */ ! 129: int N; ! 130: /* ! 131: * Definitions for looking up keywords. ! 132: * The keyword array is called yykey, and ! 133: * lastkey points at the end of it. ! 134: */ ! 135: char *lastkey; ! 136: ! 137: struct kwtab { ! 138: char *kw_str; ! 139: int kw_val; ! 140: } yykey[]; ! 141: ! 142: /* ! 143: * ERROR RECOVERY EXTERNALS ! 144: */ ! 145: ! 146: #define CLIMIT 40 /* see yyrecover.c */ ! 147: char *tokname(); ! 148: char *charname(); ! 149: ! 150: char *classes[]; ! 151: ! 152: /* ! 153: * Tokens which yacc doesn't define ! 154: */ ! 155: #define YEOF 0 ! 156: #define ERROR 256 ! 157: ! 158: /* ! 159: * Limit on the number of syntax errors ! 160: */ ! 161: #define MAXSYNERR 100 ! 162: ! 163: /* ! 164: * Big costs ! 165: */ ! 166: #define HUGE 50 ! 167: #define INFINITY 100 ! 168: ! 169: /* ! 170: * Kinds of panics ! 171: */ ! 172: #define PDECL 0 ! 173: #define PSTAT 1 ! 174: #define PEXPR 2 ! 175: #define PPROG 3 ! 176: ! 177: #define yyresume() yyResume = 1; ! 178: ! 179: char yyResume; ! 180: ! 181: char dquote; ! 182: ! 183: #ifndef PC ! 184: #ifndef OBJ ! 185: char errout; ! 186: #endif OBJ ! 187: #endif PC ! 188: ! 189: /* ! 190: * Yyidwant and yyidhave are the namelist classes ! 191: * of identifiers associated with a identifier reduce ! 192: * error, set before the recovery is called. ! 193: * Since they may be set again during the forward move ! 194: * they must be saved by yyrecover, which uses them in printing ! 195: * error messages. ! 196: */ ! 197: int yyidhave, yyidwant; ! 198: ! 199: /* ! 200: * The variables yy*shifts are used to prevent looping and the printing ! 201: * of spurious messages in the parser. Yyshifts gives the number of ! 202: * true input shifts since the last corrective action. YyOshifts ! 203: * is the value of yyshifts before it was last cleared, and is used ! 204: * by yyPerror in yypanic.c to suppress messages. ! 205: * ! 206: * Yytshifts counts true input shifts. It is used to prevent looping ! 207: * inserting unique symbols. If yytshifts == yyTshifts (local to ! 208: * yyrecover.c) then there has been no shift over true input since ! 209: * the last unique symbol insertion. We refuse, in this case, ! 210: * to insert more unique symbols so as to prevent looping. ! 211: * ! 212: * The recovery cannot loop because it guarantees the progress of the ! 213: * parse, i.e.: ! 214: * ! 215: * 1) Any insertion guarantees to shift over 2 symbols, a replacement ! 216: * over one symbol. ! 217: * ! 218: * 2) Unique symbol insertions are limited to one for each true ! 219: * symbol of input, or "safe" insertion of the keywords "end" ! 220: * and "until" at zero cost (safe since these are know to match ! 221: * stack that cannot have been generated - e.g. "begin" or "repeat") ! 222: * ! 223: * 3) We never panic more than once from a given state without ! 224: * shifting over input, i.e. we force the parse stack to shrink ! 225: * after each unsuccessful panic. ! 226: */ ! 227: int yyshifts, yyOshifts; ! 228: unsigned yytshifts; ! 229: ! 230: #ifdef PXP ! 231: ! 232: /* ! 233: * Identifier class definitions ! 234: */ ! 235: #define UNDEF 0 ! 236: #define CONST 1 ! 237: #define TYPE 2 ! 238: #define VAR 3 ! 239: #define ARRAY 4 ! 240: #define PTRFILE 5 ! 241: #define RECORD 6 ! 242: #define FIELD 7 ! 243: #define PROC 8 ! 244: #define FUNC 9 ! 245: #define FVAR 10 ! 246: #define REF 11 ! 247: #define PTR 12 ! 248: #define FILET 13 ! 249: #define SET 14 ! 250: #define RANGE 15 ! 251: #define LABEL 16 ! 252: #define WITHPTR 17 ! 253: #define SCAL 18 ! 254: #define STR 19 ! 255: #define PROG 20 ! 256: #define IMPROPER 21 ! 257: ! 258: /* ! 259: * COMMENT FORMATTING DEFINITIONS ! 260: */ ! 261: ! 262: /* ! 263: * Count of tokens on this input line ! 264: * Note that this can be off if input is not syntactically correct. ! 265: */ ! 266: int yytokcnt; ! 267: int yywhcnt; ! 268: ! 269: /* ! 270: * Types of comments ! 271: */ ! 272: #define CLMARG 0 ! 273: #define CALIGN 1 ! 274: #define CTRAIL 2 ! 275: #define CRMARG 3 ! 276: #define CSRMARG 4 ! 277: #define CNL 5 ! 278: #define CNLBL 6 ! 279: #define CFORM 7 ! 280: #define CINCLUD 8 ! 281: ! 282: /* ! 283: * Comment structure ! 284: * Cmhp is the head of the current list of comments ! 285: */ ! 286: struct comment { ! 287: struct comment *cmnext; ! 288: int cmdelim; ! 289: struct commline *cml; ! 290: int cmjust; ! 291: int cmseqid; ! 292: } *cmhp; ! 293: ! 294: /* ! 295: * Structure for holding a comment line ! 296: */ ! 297: struct commline { ! 298: char *cmtext; ! 299: int cmcol; /* Only used for first line of comment currently */ ! 300: struct commline *cml; ! 301: }; ! 302: ! 303: struct W { ! 304: int Wseqid; ! 305: int Wcol; ! 306: } yyw[MAXDEPTH + 1], *yypw; ! 307: ! 308: #define commform() quickcomm(CFORM) ! 309: #define commnl() quickcomm(CNL) ! 310: #define commnlbl() quickcomm(CNLBL) ! 311: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.