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