Annotation of 43BSDReno/pgrm/m4/mdef.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:  * Ozan Yigit.
        !             7:  *
        !             8:  * Redistribution and use in source and binary forms are permitted
        !             9:  * provided that: (1) source distributions retain this entire copyright
        !            10:  * notice and comment, and (2) distributions including binaries display
        !            11:  * the following acknowledgement:  ``This product includes software
        !            12:  * developed by the University of California, Berkeley and its contributors''
        !            13:  * in the documentation or other materials provided with the distribution
        !            14:  * and in all advertising materials mentioning features or use of this
        !            15:  * software. Neither the name of the University nor the names of its
        !            16:  * contributors may be used to endorse or promote products derived
        !            17:  * from this software without specific prior written permission.
        !            18:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            19:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            20:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            21:  *
        !            22:  *     @(#)mdef.h      5.5 (Berkeley) 6/1/90
        !            23:  */
        !            24: 
        !            25: /*
        !            26:  * mdef.h
        !            27:  * Facility: m4 macro processor
        !            28:  * by: oz
        !            29:  */
        !            30: 
        !            31: #include <sys/signal.h>
        !            32: #include <stdio.h>
        !            33: #include <ctype.h>
        !            34: #include "pathnames.h"
        !            35: 
        !            36: /*
        !            37:  *
        !            38:  * m4 constants..
        !            39:  *
        !            40:  */
        !            41:  
        !            42: #define MACRTYPE        1
        !            43: #define DEFITYPE        2
        !            44: #define EXPRTYPE        3
        !            45: #define SUBSTYPE        4
        !            46: #define IFELTYPE        5
        !            47: #define LENGTYPE        6
        !            48: #define CHNQTYPE        7
        !            49: #define SYSCTYPE        8
        !            50: #define UNDFTYPE        9
        !            51: #define INCLTYPE        10
        !            52: #define SINCTYPE        11
        !            53: #define PASTTYPE        12
        !            54: #define SPASTYPE        13
        !            55: #define INCRTYPE        14
        !            56: #define IFDFTYPE        15
        !            57: #define PUSDTYPE        16
        !            58: #define POPDTYPE        17
        !            59: #define SHIFTYPE        18
        !            60: #define DECRTYPE        19
        !            61: #define DIVRTYPE        20
        !            62: #define UNDVTYPE        21
        !            63: #define DIVNTYPE        22
        !            64: #define MKTMTYPE        23
        !            65: #define ERRPTYPE        24
        !            66: #define M4WRTYPE        25
        !            67: #define TRNLTYPE        26
        !            68: #define DNLNTYPE        27
        !            69: #define DUMPTYPE        28
        !            70: #define CHNCTYPE        29
        !            71: #define INDXTYPE        30
        !            72: #define SYSVTYPE        31
        !            73: #define EXITTYPE        32
        !            74: #define DEFNTYPE        33
        !            75:  
        !            76: #define STATIC          128
        !            77: 
        !            78: /*
        !            79:  * m4 special characters
        !            80:  */
        !            81:  
        !            82: #define ARGFLAG         '$'
        !            83: #define LPAREN          '('
        !            84: #define RPAREN          ')'
        !            85: #define LQUOTE          '`'
        !            86: #define RQUOTE          '\''
        !            87: #define COMMA           ','
        !            88: #define SCOMMT          '#'
        !            89: #define ECOMMT          '\n'
        !            90: 
        !            91: /*
        !            92:  * other important constants
        !            93:  */
        !            94: 
        !            95: #define EOS             (char) 0
        !            96: #define MAXINP          10              /* maximum include files   */
        !            97: #define MAXOUT          10              /* maximum # of diversions */
        !            98: #define MAXSTR          512             /* maximum size of string  */
        !            99: #define BUFSIZE         4096            /* size of pushback buffer */
        !           100: #define STACKMAX        1024            /* size of call stack      */
        !           101: #define STRSPMAX        4096            /* size of string space    */
        !           102: #define MAXTOK          MAXSTR          /* maximum chars in a tokn */
        !           103: #define HASHSIZE        199             /* maximum size of hashtab */
        !           104:  
        !           105: #define ALL             1
        !           106: #define TOP             0
        !           107:  
        !           108: #define TRUE            1
        !           109: #define FALSE           0
        !           110: #define cycle           for(;;)
        !           111: 
        !           112: /*
        !           113:  * m4 data structures
        !           114:  */
        !           115:  
        !           116: typedef struct ndblock *ndptr;
        !           117:  
        !           118: struct ndblock {                /* hastable structure         */
        !           119:         char    *name;          /* entry name..               */
        !           120:         char    *defn;          /* definition..               */
        !           121:         int     type;           /* type of the entry..        */
        !           122:         ndptr   nxtptr;         /* link to next entry..       */
        !           123: };
        !           124:  
        !           125: #define nil     ((ndptr) 0)
        !           126:  
        !           127: struct keyblk {
        !           128:         char    *knam;          /* keyword name */
        !           129:         int     ktyp;           /* keyword type */
        !           130: };
        !           131: 
        !           132: typedef union {                        /* stack structure */
        !           133:        int     sfra;           /* frame entry  */
        !           134:        char    *sstr;          /* string entry */
        !           135: } stae;
        !           136: 
        !           137: /*
        !           138:  * macros for readibility and/or speed
        !           139:  *
        !           140:  *      gpbc()  - get a possibly pushed-back character
        !           141:  *      min()   - select the minimum of two elements
        !           142:  *      pushf() - push a call frame entry onto stack
        !           143:  *      pushs() - push a string pointer onto stack
        !           144:  */
        !           145: #define gpbc()          (bp > buf) ? *--bp : getc(infile[ilevel])
        !           146: #define min(x,y) ((x > y) ? y : x)
        !           147: #define pushf(x) if (sp < STACKMAX) mstack[++sp].sfra = (x)
        !           148: #define pushs(x) if (sp < STACKMAX) mstack[++sp].sstr = (x)
        !           149: 
        !           150: /*
        !           151:  *         .                              .
        !           152:  *     |   .   |  <-- sp               |  .  |
        !           153:  *     +-------+                       +-----+
        !           154:  *     | arg 3 ----------------------->| str |
        !           155:  *     +-------+                       |  .  |
        !           156:  *     | arg 2 ---PREVEP-----+            .
        !           157:  *     +-------+             |
        !           158:  *         .                 |         |     |
        !           159:  *     +-------+             |         +-----+
        !           160:  *     | plev  |  PARLEV     +-------->| str |
        !           161:  *     +-------+                       |  .  |
        !           162:  *     | type  |  CALTYP                  .
        !           163:  *     +-------+
        !           164:  *     | prcf  ---PREVFP--+
        !           165:  *     +-------+          |
        !           166:  *     |   .   |  PREVSP  |
        !           167:  *         .              |
        !           168:  *     +-------+          |
        !           169:  *     |       <----------+
        !           170:  *     +-------+
        !           171:  *
        !           172:  */
        !           173: #define PARLEV  (mstack[fp].sfra)
        !           174: #define CALTYP  (mstack[fp-1].sfra)
        !           175: #define PREVEP (mstack[fp+3].sstr)
        !           176: #define PREVSP (fp-3)
        !           177: #define PREVFP (mstack[fp-2].sfra)

unix.superglobalmegacorp.com

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