aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/parser.cpp
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/parallaction/parser.cpp
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/parallaction/parser.cpp')
-rw-r--r--engines/parallaction/parser.cpp83
1 files changed, 82 insertions, 1 deletions
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