ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/preprocess
(Generate patch)

Comparing deliantra/server/include/preprocess (file contents):
Revision 1.2 by root, Thu Aug 31 09:19:34 2006 UTC vs.
Revision 1.4 by root, Sun Sep 3 22:45:56 2006 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3use List::Util;
2 4
3# todo: gather dynamically 5# todo: gather dynamically
4my @kw = qw( 6my @kw = qw(
7 no_pass
8 walk_on
9 walk_off
10 fly_on
11 fly_off
12 flying
13
5 ac 14 ac
6 activate_on_push 15 activate_on_push
7 activate_on_release 16 activate_on_release
8 alive 17 alive
9 anim_speed 18 anim_speed
245%enum 254%enum
246%define class-name kw_lex 255%define class-name kw_lex
247%define lookup-function-name match 256%define lookup-function-name match
248%struct-type 257%struct-type
249%compare-strncmp 258%compare-strncmp
259%ignore-case
250%delimiters=, 260%delimiters=,
251struct keyword_idx { const char *name; enum keyword index; }; 261struct keyword_idx { const char *name; enum keyword index; };
252%% 262%%
253EOF 263EOF
254 264
255for (@kw) { 265for (@kw) {
256 printf GPERF "%s,%s\n", $_, "KW_" . uc; 266 printf GPERF "%s,%s\n", $_, "KW_$_";
257} 267}
258 268
259print GPERF <<EOF; 269print GPERF <<EOF;
260%% 270%%
261const char *const keyword_str [] = { 271extern const char *const keyword_str [] = {
262 "<EOF>", 272 "<EOF>",
263 "<ERROR>", 273 "<ERROR>",
264EOF 274EOF
265 275
266for (@kw) { 276for (@kw) {
267 printf GPERF " \"%s\",\n", $_; 277 printf GPERF " \"%s\",\n", $_;
268} 278}
269 279
270print GPERF "};\n\n"; 280print GPERF "};\n";
281
282printf GPERF "\nextern const unsigned char keyword_len [] = { 5, 7, %s };\n\n",
283 join ", ", map length, @kw;
271 284
272open KW, ">", "keyword.h"; 285open KW, ">", "keyword.h";
273 286
274print KW <<EOF; 287print KW <<EOF;
275#ifndef KW_H__ 288#ifndef KW_H__
276#define KW_H__ 289#define KW_H__
277 290
278enum keyword { 291enum keyword {
279 KW_eof, KW_error, 292 KW_EOF, KW_ERROR,
280EOF 293EOF
281 294
282for (@kw) { 295for (@kw) {
283 printf KW " %s,\n", "KW_" . uc; 296 printf KW " %s,\n", "KW_$_",
284} 297}
285 298
286print KW <<EOF; 299print KW <<EOF;
287 NUM_KEYWORD, 300 NUM_KEYWORD,
288}; 301};
289 302
290extern const char *const keyword_str []; 303extern const char *const keyword_str [];
304extern const unsigned char keyword_len [];
305
306EOF
307
308printf KW "#define MAX_KEYWORD_LEN %d\n", List::Util::max map length, @kw;
309
310print KW <<EOF;
291 311
292#endif 312#endif
293 313
294EOF 314EOF
295 315

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines