Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Vocab.h
1 
2 #include "vtString.h"
3 #include "Array.h"
4 #include "Building.h"
5 
6 enum TokenType
7 {
8  LITERAL,
9  COUNTER,
10  NUMBER,
11  COLOR,
12  MATERIAL,
13  ROOFTYPE
14 };
15 
17 {
18 public:
19  enum TokenType type;
20  vtString str;
21 
22  // Don't bother with a union, no need to be efficient here
23  int counter;
24  float number;
25  RGBi color;
26  vtString material;
27  RoofType rooftype;
28 };
29 
30 class MatchToken : public InputToken
31 {
32 public:
33  bool m_bRequired;
34  vtStringArray alternates;
35 };
36 
38 class SentenceMatch : public vtArray<MatchToken *>
39 {
40 public:
41  virtual ~SentenceMatch() { Empty(); free(m_Data); m_Data = NULL; m_MaxSize = 0; }
42  void DestructItems(uint first, uint last) {
43  for (uint i = first; i <= last; i++) delete GetAt(i);
44  }
45  MatchToken *AddLiteral(bool required, const char *str1,
46  const char *str2 = NULL, const char *str3 = NULL, const char *str4 = NULL);
47  MatchToken *AddToken(bool required, enum TokenType type);
48 };
49 
51 {
52 public:
53  SentenceIn sen;
54  int iWords;
55 
56  int IsCounter(InputToken &t);
57  int IsNumber(InputToken &t);
58  int IsColor(int i);
59  int IsMaterial(int i);
60 
61  void ParseInput(const char *string);
62  void Apply();
63  bool Matches(SentenceMatch &pattern);
64 };
65