[Scummvm-cvs-logs] SF.net SVN: scummvm:[52985] scummvm/trunk/engines/sci/parser
wjpalenstijn at users.sourceforge.net
wjpalenstijn at users.sourceforge.net
Sun Oct 3 01:17:03 CEST 2010
Revision: 52985
http://scummvm.svn.sourceforge.net/scummvm/?rev=52985&view=rev
Author: wjpalenstijn
Date: 2010-10-02 23:17:03 +0000 (Sat, 02 Oct 2010)
Log Message:
-----------
SCI: Allow multiple word groups in parse tree leafs
This is to prepare for multilingual SCI versions. In those a single typed word
may be parsed to multiple class,group pairs, any of which may match
the said specs. The actual parsing is not yet implemented.
Modified Paths:
--------------
scummvm/trunk/engines/sci/parser/grammar.cpp
scummvm/trunk/engines/sci/parser/said.cpp
scummvm/trunk/engines/sci/parser/vocabulary.cpp
Modified: scummvm/trunk/engines/sci/parser/grammar.cpp
===================================================================
--- scummvm/trunk/engines/sci/parser/grammar.cpp 2010-10-02 22:11:51 UTC (rev 52984)
+++ scummvm/trunk/engines/sci/parser/grammar.cpp 2010-10-02 23:17:03 UTC (rev 52985)
@@ -445,6 +445,7 @@
nodes[base].left = &nodes[++(*pos)];
nodes[*pos].type = kParseTreeLeafNode;
nodes[*pos].value = value;
+ nodes[*pos].right = 0;
nodes[base].right = &nodes[++(*pos)];
nodes[*pos].type = kParseTreeBranchNode;
nodes[*pos].left = 0;
@@ -456,6 +457,7 @@
// Terminates, overwriting a nextwrite forknode
nodes[base].type = kParseTreeLeafNode;
nodes[base].value = value;
+ nodes[base].right = 0;
return *pos;
}
@@ -570,6 +572,7 @@
_parserNodes[1].type = kParseTreeLeafNode;
_parserNodes[1].value = 0x141;
+ _parserNodes[1].right = 0;
_parserNodes[2].type = kParseTreeBranchNode;
_parserNodes[2].left = 0;
Modified: scummvm/trunk/engines/sci/parser/said.cpp
===================================================================
--- scummvm/trunk/engines/sci/parser/said.cpp 2010-10-02 22:11:51 UTC (rev 52984)
+++ scummvm/trunk/engines/sci/parser/said.cpp 2010-10-02 23:17:03 UTC (rev 52985)
@@ -94,6 +94,7 @@
static ParseTreeNode* said_leaf_node(ParseTreeNode* pos, int value) {
pos->type = kParseTreeLeafNode;
pos->value = value;
+ pos->right = 0;
return pos;
}
@@ -101,6 +102,7 @@
static ParseTreeNode* said_word_node(ParseTreeNode* pos, int value) {
pos->type = kParseTreeWordNode;
pos->value = value;
+ pos->right = 0;
return pos;
}
@@ -780,18 +782,40 @@
// both saidT and parseT are terminals
int said_val = node_terminal_value(saidT);
- int parse_val = node_terminal_value(parseT);
- if (said_val != WORD_NONE &&
- (said_val == parse_val || said_val == WORD_ANY ||
- parse_val == WORD_ANY))
+#ifdef SCI_DEBUG_PARSE_TREE_AUGMENTATION
+ scidprintf("%*smatchTrees matching terminals: %03x", outputDepth, "", node_terminal_value(parseT));
+ ParseTreeNode* t = parseT->right->right;
+ while (t) {
+ scidprintf(",%03x", t->value);
+ t = t->right;
+ }
+ scidprintf(" vs %03x", said_val);
+#endif
+
+ if (said_val == WORD_NONE) {
+ ret = -1;
+ } else if (said_val == WORD_ANY) {
ret = 1;
- else
+ } else {
ret = -1;
- scidprintf("%*smatchTrees matching terminals: %03x vs %03x (%d)\n",
- outputDepth, "", parse_val, said_val, ret);
+ // scan through the word group ids in the parse tree leaf to see if
+ // one matches the word group in the said tree
+ parseT = parseT->right->right;
+ do {
+ assert(parseT->type != kParseTreeBranchNode);
+ int parse_val = parseT->value;
+ if (parse_val == WORD_ANY || parse_val == said_val) {
+ ret = 1;
+ break;
+ }
+ parseT = parseT->right;
+ } while (parseT);
+ }
+ scidprintf(" (ret %d)\n", ret);
+
} else if (node_is_terminal(saidT) && !node_is_terminal(parseT)) {
// saidT is a terminal, but parseT isn't
Modified: scummvm/trunk/engines/sci/parser/vocabulary.cpp
===================================================================
--- scummvm/trunk/engines/sci/parser/vocabulary.cpp 2010-10-02 22:11:51 UTC (rev 52984)
+++ scummvm/trunk/engines/sci/parser/vocabulary.cpp 2010-10-02 23:17:03 UTC (rev 52985)
@@ -40,6 +40,7 @@
// Mark parse tree as unused
_parserNodes[0].type = kParseTreeLeafNode;
_parserNodes[0].value = 0;
+ _parserNodes[0].right = 0;
_synonyms.clear(); // No synonyms
@@ -578,6 +579,7 @@
if (type == kParseNumber) {
_parserNodes[*pos += 1].type = kParseTreeLeafNode;
_parserNodes[*pos].value = nr;
+ _parserNodes[*pos].right = 0;
return *pos;
}
if (type == kParseEndOfInput) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list