|
|
1.1 root 1: #include <stdio.h>
2: #include "pret.h"
3: #include "pret.d"
4:
5: extern FILE *tb;
6: extern int anyerror, linenumber;
7: extern int nrrows, nrcols, curstate, curdepth;
8: extern int nrvars, realnrvars;
9: extern struct ENTRY *base;
10: extern char filename[256];
11:
12: char *
13: Emalloc(N)
14: unsigned N;
15: { char *try, *malloc();
16: if ((try = malloc(N)) == NULL)
17: whoops("out of memory");
18: return try;
19: }
20:
21: whoops(s)
22: char *s;
23: { yyerror(s, "aborting");
24: fclose(tb);
25: unlink("pret.tmp");
26: exit(1);
27: }
28:
29: yyerror(s1, s2)
30: char *s1, *s2;
31: {
32: char buf[512];
33: sprintf(buf, s1, s2);
34:
35: printf("\"%s\", line %2d: %s\n", filename, linenumber, buf);
36: fflush(stdout);
37: anyerror++;
38: }
39:
40: warning(s1, s2)
41: char *s1, *s2;
42: {
43: printf("\"%s\", line %2d, warning: %s", filename, linenumber, s1);
44: if (strlen(s2) > 0 && strcmp(s1, "syntax error") != 0)
45: printf(" (%s)\n", s2);
46: else
47: printf("\n");
48: }
49:
50: release()
51: { register struct ENTRY *this, *temp1, *temp2;
52: register struct PILAR *that, *temp3;
53:
54: this = base;
55: while (this != NULL)
56: { temp1 = this->nextrow;
57: do
58: { temp2 = this->nextcol;
59: that = this->pilar;
60: do
61: { temp3 = that->nxtp;
62: free(that);
63: that = temp3;
64: } while (that != NULL);
65: free(this);
66: this = temp2;
67: } while (this != NULL);
68: this = temp1;
69: }
70: nrrows = nrcols = curstate = curdepth = 0;
71: nrvars = realnrvars = 0;
72: }
73:
74: struct PILAR *
75: newunit()
76: { struct PILAR *try;
77:
78: try = (struct PILAR *) Emalloc(sizeof(struct PILAR));
79:
80: try->transf = NOSTATE;
81: try->code = NONE;
82: try->nxtp = NULL;
83:
84: return try;
85: }
86:
87: struct ENTRY *
88: newentry()
89: { struct ENTRY *try;
90:
91: try = (struct ENTRY *) Emalloc(sizeof(struct ENTRY));
92:
93: try->pilar = newunit();
94: try->nrpils = 0;
95: try->nextrow = try->nextcol = NULL;
96: return try;
97: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.