Annotation of researchv10no/cmd/awk/awk.h, revision 1.1

1.1     ! root        1: /*
        !             2: Copyright (c) 1989 AT&T
        !             3:        All Rights Reserved
        !             4: 
        !             5: THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T.
        !             6: 
        !             7: The copyright notice above does not evidence any
        !             8: actual or intended publication of such source code.
        !             9: */
        !            10: 
        !            11: typedef double Awkfloat;
        !            12: typedef        /*unsigned*/ char uchar;
        !            13: 
        !            14: #define        xfree(a)        { if ((a) != NULL) { free((char *) a); a = NULL; } }
        !            15: 
        !            16: #define        DEBUG
        !            17: #ifdef DEBUG
        !            18:                        /* uses have to be doubly parenthesized */
        !            19: #      define  dprintf(x)      if (dbg) printf x
        !            20: #else
        !            21: #      define  dprintf(x)
        !            22: #endif
        !            23: 
        !            24: extern char    errbuf[200];
        !            25: #define        ERROR   sprintf(errbuf,
        !            26: #define        FATAL   ), error(1, errbuf)
        !            27: #define        WARNING ), error(0, errbuf)
        !            28: #define        SYNTAX  ), yyerror(errbuf)
        !            29: 
        !            30: extern int     compile_time;   /* 1 if compiling, 0 if running */
        !            31: 
        !            32: #define        RECSIZE (3 * 1024)      /* sets limit on records, fields, etc., etc. */
        !            33: extern int     recsize;        /* variable version */
        !            34: 
        !            35: extern uchar   **FS;
        !            36: extern uchar   **RS;
        !            37: extern uchar   **ORS;
        !            38: extern uchar   **OFS;
        !            39: extern uchar   **OFMT;
        !            40: extern Awkfloat *NR;
        !            41: extern Awkfloat *FNR;
        !            42: extern Awkfloat *NF;
        !            43: extern uchar   **FILENAME;
        !            44: extern uchar   **SUBSEP;
        !            45: extern Awkfloat *RSTART;
        !            46: extern Awkfloat *RLENGTH;
        !            47: 
        !            48: extern uchar   *record;
        !            49: extern int     dbg;
        !            50: extern int     lineno;
        !            51: extern int     errorflag;
        !            52: extern int     donefld;        /* 1 if record broken into fields */
        !            53: extern int     donerec;        /* 1 if record is valid (no fld has changed */
        !            54: 
        !            55: #define        CBUFLEN 400
        !            56: extern uchar   cbuf[CBUFLEN];  /* miscellaneous character collection */
        !            57: 
        !            58: extern uchar   *patbeg;        /* beginning of pattern matched */
        !            59: extern int     patlen;         /* length.  set in b.c */
        !            60: 
        !            61: /* Cell:  all information about a variable or constant */
        !            62: 
        !            63: typedef struct Cell {
        !            64:        uchar   ctype;          /* OCELL, OBOOL, OJUMP, etc. */
        !            65:        uchar   csub;           /* CCON, CTEMP, CFLD, etc. */
        !            66:        uchar   *nval;          /* name, for variables only */
        !            67:        uchar   *sval;          /* string value */
        !            68:        Awkfloat fval;          /* value as number */
        !            69:        unsigned tval;          /* type info: STR|NUM|ARR|FCN|FLD|CON|DONTFREE */
        !            70:        struct Cell *cnext;     /* ptr to next if chained */
        !            71: } Cell;
        !            72: 
        !            73: typedef struct {               /* symbol table array */
        !            74:        int     nelem;          /* elements in table right now */
        !            75:        int     size;           /* size of tab */
        !            76:        Cell    **tab;          /* hash table pointers */
        !            77: } Array;
        !            78: 
        !            79: #define        NSYMTAB 50      /* initial size of a symbol table */
        !            80: extern Array   *symtab;
        !            81: 
        !            82: extern Cell    *recloc;        /* location of input record */
        !            83: extern Cell    *nrloc;         /* NR */
        !            84: extern Cell    *fnrloc;        /* FNR */
        !            85: extern Cell    *nfloc;         /* NF */
        !            86: extern Cell    *rstartloc;     /* RSTART */
        !            87: extern Cell    *rlengthloc;    /* RLENGTH */
        !            88: 
        !            89: /* Cell.tval values: */
        !            90: #define        NUM     01      /* number value is valid */
        !            91: #define        STR     02      /* string value is valid */
        !            92: #define DONTFREE 04    /* string space is not freeable */
        !            93: #define        CON     010     /* this is a constant */
        !            94: #define        ARR     020     /* this is an array */
        !            95: #define        FCN     040     /* this is a function name */
        !            96: #define FLD    0100    /* this is a field $1, $2, ... */
        !            97: #define        REC     0200    /* this is $0 */
        !            98: 
        !            99: #define freeable(p)    (!((p)->tval & DONTFREE))
        !           100: 
        !           101: 
        !           102: /* function types */
        !           103: #define        FLENGTH 1
        !           104: #define        FSQRT   2
        !           105: #define        FEXP    3
        !           106: #define        FLOG    4
        !           107: #define        FINT    5
        !           108: #define        FSYSTEM 6
        !           109: #define        FRAND   7
        !           110: #define        FSRAND  8
        !           111: #define        FSIN    9
        !           112: #define        FCOS    10
        !           113: #define        FATAN   11
        !           114: #define        FTOUPPER 12
        !           115: #define        FTOLOWER 13
        !           116: #define        FFLUSH  14
        !           117: 
        !           118: /* Node:  parse tree is made of nodes, with Cell's at bottom */
        !           119: 
        !           120: typedef struct Node {
        !           121:        int     ntype;
        !           122:        struct  Node *nnext;
        !           123:        int     lineno;
        !           124:        int     nobj;
        !           125:        struct Node *narg[1];   /* variable: actual size set by calling malloc */
        !           126: } Node;
        !           127: 
        !           128: #define        NIL     ((Node *) 0)
        !           129: 
        !           130: extern Node    *winner;
        !           131: extern Node    *nullstat;
        !           132: extern Node    *nullnode;
        !           133: 
        !           134: /* ctypes */
        !           135: #define OCELL  1
        !           136: #define OBOOL  2
        !           137: #define OJUMP  3
        !           138: 
        !           139: /* Cell subtypes: csub */
        !           140: #define        CFREE   7
        !           141: #define CCOPY  6
        !           142: #define CCON   5
        !           143: #define CTEMP  4
        !           144: #define CNAME  3 
        !           145: #define CVAR   2
        !           146: #define CFLD   1
        !           147: 
        !           148: /* bool subtypes */
        !           149: #define BTRUE  11
        !           150: #define BFALSE 12
        !           151: 
        !           152: /* jump subtypes */
        !           153: #define JEXIT  21
        !           154: #define JNEXT  22
        !           155: #define        JBREAK  23
        !           156: #define        JCONT   24
        !           157: #define        JRET    25
        !           158: 
        !           159: /* node types */
        !           160: #define NVALUE 1
        !           161: #define NSTAT  2
        !           162: #define NEXPR  3
        !           163: #define        NFIELD  4
        !           164: 
        !           165: 
        !           166: extern int     pairstack[], paircnt;
        !           167: 
        !           168: #define notlegal(n)    (n <= FIRSTTOKEN || n >= LASTTOKEN || proctab[n-FIRSTTOKEN] == nullproc)
        !           169: #define isvalue(n)     ((n)->ntype == NVALUE)
        !           170: #define isexpr(n)      ((n)->ntype == NEXPR)
        !           171: #define isjump(n)      ((n)->ctype == OJUMP)
        !           172: #define isexit(n)      ((n)->csub == JEXIT)
        !           173: #define        isbreak(n)      ((n)->csub == JBREAK)
        !           174: #define        iscont(n)       ((n)->csub == JCONT)
        !           175: #define        isnext(n)       ((n)->csub == JNEXT)
        !           176: #define        isret(n)        ((n)->csub == JRET)
        !           177: #define isstr(n)       ((n)->tval & STR)
        !           178: #define isnum(n)       ((n)->tval & NUM)
        !           179: #define isarr(n)       ((n)->tval & ARR)
        !           180: #define isfunc(n)      ((n)->tval & FCN)
        !           181: #define istrue(n)      ((n)->csub == BTRUE)
        !           182: #define istemp(n)      ((n)->csub == CTEMP)
        !           183: #define        isargument(n)   ((n)->nobj == ARG)
        !           184: 
        !           185: #define NCHARS (256+1)         /* 256 handles 8-bit chars; 128 does 7-bit */
        !           186:                                /* watch out in match(), etc. */
        !           187: #define NSTATES        32
        !           188: 
        !           189: typedef struct rrow {
        !           190:        int     ltype;
        !           191:        long    lval;   /* because Al stores a pointer in it! */
        !           192:        int     *lfollow;
        !           193: } rrow;
        !           194: 
        !           195: typedef struct fa {
        !           196:        uchar   *restr;
        !           197:        int     anchor;
        !           198:        int     use;
        !           199:        uchar   gototab[NSTATES][NCHARS];
        !           200:        int     *posns[NSTATES];
        !           201:        uchar   out[NSTATES];
        !           202:        int     initstat;
        !           203:        int     curstat;
        !           204:        int     accept;
        !           205:        int     reset;
        !           206:        struct  rrow re[1];
        !           207: } fa;
        !           208: 
        !           209: 
        !           210: #include "proto.h"

unix.superglobalmegacorp.com

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