SCI: Renamed some Vocabulary methods for clarity; also renamed decypherSaidBlock -> decipherSaidBlock; some cleanup in Console::cmdSentenceFragments
svn-id: r41072
This commit is contained in:
parent
4fba6e5d4c
commit
cf68dc1a7b
6 changed files with 48 additions and 46 deletions
|
@ -499,29 +499,30 @@ bool Console::cmdSentenceFragments(int argc, const char **argv) {
|
|||
for (uint i = 0; i < g_EngineState->_vocabulary->getParserBranchesSize(); i++) {
|
||||
int j = 0;
|
||||
|
||||
DebugPrintf("R%02d: [%x] ->", i, g_EngineState->_vocabulary->getParseTreeBranch(i).id);
|
||||
while ((j < 10) && g_EngineState->_vocabulary->getParseTreeBranch(i).data[j]) {
|
||||
int dat = g_EngineState->_vocabulary->getParseTreeBranch(i).data[j++];
|
||||
const parse_tree_branch_t &branch = g_EngineState->_vocabulary->getParseTreeBranch(i);
|
||||
DebugPrintf("R%02d: [%x] ->", i, branch.id);
|
||||
while ((j < 10) && branch.data[j]) {
|
||||
int dat = branch.data[j++];
|
||||
|
||||
switch (dat) {
|
||||
case VOCAB_TREE_NODE_COMPARE_TYPE:
|
||||
dat = g_EngineState->_vocabulary->getParseTreeBranch(i).data[j++];
|
||||
dat = branch.data[j++];
|
||||
DebugPrintf(" C(%x)", dat);
|
||||
break;
|
||||
|
||||
case VOCAB_TREE_NODE_COMPARE_GROUP:
|
||||
dat = g_EngineState->_vocabulary->getParseTreeBranch(i).data[j++];
|
||||
dat = branch.data[j++];
|
||||
DebugPrintf(" WG(%x)", dat);
|
||||
break;
|
||||
|
||||
case VOCAB_TREE_NODE_FORCE_STORAGE:
|
||||
dat = g_EngineState->_vocabulary->getParseTreeBranch(i).data[j++];
|
||||
dat = branch.data[j++];
|
||||
DebugPrintf(" FORCE(%x)", dat);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (dat > VOCAB_TREE_NODE_LAST_WORD_STORAGE) {
|
||||
int dat2 = g_EngineState->_vocabulary->getParseTreeBranch(i).data[j++];
|
||||
int dat2 = branch.data[j++];
|
||||
DebugPrintf(" %x[%x]", dat, dat2);
|
||||
} else
|
||||
DebugPrintf(" ?%x?", dat);
|
||||
|
|
|
@ -906,7 +906,7 @@ static void vocab_get_knames11(ResourceManager *resmgr, Common::StringList &name
|
|||
}
|
||||
#endif
|
||||
|
||||
bool Vocabulary::getKernelNames() {
|
||||
bool Vocabulary::loadKernelNames() {
|
||||
_kernelNames.clear();
|
||||
|
||||
switch (_resmgr->_sciVersion) {
|
||||
|
|
|
@ -95,7 +95,7 @@ reg_t kSaid(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
|||
|
||||
#ifdef DEBUG_PARSER
|
||||
debugC(2, kDebugLevelParser, "Said block:", 0);
|
||||
s->_vocabulary->decypherSaidBlock(said_block);
|
||||
s->_vocabulary->decipherSaidBlock(said_block);
|
||||
#endif
|
||||
|
||||
if (s->parser_event.isNull() || (GET_SEL32V(s->parser_event, claimed))) {
|
||||
|
|
|
@ -2448,7 +2448,7 @@ int said(EngineState *s, byte *spec, int verbose) {
|
|||
if (s->parser_valid) {
|
||||
if (said_parse_spec(s, spec)) {
|
||||
sciprintf("Offending spec was: ");
|
||||
s->_vocabulary->decypherSaidBlock(spec);
|
||||
s->_vocabulary->decipherSaidBlock(spec);
|
||||
return SAID_NO_MATCH;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,8 +92,8 @@ Vocabulary::Vocabulary(ResourceManager *resmgr, bool isOldSci0) : _resmgr(resmgr
|
|||
|
||||
debug(2, "Initializing vocabulary");
|
||||
|
||||
if (_resmgr->_sciVersion < SCI_VERSION_01_VGA && getParserWords()) {
|
||||
getSuffixes();
|
||||
if (_resmgr->_sciVersion < SCI_VERSION_01_VGA && loadParserWords()) {
|
||||
loadSuffixes();
|
||||
if (getBranches())
|
||||
// Now build a GNF grammar out of this
|
||||
_parserRules = buildGNF();
|
||||
|
@ -102,16 +102,16 @@ Vocabulary::Vocabulary(ResourceManager *resmgr, bool isOldSci0) : _resmgr(resmgr
|
|||
_parserRules = NULL;
|
||||
}
|
||||
|
||||
getOpcodes();
|
||||
loadOpcodes();
|
||||
|
||||
if (!getSelectorNames()) {
|
||||
if (!loadSelectorNames()) {
|
||||
error("Vocabulary: Could not retrieve selector names");
|
||||
}
|
||||
|
||||
// Map a few special selectors for later use
|
||||
mapSelectors();
|
||||
|
||||
getKernelNames();
|
||||
loadKernelNames();
|
||||
}
|
||||
|
||||
Vocabulary::~Vocabulary() {
|
||||
|
@ -124,7 +124,7 @@ Vocabulary::~Vocabulary() {
|
|||
freeSuffixes();
|
||||
}
|
||||
|
||||
bool Vocabulary::getSelectorNames() {
|
||||
bool Vocabulary::loadSelectorNames() {
|
||||
int count;
|
||||
|
||||
Resource *r = _resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_SNAMES, 0);
|
||||
|
@ -150,7 +150,7 @@ bool Vocabulary::getSelectorNames() {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Vocabulary::getOpcodes() {
|
||||
bool Vocabulary::loadOpcodes() {
|
||||
int count, i = 0;
|
||||
Resource* r = _resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_OPCODES, 0);
|
||||
|
||||
|
@ -176,7 +176,7 @@ bool Vocabulary::getOpcodes() {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Vocabulary::getParserWords() {
|
||||
bool Vocabulary::loadParserWords() {
|
||||
|
||||
char currentword[256] = ""; // They're not going to use words longer than 255 ;-)
|
||||
int currentwordpos = 0;
|
||||
|
@ -260,7 +260,7 @@ const char *Vocabulary::getAnyWordFromGroup(int group) {
|
|||
return "{invalid}";
|
||||
}
|
||||
|
||||
bool Vocabulary::getSuffixes() {
|
||||
bool Vocabulary::loadSuffixes() {
|
||||
// Determine if we can find a SCI1 suffix vocabulary first
|
||||
Resource* resource = NULL;
|
||||
|
||||
|
@ -410,7 +410,7 @@ ResultWord Vocabulary::lookupWord(const char *word, int word_len) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
void Vocabulary::decypherSaidBlock(byte *addr) {
|
||||
void Vocabulary::decipherSaidBlock(byte *addr) {
|
||||
int nextitem;
|
||||
|
||||
do {
|
||||
|
@ -503,7 +503,7 @@ bool Vocabulary::tokenizeString(ResultWordList &retval, const char *sentence, ch
|
|||
return true;
|
||||
}
|
||||
|
||||
void Vocabulary::printSuffixes() {
|
||||
void Vocabulary::printSuffixes() const {
|
||||
char word_buf[256], alt_buf[256];
|
||||
Sci::Console *con = ((SciEngine *)g_engine)->_console;
|
||||
|
||||
|
@ -519,7 +519,7 @@ void Vocabulary::printSuffixes() {
|
|||
}
|
||||
}
|
||||
|
||||
void Vocabulary::printParserWords() {
|
||||
void Vocabulary::printParserWords() const {
|
||||
Sci::Console *con = ((SciEngine *)g_engine)->_console;
|
||||
|
||||
int j = 0;
|
||||
|
|
|
@ -195,10 +195,11 @@ public:
|
|||
const char *getAnyWordFromGroup(int group);
|
||||
|
||||
|
||||
/* Looks up a single word in the words and suffixes list
|
||||
** Parameters: (char *) word: Pointer to the word to look up
|
||||
** (int) word_len: Length of the word to look up
|
||||
** Returns : (const ResultWordList &) A list containing 1 or 0 words
|
||||
/**
|
||||
* Looks up a single word in the words and suffixes list.
|
||||
* @param word pointer to the word to look up
|
||||
* @param word_len length of the word to look up
|
||||
* @return the matching word (or (-1,-1) if there was no match)
|
||||
*/
|
||||
ResultWord lookupWord(const char *word, int word_len);
|
||||
|
||||
|
@ -239,22 +240,22 @@ public:
|
|||
*/
|
||||
parse_rule_list_t *buildGNF(bool verbose = false);
|
||||
|
||||
/* Decyphers a said block and dumps its content via sciprintf.
|
||||
** Parameters: (EngineState *) s: The state to use
|
||||
** (byte *) pos: Pointer to the data to dump
|
||||
** For debugging only.
|
||||
/**
|
||||
* Deciphers a said block and dumps its content via sciprintf.
|
||||
* For debugging only.
|
||||
* @param pos pointer to the data to dump
|
||||
*/
|
||||
void decypherSaidBlock(byte *pos);
|
||||
void decipherSaidBlock(byte *pos);
|
||||
|
||||
/**
|
||||
* Prints the parser suffixes to the debug console
|
||||
* Prints the parser suffixes to the debug console.
|
||||
*/
|
||||
void printSuffixes();
|
||||
void printSuffixes() const;
|
||||
|
||||
/**
|
||||
* Prints the parser words to the debug console
|
||||
* Prints the parser words to the debug console.
|
||||
*/
|
||||
void printParserWords();
|
||||
void printParserWords() const;
|
||||
|
||||
uint getParserBranchesSize() const { return _parserBranches.size(); }
|
||||
const parse_tree_branch_t &getParseTreeBranch(int number) const { return _parserBranches[number]; }
|
||||
|
@ -293,7 +294,7 @@ private:
|
|||
* Loads the vocabulary selector names.
|
||||
* Returns true upon success, false otherwise.
|
||||
*/
|
||||
bool getSelectorNames();
|
||||
bool loadSelectorNames();
|
||||
|
||||
/* Maps special selectors
|
||||
** Returns : (void)
|
||||
|
@ -301,33 +302,33 @@ private:
|
|||
void mapSelectors();
|
||||
|
||||
/**
|
||||
* Fills the given Array with opcodes.
|
||||
* Loads the opcode names (only used for debugging).
|
||||
* @return true on success, false on failure
|
||||
*/
|
||||
bool getOpcodes();
|
||||
bool loadOpcodes();
|
||||
|
||||
/**
|
||||
* Fills the given StringList with kernel function names.
|
||||
* Loads the kernel function names.
|
||||
*
|
||||
* This function reads the kernel function name table from resource_map,
|
||||
* and fills the given StringList with them.
|
||||
* and fills the _kernelNames array with them.
|
||||
* The resulting list has the same format regardless of the format of the
|
||||
* name table of the resource (the format changed between version 0 and 1).
|
||||
* @return true on success, false on failure
|
||||
*/
|
||||
bool getKernelNames();
|
||||
bool loadKernelNames();
|
||||
|
||||
/**
|
||||
* Gets all words from the main vocabulary.
|
||||
* Loads all words from the main vocabulary.
|
||||
* @return true on success, false on failure
|
||||
*/
|
||||
bool getParserWords();
|
||||
bool loadParserWords();
|
||||
|
||||
/**
|
||||
* Loads all suffixes from the suffix vocabulary.
|
||||
* @return true on success, false on failure
|
||||
*/
|
||||
bool getSuffixes();
|
||||
bool loadSuffixes();
|
||||
|
||||
/**
|
||||
* Frees all suffixes in the given list.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue