ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/preprocess
Revision: 1.4
Committed: Sun Sep 3 22:45:56 2006 UTC (17 years, 8 months ago) by root
Branch: MAIN
Changes since 1.3: +8 -0 lines
Log Message:
string scanning (e.g. for patch) is not implemented ATM but should be easy
to add with an alternative constructor for object_thawer.

Rewrote flex scanner to be simpler, faster and more modularised.

Initial speedup: 16%

(ah well)

File Contents

# User Rev Content
1 root 1.1 #!/opt/bin/perl
2    
3 root 1.3 use List::Util;
4    
5 root 1.1 # todo: gather dynamically
6     my @kw = qw(
7 root 1.4 no_pass
8     walk_on
9     walk_off
10     fly_on
11     fly_off
12     flying
13    
14 root 1.1 ac
15     activate_on_push
16     activate_on_release
17     alive
18     anim_speed
19     animation
20     applied
21     arch
22     armour
23     attach
24     attack_movement
25     attacktype
26     auto_apply
27     been_applied
28     berserk
29     blocksview
30     body_range
31     body_arm
32     body_torso
33     body_head
34     body_neck
35     body_skill
36     body_finger
37     body_shoulder
38     body_foot
39     body_hand
40     body_wrist
41     body_waist
42     can_apply
43     can_cast_spell
44     can_roll
45     can_see_in_dark
46     can_use_armour
47     can_use_bow
48     can_use_horn
49     can_use_range
50     can_use_ring
51     can_use_rod
52     can_use_scroll
53     can_use_shield
54     can_use_skill
55     can_use_wand
56     can_use_weapon
57     carrying
58     casting_time
59     cha
60     changing
61     client_type
62     con
63     confused
64     connected
65     container
66     cursed
67     custom_name
68     dam
69     dam_modifier
70     damned
71     dex
72     direction
73     duration
74     duration_modifier
75     editable
76     editor_folder
77     elevation
78     end
79     endlore
80     endmsg
81     exp
82     expmul
83     face
84     food
85     friendly
86     gen_sp_armour
87     generator
88     glow_radius
89     grace
90     has_ready_bow
91     has_ready_horn
92     has_ready_rod
93     has_ready_scroll
94     has_ready_skill
95     has_ready_wand
96     has_ready_weapon
97     hitback
98     hp
99     identified
100     immune
101     int
102     inv_locked
103     invisible
104     is_animated
105     is_blind
106     is_buildable
107     is_cauldron
108     is_floor
109     is_hilly
110     is_lightable
111     is_thrown
112     is_turnable
113     is_used_up
114     is_water
115     is_wooded
116     item_power
117     known_cursed
118     known_magical
119     last_eat
120     last_grace
121     last_heal
122     last_sp
123     level
124     lifesave
125     lore
126     luck
127     magic
128     make_invisible
129     material
130     materialname
131     maxgrace
132     maxhp
133     maxsp
134     monster
135     more
136     move_allow
137     move_block
138     move_off
139     move_on
140     move_slow
141     move_slow_penalty
142     move_state
143     move_type
144     msg
145     name
146     name_pl
147     neutral
148     no_attack
149     no_damage
150     no_drop
151     no_fix_player
152     no_magic
153     no_pick
154     no_skill_ident
155     no_steal
156     no_strength
157     nrof
158     object
159     oid
160     one_hit
161     only_attack
162     other_arch
163     overlay_floor
164     path_attuned
165     path_denied
166     path_repelled
167     perm_exp
168     pick_up
169     pow
170     protected
171     race
172     random_move
173     random_movement
174     randomitems
175     range
176     range_modifier
177     reflect_missile
178     reflect_spell
179     reflecting
180     resist_acid
181     resist_blind
182     resist_cancellation
183     resist_chaos
184     resist_cold
185     resist_confusion
186     resist_counterspell
187     resist_death
188     resist_deplete
189     resist_disease
190     resist_drain
191     resist_electricity
192     resist_fear
193     resist_fire
194     resist_ghosthit
195     resist_godpower
196     resist_holyword
197     resist_internal
198     resist_life_stealing
199     resist_magic
200     resist_paralyze
201     resist_physical
202     resist_poison
203     resist_slow
204     resist_turn_undead
205     resist_weaponmagic
206     run_away
207     scared
208     see_anywhere
209     see_invisible
210     skill
211     slaying
212     sleep
213     slow_move
214     smoothlevel
215     sp
216     speed
217     speed_left
218     splitting
219     stand_still
220     startequip
221     state
222     stealth
223     str
224     subtype
225     tear_down
226     title
227     tooltype
228     treasure
229     type
230     unaggressive
231     undead
232     unique
233     unpaid
234     use_content_on_gen
235     value
236     vulnerable
237     was_wiz
238     wc
239     weapontype
240     weight
241     will_apply
242     wis
243     wiz
244     x
245     xrays
246     y
247     );
248    
249     open GPERF, "|-", "gperf -m50 >kw_hash.h"
250     or die "gperf: $!";
251    
252     print GPERF <<EOF;
253     %language=C++
254     %enum
255     %define class-name kw_lex
256     %define lookup-function-name match
257     %struct-type
258     %compare-strncmp
259 root 1.4 %ignore-case
260 root 1.1 %delimiters=,
261 root 1.2 struct keyword_idx { const char *name; enum keyword index; };
262 root 1.1 %%
263     EOF
264    
265     for (@kw) {
266 root 1.3 printf GPERF "%s,%s\n", $_, "KW_$_";
267 root 1.1 }
268    
269     print GPERF <<EOF;
270     %%
271 root 1.3 extern const char *const keyword_str [] = {
272 root 1.1 "<EOF>",
273     "<ERROR>",
274     EOF
275    
276     for (@kw) {
277     printf GPERF " \"%s\",\n", $_;
278     }
279    
280 root 1.3 print GPERF "};\n";
281    
282     printf GPERF "\nextern const unsigned char keyword_len [] = { 5, 7, %s };\n\n",
283     join ", ", map length, @kw;
284 root 1.1
285     open KW, ">", "keyword.h";
286    
287     print KW <<EOF;
288     #ifndef KW_H__
289     #define KW_H__
290    
291     enum keyword {
292 root 1.3 KW_EOF, KW_ERROR,
293 root 1.1 EOF
294    
295     for (@kw) {
296 root 1.3 printf KW " %s,\n", "KW_$_",
297 root 1.1 }
298    
299     print KW <<EOF;
300     NUM_KEYWORD,
301     };
302    
303     extern const char *const keyword_str [];
304 root 1.3 extern const unsigned char keyword_len [];
305    
306     EOF
307    
308     printf KW "#define MAX_KEYWORD_LEN %d\n", List::Util::max map length, @kw;
309    
310     print KW <<EOF;
311 root 1.1
312     #endif
313    
314     EOF
315