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