aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2007-02-19 12:53:59 +0000
committerNicola Mettifogo2007-02-19 12:53:59 +0000
commit1121fe494856f0d45ac52ac8f4ce59022fbbdfd7 (patch)
tree79d5c8e2fd3000c5ed6d278a3db9c478bde69c25 /engines
parent85a0a0299638fc2c85021132b6e869da51c23e4d (diff)
downloadscummvm-rg350-1121fe494856f0d45ac52ac8f4ce59022fbbdfd7.tar.gz
scummvm-rg350-1121fe494856f0d45ac52ac8f4ce59022fbbdfd7.tar.bz2
scummvm-rg350-1121fe494856f0d45ac52ac8f4ce59022fbbdfd7.zip
moved specialised parsing routines in parser.cpp, so code can be refactored more easily
svn-id: r25718
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/animation.cpp41
-rw-r--r--engines/parallaction/parser.cpp83
-rw-r--r--engines/parallaction/parser.h5
-rw-r--r--engines/parallaction/table.cpp37
4 files changed, 87 insertions, 79 deletions
diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp
index d393ef6d59..0dc76d38d4 100644
--- a/engines/parallaction/animation.cpp
+++ b/engines/parallaction/animation.cpp
@@ -57,7 +57,6 @@ void sortAnimations();
LValue getLValue(Instruction *inst, char *str, LocalVariable *locals, Animation *a);
-int16 scriptFillBuffers(ArchivedFile *file);
uint16 _numLocals = 0;
char _localNames[10][10];
@@ -294,46 +293,6 @@ void Parallaction::loadProgram(Animation *a, char *filename) {
-// FIXME
-// this function does the same Job as parseFillBuffers, except that
-// it gets input from an ArchivedFile instead of a memory buffer
-//
-int16 scriptFillBuffers(ArchivedFile *file) {
-// printf("scriptFillBuffers()\n");
- char v2[] = "\"\0";
-
- int16 _si = 0;
-
- for (; _si < 15; _si++)
- _tokens[_si][0] = '\0';
-
- char vCA[200];
- char *vCE = NULL;
- do {
- vCE = readArchivedFileText(vCA, 200, file);
- if (vCE == 0) return 0;
-
- vCE = Common::ltrim(vCE);
- } while (strlen(vCE) == 0 || vCE[0] == '#');
-
- _si = 0;
- while (strlen(vCE) > 0 && _si < 20) {
- vCE = parseNextToken(vCE, _tokens[_si], 40, " \t\n");
- if (_tokens[_si][0] == '"' && _tokens[_si][strlen(_tokens[_si])-1] != '"') {
-
- vCE = parseNextToken(vCE, _tokens[_si+1], 40, v2);
- strcat(_tokens[_si], _tokens[_si+1]);
- _tokens[_si][0] = ' ';
- vCE++;
-
- }
-
- vCE = Common::ltrim(vCE);
- _si++;
- }
-
- return _si;
-}
diff --git a/engines/parallaction/parser.cpp b/engines/parallaction/parser.cpp
index cfa9da4200..1a03201b11 100644
--- a/engines/parallaction/parser.cpp
+++ b/engines/parallaction/parser.cpp
@@ -22,7 +22,7 @@
#include "parallaction/defs.h"
#include "parallaction/parser.h"
-
+#include "parallaction/disk.h"
namespace Parallaction {
@@ -119,6 +119,87 @@ uint16 parseFillBuffers() {
return _si;
}
+//
+// FIXME
+// this function does the same Job as parseFillBuffers, except that
+// it gets input from a SeekableStream instead of a memory buffer
+//
+uint16 tableFillBuffers(Common::SeekableReadStream &stream) {
+
+ for (uint16 i = 0; i < 20; i++)
+ _tokens[i][0] = '\0';
+
+ char buf[200];
+ char *line = NULL;
+ do {
+ line = stream.readLine(buf, 200);
+ if (line == NULL) return 0;
+
+ line = Common::ltrim(line);
+ } while (strlen(line) == 0 || line[0] == '#');
+
+ uint16 count = 0;
+ while (strlen(line) > 0 && count < 20) {
+ line = parseNextToken(line, _tokens[count], 40, " \t\n");
+ if (_tokens[count][0] == '"' && _tokens[count][strlen(_tokens[count]) - 1] != '"') {
+
+ line = parseNextToken(line, _tokens[count+1], 40, "\"");
+ strcat(_tokens[count], _tokens[count+1] );
+ _tokens[count][0] = ' ';
+ line++;
+
+ }
+
+ line = Common::ltrim(line);
+ count++;
+ }
+
+ return count;
+
+}
+
+// FIXME
+// this function does the same Job as parseFillBuffers, except that
+// it gets input from an ArchivedFile instead of a memory buffer
+//
+int16 scriptFillBuffers(ArchivedFile *file) {
+// printf("scriptFillBuffers()\n");
+ char v2[] = "\"\0";
+
+ int16 _si = 0;
+
+ for (; _si < 15; _si++)
+ _tokens[_si][0] = '\0';
+
+ char vCA[200];
+ char *vCE = NULL;
+ do {
+ vCE = readArchivedFileText(vCA, 200, file);
+ if (vCE == 0) return 0;
+
+ vCE = Common::ltrim(vCE);
+ } while (strlen(vCE) == 0 || vCE[0] == '#');
+
+ _si = 0;
+ while (strlen(vCE) > 0 && _si < 20) {
+ vCE = parseNextToken(vCE, _tokens[_si], 40, " \t\n");
+ if (_tokens[_si][0] == '"' && _tokens[_si][strlen(_tokens[_si])-1] != '"') {
+
+ vCE = parseNextToken(vCE, _tokens[_si+1], 40, v2);
+ strcat(_tokens[_si], _tokens[_si+1]);
+ _tokens[_si][0] = ' ';
+ vCE++;
+
+ }
+
+ vCE = Common::ltrim(vCE);
+ _si++;
+ }
+
+ return _si;
+}
+
+
// looks for next token in a string
//
// scans 's' until one of the stop-chars in 'brk' is found
diff --git a/engines/parallaction/parser.h b/engines/parallaction/parser.h
index e78d7f5e8b..f8e8741914 100644
--- a/engines/parallaction/parser.h
+++ b/engines/parallaction/parser.h
@@ -24,6 +24,7 @@
#define PARALLACTION_PARSER_H
#include "parallaction/defs.h"
+#include "common/file.h"
namespace Parallaction {
@@ -35,6 +36,10 @@ char *parseComment(ArchivedFile *file);
uint16 parseFillBuffers();
char *parseNextToken(char *s, char *tok, uint16 count, const char *brk);
+uint16 tableFillBuffers(Common::SeekableReadStream &stream);
+int16 scriptFillBuffers(ArchivedFile *file);
+
+
extern char _tokens[][40];
} // namespace Parallaction
diff --git a/engines/parallaction/table.cpp b/engines/parallaction/table.cpp
index 7df6120d7b..8d184410bb 100644
--- a/engines/parallaction/table.cpp
+++ b/engines/parallaction/table.cpp
@@ -28,46 +28,9 @@
namespace Parallaction {
-uint16 tableFillBuffers(Common::SeekableReadStream &stream);
-//
-// FIXME
-// this function does the same Job as parseFillBuffers, except that
-// it gets input from a SeekableStream instead of a memory buffer
-//
-uint16 tableFillBuffers(Common::SeekableReadStream &stream) {
- for (uint16 i = 0; i < 20; i++)
- _tokens[i][0] = '\0';
- char buf[200];
- char *line = NULL;
- do {
- line = stream.readLine(buf, 200);
- if (line == NULL) return 0;
-
- line = Common::ltrim(line);
- } while (strlen(line) == 0 || line[0] == '#');
-
- uint16 count = 0;
- while (strlen(line) > 0 && count < 20) {
- line = parseNextToken(line, _tokens[count], 40, " \t\n");
- if (_tokens[count][0] == '"' && _tokens[count][strlen(_tokens[count]) - 1] != '"') {
-
- line = parseNextToken(line, _tokens[count+1], 40, "\"");
- strcat(_tokens[count], _tokens[count+1] );
- _tokens[count][0] = ' ';
- line++;
-
- }
-
- line = Common::ltrim(line);
- count++;
- }
-
- return count;
-
-}
void Parallaction::initTable(const char *path, char** table) {
// printf("initTable(%s)\n", path);