From b2d7ae871bb82da68caa08a9c8695bcacbc67ce8 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sat, 3 Jan 2009 14:03:12 +0000 Subject: Dropped the script preprocessor introduced to fix the broken scripts. The parser has evolved in the meantime and can deal with it accordingly. svn-id: r35700 --- engines/parallaction/parser.h | 113 ------------------------------------------ 1 file changed, 113 deletions(-) (limited to 'engines/parallaction/parser.h') diff --git a/engines/parallaction/parser.h b/engines/parallaction/parser.h index 48facb620e..f83fc1384b 100644 --- a/engines/parallaction/parser.h +++ b/engines/parallaction/parser.h @@ -415,119 +415,6 @@ public: }; -/* - This simple stream is temporarily needed to hook the - preprocessor output to the parser. It will go away - when the parser is rewritten to fully exploit the - statement list provided by the preprocessor. -*/ - -class ReadStringStream : public Common::ReadStream { - - char *_text; - uint32 _pos; - uint32 _size; - bool _eos; - -public: - ReadStringStream(const Common::String &text) { - _text = new char[text.size() + 1]; - strcpy(_text, text.c_str()); - _size = text.size(); - _pos = 0; - _eos = false; - } - - ~ReadStringStream() { - delete []_text; - } - - uint32 read(void *buffer, uint32 size) { - if (_pos + size > _size) { - size = _size - _pos; - _eos = true; - } - memcpy(buffer, _text + _pos, size); - _pos += size; - return size; - } - - bool eos() const { - return _eos; - } - -}; - - -/* - Demented as it may sound, the success of a parsing operation in the - original BRA depends on what has been parsed before. The game features - an innovative chaos system that involves the parser and the very game - engine, in order to inflict the user an unforgettable game experience. - - Ok, now for the serious stuff. - - The PreProcessor implemented here fixes the location scripts before - they are fed to the parser. It tries to do so by a preliminary scan - of the text file, during which a score is assigned to each statement - (more on this later). When the whole file has been analyzed, the - statements are sorted according to their score, to create a parsable - sequence. - - For parsing, the statements in location scripts can be conveniently - divided into 3 groups: - - * location definitions - * element definitions - * start-up commands - - Since the parsing of element definitions requires location parameters - to be set, location definitions should be encountered first in the - script. Start-up commands in turn may reference elements, so they can - be parsed last. The first goal is to make sure the parser gets these - three sets in this order. - - Location definitions must also be presented in a certain sequence, - because resource files are not fully self-describing. In short, some - critical game data in contained in certain files, that must obviously - be read before any other can be analyzed. This is the second goal. - - TODO: some words about actual implementation. -*/ - -class StatementDef; - -struct StatementListNode { - int _score; - Common::String _name; - Common::String _text; - - StatementListNode(int score, const Common::String &name, const Common::String &text) : _score(score), _name(name), _text(text) { } - - bool operator<(const StatementListNode& node) const { - return _score < node._score; - } -}; -typedef Common::List StatementList; - - -class PreProcessor { - typedef Common::List DefList; - - int _numZones; - DefList _defs; - - StatementDef* findDef(const char* name); - uint getDefScore(StatementDef*); - -public: - PreProcessor(); - ~PreProcessor(); - void preprocessScript(Script &script, StatementList &list); -}; - - - } // namespace Parallaction #endif -- cgit v1.2.3