Annotation of 43BSDReno/pgrm/yacc/defs.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1989 The Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * This code is derived from software contributed to Berkeley by
        !             6:  * Robert Paul Corbett.
        !             7:  *
        !             8:  * Redistribution and use in source and binary forms are permitted provided
        !             9:  * that: (1) source distributions retain this entire copyright notice and
        !            10:  * comment, and (2) distributions including binaries display the following
        !            11:  * acknowledgement:  ``This product includes software developed by the
        !            12:  * University of California, Berkeley and its contributors'' in the
        !            13:  * documentation or other materials provided with the distribution and in
        !            14:  * all advertising materials mentioning features or use of this software.
        !            15:  * Neither the name of the University nor the names of its contributors may
        !            16:  * be used to endorse or promote products derived from this software without
        !            17:  * specific prior written permission.
        !            18:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            19:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            20:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            21:  *
        !            22:  *     @(#)defs.h      5.4 (Berkeley) 6/1/90
        !            23:  */
        !            24: 
        !            25: #include <assert.h>
        !            26: #include <ctype.h>
        !            27: #include <stdio.h>
        !            28: 
        !            29: 
        !            30: /*  machine dependent definitions                      */
        !            31: /*  the following definitions are for the VAX          */
        !            32: /*  they might have to be changed for other machines   */
        !            33: 
        !            34: /*  MAXCHAR is the largest character value             */
        !            35: /*  MAXSHORT is the largest value of a C short         */
        !            36: /*  MINSHORT is the most negative value of a C short   */
        !            37: /*  MAXTABLE is the maximum table size                 */
        !            38: /*  BITS_PER_WORD is the number of bits in a C unsigned        */
        !            39: /*  WORDSIZE computes the number of words needed to    */
        !            40: /*     store n bits                                    */
        !            41: /*  BIT returns the value of the n-th bit starting     */
        !            42: /*     from r (0-indexed)                              */
        !            43: /*  SETBIT sets the n-th bit starting from r           */
        !            44: 
        !            45: #define        MAXCHAR         255
        !            46: #define        MAXSHORT        32767
        !            47: #define MINSHORT       -32768
        !            48: #define MAXTABLE       32500
        !            49: #define BITS_PER_WORD  32
        !            50: #define        WORDSIZE(n)     (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD)
        !            51: #define        BIT(r, n)       ((((r)[(n) >> 5]) >> ((n) & 31)) & 1)
        !            52: #define        SETBIT(r, n)    ((r)[(n) >> 5] |= (1 << ((n) & 31)))
        !            53: 
        !            54: 
        !            55: /*  character names  */
        !            56: 
        !            57: #define        NUL             '\0'    /*  the null character  */
        !            58: #define        NEWLINE         '\n'    /*  line feed  */
        !            59: #define        SP              ' '     /*  space  */
        !            60: #define        BS              '\b'    /*  backspace  */
        !            61: #define        HT              '\t'    /*  horizontal tab  */
        !            62: #define        VT              '\013'  /*  vertical tab  */
        !            63: #define        CR              '\r'    /*  carriage return  */
        !            64: #define        FF              '\f'    /*  form feed  */
        !            65: #define        QUOTE           '\''    /*  single quote  */
        !            66: #define        DOUBLE_QUOTE    '\"'    /*  double quote  */
        !            67: #define        BACKSLASH       '\\'    /*  backslash  */
        !            68: 
        !            69: 
        !            70: /* defines for constructing filenames */
        !            71: 
        !            72: #define        DEFINES_SUFFIX  ".tab.h"
        !            73: #define        OUTPUT_SUFFIX   ".tab.c"
        !            74: #define        VERBOSE_SUFFIX  ".output"
        !            75: 
        !            76: 
        !            77: /* keyword codes */
        !            78: 
        !            79: #define TOKEN 0
        !            80: #define LEFT 1
        !            81: #define RIGHT 2
        !            82: #define NONASSOC 3
        !            83: #define MARK 4
        !            84: #define TEXT 5
        !            85: #define TYPE 6
        !            86: #define START 7
        !            87: #define UNION 8
        !            88: #define IDENT 9
        !            89: 
        !            90: 
        !            91: /*  symbol classes  */
        !            92: 
        !            93: #define UNKNOWN 0
        !            94: #define TERM 1
        !            95: #define NONTERM 2
        !            96: 
        !            97: 
        !            98: /*  the undefined value  */
        !            99: 
        !           100: #define UNDEFINED (-1)
        !           101: 
        !           102: 
        !           103: /*  action codes  */
        !           104: 
        !           105: #define SHIFT 1
        !           106: #define REDUCE 2
        !           107: #define ERROR 3
        !           108: 
        !           109: 
        !           110: /*  character macros  */
        !           111: 
        !           112: #define IS_IDENT(c)    (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$')
        !           113: #define        IS_OCTAL(c)     ((c) >= '0' && (c) <= '7')
        !           114: #define        NUMERIC_VALUE(c)        ((c) - '0')
        !           115: 
        !           116: 
        !           117: /*  symbol macros  */
        !           118: 
        !           119: #define ISTOKEN(s)     ((s) < start_symbol)
        !           120: #define ISVAR(s)       ((s) >= start_symbol)
        !           121: 
        !           122: 
        !           123: /*  storage allocation macros  */
        !           124: 
        !           125: #define        FREE(x)         (free((char*)(x)))
        !           126: #define MALLOC(n)      (malloc((unsigned)(n)))
        !           127: #define        NEW(t)          ((t*)allocate(sizeof(t)))
        !           128: #define        NEW2(n,t)       ((t*)allocate((unsigned)((n)*sizeof(t))))
        !           129: #define REALLOC(p,n)   (realloc((char*)(p),(unsigned)(n)))
        !           130: 
        !           131: 
        !           132: /*  the structure of a symbol table entry  */
        !           133: 
        !           134: typedef struct bucket bucket;
        !           135: struct bucket
        !           136: {
        !           137:     struct bucket *link;
        !           138:     struct bucket *next;
        !           139:     char *name;
        !           140:     char *tag;
        !           141:     short value;
        !           142:     short index;
        !           143:     short prec;
        !           144:     char class;
        !           145:     char assoc;
        !           146: };
        !           147: 
        !           148: 
        !           149: /*  the structure of the LR(0) state machine  */
        !           150: 
        !           151: typedef struct core core;
        !           152: struct core
        !           153: {
        !           154:     struct core *next;
        !           155:     struct core *link;
        !           156:     short number;
        !           157:     short accessing_symbol;
        !           158:     short nitems;
        !           159:     short items[1];
        !           160: };
        !           161: 
        !           162: 
        !           163: /*  the structure used to record shifts  */
        !           164: 
        !           165: typedef struct shifts shifts;
        !           166: struct shifts
        !           167: {
        !           168:     struct shifts *next;
        !           169:     short number;
        !           170:     short nshifts;
        !           171:     short shift[1];
        !           172: };
        !           173: 
        !           174: 
        !           175: /*  the structure used to store reductions  */
        !           176: 
        !           177: typedef struct reductions reductions;
        !           178: struct reductions
        !           179: {
        !           180:     struct reductions *next;
        !           181:     short number;
        !           182:     short nreds;
        !           183:     short rules[1];
        !           184: };
        !           185: 
        !           186: 
        !           187: /*  the structure used to represent parser actions  */
        !           188: 
        !           189: typedef struct action action;
        !           190: struct action
        !           191: {
        !           192:     struct action *next;
        !           193:     short symbol;
        !           194:     short number;
        !           195:     short prec;
        !           196:     char action_code;
        !           197:     char assoc;
        !           198:     char suppressed;
        !           199: };
        !           200: 
        !           201: 
        !           202: /* global variables */
        !           203: 
        !           204: extern char dflag;
        !           205: extern char lflag;
        !           206: extern char tflag;
        !           207: extern char vflag;
        !           208: 
        !           209: extern char *myname;
        !           210: extern char *cptr;
        !           211: extern char *line;
        !           212: extern int lineno;
        !           213: extern int outline;
        !           214: 
        !           215: extern char *banner[];
        !           216: extern char *header[];
        !           217: extern char *body[];
        !           218: extern char *trailer[];
        !           219: 
        !           220: extern char *action_file_name;
        !           221: extern char *defines_file_name;
        !           222: extern char *input_file_name;
        !           223: extern char *output_file_name;
        !           224: extern char *text_file_name;
        !           225: extern char *union_file_name;
        !           226: extern char *verbose_file_name;
        !           227: 
        !           228: extern FILE *action_file;
        !           229: extern FILE *defines_file;
        !           230: extern FILE *input_file;
        !           231: extern FILE *output_file;
        !           232: extern FILE *text_file;
        !           233: extern FILE *union_file;
        !           234: extern FILE *verbose_file;
        !           235: 
        !           236: extern int nitems;
        !           237: extern int nrules;
        !           238: extern int nsyms;
        !           239: extern int ntokens;
        !           240: extern int nvars;
        !           241: extern int ntags;
        !           242: 
        !           243: extern char unionized;
        !           244: extern char line_format[];
        !           245: 
        !           246: extern int   start_symbol;
        !           247: extern char  **symbol_name;
        !           248: extern short *symbol_value;
        !           249: extern short *symbol_prec;
        !           250: extern char  *symbol_assoc;
        !           251: 
        !           252: extern short *ritem;
        !           253: extern short *rlhs;
        !           254: extern short *rrhs;
        !           255: extern short *rprec;
        !           256: extern char  *rassoc;
        !           257: 
        !           258: extern short **derives;
        !           259: extern char *nullable;
        !           260: 
        !           261: extern bucket *first_symbol;
        !           262: extern bucket *last_symbol;
        !           263: 
        !           264: extern int nstates;
        !           265: extern core *first_state;
        !           266: extern shifts *first_shift;
        !           267: extern reductions *first_reduction;
        !           268: extern short *accessing_symbol;
        !           269: extern core **state_table;
        !           270: extern shifts **shift_table;
        !           271: extern reductions **reduction_table;
        !           272: extern unsigned *LA;
        !           273: extern short *LAruleno;
        !           274: extern short *lookaheads;
        !           275: extern short *goto_map;
        !           276: extern short *from_state;
        !           277: extern short *to_state;
        !           278: 
        !           279: extern action **parser;
        !           280: extern int SRtotal;
        !           281: extern int RRtotal;
        !           282: extern short *SRconflicts;
        !           283: extern short *RRconflicts;
        !           284: extern short *defred;
        !           285: extern short *rules_used;
        !           286: extern short nunused;
        !           287: extern short final_state;
        !           288: 
        !           289: /* global functions */
        !           290: 
        !           291: extern char *allocate();
        !           292: extern bucket *lookup();
        !           293: extern bucket *make_bucket();
        !           294: 
        !           295: 
        !           296: /* system variables */
        !           297: 
        !           298: extern int errno;
        !           299: 
        !           300: 
        !           301: /* system functions */
        !           302: 
        !           303: extern void free();
        !           304: extern char *calloc();
        !           305: extern char *malloc();
        !           306: extern char *realloc();
        !           307: extern char *strcpy();

unix.superglobalmegacorp.com

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