22 #ifndef PARALLACTION_PARSER_H 23 #define PARALLACTION_PARSER_H 25 #include "common/stream.h" 26 #include "common/stack.h" 27 #include "parallaction/objects.h" 31 #define MAX_TOKEN_LEN 50 32 extern int _numTokens;
33 extern char _tokens[][MAX_TOKEN_LEN];
42 char *parseNextToken(
char *s,
char *tok, uint16 count,
const char *brk);
43 char *readLineIntern(
char *buf,
size_t bufSize);
49 char *readLine(
char *buf,
size_t bufSize);
50 uint16 readLineToken(
bool errorOnEOF =
false);
52 void skip(
const char* endToken);
54 uint getLine() {
return _line; }
74 OpcodeSet *_currentOpcodes;
75 Table *_currentStatements;
78 void pushTables(OpcodeSet *opcodes,
Table* statements);
80 void parseStatement();
84 #define DECLARE_UNQUALIFIED_ZONE_PARSER(sig) void locZoneParse_##sig() 85 #define DECLARE_UNQUALIFIED_ANIM_PARSER(sig) void locAnimParse_##sig() 86 #define DECLARE_UNQUALIFIED_COMMAND_PARSER(sig) void cmdParse_##sig() 87 #define DECLARE_UNQUALIFIED_LOCATION_PARSER(sig) void locParse_##sig() 88 #define DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(sig) void instParse_##sig() 90 #define MAX_FORWARDS 50 103 Table *_zoneTypeNames;
104 Table *_zoneFlagNames;
108 OpcodeSet _locationParsers;
109 OpcodeSet _locationZoneParsers;
110 OpcodeSet _locationAnimParsers;
111 OpcodeSet _commandParsers;
112 Table *_commandsNames;
113 Table *_locationStmt;
114 Table *_locationZoneStmt;
115 Table *_locationAnimStmt;
120 const char *filename;
129 void warning_unexpected();
131 DECLARE_UNQUALIFIED_LOCATION_PARSER(endlocation);
132 DECLARE_UNQUALIFIED_LOCATION_PARSER(location);
133 DECLARE_UNQUALIFIED_LOCATION_PARSER(disk);
134 DECLARE_UNQUALIFIED_LOCATION_PARSER(nodes);
135 DECLARE_UNQUALIFIED_LOCATION_PARSER(zone);
136 DECLARE_UNQUALIFIED_LOCATION_PARSER(animation);
137 DECLARE_UNQUALIFIED_LOCATION_PARSER(localflags);
138 DECLARE_UNQUALIFIED_LOCATION_PARSER(commands);
139 DECLARE_UNQUALIFIED_LOCATION_PARSER(acommands);
140 DECLARE_UNQUALIFIED_LOCATION_PARSER(flags);
141 DECLARE_UNQUALIFIED_LOCATION_PARSER(comment);
142 DECLARE_UNQUALIFIED_LOCATION_PARSER(endcomment);
143 DECLARE_UNQUALIFIED_LOCATION_PARSER(sound);
144 DECLARE_UNQUALIFIED_LOCATION_PARSER(music);
145 DECLARE_UNQUALIFIED_ZONE_PARSER(limits);
146 DECLARE_UNQUALIFIED_ZONE_PARSER(moveto);
147 DECLARE_UNQUALIFIED_ZONE_PARSER(type);
148 DECLARE_UNQUALIFIED_ZONE_PARSER(commands);
149 DECLARE_UNQUALIFIED_ZONE_PARSER(label);
150 DECLARE_UNQUALIFIED_ZONE_PARSER(flags);
151 DECLARE_UNQUALIFIED_ZONE_PARSER(endzone);
152 DECLARE_UNQUALIFIED_ZONE_PARSER(null);
153 DECLARE_UNQUALIFIED_ANIM_PARSER(script);
154 DECLARE_UNQUALIFIED_ANIM_PARSER(commands);
155 DECLARE_UNQUALIFIED_ANIM_PARSER(type);
156 DECLARE_UNQUALIFIED_ANIM_PARSER(label);
157 DECLARE_UNQUALIFIED_ANIM_PARSER(flags);
158 DECLARE_UNQUALIFIED_ANIM_PARSER(file);
159 DECLARE_UNQUALIFIED_ANIM_PARSER(position);
160 DECLARE_UNQUALIFIED_ANIM_PARSER(moveto);
161 DECLARE_UNQUALIFIED_ANIM_PARSER(endanimation);
162 DECLARE_UNQUALIFIED_COMMAND_PARSER(flags);
163 DECLARE_UNQUALIFIED_COMMAND_PARSER(animation);
164 DECLARE_UNQUALIFIED_COMMAND_PARSER(zone);
165 DECLARE_UNQUALIFIED_COMMAND_PARSER(location);
166 DECLARE_UNQUALIFIED_COMMAND_PARSER(invObject);
167 DECLARE_UNQUALIFIED_COMMAND_PARSER(call);
168 DECLARE_UNQUALIFIED_COMMAND_PARSER(simple);
169 DECLARE_UNQUALIFIED_COMMAND_PARSER(
move);
170 DECLARE_UNQUALIFIED_COMMAND_PARSER(endcommands);
172 virtual void parseGetData(
ZonePtr z);
173 virtual void parseExamineData(
ZonePtr z);
174 virtual void parseDoorData(
ZonePtr z);
175 virtual void parseMergeData(
ZonePtr z);
176 virtual void parseHearData(
ZonePtr z);
177 virtual void parseSpeakData(
ZonePtr z);
178 virtual void parseNoneData(
ZonePtr z);
183 virtual Answer *parseAnswer();
184 void parseAnswerFlags(
Answer *answer);
185 void parseAnswerBody(
Answer *answer);
188 uint32 buildZoneType(
const char *t0,
const char* t1);
190 void parseZone(
ZoneList &list,
char *name);
191 virtual void parseZoneTypeBlock(
ZonePtr z);
195 void parseCommandFlags();
197 void createCommand(uint
id);
200 void clearSet(OpcodeSet &opcodes) {
208 _locationZoneStmt(0), _locationAnimStmt(0) {
220 delete _commandsNames;
221 delete _locationStmt;
222 delete _locationZoneStmt;
223 delete _locationAnimStmt;
224 delete _zoneTypeNames;
225 delete _zoneFlagNames;
227 clearSet(_commandParsers);
228 clearSet(_locationAnimParsers);
229 clearSet(_locationZoneParsers);
230 clearSet(_locationParsers);
233 void parse(
Script *script);
251 Table *_audioCommandsNames;
255 DECLARE_UNQUALIFIED_LOCATION_PARSER(location);
256 DECLARE_UNQUALIFIED_LOCATION_PARSER(zone);
257 DECLARE_UNQUALIFIED_LOCATION_PARSER(animation);
258 DECLARE_UNQUALIFIED_LOCATION_PARSER(localflags);
259 DECLARE_UNQUALIFIED_LOCATION_PARSER(flags);
260 DECLARE_UNQUALIFIED_LOCATION_PARSER(comment);
261 DECLARE_UNQUALIFIED_LOCATION_PARSER(endcomment);
262 DECLARE_UNQUALIFIED_LOCATION_PARSER(sound);
263 DECLARE_UNQUALIFIED_LOCATION_PARSER(music);
264 DECLARE_UNQUALIFIED_LOCATION_PARSER(redundant);
265 DECLARE_UNQUALIFIED_LOCATION_PARSER(ifchar);
266 DECLARE_UNQUALIFIED_LOCATION_PARSER(character);
267 DECLARE_UNQUALIFIED_LOCATION_PARSER(mask);
268 DECLARE_UNQUALIFIED_LOCATION_PARSER(path);
269 DECLARE_UNQUALIFIED_LOCATION_PARSER(escape);
270 DECLARE_UNQUALIFIED_LOCATION_PARSER(zeta);
271 DECLARE_UNQUALIFIED_LOCATION_PARSER(null);
272 DECLARE_UNQUALIFIED_COMMAND_PARSER(ifchar);
273 DECLARE_UNQUALIFIED_COMMAND_PARSER(endif);
274 DECLARE_UNQUALIFIED_COMMAND_PARSER(location);
275 DECLARE_UNQUALIFIED_COMMAND_PARSER(toggle);
276 DECLARE_UNQUALIFIED_COMMAND_PARSER(
string);
277 DECLARE_UNQUALIFIED_COMMAND_PARSER(math);
278 DECLARE_UNQUALIFIED_COMMAND_PARSER(test);
279 DECLARE_UNQUALIFIED_COMMAND_PARSER(music);
280 DECLARE_UNQUALIFIED_COMMAND_PARSER(zeta);
281 DECLARE_UNQUALIFIED_COMMAND_PARSER(swap);
282 DECLARE_UNQUALIFIED_COMMAND_PARSER(give);
283 DECLARE_UNQUALIFIED_COMMAND_PARSER(text);
284 DECLARE_UNQUALIFIED_COMMAND_PARSER(unary);
285 DECLARE_UNQUALIFIED_ZONE_PARSER(limits);
286 DECLARE_UNQUALIFIED_ZONE_PARSER(moveto);
287 DECLARE_UNQUALIFIED_ZONE_PARSER(type);
288 DECLARE_UNQUALIFIED_ANIM_PARSER(file);
289 DECLARE_UNQUALIFIED_ANIM_PARSER(position);
290 DECLARE_UNQUALIFIED_ANIM_PARSER(moveto);
291 DECLARE_UNQUALIFIED_ANIM_PARSER(endanimation);
293 void parseZoneTypeBlock(
ZonePtr z)
override;
295 virtual void parsePathData(
ZonePtr z);
296 void parseGetData(
ZonePtr z)
override;
297 void parseDoorData(
ZonePtr z)
override;
298 void parseHearData(
ZonePtr z)
override;
299 void parseNoneData(
ZonePtr z)
override;
301 void parseAnswerCounter(
Answer *answer);
302 Answer *parseAnswer()
override;
306 _audioCommandsNames(0), _out(0) {
309 void init()
override;
312 delete _audioCommandsNames;
331 OpcodeSet _instructionParsers;
332 Table *_instructionNames;
334 uint32 _currentInstruction;
343 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(defLocal);
344 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(animation);
345 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(loop);
346 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(x);
347 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(y);
348 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(z);
349 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(f);
350 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(inc);
351 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(
set);
352 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(
move);
353 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(put);
354 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(call);
355 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(sound);
356 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(null);
357 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(endscript);
359 void parseInstruction();
360 void parseLValue(
ScriptVar &var,
const char *str);
361 virtual void parseRValue(
ScriptVar &var,
const char *str);
363 void clearSet(OpcodeSet &opcodes) {
377 delete _instructionNames;
379 clearSet(_instructionParsers);
392 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(zone);
393 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(color);
394 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(mask);
395 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(print);
396 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(text);
397 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(if_op);
398 DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(endif);
400 int32 _openIfStatement;
401 void beginIfStatement();
402 void endIfStatement();
404 void parseRValue(
ScriptVar &var,
const char *str)
override;
410 void init()
override;
Definition: objects.h:388
Definition: objects.h:145
void clear()
Definition: array.h:320
iterator end()
Definition: array.h:379
iterator begin()
Definition: array.h:374
Definition: objects.h:318
T * iterator
Definition: array.h:54
Definition: parallaction.h:377
Definition: graphics.h:352
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: objects.h:165
Definition: objects.h:178
Definition: parallaction.h:489
Definition: objects.h:509