SCI: added said spec dump ability to logkernel
svn-id: r51242
This commit is contained in:
parent
9672c757d6
commit
d49d1d60fe
5 changed files with 63 additions and 51 deletions
|
@ -1302,7 +1302,8 @@ bool Console::cmdSaid(int argc, const char **argv) {
|
|||
spec[len++] = 0xFF;
|
||||
|
||||
printf("Matching '%s' against:", string);
|
||||
_engine->getVocabulary()->decipherSaidBlock(spec);
|
||||
_engine->getVocabulary()->debugDecipherSaidBlock(spec);
|
||||
printf("\n");
|
||||
|
||||
bool res = _engine->getVocabulary()->tokenizeString(words, string, &error);
|
||||
if (res && !words.empty()) {
|
||||
|
|
|
@ -664,8 +664,18 @@ static void logKernelCall(const KernelFunction *kernelCall, EngineState *s, int
|
|||
printf(" (%s)", s->_segMan->getObjectName(argv[parmNr]));
|
||||
break;
|
||||
case SIG_TYPE_REFERENCE:
|
||||
if (kernelCall->function == kSaid) {
|
||||
SegmentRef saidSpec = s->_segMan->dereference(argv[parmNr]);
|
||||
if (saidSpec.isRaw) {
|
||||
printf(" ('");
|
||||
g_sci->getVocabulary()->debugDecipherSaidBlock(saidSpec.raw);
|
||||
printf("')");
|
||||
} else {
|
||||
printf(" (non-raw said-spec)");
|
||||
}
|
||||
} else {
|
||||
printf(" ('%s')", s->_segMan->getString(argv[parmNr]).c_str());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1003,11 +1003,8 @@ int said(EngineState *s, byte *spec, bool verbose) {
|
|||
ParseTreeNode *parse_tree_ptr = voc->_parserNodes;
|
||||
|
||||
if (voc->parserIsValid) {
|
||||
if (said_parse_spec(spec)) {
|
||||
scidprintf("Offending spec was: ");
|
||||
voc->decipherSaidBlock(spec);
|
||||
if (said_parse_spec(spec))
|
||||
return SAID_NO_MATCH;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
vocab_dump_parse_tree("Said-tree", said_tree);
|
||||
|
|
|
@ -321,54 +321,58 @@ ResultWord Vocabulary::lookupWord(const char *word, int word_len) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
void Vocabulary::decipherSaidBlock(byte *addr) {
|
||||
uint16 nextitem;
|
||||
void Vocabulary::debugDecipherSaidBlock(const byte *addr) {
|
||||
bool first = true;
|
||||
uint16 nextItem;
|
||||
|
||||
do {
|
||||
nextitem = *addr++;
|
||||
nextItem = *addr++;
|
||||
if (nextItem != 0xff) {
|
||||
if ((!first) && (nextItem != 0xf0))
|
||||
printf(" ");
|
||||
first = false;
|
||||
|
||||
if (nextitem < 0xf0) {
|
||||
nextitem = nextitem << 8 | *addr++;
|
||||
printf(" %s[%03x]", getAnyWordFromGroup(nextitem), nextitem);
|
||||
if (nextItem < 0xf0) {
|
||||
nextItem = nextItem << 8 | *addr++;
|
||||
printf("%s{%03x}", getAnyWordFromGroup(nextItem), nextItem);
|
||||
|
||||
nextitem = 42; // Make sure that group 0xff doesn't abort
|
||||
} else switch (nextitem) {
|
||||
nextItem = 0; // Make sure that group 0xff doesn't abort
|
||||
} else switch (nextItem) {
|
||||
case 0xf0:
|
||||
printf(" ,");
|
||||
printf(",");
|
||||
break;
|
||||
case 0xf1:
|
||||
printf(" &");
|
||||
printf("&");
|
||||
break;
|
||||
case 0xf2:
|
||||
printf(" /");
|
||||
printf("/");
|
||||
break;
|
||||
case 0xf3:
|
||||
printf(" (");
|
||||
printf("(");
|
||||
break;
|
||||
case 0xf4:
|
||||
printf(" )");
|
||||
printf(")");
|
||||
break;
|
||||
case 0xf5:
|
||||
printf(" [");
|
||||
printf("[");
|
||||
break;
|
||||
case 0xf6:
|
||||
printf(" ]");
|
||||
printf("]");
|
||||
break;
|
||||
case 0xf7:
|
||||
printf(" #");
|
||||
printf("#");
|
||||
break;
|
||||
case 0xf8:
|
||||
printf(" <");
|
||||
printf("<");
|
||||
break;
|
||||
case 0xf9:
|
||||
printf(" >");
|
||||
printf(">");
|
||||
break;
|
||||
case 0xff:
|
||||
break;
|
||||
}
|
||||
} while (nextitem != 0xff);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
} while (nextItem != 0xff);
|
||||
}
|
||||
|
||||
static const byte lowerCaseMap[256] = {
|
||||
|
|
|
@ -235,7 +235,7 @@ public:
|
|||
* For debugging only.
|
||||
* @param pos pointer to the data to dump
|
||||
*/
|
||||
void decipherSaidBlock(byte *pos);
|
||||
void debugDecipherSaidBlock(const byte *pos);
|
||||
|
||||
/**
|
||||
* Prints the parser suffixes to the debug console.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue