annotate lib-src/make-msgfile.lex @ 440:8de8e3f6228a r21-2-28

Import from CVS: tag r21-2-28
author cvs
date Mon, 13 Aug 2007 11:33:38 +0200
parents 3ecd8885ac67
children ecf1ebac70d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 %{
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 /* This is a Lex file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 /* Localizable-message snarfing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 Copyright (C) 1994, 1995 Amdahl Corporation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 XEmacs is free software; you can redistribute it and/or modify
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 it under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 XEmacs is distributed in the hope that it will be useful,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 GNU General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /* Written by Ben Wing, November 1994. Some code based on earlier
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 make-msgfile.c. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 /* Note: there is still much work to be done on this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 1) Definition of Arg below won't handle a generalized argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 as might appear in a function call. This is fine for DEFUN
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 and friends, because only simple arguments appear there; but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 it might run into problems if Arg is used for other sorts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 of functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 2) snarf() should be modified so that it doesn't output null
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 strings and non-textual strings (see the comment at the top
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 of make-msgfile.c).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 3) parsing of (insert) should snarf all of the arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 4) need to add set-keymap-prompt and deal with gettext of that.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 5) parsing of arguments should snarf all strings anywhere within
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 the arguments, rather than just looking for a string as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 argument. This allows if statements as arguments to get parsed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 6) begin_paren_counting() et al. should handle recursive entry.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 7) handle set-window-buffer and other such functions that take
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 a buffer as the other-than-first argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 8) there is a fair amount of work to be done on the C code.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 Look through the code for #### comments associated with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 '#ifdef I18N3' or with an I18N3 nearby.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 9) Deal with `get-buffer-process' et al.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 10) Many of the changes in the Lisp code marked
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 'rewritten for I18N3 snarfing' should be undone once (5) is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 implemented.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 11) Go through the Lisp code in prim and make sure that all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 strings are gettexted as necessary. This may reveal more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 things to implement.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 12) Do the equivalent of (8) for the Lisp code.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 13) Deal with parsing of menu specifications.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 --ben
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 /* Long comment from jwz:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 (much of this comment is outdated, and a lot of it is actually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 implemented)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 PROPOSAL FOR HOW THIS ALL OUGHT TO WORK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 this isn't implemented yet, but this is the plan-in-progress
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 In general, it's accepted that the best way to internationalize is for all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 messages to be referred to by a symbolic name (or number) and come out of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 table or tables, which are easy to change.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 However, with Emacs, we've got the task of internationalizing a huge body
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 of existing code, which already contains messages internally.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 For the C code we've got two options:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 - Use a Sun-like gettext() form, which takes an "english" string which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 appears literally in the source, and uses that as a hash key to find
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 a translated string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 - Rip all of the strings out and put them in a table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 In this case, it's desirable to make as few changes as possible to the C
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 code, to make it easier to merge the code with the FSF version of emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 which won't ever have these changes made to it. So we should go with the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 former option.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 The way it has been done (between 19.8 and 19.9) was to use gettext(), but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 *also* to make massive changes to the source code. The goal now is to use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 gettext() at run-time and yet not require a textual change to every line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 in the C code which contains a string constant. A possible way to do this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 is described below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 (gettext() can be implemented in terms of catgets() for non-Sun systems, so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 that in itself isn't a problem.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 For the Lisp code, we've got basically the same options: put everything in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 a table, or translate things implicitly.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 Another kink that lisp code introduces is that there are thousands of third-
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 party packages, so changing the source for all of those is simply not an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 option.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 Is it a goal that if some third party package displays a message which is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 one we know how to translate, then we translate it? I think this is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 worthy goal. It remains to be seen how well it will work in practice.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 So, we should endeavor to minimize the impact on the lisp code. Certain
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 primitive lisp routines (the stuff in lisp/prim/, and especially in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 cmdloop.el and minibuf.el) may need to be changed to know about translation,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 but that's an ideologically clean thing to do because those are considered
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 a part of the emacs substrate.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 However, if we find ourselves wanting to make changes to, say, RMAIL, then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 something has gone wrong. (Except to do things like remove assumptions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 about the order of words within a sentence, or how pluralization works.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 There are two parts to the task of displaying translated strings to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 user: the first is to extract the strings which need to be translated from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 the sources; and the second is to make some call which will translate those
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 strings before they are presented to the user.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 The old way was to use the same form to do both, that is, GETTEXT() was both
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 the tag that we searched for to build a catalog, and was the form which did
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 the translation. The new plan is to separate these two things more: the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 tags that we search for to build the catalog will be stuff that was in there
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 already, and the translation will get done in some more centralized, lower
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 level place.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 This program (make-msgfile.c) addresses the first part, extracting the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 strings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 For the emacs C code, we need to recognize the following patterns:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 message ("string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 error ("string")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 report_file_error ("string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 signal_simple_error ("string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 signal_simple_error_2 ("string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 build_translated_string ("string")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 #### add this and use it instead of build_string() in some places.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 yes_or_no_p ("string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 #### add this instead of funcalling Qyes_or_no_p directly.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 barf_or_query_if_file_exists #### restructure this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 check all callers of Fsignal #### restructure these
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 signal_error (Qerror ... ) #### change all of these to error()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 And we also parse out the `interactive' prompts from DEFUN() forms.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 #### When we've got a string which is a candidate for translation, we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 should ignore it if it contains only format directives, that is, if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 there are no alphabetic characters in it that are not a part of a `%'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 directive. (Careful not to translate either "%s%s" or "%s: ".)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 For the emacs Lisp code, we need to recognize the following patterns:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 (message "string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 (error "string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 (format "string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 (read-from-minibuffer "string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (read-shell-command "string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (y-or-n-p "string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 (yes-or-no-p "string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (read-file-name "string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 (temp-minibuffer-message "string")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 (query-replace-read-args "string" ... )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 I expect there will be a lot like the above; basically, any function which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 is a commonly used wrapper around an eventual call to `message' or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 `read-from-minibuffer' needs to be recognized by this program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (dgettext "domain-name" "string") #### do we still need this?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 things that should probably be restructured:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 `princ' in cmdloop.el
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 `insert' in debug.el
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 face-interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 help.el, syntax.el all messed up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 BPW: (format) is a tricky case. If I use format to create a string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 that I then send to a file, I probably don't want the string translated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 On the other hand, If the string gets used as an argument to (y-or-n-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 or some such function, I do want it translated, and it needs to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 translated before the %s and such are replaced. The proper solution
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 here is for (format) and other functions that call gettext but don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 immediately output the string to the user to add the translated (and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 formatted) string as a string property of the object, and have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 functions that output potentially translated strings look for a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 "translated string" property. Of course, this will fail if someone
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 does something like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 (y-or-n-p (concat (if you-p "Do you " "Does he ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 (format "want to delete %s? " filename))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 But you shouldn't be doing things like this anyway.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 BPW: Also, to avoid excessive translating, strings should be marked
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 as translated once they get translated, and further calls to gettext
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 don't do any more translating. Otherwise, a call like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 (y-or-n-p (format "Delete %s? " filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 would cause translation on both the pre-formatted and post-formatted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 strings, which could lead to weird results in some cases (y-or-n-p
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 has to translate its argument because someone could pass a string to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 it directly). Note that the "translating too much" solution outlined
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 below could be implemented by just marking all strings that don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 come from a .el or .elc file as already translated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 Menu descriptors: one way to extract the strings in menu labels would be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 to teach this program about "^(defvar .*menu\n" forms; that's probably
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 kind of hard, though, so perhaps a better approach would be to make this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 program recognize lines of the form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 "string" ... ;###translate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 where the magic token ";###translate" on a line means that the string
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
226 constant on this line should go into the message catalog. This is analogous
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 to the magic ";###autoload" comments, and to the magic comments used in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 EPSF structuring conventions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 -----
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 So this program manages to build up a catalog of strings to be translated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 To address the second part of the problem, of actually looking up the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 translations, there are hooks in a small number of low level places in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 Assume the existence of a C function gettext(str) which returns the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 translation of `str' if there is one, otherwise returns `str'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 - message() takes a char* as its argument, and always filters it through
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 gettext() before displaying it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 - errors are printed by running the lisp function `display-error' which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 doesn't call `message' directly (it princ's to streams), so it must be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 carefully coded to translate its arguments. This is only a few lines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 of code.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 - Fread_minibuffer_internal() is the lowest level interface to all minibuf
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 interactions, so it is responsible for translating the value that will go
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 into Vminibuf_prompt.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 - Fpopup_menu filters the menu titles through gettext().
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 The above take care of 99% of all messages the user ever sees.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 - The lisp function temp-minibuffer-message translates its arg.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 - query-replace-read-args is funny; it does
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 (setq from (read-from-minibuffer (format "%s: " string) ... ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 (setq to (read-from-minibuffer (format "%s %s with: " string from) ... ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 What should we do about this? We could hack query-replace-read-args to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 translate its args, but might this be a more general problem? I don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 think we ought to translate all calls to format. We could just change
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 the calling sequence, since this is odd in that the first %s wants to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 translated but the second doesn't.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 Solving the "translating too much" problem:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 The concern has been raised that in this situation:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 - "Help" is a string for which we know a translation;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 - someone visits a file called Help, and someone does something
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 contrived like (error buffer-file-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 then we would display the translation of Help, which would not be correct.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 We can solve this by adding a bit to Lisp_String objects which identifies
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 them as having been read as literal constants from a .el or .elc file (as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 opposed to having been constructed at run time as it would in the above
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 case.) To solve this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 - Fmessage() takes a lisp string as its first argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 If that string is a constant, that is, was read from a source file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 as a literal, then it calls message() with it, which translates.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 Otherwise, it calls message_no_translate(), which does not translate.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 - Ferror() (actually, Fsignal() when condition is Qerror) works similarly.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 /* Some notes:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 -- {Arg} below could get confused by commas inside of quotes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 -- {LispToken} below can match some things that are not tokens (e.g.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 numbers) but for all practical purposes it should be fine.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 int snarf_return_state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 %}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 %p 6000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 %e 2000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 %n 1000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 %a 4000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 %s C_QUOTE C_COMMENT LQUO LCOM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 %s CSNARF LSNARF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 %s DO_C DO_LISP DEFUN
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 %s DEFUN2 DEFUN3 LDEF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 W [ \t\n]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 Any (.|"\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 Q "\""
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 NQ [^"]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 NT [^A-Za-z_0-9]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 LP "("
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 RP ")"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 BS "\\"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 Esc ({BS}{Any})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 Wh ({W}*)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 LCom (";"({Esc}|.)*)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 LWh (({W}|{Lcom})*)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 Open ({Wh}{LP})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 OpWQ ({Open}{Wh}{Q})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 String ({Q}({Esc}|{NQ})*{Q})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 Arg ([^,]*",")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 StringArg ({Wh}{String}{Wh}",")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 OpenString ({Open}{StringArg})
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 LispToken (({Esc}|[-A-Za-z0-9!@$%^&*_=+|{}`~,<.>/?])+)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 %%
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 <DO_C>{NT}"GETTEXT"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 <DO_C>{NT}"DEFER_GETTEXT"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 <DO_C>{NT}"build_translated_string"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 <DO_C>{NT}"insert_string"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 <DO_C>{NT}"message"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 <DO_C>{NT}"warn_when_safe"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 <DO_C>{NT}"error"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 <DO_C>{NT}"continuable_error"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 <DO_C>{NT}"signal_simple_error"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 <DO_C>{NT}"signal_simple_error_2"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 <DO_C>{NT}"signal_simple_continuable_error"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 <DO_C>{NT}"signal_simple_continuable_error_2"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 <DO_C>{NT}"report_file_error"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 <DO_C>{NT}"signal_file_error"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 <DO_C>{NT}"signal_double_file_error"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 <DO_C>{NT}"signal_double_file_error_2"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 <DO_C>{NT}"syntax_error"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 <DO_C>{NT}"continuable_syntax_error"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 <DO_C>{NT}"CTB_ERROR"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 <DO_C>{NT}"fatal"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 <DO_C>{NT}"stdout_out"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 <DO_C>{NT}"stderr_out"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 <DO_C>{NT}"with_output_to_temp_buffer"{OpWQ} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 <DO_C>{NT}"DEFVAR_BOOL"{OpenString}{Arg}{Wh}{Q} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 <DO_C>{NT}"DEFVAR_LISP"{OpenString}{Arg}{Wh}{Q} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 <DO_C>{NT}"DEFVAR_SPECIFIER"{OpenString}{Arg}{Wh}{Q} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 <DO_C>{NT}"DEFVAR_INT"{OpenString}{Arg}{Wh}{Q} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 <DO_C>{NT}"DEFVAR_BUFFER_LOCAL"{OpenString}{Arg}{Wh}{Q} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 <DO_C>{NT}"DEFVAR_BUFFER_DEFAULTS"{OpenString}{Arg}{Wh}{Q} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 <DO_C>{NT}"deferror"{Open}{Arg}{StringArg}{Wh}{Q} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 <DO_C>{NT}"barf_or_query_if_file_exists"{Open}{Arg}{Wh}{Q} {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 /* #### see comment above about use of Arg */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 snarf ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 <DO_C>{NT}"DEFUN"{Open} { BEGIN DEFUN; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 <DO_C>"/*" {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 /* This is hateful, but doc strings are sometimes put inside of comments
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 (to get around limits in cpp), so we can't ignore stuff inside of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 comments. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 /* BEGIN C_COMMENT; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 <DO_C>{Q} { BEGIN C_QUOTE; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 <DO_C>{Any} { }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 <DEFUN>{StringArg}{Arg}{Arg}{Arg}{Arg}{Wh} { BEGIN DEFUN2; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 <DEFUN>{Any} { bad_c_defun (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 <DEFUN2>{Q} {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 /* We found an interactive specification. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 snarf_return_state = DEFUN3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 snarf ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 <DEFUN2>[^,]* {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 /* This function doesn't have an interactive specification.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 Don't use {Arg} in the specification because DEFUN3 looks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 for the comma. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 BEGIN DEFUN3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 <DEFUN3>{Wh}","{Wh}{Q} {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 snarf_return_state = DO_C;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 snarf ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 <DEFUN3>{Any} { bad_c_defun (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 <C_QUOTE>{Esc} { }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 <C_QUOTE>{Q} { BEGIN DO_C; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 <C_QUOTE>{Any} { }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 <C_COMMENT>"*/" { BEGIN DO_C; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 <C_COMMENT>{Any} { }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 <DO_LISP>{LP}{LWh}"gettext"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 <DO_LISP>{LP}{LWh}"purecopy"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 <DO_LISP>{LP}{LWh}"interactive"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 <DO_LISP>{LP}{LWh}"message"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 <DO_LISP>{LP}{LWh}"error"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 <DO_LISP>{LP}{LWh}"warn"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 <DO_LISP>{LP}{LWh}"format"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 <DO_LISP>{LP}{LWh}"substitute-command-keys"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 <DO_LISP>{LP}{LWh}"temp-minibuffer-message"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 <DO_LISP>{LP}{LWh}"momentary-string-display"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 <DO_LISP>{LP}{LWh}"princ"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 <DO_LISP>{LP}{LWh}"prin1"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 <DO_LISP>{LP}{LWh}"prin1-to-string"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 <DO_LISP>{LP}{LWh}"print"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 <DO_LISP>{LP}{LWh}"insert"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 <DO_LISP>{LP}{LWh}"insert-before-markers"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 <DO_LISP>{LP}{LWh}"get-buffer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 <DO_LISP>{LP}{LWh}"get-buffer-create"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 <DO_LISP>{LP}{LWh}"generate-new-buffer-name"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 <DO_LISP>{LP}{LWh}"rename-buffer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 <DO_LISP>{LP}{LWh}"set-buffer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 <DO_LISP>{LP}{LWh}"switch-to-buffer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 <DO_LISP>{LP}{LWh}"pop-to-buffer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 <DO_LISP>{LP}{LWh}"with-output-to-temp-buffer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 <DO_LISP>{LP}{LWh}"buffer-enable-undo"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 <DO_LISP>{LP}{LWh}"buffer-disable-undo"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 <DO_LISP>{LP}{LWh}"get-buffer-window"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 <DO_LISP>{LP}{LWh}"delete-windows-on"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 <DO_LISP>{LP}{LWh}"replace-buffer-in-windows"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 <DO_LISP>{LP}{LWh}"display-buffer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 <DO_LISP>{LP}{LWh}"other-buffer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 <DO_LISP>{LP}{LWh}"read-from-minibuffer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 <DO_LISP>{LP}{LWh}"read-shell-command"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 <DO_LISP>{LP}{LWh}"read-file-name"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 <DO_LISP>{LP}{LWh}"read-buffer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 <DO_LISP>{LP}{LWh}"read-variable"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 <DO_LISP>{LP}{LWh}"read-command"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 <DO_LISP>{LP}{LWh}"read-function"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 <DO_LISP>{LP}{LWh}"read-directory-name"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 <DO_LISP>{LP}{LWh}"read-string"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 <DO_LISP>{LP}{LWh}"read-number"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 <DO_LISP>{LP}{LWh}"read-minibuffer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 <DO_LISP>{LP}{LWh}"read-quoted-char"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 <DO_LISP>{LP}{LWh}"read-face-name"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 <DO_LISP>{LP}{LWh}"read-itimer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 <DO_LISP>{LP}{LWh}"completing-read"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 <DO_LISP>{LP}{LWh}"y-or-n-p"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 <DO_LISP>{LP}{LWh}"yes-or-no-p"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 <DO_LISP>{LP}{LWh}"query-replace-read-args"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 <DO_LISP>{LP}{LWh}"eval-minibuffer"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 <DO_LISP>{LP}{LWh}"edit-and-eval-command"{LWh}{Q} { inc_paren (); snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 <DO_LISP>{LP}{LWh}"defvar"{LWh}{LispToken}{LWh} {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 inc_paren (); begin_paren_counting (LDEF);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 <DO_LISP>{LP}{LWh}"defconst"{LWh}{LispToken}{LWh} {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 inc_paren (); begin_paren_counting (LDEF);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 <DO_LISP>{LP}{LWh}"defun"{LWh}{LispToken}{LWh} {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 inc_paren (); begin_paren_counting (LDEF);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 <DO_LISP>{LP}{LWh}"defmacro"{LWh}{LispToken}{LWh} {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 inc_paren (); begin_paren_counting (LDEF);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 <DO_LISP>{LP}{LWh}"defsubst"{LWh}{LispToken}{LWh} {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 inc_paren (); begin_paren_counting (LDEF);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 <DO_LISP>{Q} { BEGIN LQUO; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 <DO_LISP>";" { BEGIN LCOM; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 <DO_LISP>{LP} { inc_paren (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 <DO_LISP>{RP} { dec_paren (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 <DO_LISP>{Esc} { }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 <DO_LISP>{W} { lisp_whitespace (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 <DO_LISP>{Any} { }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 <LQUO>{Esc} { }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 <LQUO>{Q} { BEGIN DO_LISP; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 <LQUO>{Any} { }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 <LCOM>"\n" { BEGIN DO_LISP; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 <LCOM>{Any} { }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 <LDEF>{LWh}{Q} { snarf (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 <LDEF>{Any} { BEGIN DO_LISP; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 <CSNARF>{Esc} { ECHO; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 <CSNARF>{Q} { ECHO; fprintf (yyout, ")\n"); BEGIN snarf_return_state; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 <CSNARF>{Any} { ECHO; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 <LSNARF>{Esc} { ECHO; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 <LSNARF>"\n" { fprintf (yyout, "\\n\\\n"); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 <LSNARF>{Q} { ECHO; fprintf (yyout, ")\n"); BEGIN snarf_return_state; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 <LSNARF>{Any} { ECHO; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 %%
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 enum filetype { C_FILE, LISP_FILE, INVALID_FILE };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 /* some brain-dead headers define this ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 #undef FALSE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 #undef TRUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 enum boolean { FALSE, TRUE };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 void scan_file (char *filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 void process_C_file (void);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 void process_Lisp_file (void);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 int in_c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 int in_paren_counting, paren_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 int paren_return_state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 snarf ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 fprintf (yyout, "gettext(\"");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 if (in_c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 BEGIN CSNARF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 BEGIN LSNARF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 bad_c_defun ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 fprintf (stderr, "Warning: Invalid DEFUN encountered in C, line %d.\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 yylineno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 snarf_return_state = DO_C;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 BEGIN DO_C;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 /* REJECT; Sun's lex is broken! Use Flex! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 bad_lisp_def ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 fprintf (stderr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 "Warning: Invalid defmumble encountered in Lisp, line %d.\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 yylineno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 snarf_return_state = DO_LISP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 BEGIN DO_LISP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 /* REJECT; Sun's lex is broken! Use Flex! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 inc_paren ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 if (in_paren_counting)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 paren_count++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 dec_paren ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 if (in_paren_counting)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 /* If we find a right paren without a matching left paren, it usually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 just indicates a statement like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 (defvar foo-mumble nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 where 'nil' is the sexp we are skipping over, and there's no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 doc string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 if (paren_count > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 paren_count--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 unput (')');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 if (paren_count == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 in_paren_counting = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 BEGIN paren_return_state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 /* #### begin_paren_counting () does not handle recursive entries */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 begin_paren_counting (int return_state)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 in_paren_counting = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 paren_count = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 paren_return_state = return_state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 lisp_whitespace ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 if (in_paren_counting && !paren_count)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 /* We got to the end of a token and we're not in a parenthesized
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 expression, so we're at the end of an sexp. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 in_paren_counting = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 BEGIN paren_return_state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 yywrap ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 main (int argc, char *argv[])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 register int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 yyout = stdout;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 /* If first two args are -o FILE, output to FILE. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 i = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 if (argc > i + 1 && strcmp (argv[i], "-o") == 0) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 yyout = fopen (argv[++i], "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 ++i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 /* ...Or if args are -a FILE, append to FILE. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 if (argc > i + 1 && strcmp (argv[i], "-a") == 0) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 yyout = fopen (argv[++i], "a");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 ++i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 if (!yyout) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 fprintf (stderr, "Unable to open output file %s\n", argv[--i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 for (; i < argc; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 scan_file (argv[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 void scan_file (char *filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 enum filetype type = INVALID_FILE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 register char *p = filename + strlen (filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 if (strcmp (p - 4, ".elc") == 0) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 *--p = '\0'; /* Use .el file instead */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 type = LISP_FILE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 } else if (strcmp (p - 3, ".el") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 type = LISP_FILE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 else if (strcmp (p - 2, ".o") == 0) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 *--p = 'c'; /* Use .c file instead */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 type = C_FILE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 } else if (strcmp (p - 2, ".c") == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 type = C_FILE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 if (type == INVALID_FILE) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 fprintf (stderr, "File %s being ignored\n", filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 yyin = fopen (filename, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 if (!yyin) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 fprintf (stderr, "Unable to open input file %s\n", filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 fprintf (yyout, "/* %s */\n", filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 if (type == C_FILE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 process_C_file ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 process_Lisp_file ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 fputc ('\n', yyout);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 fclose (yyin);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 void process_C_file ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 snarf_return_state = DO_C;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 in_c = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 BEGIN DO_C;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 yylex ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 void process_Lisp_file ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 snarf_return_state = DO_LISP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 in_c = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 BEGIN DO_LISP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 yylex ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681