Mercurial > hg > index.cgi
annotate src/buildkeywordtab.c @ 126:ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
Add ability to turn a token code into a keyword string. Also correct some
details related to token table generation with some additiona adjustments
for token symbols.
Also rework token symbol definitions and creation of some parsing tables as
well as the main statement parsing loop.
author | William Astle <lost@l-w.ca> |
---|---|
date | Mon, 08 Jan 2024 22:58:08 -0700 |
parents | 8770e6f977c3 |
children | 5d4801c0566d |
rev | line source |
---|---|
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1 /* |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
2 Build the keyword parse table for lwbasic |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
3 */ |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
4 |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
5 #define _POSIX_C_SOURCE 200809L // for getline() |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
6 |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
7 #include <stdio.h> |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
8 #include <stdlib.h> |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
9 #include <string.h> |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
10 |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
11 struct treenode |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
12 { |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
13 int ccode; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
14 char *toksym; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
15 struct treenode *nextsibling; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
16 struct treenode *firstchild; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
17 }; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
18 |
123
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
19 /* |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
20 lookaheaddepth will start at 255 and count down which gives an appropriate |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
21 two's complement negative number. |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
22 */ |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
23 |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
24 int treedepth = 0; |
123
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
25 void print_tree(FILE *fp, struct treenode *tn, char *lookahead, int lookaheaddepth) |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
26 { |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
27 struct treenode *tn1; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
28 int depth = ++treedepth; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
29 |
126
ac183a519439
Update parsing scheme with a keyword lookup by token value and other framework
William Astle <lost@l-w.ca>
parents:
124
diff
changeset
|
30 fprintf(fp, "parse_wt%d fdb parse_wt%de-parse_wt%d\n", depth, depth, depth); |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
31 |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
32 for (tn1 = tn -> firstchild; tn1; tn1 = tn1 -> nextsibling) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
33 { |
123
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
34 // if there are child nodes, insert the sub tree |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
35 if (tn1 -> firstchild) |
123
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
36 { |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
37 fprintf(fp, " fcb 0x%02x,token_eot\n", tn1 -> ccode); |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
38 if (tn1 -> toksym) |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
39 { |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
40 print_tree(fp, tn1, tn1 -> toksym, 255); |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
41 } |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
42 else |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
43 { |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
44 if (lookahead) |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
45 { |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
46 print_tree(fp, tn1, lookahead, lookaheaddepth - 1); |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
47 } |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
48 else |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
49 { |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
50 print_tree(fp, tn1, NULL, 0); |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
51 } |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
52 } |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
53 } |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
54 // if there is also a terminal symbol here |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
55 if (tn1 -> toksym) |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
56 { |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
57 fprintf(fp, " fcb 0x%02x,%s\n", tn1 -> ccode, tn1 -> toksym); |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
58 } |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
59 } |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
60 // handle lookahead failure |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
61 if (lookahead) |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
62 { |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
63 fprintf(fp, " fcb 0x%02x,%s\n", lookaheaddepth, lookahead); |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
64 } |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
65 |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
66 fprintf(fp, "parse_wt%de\n", depth); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
67 } |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
68 |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
69 int main(int argc, char **argv) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
70 { |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
71 FILE *infile, *outfile; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
72 struct treenode *treeroot; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
73 struct treenode *tnp, *tn, *tnprev; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
74 char *linebuf = NULL; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
75 size_t bufsize = 0; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
76 ssize_t rval; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
77 char *ptr, *ptr2; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
78 |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
79 if (argc != 3) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
80 { |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
81 fprintf(stderr, "Usage: %s <source> <output>\n", argv[0]); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
82 exit(1); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
83 } |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
84 |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
85 infile = fopen(argv[1], "rb"); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
86 if (!infile) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
87 { |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
88 perror("Opening input file"); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
89 exit(1); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
90 } |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
91 |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
92 treeroot = calloc(1, sizeof(struct treenode)); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
93 while (1) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
94 { |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
95 rval = getline(&linebuf, &bufsize, infile); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
96 if (rval == -1) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
97 { |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
98 if (feof(infile)) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
99 break; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
100 perror("Reading keyword list line"); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
101 fclose(infile); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
102 if (linebuf) free(linebuf); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
103 exit(1); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
104 } |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
105 ptr = linebuf + rval - 1; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
106 // lose any line terminators |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
107 while (*ptr == '\r' || *ptr == '\n') |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
108 *ptr-- = '\0'; |
124
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
109 ptr = strchr(linebuf, '\t'); |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
110 if (!ptr) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
111 { |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
112 fprintf(stderr, "WARNING: malformed input line\n"); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
113 continue; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
114 } |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
115 *ptr++ = '\0'; // put a NUL break in |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
116 tnp = treeroot; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
117 for (ptr2 = linebuf; *ptr2; ptr2++) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
118 { |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
119 for (tn = tnp -> firstchild, tnprev = NULL; tn; tn = tn -> nextsibling) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
120 { |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
121 if (tn -> ccode == *ptr2) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
122 break; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
123 tnprev = tn; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
124 } |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
125 if (!tn) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
126 { |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
127 tn = calloc(1, sizeof(struct treenode)); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
128 tn -> ccode = *ptr2; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
129 if (!*(ptr2 + 1)) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
130 tn -> toksym = strdup(ptr); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
131 if (tnprev) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
132 tnprev -> nextsibling = tn; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
133 else |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
134 tnp -> firstchild = tn; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
135 } |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
136 tnp = tn; |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
137 } |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
138 } |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
139 fclose(infile); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
140 |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
141 outfile = fopen(argv[2], "wb"); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
142 if (!outfile) |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
143 { |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
144 perror("Opening output file"); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
145 exit(1); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
146 } |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
147 fprintf(outfile, "; This file is automatically generated. Edit %s and rebuild to make changes.\n", argv[1]); |
123
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
148 fprintf(outfile, " *pragmapush list\n *pragma list\n"); |
124
8770e6f977c3
Rework parser to use parse_wordtab for symbols too
William Astle <lost@l-w.ca>
parents:
123
diff
changeset
|
149 fprintf(outfile, "parse_wt\n"); |
123
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
150 print_tree(outfile, treeroot, NULL, 0); |
5681cdada362
Redo keyword table handling to handle keywords differing in length
William Astle <lost@l-w.ca>
parents:
121
diff
changeset
|
151 fprintf(outfile, " *pragmapop list\n"); |
121
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
152 fclose(outfile); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
153 exit(0); |
5d5472b11ccd
Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
154 } |