[BACK]Return to mdef.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / m4

Annotation of src/usr.bin/m4/mdef.h, Revision 1.1

1.1     ! deraadt     1: /*     $NetBSD: mdef.h,v 1.6 1995/09/28 05:37:39 tls Exp $     */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 1989, 1993
        !             5:  *     The Regents of the University of California.  All rights reserved.
        !             6:  *
        !             7:  * This code is derived from software contributed to Berkeley by
        !             8:  * Ozan Yigit at York University.
        !             9:  *
        !            10:  * Redistribution and use in source and binary forms, with or without
        !            11:  * modification, are permitted provided that the following conditions
        !            12:  * are met:
        !            13:  * 1. Redistributions of source code must retain the above copyright
        !            14:  *    notice, this list of conditions and the following disclaimer.
        !            15:  * 2. Redistributions in binary form must reproduce the above copyright
        !            16:  *    notice, this list of conditions and the following disclaimer in the
        !            17:  *    documentation and/or other materials provided with the distribution.
        !            18:  * 3. All advertising materials mentioning features or use of this software
        !            19:  *    must display the following acknowledgement:
        !            20:  *     This product includes software developed by the University of
        !            21:  *     California, Berkeley and its contributors.
        !            22:  * 4. Neither the name of the University nor the names of its contributors
        !            23:  *    may be used to endorse or promote products derived from this software
        !            24:  *    without specific prior written permission.
        !            25:  *
        !            26:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            28:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            29:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            30:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            31:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            32:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            33:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            34:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            35:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            36:  * SUCH DAMAGE.
        !            37:  *
        !            38:  *     @(#)mdef.h      8.1 (Berkeley) 6/6/93
        !            39:  */
        !            40:
        !            41: #define MACRTYPE        1
        !            42: #define DEFITYPE        2
        !            43: #define EXPRTYPE        3
        !            44: #define SUBSTYPE        4
        !            45: #define IFELTYPE        5
        !            46: #define LENGTYPE        6
        !            47: #define CHNQTYPE        7
        !            48: #define SYSCTYPE        8
        !            49: #define UNDFTYPE        9
        !            50: #define INCLTYPE        10
        !            51: #define SINCTYPE        11
        !            52: #define PASTTYPE        12
        !            53: #define SPASTYPE        13
        !            54: #define INCRTYPE        14
        !            55: #define IFDFTYPE        15
        !            56: #define PUSDTYPE        16
        !            57: #define POPDTYPE        17
        !            58: #define SHIFTYPE        18
        !            59: #define DECRTYPE        19
        !            60: #define DIVRTYPE        20
        !            61: #define UNDVTYPE        21
        !            62: #define DIVNTYPE        22
        !            63: #define MKTMTYPE        23
        !            64: #define ERRPTYPE        24
        !            65: #define M4WRTYPE        25
        !            66: #define TRNLTYPE        26
        !            67: #define DNLNTYPE        27
        !            68: #define DUMPTYPE        28
        !            69: #define CHNCTYPE        29
        !            70: #define INDXTYPE        30
        !            71: #define SYSVTYPE        31
        !            72: #define EXITTYPE        32
        !            73: #define DEFNTYPE        33
        !            74:
        !            75: #define STATIC          128
        !            76:
        !            77: /*
        !            78:  * m4 special characters
        !            79:  */
        !            80:
        !            81: #define ARGFLAG         '$'
        !            82: #define LPAREN          '('
        !            83: #define RPAREN          ')'
        !            84: #define LQUOTE          '`'
        !            85: #define RQUOTE          '\''
        !            86: #define COMMA           ','
        !            87: #define SCOMMT          '#'
        !            88: #define ECOMMT          '\n'
        !            89:
        !            90: #ifdef msdos
        !            91: #define system(str)    (-1)
        !            92: #endif
        !            93:
        !            94: /*
        !            95:  * other important constants
        !            96:  */
        !            97:
        !            98: #define EOS             (char) 0
        !            99: #define MAXINP          10              /* maximum include files   */
        !           100: #define MAXOUT          10              /* maximum # of diversions */
        !           101: #define MAXSTR          512             /* maximum size of string  */
        !           102: #define BUFSIZE         4096            /* size of pushback buffer */
        !           103: #define STACKMAX        1024            /* size of call stack      */
        !           104: #define STRSPMAX        4096            /* size of string space    */
        !           105: #define MAXTOK          MAXSTR          /* maximum chars in a tokn */
        !           106: #define HASHSIZE        199             /* maximum size of hashtab */
        !           107:
        !           108: #define ALL             1
        !           109: #define TOP             0
        !           110:
        !           111: #define TRUE            1
        !           112: #define FALSE           0
        !           113: #define cycle           for(;;)
        !           114:
        !           115: /*
        !           116:  * m4 data structures
        !           117:  */
        !           118:
        !           119: typedef struct ndblock *ndptr;
        !           120:
        !           121: struct ndblock {                /* hastable structure         */
        !           122:         char    *name;          /* entry name..               */
        !           123:         char    *defn;          /* definition..               */
        !           124:         int     type;           /* type of the entry..        */
        !           125:         ndptr   nxtptr;         /* link to next entry..       */
        !           126: };
        !           127:
        !           128: #define nil     ((ndptr) 0)
        !           129:
        !           130: struct keyblk {
        !           131:         char    *knam;          /* keyword name */
        !           132:         int     ktyp;           /* keyword type */
        !           133: };
        !           134:
        !           135: typedef union {                        /* stack structure */
        !           136:        int     sfra;           /* frame entry  */
        !           137:        char    *sstr;          /* string entry */
        !           138: } stae;
        !           139:
        !           140: /*
        !           141:  * macros for readibility and/or speed
        !           142:  *
        !           143:  *      gpbc()  - get a possibly pushed-back character
        !           144:  *      pushf() - push a call frame entry onto stack
        !           145:  *      pushs() - push a string pointer onto stack
        !           146:  */
        !           147: #define gpbc()          (bp > bufbase) ? *--bp : getc(infile[ilevel])
        !           148: #define pushf(x) if (sp < STACKMAX) mstack[++sp].sfra = (x)
        !           149: #define pushs(x) if (sp < STACKMAX) mstack[++sp].sstr = (x)
        !           150:
        !           151: /*
        !           152:  *         .                              .
        !           153:  *     |   .   |  <-- sp               |  .  |
        !           154:  *     +-------+                       +-----+
        !           155:  *     | arg 3 ----------------------->| str |
        !           156:  *     +-------+                       |  .  |
        !           157:  *     | arg 2 ---PREVEP-----+            .
        !           158:  *     +-------+             |
        !           159:  *         .                 |         |     |
        !           160:  *     +-------+             |         +-----+
        !           161:  *     | plev  |  PARLEV     +-------->| str |
        !           162:  *     +-------+                       |  .  |
        !           163:  *     | type  |  CALTYP                  .
        !           164:  *     +-------+
        !           165:  *     | prcf  ---PREVFP--+
        !           166:  *     +-------+          |
        !           167:  *     |   .   |  PREVSP  |
        !           168:  *         .              |
        !           169:  *     +-------+          |
        !           170:  *     |       <----------+
        !           171:  *     +-------+
        !           172:  *
        !           173:  */
        !           174: #define PARLEV  (mstack[fp].sfra)
        !           175: #define CALTYP  (mstack[fp-1].sfra)
        !           176: #define PREVEP (mstack[fp+3].sstr)
        !           177: #define PREVSP (fp-3)
        !           178: #define PREVFP (mstack[fp-2].sfra)