comparison lib-src/make-msgfile.lex @ 4950:c50b0b3c7b8d

Random changes to make-msgfile.lex -------------------- ChangeLog entries follow: -------------------- lib-src/ChangeLog addition: 2010-01-26 Ben Wing <ben@xemacs.org> * make-msgfile.lex: Vague hacking on this file, insert a comment about what should be done if we ever want this to work.
author Ben Wing <ben@xemacs.org>
date Tue, 26 Jan 2010 22:44:43 -0600
parents ecf1ebac70d8
children 308d34e9f07d
comparison
equal deleted inserted replaced
4949:018e13fdeaeb 4950:c50b0b3c7b8d
2 2
3 /* This is a Lex file. */ 3 /* This is a Lex file. */
4 4
5 /* Localizable-message snarfing. 5 /* Localizable-message snarfing.
6 Copyright (C) 1994, 1995 Amdahl Corporation. 6 Copyright (C) 1994, 1995 Amdahl Corporation.
7 Copyright (C) 2010 Ben Wing.
7 8
8 This file is part of XEmacs. 9 This file is part of XEmacs.
9 10
10 XEmacs is free software; you can redistribute it and/or modify 11 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 it under the terms of the GNU General Public License as published by
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */ 24 Boston, MA 02111-1307, USA. */
24 25
25 /* Written by Ben Wing, November 1994. Some code based on earlier 26 /* Written by Ben Wing, November 1994. Some code based on earlier
26 make-msgfile.c. */ 27 make-msgfile.c. */
28
29 /* #### A comment:
30
31 Directly writing a lex file isn't right. We want to be able to specify
32 functions to snarf in simpler ways, e.g.
33
34 BEGIN_C_FUNCS
35
36 weird_doc (arg, snarf, snarf, arg);
37 signal_error (arg, snarf, arg);
38 etc.
39
40 END_C_FUNCS
41
42 In this case, `arg' indicates an arbitrary argument and `snarf' indicates
43 that when a quoted string is seen, it should be snarfed.
44
45 Then either we write a program to read this script and directly snarf
46 messages, or we write a program to convert the script into lex.
47
48 --ben, 1/26/10 */
27 49
28 /* See text.c for a proposal about how this whole system should work. */ 50 /* See text.c for a proposal about how this whole system should work. */
29 51
30 /* Note: there is still much work to be done on this. 52 /* Note: there is still much work to be done on this.
31 53
82 %s C_QUOTE C_COMMENT LQUO LCOM 104 %s C_QUOTE C_COMMENT LQUO LCOM
83 %s CSNARF LSNARF 105 %s CSNARF LSNARF
84 %s DO_C DO_LISP DEFUN 106 %s DO_C DO_LISP DEFUN
85 %s DEFUN2 DEFUN3 LDEF 107 %s DEFUN2 DEFUN3 LDEF
86 108
87 W [ \t\n] 109 W [ \t\n]
88 Any (.|"\n") 110 Any .|\n
89 Q "\"" 111 Q \"
90 NQ [^"] 112 Cm ,
91 NT [^A-Za-z_0-9] 113 NQ [^\"]
92 LP "(" 114 NT [^A-Za-z_0-9]
93 RP ")" 115 LP "("
94 BS "\\" 116 RP ")"
95 Esc ({BS}{Any}) 117 NQP [^\"()]
96 Wh ({W}*) 118 NQPCm [^,\"()]
97 LCom (";"({Esc}|.)*) 119 BS "\\"
98 LWh (({W}|{Lcom})*) 120 Esc ({BS}{Any})
99 Open ({Wh}{LP}) 121 Wh ({W}*)
100 OpWQ ({Open}{Wh}{Q}) 122 LCom (;({Esc}|.)*)
101 String ({Q}({Esc}|{NQ})*{Q}) 123 LWh ({W}|{LCom})*
102 Arg ([^,]*",") 124 Open {Wh}{LP}
103 StringArg ({Wh}{String}{Wh}",") 125 OpWQ {Open}{Wh}{Q}
104 OpenString ({Open}{StringArg}) 126 String {Q}({Esc}|{NQ})*{Q}
105 LispToken (({Esc}|[-A-Za-z0-9!@$%^&*_=+|{}`~,<.>/?])+) 127 ParenExpr5 "("({String}|{NQP})*")"
128 ParenExpr4 "("({String}|{NQP}|{ParenExpr5})*")"
129 ParenExpr3 "("({String}|{NQP}|{ParenExpr4})*")"
130 ParenExpr2 "("({String}|{NQP}|{ParenExpr3})*")"
131 ParenExpr "("({String}|{NQP}|{ParenExpr5})*")"
132 Arg ({NQPCm}|{String}|{ParenExpr})*
133 ArgCm {Arg}{Cm}
134 StringArg {Wh}{String}{Wh}","
135 OpenString {Open}{StringArg}
136 LispToken ({Esc}|[-A-Za-z0-9!@$%^&*_=+|{}`~,<.>/?])+
106 %% 137 %%
107 138
108 <DO_C>{NT}"GETTEXT"{OpWQ} { snarf (); } 139 <DO_C>{NT}"GETTEXT"{OpWQ} { snarf (); }
109 <DO_C>{NT}"DEFER_GETTEXT"{OpWQ} { snarf (); } 140 <DO_C>{NT}"DEFER_GETTEXT"{OpWQ} { snarf (); }
110 <DO_C>{NT}"build_translated_string"{OpWQ} { snarf (); } 141 <DO_C>{NT}"build_translated_string"{OpWQ} { snarf (); }
126 <DO_C>{NT}"CTB_ERROR"{OpWQ} { snarf (); } 157 <DO_C>{NT}"CTB_ERROR"{OpWQ} { snarf (); }
127 <DO_C>{NT}"fatal"{OpWQ} { snarf (); } 158 <DO_C>{NT}"fatal"{OpWQ} { snarf (); }
128 <DO_C>{NT}"stdout_out"{OpWQ} { snarf (); } 159 <DO_C>{NT}"stdout_out"{OpWQ} { snarf (); }
129 <DO_C>{NT}"stderr_out"{OpWQ} { snarf (); } 160 <DO_C>{NT}"stderr_out"{OpWQ} { snarf (); }
130 <DO_C>{NT}"with_output_to_temp_buffer"{OpWQ} { snarf (); } 161 <DO_C>{NT}"with_output_to_temp_buffer"{OpWQ} { snarf (); }
131 162 <DO_C>{NT}"weird_doc"{Open}{ArgCm}{Wh}{Q} { snarf (); /* #### FIXME snarf next arg() */}
132 <DO_C>{NT}"DEFVAR_BOOL"{OpenString}{Arg}{Wh}{Q} { snarf (); } 163
133 <DO_C>{NT}"DEFVAR_LISP"{OpenString}{Arg}{Wh}{Q} { snarf (); } 164 <DO_C>{NT}"DEFVAR_BOOL"{OpenString}{ArgCm}{Wh}{Q} { snarf (); }
134 <DO_C>{NT}"DEFVAR_SPECIFIER"{OpenString}{Arg}{Wh}{Q} { snarf (); } 165 <DO_C>{NT}"DEFVAR_LISP"{OpenString}{ArgCm}{Wh}{Q} { snarf (); }
135 <DO_C>{NT}"DEFVAR_INT"{OpenString}{Arg}{Wh}{Q} { snarf (); } 166 <DO_C>{NT}"DEFVAR_SPECIFIER"{OpenString}{ArgCm}{Wh}{Q} { snarf (); }
136 <DO_C>{NT}"DEFVAR_BUFFER_LOCAL"{OpenString}{Arg}{Wh}{Q} { snarf (); } 167 <DO_C>{NT}"DEFVAR_INT"{OpenString}{ArgCm}{Wh}{Q} { snarf (); }
137 <DO_C>{NT}"DEFVAR_BUFFER_DEFAULTS"{OpenString}{Arg}{Wh}{Q} { snarf (); } 168 <DO_C>{NT}"DEFVAR_BUFFER_LOCAL"{OpenString}{ArgCm}{Wh}{Q} { snarf (); }
138 <DO_C>{NT}"deferror"{Open}{Arg}{StringArg}{Wh}{Q} { snarf (); } 169 <DO_C>{NT}"DEFVAR_BUFFER_DEFAULTS"{OpenString}{ArgCm}{Wh}{Q} { snarf (); }
139 170 <DO_C>{NT}"deferror"{Open}{ArgCm}{StringArg}{Wh}{Q} { snarf (); }
140 <DO_C>{NT}"barf_or_query_if_file_exists"{Open}{Arg}{Wh}{Q} { 171
172 <DO_C>{NT}"barf_or_query_if_file_exists"{Open}{ArgCm}{Wh}{Q} {
141 /* #### see comment above about use of Arg */ 173 /* #### see comment above about use of Arg */
142 snarf (); 174 snarf ();
143 } 175 }
144 176
145 <DO_C>{NT}"DEFUN"{Open} { BEGIN DEFUN; } 177 <DO_C>{NT}"DEFUN"{Open} { BEGIN DEFUN; }
151 /* BEGIN C_COMMENT; */ 183 /* BEGIN C_COMMENT; */
152 } 184 }
153 <DO_C>{Q} { BEGIN C_QUOTE; } 185 <DO_C>{Q} { BEGIN C_QUOTE; }
154 <DO_C>{Any} { } 186 <DO_C>{Any} { }
155 187
156 <DEFUN>{StringArg}{Arg}{Arg}{Arg}{Arg}{Wh} { BEGIN DEFUN2; } 188 <DEFUN>{StringArg}{ArgCm}{ArgCm}{ArgCm}{ArgCm}{Wh} { BEGIN DEFUN2; }
157 <DEFUN>{Any} { bad_c_defun (); } 189 <DEFUN>{Any} { bad_c_defun (); }
158 190
159 <DEFUN2>{Q} { 191 <DEFUN2>{Q} {
160 /* We found an interactive specification. */ 192 /* We found an interactive specification. */
161 snarf_return_state = DEFUN3; 193 snarf_return_state = DEFUN3;
162 snarf (); 194 snarf ();
163 } 195 }
164 <DEFUN2>[^,]* { 196 <DEFUN2>[^,]* {
165 /* This function doesn't have an interactive specification. 197 /* This function doesn't have an interactive specification.
166 Don't use {Arg} in the specification because DEFUN3 looks 198 Don't use {ArgCm} in the specification because DEFUN3 looks
167 for the comma. */ 199 for the comma. */
168 BEGIN DEFUN3; 200 BEGIN DEFUN3;
169 } 201 }
170 202
171 <DEFUN3>{Wh}","{Wh}{Q} { 203 <DEFUN3>{Wh}","{Wh}{Q} {