ScummVM API documentation
tt_parser.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TITANIC_TT_PARSER_H
23 #define TITANIC_TT_PARSER_H
24 
25 #include "titanic/true_talk/tt_node.h"
26 #include "titanic/true_talk/tt_pronoun.h"
27 #include "titanic/true_talk/tt_sentence.h"
28 #include "titanic/true_talk/tt_string.h"
29 
30 namespace Titanic {
31 
32 enum NumberFlag { NF_1 = 1, NF_2 = 2, NF_4 = 4, NF_8 = 8, NF_10 = 0x10 };
33 
34 enum ParserAction {
35  NO_ACTION = 0, CHECK_COMMAND_FORM, EXPECT_THING, OBJECT_IS_TO,
36  SEEK_ACTOR, SEEK_OBJECT, SEEK_OBJECT_OVERRIDE, SEEK_TO,
37  SEEK_FROM, SEEK_TO_OVERRIDE, SEEK_FROM_OVERRIDE, SEEK_LOCATION,
38  SEEK_OWNERSHIP, SEEK_STATE, SEEK_MODIFIERS, SEEK_NEW_FRAME,
39  SEEK_STATE_OBJECT, SET_ACTION, SET_COLOR, ACTOR_IS_TO,
40  ACTOR_IS_FROM, ACTOR_IS_OBJECT, STATE_IDENTITY,
41  WORD_TYPE_IS_SENTENCE_TYPE, COMPLEX_VERB
42 };
43 
44 class CScriptHandler;
45 class TTconcept;
46 
47 struct NumberEntry {
48  CString _text;
49  int _value;
50  int _flags;
51 
52  NumberEntry() : _value(0), _flags(0) {}
53  NumberEntry(const CString &text, int value, int flags) :
54  _text(text), _value(value), _flags(flags) {}
55 };
57 
58 class TTparserNode : public TTnode {
59 public:
60  uint _tag;
61 public:
62  TTparserNode() : TTnode(), _tag(0) {}
63  TTparserNode(uint tag) : TTnode(), _tag(tag) {}
64 };
65 
66 class TTparser {
67 private:
68  StringArray _replacements1;
69  StringArray _replacements2;
70  StringArray _replacements3;
71  StringArray _replacements4;
72  StringArray _phrases;
73  NumberArray _numbers;
74  TTparserNode *_nodesP;
75  TTconcept *_conceptP;
76  TTconcept *_currentConceptP;
77 private:
81  void clear();
82 
86  void loadArray(StringArray &arr, const CString &name);
87 
91  void loadArrays();
92 
97  int normalize(TTsentence *sentence);
98 
103  bool normalizeContraction(const TTstring &srcLine, int &srcIndex, TTstring &destLine);
104 
108  static int isEmoticon(const TTstring &str, int &index);
109 
117  static void searchAndReplace(TTstring &line, const StringArray &strings);
118 
128  static int searchAndReplace(TTstring &line, int startIndex, const StringArray &strings);
129 
138  int replaceNumbers(TTstring &line, int startIndex);
139 
148  const NumberEntry *replaceNumbers2(TTstring &line, int *startIndex);
149 
150  int loadRequests(TTword *word);
151  int considerRequests(TTword *word);
152  int processRequests(TTword *word);
153 
154  int addToConceptList(TTword *word);
155  int checkReferent(TTpronoun *pronoun);
156 
160  void addNode(uint tag);
161 
165  int addConcept(TTconcept *c);
166 
170  void removeConcept(TTconcept *c);
171 
175  void removeNode(TTparserNode *node);
176 
181  void preprocessGerman(TTstring &line);
182 
183  int processModifiers(int modifier, TTword *word);
184 
185  int checkForAction();
186  int fn2(TTword *word);
187  bool checkConcept2(TTconcept *conceptP, int conceptMode);
188  int filterConcepts(int conceptMode, int conceptIndex);
189  bool resetConcept(TTconcept **conceptPP, int conceptIndex);
190 public:
191  CScriptHandler *_owner;
192  TTsentenceConcept *_sentenceConcept;
193  TTsentence *_sentence;
194  int _fieldC;
195  int _field10;
196  int _field14;
197  TTword *_currentWordP;
198  StringArray _pronouns;
199 public:
200  TTparser(CScriptHandler *owner);
201  ~TTparser();
202 
207  int preprocess(TTsentence *sentence);
208 
209  int findFrames(TTsentence *sentence);
210 
214  void conceptChanged(TTconcept *newConcept, TTconcept *oldConcept);
215 };
216 
217 } // End of namespace Titanic
218 
219 #endif /* TITANIC_TT_PARSER_H */
Definition: tt_sentence.h:37
Definition: tt_parser.h:47
Definition: tt_concept.h:35
Definition: tt_parser.h:66
Definition: tt_sentence.h:49
Definition: tt_pronoun.h:29
Definition: arm.h:30
Definition: string.h:40
Definition: tt_string.h:45
Definition: tt_parser.h:58
Definition: tt_node.h:27
Definition: tt_word.h:41
Definition: script_handler.h:36