428
|
1 %{
|
|
2
|
|
3 /* This is a Lex file. */
|
|
4
|
|
5 /* Localizable-message snarfing.
|
|
6 Copyright (C) 1994, 1995 Amdahl Corporation.
|
|
7
|
|
8 This file is part of XEmacs.
|
|
9
|
|
10 XEmacs is free software; you can redistribute it and/or modify
|
|
11 it under the terms of the GNU General Public License as published by
|
|
12 the Free Software Foundation; either version 2, or (at your option)
|
|
13 any later version.
|
|
14
|
|
15 XEmacs is distributed in the hope that it will be useful,
|
|
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 GNU General Public License for more details.
|
|
19
|
|
20 You should have received a copy of the GNU General Public License
|
|
21 along with XEmacs; see the file COPYING. If not, write to
|
|
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
23 Boston, MA 02111-1307, USA. */
|
|
24
|
|
25 /* Written by Ben Wing, November 1994. Some code based on earlier
|
|
26 make-msgfile.c. */
|
|
27
|
2367
|
28 /* See text.c for a proposal about how this whole system should work. */
|
|
29
|
428
|
30 /* Note: there is still much work to be done on this.
|
|
31
|
|
32 1) Definition of Arg below won't handle a generalized argument
|
|
33 as might appear in a function call. This is fine for DEFUN
|
|
34 and friends, because only simple arguments appear there; but
|
|
35 it might run into problems if Arg is used for other sorts
|
|
36 of functions.
|
|
37 2) snarf() should be modified so that it doesn't output null
|
|
38 strings and non-textual strings (see the comment at the top
|
|
39 of make-msgfile.c).
|
|
40 3) parsing of (insert) should snarf all of the arguments.
|
|
41 4) need to add set-keymap-prompt and deal with gettext of that.
|
|
42 5) parsing of arguments should snarf all strings anywhere within
|
|
43 the arguments, rather than just looking for a string as the
|
|
44 argument. This allows if statements as arguments to get parsed.
|
|
45 6) begin_paren_counting() et al. should handle recursive entry.
|
|
46 7) handle set-window-buffer and other such functions that take
|
|
47 a buffer as the other-than-first argument.
|
|
48 8) there is a fair amount of work to be done on the C code.
|
|
49 Look through the code for #### comments associated with
|
|
50 '#ifdef I18N3' or with an I18N3 nearby.
|
|
51 9) Deal with `get-buffer-process' et al.
|
|
52 10) Many of the changes in the Lisp code marked
|
|
53 'rewritten for I18N3 snarfing' should be undone once (5) is
|
|
54 implemented.
|
|
55 11) Go through the Lisp code in prim and make sure that all
|
|
56 strings are gettexted as necessary. This may reveal more
|
|
57 things to implement.
|
|
58 12) Do the equivalent of (8) for the Lisp code.
|
|
59 13) Deal with parsing of menu specifications.
|
|
60
|
|
61 --ben
|
|
62
|
|
63 */
|
|
64
|
|
65 /* Some notes:
|
|
66
|
|
67 -- {Arg} below could get confused by commas inside of quotes.
|
|
68 -- {LispToken} below can match some things that are not tokens (e.g.
|
|
69 numbers) but for all practical purposes it should be fine.
|
|
70 */
|
|
71
|
|
72 #include <stdio.h>
|
|
73
|
|
74 int snarf_return_state;
|
|
75
|
|
76 %}
|
|
77
|
|
78 %p 6000
|
|
79 %e 2000
|
|
80 %n 1000
|
|
81 %a 4000
|
|
82 %s C_QUOTE C_COMMENT LQUO LCOM
|
|
83 %s CSNARF LSNARF
|
|
84 %s DO_C DO_LISP DEFUN
|
|
85 %s DEFUN2 DEFUN3 LDEF
|
|
86
|
|
87 W [ \t\n]
|
|
88 Any (.|"\n")
|
|
89 Q "\""
|
|
90 NQ [^"]
|
|
91 NT [^A-Za-z_0-9]
|
|
92 LP "("
|
|
93 RP ")"
|
|
94 BS "\\"
|
|
95 Esc ({BS}{Any})
|
|
96 Wh ({W}*)
|
|
97 LCom (";"({Esc}|.)*)
|
|
98 LWh (({W}|{Lcom})*)
|
|
99 Open ({Wh}{LP})
|
|
100 OpWQ ({Open}{Wh}{Q})
|
|
101 String ({Q}({Esc}|{NQ})*{Q})
|
|
102 Arg ([^,]*",")
|
|
103 StringArg ({Wh}{String}{Wh}",")
|
|
104 OpenString ({Open}{StringArg})
|
|
105 LispToken (({Esc}|[-A-Za-z0-9!@$%^&*_=+|{}`~,<.>/?])+)
|
|
106 %%
|
|
107
|
|
108 <DO_C>{NT}"GETTEXT"{OpWQ} { snarf (); }
|
|
109 <DO_C>{NT}"DEFER_GETTEXT"{OpWQ} { snarf (); }
|
|
110 <DO_C>{NT}"build_translated_string"{OpWQ} { snarf (); }
|
|
111 <DO_C>{NT}"insert_string"{OpWQ} { snarf (); }
|
|
112 <DO_C>{NT}"message"{OpWQ} { snarf (); }
|
|
113 <DO_C>{NT}"warn_when_safe"{OpWQ} { snarf (); }
|
|
114 <DO_C>{NT}"error"{OpWQ} { snarf (); }
|
|
115 <DO_C>{NT}"continuable_error"{OpWQ} { snarf (); }
|
|
116 <DO_C>{NT}"signal_simple_error"{OpWQ} { snarf (); }
|
|
117 <DO_C>{NT}"signal_simple_error_2"{OpWQ} { snarf (); }
|
|
118 <DO_C>{NT}"signal_simple_continuable_error"{OpWQ} { snarf (); }
|
|
119 <DO_C>{NT}"signal_simple_continuable_error_2"{OpWQ} { snarf (); }
|
|
120 <DO_C>{NT}"report_file_error"{OpWQ} { snarf (); }
|
|
121 <DO_C>{NT}"signal_file_error"{OpWQ} { snarf (); }
|
|
122 <DO_C>{NT}"signal_double_file_error"{OpWQ} { snarf (); }
|
|
123 <DO_C>{NT}"signal_double_file_error_2"{OpWQ} { snarf (); }
|
|
124 <DO_C>{NT}"syntax_error"{OpWQ} { snarf (); }
|
|
125 <DO_C>{NT}"continuable_syntax_error"{OpWQ} { snarf (); }
|
|
126 <DO_C>{NT}"CTB_ERROR"{OpWQ} { snarf (); }
|
|
127 <DO_C>{NT}"fatal"{OpWQ} { snarf (); }
|
|
128 <DO_C>{NT}"stdout_out"{OpWQ} { snarf (); }
|
|
129 <DO_C>{NT}"stderr_out"{OpWQ} { snarf (); }
|
|
130 <DO_C>{NT}"with_output_to_temp_buffer"{OpWQ} { snarf (); }
|
|
131
|
|
132 <DO_C>{NT}"DEFVAR_BOOL"{OpenString}{Arg}{Wh}{Q} { snarf (); }
|
|
133 <DO_C>{NT}"DEFVAR_LISP"{OpenString}{Arg}{Wh}{Q} { snarf (); }
|
|
134 <DO_C>{NT}"DEFVAR_SPECIFIER"{OpenString}{Arg}{Wh}{Q} { snarf (); }
|
|
135 <DO_C>{NT}"DEFVAR_INT"{OpenString}{Arg}{Wh}{Q} { snarf (); }
|
|
136 <DO_C>{NT}"DEFVAR_BUFFER_LOCAL"{OpenString}{Arg}{Wh}{Q} { snarf (); }
|
|
137 <DO_C>{NT}"DEFVAR_BUFFER_DEFAULTS"{OpenString}{Arg}{Wh}{Q} { snarf (); }
|
|
138 <DO_C>{NT}"deferror"{Open}{Arg}{StringArg}{Wh}{Q} { snarf (); }
|
|
139
|
|
140 <DO_C>{NT}"barf_or_query_if_file_exists"{Open}{Arg}{Wh}{Q} {
|
|
141 /* #### see comment above about use of Arg */
|
|
142 snarf ();
|
|
143 }
|
|
144
|
|
145 <DO_C>{NT}"DEFUN"{Open} { BEGIN DEFUN; }
|
|
146
|
|
147 <DO_C>"/*" {
|
|
148 /* This is hateful, but doc strings are sometimes put inside of comments
|
|
149 (to get around limits in cpp), so we can't ignore stuff inside of
|
|
150 comments. */
|
|
151 /* BEGIN C_COMMENT; */
|
|
152 }
|
|
153 <DO_C>{Q} { BEGIN C_QUOTE; }
|
|
154 <DO_C>{Any} { }
|
|
155
|
|
156 <DEFUN>{StringArg}{Arg}{Arg}{Arg}{Arg}{Wh} { BEGIN DEFUN2; }
|
|
157 <DEFUN>{Any} { bad_c_defun (); }
|
|
158
|
|
159 <DEFUN2>{Q} {
|
|
160 /* We found an interactive specification. */
|
|
161 snarf_return_state = DEFUN3;
|
|
162 snarf ();
|
|
163 }
|
|
164 <DEFUN2>[^,]* {
|
|
165 /* This function doesn't have an interactive specification.
|
|
166 Don't use {Arg} in the specification because DEFUN3 looks
|
|
167 for the comma. */
|
|
168 BEGIN DEFUN3;
|
|
169 }
|
|
170
|
|
171 <DEFUN3>{Wh}","{Wh}{Q} {
|
|
172 snarf_return_state = DO_C;
|
|
173 snarf ();
|
|
174 }
|
|
175 <DEFUN3>{Any} { bad_c_defun (); }
|
|
176
|
|
177 <C_QUOTE>{Esc} { }
|
|
178 <C_QUOTE>{Q} { BEGIN DO_C; }
|
|
179 <C_QUOTE>{Any} { }
|
|
180
|
|
181 <C_COMMENT>"*/" { BEGIN DO_C; }
|
|
182 <C_COMMENT>{Any} { }
|
|
183
|
|
184 <DO_LISP>{LP}{LWh}"gettext"{LWh}{Q} { inc_paren (); snarf (); }
|
|
185 <DO_LISP>{LP}{LWh}"purecopy"{LWh}{Q} { inc_paren (); snarf (); }
|
|
186 <DO_LISP>{LP}{LWh}"interactive"{LWh}{Q} { inc_paren (); snarf (); }
|
|
187 <DO_LISP>{LP}{LWh}"message"{LWh}{Q} { inc_paren (); snarf (); }
|
|
188 <DO_LISP>{LP}{LWh}"error"{LWh}{Q} { inc_paren (); snarf (); }
|
|
189 <DO_LISP>{LP}{LWh}"warn"{LWh}{Q} { inc_paren (); snarf (); }
|
|
190 <DO_LISP>{LP}{LWh}"format"{LWh}{Q} { inc_paren (); snarf (); }
|
|
191 <DO_LISP>{LP}{LWh}"substitute-command-keys"{LWh}{Q} { inc_paren (); snarf (); }
|
|
192 <DO_LISP>{LP}{LWh}"temp-minibuffer-message"{LWh}{Q} { inc_paren (); snarf (); }
|
|
193 <DO_LISP>{LP}{LWh}"momentary-string-display"{LWh}{Q} { inc_paren (); snarf (); }
|
|
194 <DO_LISP>{LP}{LWh}"princ"{LWh}{Q} { inc_paren (); snarf (); }
|
|
195 <DO_LISP>{LP}{LWh}"prin1"{LWh}{Q} { inc_paren (); snarf (); }
|
|
196 <DO_LISP>{LP}{LWh}"prin1-to-string"{LWh}{Q} { inc_paren (); snarf (); }
|
|
197 <DO_LISP>{LP}{LWh}"print"{LWh}{Q} { inc_paren (); snarf (); }
|
|
198 <DO_LISP>{LP}{LWh}"insert"{LWh}{Q} { inc_paren (); snarf (); }
|
|
199 <DO_LISP>{LP}{LWh}"insert-before-markers"{LWh}{Q} { inc_paren (); snarf (); }
|
|
200
|
|
201 <DO_LISP>{LP}{LWh}"get-buffer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
202 <DO_LISP>{LP}{LWh}"get-buffer-create"{LWh}{Q} { inc_paren (); snarf (); }
|
|
203 <DO_LISP>{LP}{LWh}"generate-new-buffer-name"{LWh}{Q} { inc_paren (); snarf (); }
|
|
204 <DO_LISP>{LP}{LWh}"rename-buffer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
205 <DO_LISP>{LP}{LWh}"set-buffer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
206 <DO_LISP>{LP}{LWh}"switch-to-buffer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
207 <DO_LISP>{LP}{LWh}"pop-to-buffer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
208 <DO_LISP>{LP}{LWh}"with-output-to-temp-buffer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
209 <DO_LISP>{LP}{LWh}"buffer-enable-undo"{LWh}{Q} { inc_paren (); snarf (); }
|
|
210 <DO_LISP>{LP}{LWh}"buffer-disable-undo"{LWh}{Q} { inc_paren (); snarf (); }
|
|
211 <DO_LISP>{LP}{LWh}"get-buffer-window"{LWh}{Q} { inc_paren (); snarf (); }
|
|
212 <DO_LISP>{LP}{LWh}"delete-windows-on"{LWh}{Q} { inc_paren (); snarf (); }
|
|
213 <DO_LISP>{LP}{LWh}"replace-buffer-in-windows"{LWh}{Q} { inc_paren (); snarf (); }
|
|
214 <DO_LISP>{LP}{LWh}"display-buffer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
215 <DO_LISP>{LP}{LWh}"other-buffer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
216
|
|
217 <DO_LISP>{LP}{LWh}"read-from-minibuffer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
218 <DO_LISP>{LP}{LWh}"read-shell-command"{LWh}{Q} { inc_paren (); snarf (); }
|
|
219 <DO_LISP>{LP}{LWh}"read-file-name"{LWh}{Q} { inc_paren (); snarf (); }
|
|
220 <DO_LISP>{LP}{LWh}"read-buffer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
221 <DO_LISP>{LP}{LWh}"read-variable"{LWh}{Q} { inc_paren (); snarf (); }
|
|
222 <DO_LISP>{LP}{LWh}"read-command"{LWh}{Q} { inc_paren (); snarf (); }
|
|
223 <DO_LISP>{LP}{LWh}"read-function"{LWh}{Q} { inc_paren (); snarf (); }
|
|
224 <DO_LISP>{LP}{LWh}"read-directory-name"{LWh}{Q} { inc_paren (); snarf (); }
|
|
225 <DO_LISP>{LP}{LWh}"read-string"{LWh}{Q} { inc_paren (); snarf (); }
|
|
226 <DO_LISP>{LP}{LWh}"read-number"{LWh}{Q} { inc_paren (); snarf (); }
|
|
227 <DO_LISP>{LP}{LWh}"read-minibuffer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
228 <DO_LISP>{LP}{LWh}"read-quoted-char"{LWh}{Q} { inc_paren (); snarf (); }
|
|
229 <DO_LISP>{LP}{LWh}"read-face-name"{LWh}{Q} { inc_paren (); snarf (); }
|
|
230 <DO_LISP>{LP}{LWh}"read-itimer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
231 <DO_LISP>{LP}{LWh}"completing-read"{LWh}{Q} { inc_paren (); snarf (); }
|
|
232 <DO_LISP>{LP}{LWh}"y-or-n-p"{LWh}{Q} { inc_paren (); snarf (); }
|
|
233 <DO_LISP>{LP}{LWh}"yes-or-no-p"{LWh}{Q} { inc_paren (); snarf (); }
|
|
234 <DO_LISP>{LP}{LWh}"query-replace-read-args"{LWh}{Q} { inc_paren (); snarf (); }
|
|
235 <DO_LISP>{LP}{LWh}"eval-minibuffer"{LWh}{Q} { inc_paren (); snarf (); }
|
|
236 <DO_LISP>{LP}{LWh}"edit-and-eval-command"{LWh}{Q} { inc_paren (); snarf (); }
|
|
237
|
|
238 <DO_LISP>{LP}{LWh}"defvar"{LWh}{LispToken}{LWh} {
|
|
239 inc_paren (); begin_paren_counting (LDEF);
|
|
240 }
|
|
241 <DO_LISP>{LP}{LWh}"defconst"{LWh}{LispToken}{LWh} {
|
|
242 inc_paren (); begin_paren_counting (LDEF);
|
|
243 }
|
|
244 <DO_LISP>{LP}{LWh}"defun"{LWh}{LispToken}{LWh} {
|
|
245 inc_paren (); begin_paren_counting (LDEF);
|
|
246 }
|
|
247 <DO_LISP>{LP}{LWh}"defmacro"{LWh}{LispToken}{LWh} {
|
|
248 inc_paren (); begin_paren_counting (LDEF);
|
|
249 }
|
|
250 <DO_LISP>{LP}{LWh}"defsubst"{LWh}{LispToken}{LWh} {
|
|
251 inc_paren (); begin_paren_counting (LDEF);
|
|
252 }
|
|
253
|
|
254 <DO_LISP>{Q} { BEGIN LQUO; }
|
|
255 <DO_LISP>";" { BEGIN LCOM; }
|
|
256 <DO_LISP>{LP} { inc_paren (); }
|
|
257 <DO_LISP>{RP} { dec_paren (); }
|
|
258 <DO_LISP>{Esc} { }
|
|
259 <DO_LISP>{W} { lisp_whitespace (); }
|
|
260 <DO_LISP>{Any} { }
|
|
261
|
|
262 <LQUO>{Esc} { }
|
|
263 <LQUO>{Q} { BEGIN DO_LISP; }
|
|
264 <LQUO>{Any} { }
|
|
265
|
|
266 <LCOM>"\n" { BEGIN DO_LISP; }
|
|
267 <LCOM>{Any} { }
|
|
268
|
|
269 <LDEF>{LWh}{Q} { snarf (); }
|
|
270 <LDEF>{Any} { BEGIN DO_LISP; }
|
|
271
|
|
272 <CSNARF>{Esc} { ECHO; }
|
|
273 <CSNARF>{Q} { ECHO; fprintf (yyout, ")\n"); BEGIN snarf_return_state; }
|
|
274 <CSNARF>{Any} { ECHO; }
|
|
275
|
|
276 <LSNARF>{Esc} { ECHO; }
|
|
277 <LSNARF>"\n" { fprintf (yyout, "\\n\\\n"); }
|
|
278 <LSNARF>{Q} { ECHO; fprintf (yyout, ")\n"); BEGIN snarf_return_state; }
|
|
279 <LSNARF>{Any} { ECHO; }
|
|
280
|
|
281 %%
|
|
282
|
|
283 enum filetype { C_FILE, LISP_FILE, INVALID_FILE };
|
|
284 /* some brain-dead headers define this ... */
|
|
285 #undef FALSE
|
|
286 #undef TRUE
|
|
287 enum boolean { FALSE, TRUE };
|
|
288
|
|
289 void scan_file (char *filename);
|
|
290 void process_C_file (void);
|
|
291 void process_Lisp_file (void);
|
|
292
|
|
293 int in_c;
|
|
294 int in_paren_counting, paren_count;
|
|
295 int paren_return_state;
|
|
296
|
|
297 snarf ()
|
|
298 {
|
|
299 fprintf (yyout, "gettext(\"");
|
|
300 if (in_c)
|
|
301 BEGIN CSNARF;
|
|
302 else
|
|
303 BEGIN LSNARF;
|
|
304 }
|
|
305
|
|
306 bad_c_defun ()
|
|
307 {
|
|
308 fprintf (stderr, "Warning: Invalid DEFUN encountered in C, line %d.\n",
|
|
309 yylineno);
|
|
310 snarf_return_state = DO_C;
|
|
311 BEGIN DO_C;
|
|
312 /* REJECT; Sun's lex is broken! Use Flex! */
|
|
313 }
|
|
314
|
|
315 bad_lisp_def ()
|
|
316 {
|
|
317 fprintf (stderr,
|
|
318 "Warning: Invalid defmumble encountered in Lisp, line %d.\n",
|
|
319 yylineno);
|
|
320 snarf_return_state = DO_LISP;
|
|
321 BEGIN DO_LISP;
|
|
322 /* REJECT; Sun's lex is broken! Use Flex! */
|
|
323 }
|
|
324
|
|
325 inc_paren ()
|
|
326 {
|
|
327 if (in_paren_counting)
|
|
328 paren_count++;
|
|
329 }
|
|
330
|
|
331 dec_paren ()
|
|
332 {
|
|
333 if (in_paren_counting)
|
|
334 {
|
|
335 /* If we find a right paren without a matching left paren, it usually
|
|
336 just indicates a statement like
|
|
337
|
|
338 (defvar foo-mumble nil)
|
|
339
|
|
340 where 'nil' is the sexp we are skipping over, and there's no
|
|
341 doc string. */
|
|
342 if (paren_count > 0)
|
|
343 paren_count--;
|
|
344 else
|
|
345 unput (')');
|
|
346 if (paren_count == 0)
|
|
347 {
|
|
348 in_paren_counting = 0;
|
|
349 BEGIN paren_return_state;
|
|
350 }
|
|
351 }
|
|
352 }
|
|
353
|
|
354 /* #### begin_paren_counting () does not handle recursive entries */
|
|
355
|
|
356 begin_paren_counting (int return_state)
|
|
357 {
|
|
358 in_paren_counting = 1;
|
|
359 paren_count = 0;
|
|
360 paren_return_state = return_state;
|
|
361 }
|
|
362
|
|
363 lisp_whitespace ()
|
|
364 {
|
|
365 if (in_paren_counting && !paren_count)
|
|
366 {
|
|
367 /* We got to the end of a token and we're not in a parenthesized
|
|
368 expression, so we're at the end of an sexp. */
|
|
369 in_paren_counting = 0;
|
|
370 BEGIN paren_return_state;
|
|
371 }
|
|
372 }
|
|
373
|
|
374 yywrap ()
|
|
375 {
|
|
376 return 1;
|
|
377 }
|
|
378
|
|
379 main (int argc, char *argv[])
|
|
380 {
|
|
381 register int i;
|
|
382
|
|
383 yyout = stdout;
|
|
384
|
|
385 /* If first two args are -o FILE, output to FILE. */
|
|
386 i = 1;
|
|
387 if (argc > i + 1 && strcmp (argv[i], "-o") == 0) {
|
|
388 yyout = fopen (argv[++i], "w");
|
|
389 ++i;
|
|
390 }
|
|
391 /* ...Or if args are -a FILE, append to FILE. */
|
|
392 if (argc > i + 1 && strcmp (argv[i], "-a") == 0) {
|
|
393 yyout = fopen (argv[++i], "a");
|
|
394 ++i;
|
|
395 }
|
|
396 if (!yyout) {
|
|
397 fprintf (stderr, "Unable to open output file %s\n", argv[--i]);
|
|
398 return;
|
|
399 }
|
|
400
|
|
401 for (; i < argc; i++)
|
|
402 scan_file (argv[i]);
|
|
403
|
|
404 return 0;
|
|
405 }
|
|
406
|
|
407
|
|
408 void scan_file (char *filename)
|
|
409 {
|
|
410 enum filetype type = INVALID_FILE;
|
|
411 register char *p = filename + strlen (filename);
|
|
412
|
|
413 if (strcmp (p - 4, ".elc") == 0) {
|
|
414 *--p = '\0'; /* Use .el file instead */
|
|
415 type = LISP_FILE;
|
|
416 } else if (strcmp (p - 3, ".el") == 0)
|
|
417 type = LISP_FILE;
|
|
418 else if (strcmp (p - 2, ".o") == 0) {
|
|
419 *--p = 'c'; /* Use .c file instead */
|
|
420 type = C_FILE;
|
|
421 } else if (strcmp (p - 2, ".c") == 0)
|
|
422 type = C_FILE;
|
|
423
|
|
424 if (type == INVALID_FILE) {
|
|
425 fprintf (stderr, "File %s being ignored\n", filename);
|
|
426 return;
|
|
427 }
|
|
428 yyin = fopen (filename, "r");
|
|
429 if (!yyin) {
|
|
430 fprintf (stderr, "Unable to open input file %s\n", filename);
|
|
431 return;
|
|
432 }
|
|
433
|
|
434 fprintf (yyout, "/* %s */\n", filename);
|
|
435 if (type == C_FILE)
|
|
436 process_C_file ();
|
|
437 else
|
|
438 process_Lisp_file ();
|
|
439 fputc ('\n', yyout);
|
|
440
|
|
441 fclose (yyin);
|
|
442 }
|
|
443
|
|
444 void process_C_file ()
|
|
445 {
|
|
446 snarf_return_state = DO_C;
|
|
447 in_c = 1;
|
|
448 BEGIN DO_C;
|
|
449 yylex ();
|
|
450 }
|
|
451
|
|
452 void process_Lisp_file ()
|
|
453 {
|
|
454 snarf_return_state = DO_LISP;
|
|
455 in_c = 0;
|
|
456 BEGIN DO_LISP;
|
|
457 yylex ();
|
|
458 }
|
|
459
|