1: #ifndef lint
   2: static char sccsid[] = "@(#)parse.c	4.2 8/11/83";
   3: #endif
   4: 
   5: #include "awk.def"
   6: #include "awk.h"
   7: #include "stdio.h"
   8: node *ALLOC(n)
   9: {
  10:     register node *x;
  11:     x = (node *) malloc(sizeof(node) + (n-1)*sizeof(node *));
  12:     if (x == NULL)
  13:         error(FATAL, "out of space in ALLOC");
  14:     return(x);
  15: }
  16: node *exptostat(a) node *a;
  17: {
  18:     a->ntype = NSTAT;
  19:     return(a);
  20: }
  21: node    *nullstat;
  22: node *node0(a)
  23: {
  24:     register node *x;
  25:     x=ALLOC(0);
  26:     x->nnext = NULL;
  27:     x->nobj=a;
  28:     return(x);
  29: }
  30: node *node1(a,b) node *b;
  31: {
  32:     register node *x;
  33:     x=ALLOC(1);
  34:     x->nnext = NULL;
  35:     x->nobj=a;
  36:     x->narg[0]=b;
  37:     return(x);
  38: }
  39: node *node2(a,b,c) node *b, *c;
  40: {
  41:     register node *x;
  42:     x = ALLOC(2);
  43:     x->nnext = NULL;
  44:     x->nobj = a;
  45:     x->narg[0] = b;
  46:     x->narg[1] = c;
  47:     return(x);
  48: }
  49: node *node3(a,b,c,d) node *b, *c, *d;
  50: {
  51:     register node *x;
  52:     x = ALLOC(3);
  53:     x->nnext = NULL;
  54:     x->nobj = a;
  55:     x->narg[0] = b;
  56:     x->narg[1] = c;
  57:     x->narg[2] = d;
  58:     return(x);
  59: }
  60: node *node4(a,b,c,d,e) node *b, *c, *d, *e;
  61: {
  62:     register node *x;
  63:     x = ALLOC(4);
  64:     x->nnext = NULL;
  65:     x->nobj = a;
  66:     x->narg[0] = b;
  67:     x->narg[1] = c;
  68:     x->narg[2] = d;
  69:     x->narg[3] = e;
  70:     return(x);
  71: }
  72: node *stat3(a,b,c,d) node *b, *c, *d;
  73: {
  74:     register node *x;
  75:     x = node3(a,b,c,d);
  76:     x->ntype = NSTAT;
  77:     return(x);
  78: }
  79: node *op2(a,b,c) node *b, *c;
  80: {
  81:     register node *x;
  82:     x = node2(a,b,c);
  83:     x->ntype = NEXPR;
  84:     return(x);
  85: }
  86: node *op1(a,b) node *b;
  87: {
  88:     register node *x;
  89:     x = node1(a,b);
  90:     x->ntype = NEXPR;
  91:     return(x);
  92: }
  93: node *stat1(a,b) node *b;
  94: {
  95:     register node *x;
  96:     x = node1(a,b);
  97:     x->ntype = NSTAT;
  98:     return(x);
  99: }
 100: node *op3(a,b,c,d) node *b, *c, *d;
 101: {
 102:     register node *x;
 103:     x = node3(a,b,c,d);
 104:     x->ntype = NEXPR;
 105:     return(x);
 106: }
 107: node *stat2(a,b,c) node *b, *c;
 108: {
 109:     register node *x;
 110:     x = node2(a,b,c);
 111:     x->ntype = NSTAT;
 112:     return(x);
 113: }
 114: node *stat4(a,b,c,d,e) node *b, *c, *d, *e;
 115: {
 116:     register node *x;
 117:     x = node4(a,b,c,d,e);
 118:     x->ntype = NSTAT;
 119:     return(x);
 120: }
 121: node *valtonode(a, b) cell *a;
 122: {
 123:     register node *x;
 124:     x = node0(a);
 125:     x->ntype = NVALUE;
 126:     x->subtype = b;
 127:     return(x);
 128: }
 129: node *pa2stat(a,b,c) node *a, *b, *c;
 130: {
 131:     register node *x;
 132:     x = node3(paircnt++, a, b, c);
 133:     x->ntype = NPA2;
 134:     return(x);
 135: }
 136: node *linkum(a,b) node *a, *b;
 137: {
 138:     register node *c;
 139:     if(a == NULL) return(b);
 140:     else if(b == NULL) return(a);
 141:     for(c=a; c->nnext != NULL; c=c->nnext);
 142:     c->nnext = b;
 143:     return(a);
 144: }
 145: node *genprint()
 146: {
 147:     register node *x;
 148:     x = stat2(PRINT,valtonode(lookup("$record", symtab, 0), CFLD), nullstat);
 149:     return(x);
 150: }

Defined functions

ALLOC defined in line 8; used 5 times
exptostat defined in line 16; used 1 times
genprint defined in line 145; used 2 times
linkum defined in line 136; used 5 times
node0 defined in line 22; used 1 times
node1 defined in line 30; used 2 times
node2 defined in line 39; used 2 times
node3 defined in line 49; used 3 times
node4 defined in line 60; used 1 times
op1 defined in line 86; used 10 times
op2 defined in line 79; used 35 times
op3 defined in line 100; used 4 times
pa2stat defined in line 129; used 2 times
stat1 defined in line 93; used 5 times
stat2 defined in line 107; used 6 times
stat3 defined in line 72; used 8 times
stat4 defined in line 114; used 2 times
valtonode defined in line 121; used 10 times

Defined variables

nullstat defined in line 21; used 22 times
sccsid defined in line 2; never used
Last modified: 1983-08-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1222
Valid CSS Valid XHTML 1.0 Strict