22 #ifndef SCI_PARSER_VOCABULARY_H 23 #define SCI_PARSER_VOCABULARY_H 25 #include "common/str.h" 26 #include "common/hashmap.h" 27 #include "common/hash-str.h" 28 #include "common/list.h" 31 #include "sci/engine/vm_types.h" 42 class ResourceManager;
47 VOCAB_RESOURCE_SELECTORS = 997,
49 VOCAB_RESOURCE_SCI0_MAIN_VOCAB = 0,
50 VOCAB_RESOURCE_SCUMM_LOC_VOCAB = 1,
51 VOCAB_RESOURCE_SCI0_PARSE_TREE_BRANCHES = 900,
52 VOCAB_RESOURCE_SCI0_SUFFIX_VOCAB = 901,
54 VOCAB_RESOURCE_SCI1_MAIN_VOCAB = 900,
55 VOCAB_RESOURCE_SCI1_PARSE_TREE_BRANCHES = 901,
56 VOCAB_RESOURCE_SCI1_SUFFIX_VOCAB = 902,
58 VOCAB_RESOURCE_ALT_INPUTS = 913
63 VOCAB_CLASS_PREPOSITION = 0x01,
64 VOCAB_CLASS_ARTICLE = 0x02,
65 VOCAB_CLASS_ADJECTIVE = 0x04,
66 VOCAB_CLASS_PRONOUN = 0x08,
67 VOCAB_CLASS_NOUN = 0x10,
68 VOCAB_CLASS_INDICATIVE_VERB = 0x20,
69 VOCAB_CLASS_ADVERB = 0x40,
70 VOCAB_CLASS_IMPERATIVE_VERB = 0x80,
71 VOCAB_CLASS_NUMBER = 0x001
76 kParseOpeningParenthesis = 1,
77 kParseClosingParenthesis = 2,
82 #define VOCAB_MAX_WORDLENGTH 256 85 #define VOCAB_CLASS_ANYWORD 0xff 88 #define VOCAB_MAGIC_NUMBER_GROUP 0xffd 89 #define VOCAB_MAGIC_NOTHING_GROUP 0xffe 92 #define VOCAB_TREE_NODES 500 94 #define VOCAB_TREE_NODE_LAST_WORD_STORAGE 0x140 95 #define VOCAB_TREE_NODE_COMPARE_TYPE 0x146 96 #define VOCAB_TREE_NODE_COMPARE_GROUP 0x14d 97 #define VOCAB_TREE_NODE_FORCE_STORAGE 0x154 99 #define SAID_COMMA 0xf0 100 #define SAID_AMP 0xf1 101 #define SAID_SLASH 0xf2 102 #define SAID_PARENO 0xf3 103 #define SAID_PARENC 0xf4 104 #define SAID_BRACKO 0xf5 105 #define SAID_BRACKC 0xf6 106 #define SAID_HASH 0xf7 109 #define SAID_TERM 0xff 111 #define SAID_FIRST SAID_COMMA 114 #define SAID_FULL_MATCH 0xffff 115 #define SAID_NO_MATCH 0xfffe 116 #define SAID_PARTIAL_MATCH 0xfffd 118 #define SAID_LONG(x) ((x) << 8) 131 struct ParseRuleList;
159 const char *_replacement;
161 uint32 _replacementLength;
172 kParseTreeWordNode = 4,
173 kParseTreeLeafNode = 5,
174 kParseTreeBranchNode = 6
184 enum VocabularyVersions {
201 const char *getAnyWordFromGroup(
int group);
210 void lookupWord(ResultWordList &retval,
const char *word,
int word_len);
221 void lookupWordPrefix(ResultWordListList &parent_retval, ResultWordList &retval,
const char *word,
int word_len);
234 bool lookupSpecificPrefixWithMeaning(ResultWordListList &parent_retval, ResultWordList &retval,
const char *word,
int word_len,
unsigned char prefix,
const char *meaning);
246 bool lookupVerbPrefix(ResultWordListList &parent_retval, ResultWordList &retval,
Common::String word,
int word_len,
Common::String prefix);
259 bool tokenizeString(ResultWordListList &retval,
const char *sentence,
char **
error);
270 int parseGNF(
const ResultWordListList &words,
bool verbose =
false);
275 bool storePronounReference();
280 void replacePronouns(ResultWordListList &words);
293 ParseRuleList *buildGNF(
bool verbose =
false);
305 void printSuffixes()
const;
310 void printParserWords()
const;
312 uint getParserBranchesSize()
const {
return _parserBranches.size(); }
313 const parse_tree_branch_t &getParseTreeBranch(
int number)
const {
return _parserBranches[number]; }
329 void synonymizeTokens(ResultWordListList &words);
331 void printParserNodes(
int num);
333 void dumpParseTree();
335 int parseNodes(
int *i,
int *pos,
int type,
int nr,
int argc,
const char **argv);
355 bool loadParserWords();
361 void loadTranslatedWords();
386 void freeRuleList(ParseRuleList *rule_list);
393 bool loadAltInputs();
398 void freeAltInputs();
401 VocabularyVersions _vocabVersion;
404 uint16 _resourceIdWords;
405 uint16 _resourceIdSuffixes;
406 uint16 _resourceIdBranches;
409 SuffixList _parserSuffixes;
410 ParseRuleList *_parserRules;
412 WordMap _parserWords;
413 SynonymList _synonyms;
416 struct PrefixMeaning {
417 unsigned char prefix;
421 int _pronounReference;
447 int said(
const byte *spec,
bool verbose);
451 #endif // SCI_PARSER_VOCABULARY_H const char * word_suffix
Definition: vocabulary.h:142
Definition: vocabulary.h:120
Definition: vocabulary.h:166
const char * alt_suffix
Definition: vocabulary.h:141
void vocab_dump_parse_tree(const char *tree_name, ParseTreeNode *nodes)
int value
Definition: vocabulary.h:179
Definition: vocabulary.h:189
Definition: serializer.h:79
int alt_suffix_length
Definition: vocabulary.h:138
Definition: resource.h:327
int _group
Definition: vocabulary.h:122
int word_suffix_length
Definition: vocabulary.h:139
int _class
Definition: vocabulary.h:121
uint16 replaceant
Definition: vocabulary.h:150
void clearSynonyms()
Definition: vocabulary.h:323
ParseTypes type
Definition: vocabulary.h:178
Definition: algorithm.h:29
Definition: vocabulary.h:133
ParseTreeNode * left
Definition: vocabulary.h:180
uint16 replacement
Definition: vocabulary.h:151
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
int said(const byte *spec, bool verbose)
Definition: vocabulary.h:149
void addSynonym(synonym_t syn)
Definition: vocabulary.h:318
int result_class
Definition: vocabulary.h:136
reg_t parser_event
Definition: vocabulary.h:428
ParseTreeNode * right
Definition: vocabulary.h:181
Definition: vocabulary.h:177
Definition: vm_types.h:39
bool parserIsValid
Definition: vocabulary.h:429
int class_mask
Definition: vocabulary.h:135