Mercurial > hg-old > index.cgi
annotate lwasm/macro.c @ 397:09fe7c40a082 3.0-beta1
Branched for 3.0-beta1 release
author | lost@l-w.ca |
---|---|
date | Fri, 23 Jul 2010 17:12:47 -0600 |
parents | a82c55070624 |
children |
rev | line source |
---|---|
339 | 1 /* |
2 macro.c | |
3 Copyright © 2008 William Astle | |
4 | |
5 This file is part of LWASM. | |
6 | |
7 LWASM is free software: you can redistribute it and/or modify it under the | |
8 terms of the GNU General Public License as published by the Free Software | |
9 Foundation, either version 3 of the License, or (at your option) any later | |
10 version. | |
11 | |
12 This program is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
15 more details. | |
16 | |
17 You should have received a copy of the GNU General Public License along with | |
18 this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 Contains stuff associated with macro processing | |
21 */ | |
22 | |
23 #include <config.h> | |
24 | |
25 #include <ctype.h> | |
26 #include <stdlib.h> | |
27 #include <string.h> | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
28 #include <stdio.h> |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
29 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
30 #include <lw_alloc.h> |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
31 #include <lw_string.h> |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
32 |
339 | 33 #include "lwasm.h" |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
34 #include "input.h" |
339 | 35 #include "instab.h" |
36 | |
346
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
345
diff
changeset
|
37 PARSEFUNC(pseudo_parse_macro) |
339 | 38 { |
39 macrotab_t *m; | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
40 |
346
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
345
diff
changeset
|
41 l -> len = 0; |
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
345
diff
changeset
|
42 |
339 | 43 if (as -> skipcond) |
44 { | |
45 as -> skipmacro = 1; | |
46 return; | |
47 } | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
48 |
339 | 49 if (as -> inmacro) |
50 { | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
51 lwasm_register_error(as, l, "Attempt to define a macro inside a macro"); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
52 return; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
53 } |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
54 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
55 if (!(l -> sym)) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
56 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
57 lwasm_register_error(as, l, "Missing macro name"); |
339 | 58 return; |
59 } | |
60 | |
61 for (m = as -> macros; m; m = m -> next) | |
62 { | |
63 if (!strcmp(m -> name, l -> sym)) | |
64 break; | |
65 } | |
66 if (m) | |
67 { | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
68 lwasm_register_error(as, l, "Duplicate macro definition"); |
339 | 69 return; |
70 } | |
71 | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
72 m = lw_alloc(sizeof(macrotab_t)); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
73 m -> name = lw_strdup(l -> sym); |
339 | 74 m -> next = as -> macros; |
75 m -> lines = NULL; | |
76 m -> numlines = 0; | |
77 as -> macros = m; | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
78 |
339 | 79 while (**p && !isspace(**p)) |
80 (*p)++; | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
81 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
82 as -> inmacro = 1; |
339 | 83 } |
84 | |
346
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
345
diff
changeset
|
85 PARSEFUNC(pseudo_parse_endm) |
339 | 86 { |
346
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
345
diff
changeset
|
87 l -> len = 0; |
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
345
diff
changeset
|
88 |
339 | 89 if (as -> skipcond) |
90 { | |
91 as -> skipmacro = 0; | |
92 return; | |
93 } | |
94 | |
95 if (!as -> inmacro) | |
96 { | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
97 lwasm_register_error(as, l, "ENDM without MACRO"); |
339 | 98 return; |
99 } | |
100 | |
101 as -> inmacro = 0; | |
102 | |
103 // a macro definition counts as a context break for local symbols | |
104 as -> context = lwasm_next_context(as); | |
105 } | |
106 | |
107 // the current macro will ALWAYS be the first one in the table | |
108 int add_macro_line(asmstate_t *as, char *optr) | |
109 { | |
110 if (!as -> inmacro) | |
111 return 0; | |
112 | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
113 as -> macros -> lines = lw_realloc(as -> macros -> lines, sizeof(char *) * (as -> macros -> numlines + 1)); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
114 as -> macros -> lines[as -> macros -> numlines] = lw_strdup(optr); |
339 | 115 as -> macros -> numlines += 1; |
116 return 1; | |
117 } | |
118 | |
119 void macro_add_to_buff(char **buff, int *loc, int *len, char c) | |
120 { | |
121 if (*loc == *len) | |
122 { | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
123 *buff = lw_realloc(*buff, *len + 32); |
339 | 124 *len += 32; |
125 } | |
126 (*buff)[(*loc)++] = c; | |
127 } | |
128 | |
129 // this is just like a regular operation function | |
130 /* | |
131 macro args are referenced by "\n" where 1 <= n <= 9 | |
132 or by "\{n}"; a \ can be included by writing \\ | |
133 a comma separates argument but one can be included with "\," | |
134 whitespace ends argument list but can be included with "\ " or the like | |
135 | |
136 */ | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
137 int expand_macro(asmstate_t *as, line_t *l, char **p, char *opc) |
339 | 138 { |
139 int lc; | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
140 line_t *cl, *nl; |
339 | 141 int oldcontext; |
142 macrotab_t *m; | |
143 | |
144 char **args = NULL; // macro arguments | |
145 int nargs = 0; // number of arguments | |
146 | |
147 char *p2, *p3; | |
148 | |
149 int bloc, blen; | |
150 char *linebuff; | |
151 | |
152 for (m = as -> macros; m; m = m -> next) | |
153 { | |
154 if (!strcmp(opc, m -> name)) | |
155 break; | |
156 } | |
157 // signal no macro expansion | |
158 if (!m) | |
159 return -1; | |
160 | |
161 // save current symbol context for after macro expansion | |
162 oldcontext = as -> context; | |
163 | |
164 cl = l; | |
165 | |
166 as -> context = lwasm_next_context(as); | |
167 | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
168 while (**p && !isspace(**p) && **p != ',') |
339 | 169 { |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
170 p2 = *p; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
171 while (*p2 && !isspace(*p2) && *p2 != ',') |
339 | 172 { |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
173 if (*p2 == '\\') |
339 | 174 { |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
175 if (p2[1]) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
176 p2++; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
177 } |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
178 p2++; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
179 } |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
180 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
181 // have arg here |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
182 args = lw_realloc(args, sizeof(char *) * (nargs + 1)); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
183 args[nargs] = lw_alloc(p2 - *p + 1); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
184 args[nargs][p2 - *p] = '\0'; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
185 memcpy(args[nargs], *p, p2 - *p); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
186 *p = p2; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
187 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
188 // now collapse out "\" characters |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
189 for (p3 = p2 = args[nargs]; *p2; p2++, p3++) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
190 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
191 if (*p2 == '\\' && p2[1]) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
192 { |
339 | 193 p2++; |
194 } | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
195 *p3 = *p2; |
339 | 196 } |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
197 *p3 = '\0'; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
198 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
199 nargs++; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
200 if (**p == ',') |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
201 (*p)++; |
339 | 202 } |
203 | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
204 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
205 // now create a string for the macro |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
206 // and push it into the front of the input stack |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
207 bloc = blen = 0; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
208 linebuff = NULL; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
209 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
210 for (lc = 0; lc < m -> numlines; lc++) |
339 | 211 { |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
212 for (p2 = m -> lines[lc]; *p2; p2++) |
339 | 213 { |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
214 if (*p2 == '\\' && isdigit(p2[1])) |
339 | 215 { |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
216 int n; |
339 | 217 |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
218 p2++; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
219 n = *p2 - '0'; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
220 if (n == 0) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
221 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
222 for (p3 = m -> name; *p3; p3++) |
339 | 223 macro_add_to_buff(&linebuff, &bloc, &blen, *p3); |
224 continue; | |
225 } | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
226 if (n < 1 || n > nargs) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
227 continue; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
228 for (p3 = args[n - 1]; *p3; p3++) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
229 macro_add_to_buff(&linebuff, &bloc, &blen, *p3); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
230 continue; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
231 } |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
232 else if (*p2 == '{') |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
233 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
234 int n = 0, n2; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
235 p2++; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
236 while (*p2 && isdigit(*p2)) |
339 | 237 { |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
238 n2 = *p2 - '0'; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
239 if (n2 < 0 || n2 > 9) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
240 n2 = 0; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
241 n = n * 10 + n2; |
339 | 242 p2++; |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
243 } |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
244 if (*p2 == '}') |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
245 p2++; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
246 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
247 if (n == 0) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
248 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
249 for (p3 = m -> name; *p3; p3++) |
339 | 250 macro_add_to_buff(&linebuff, &bloc, &blen, *p3); |
251 continue; | |
252 } | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
253 if (n < 1 || n > nargs) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
254 continue; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
255 for (p3 = args[n - 1]; *p3; p3++) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
256 macro_add_to_buff(&linebuff, &bloc, &blen, *p3); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
257 continue; |
339 | 258 } |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
259 else |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
260 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
261 macro_add_to_buff(&linebuff, &bloc, &blen, *p2); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
262 } |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
263 } |
339 | 264 |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
265 macro_add_to_buff(&linebuff, &bloc, &blen, '\n'); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
266 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
267 } |
339 | 268 |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
269 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
270 char ctcbuf[100]; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
271 char *p; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
272 snprintf(ctcbuf, 100, "\001\001SETCONTEXT %d\n", oldcontext); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
273 for (p = ctcbuf; *p; p++) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
274 macro_add_to_buff(&linebuff, &bloc, &blen, *p); |
339 | 275 } |
276 | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
277 // push the macro into the front of the stream |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
278 input_openstring(as, opc, linebuff); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
279 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
280 lw_free(linebuff); |
339 | 281 |
282 // clean up | |
283 if (args) | |
284 { | |
285 while (nargs) | |
286 { | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
287 lw_free(args[--nargs]); |
339 | 288 } |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
339
diff
changeset
|
289 lw_free(args); |
339 | 290 } |
291 | |
292 // indicate a macro was expanded | |
293 return 0; | |
294 } |