Annotation of 41BSD/cmd/pi/yy.h, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.