Game Develop Core: VariableParser.h Source File

| Game Develop Core Core library for developing platforms and tools compatible with Game Develop.

- Main Page
- Modules
- Classes

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Macros Groups Pages
VariableParser.h
Go to the documentation of this file.
1
5 #ifndef GDCORE_VARIABLEPARSER_H
6 #define GDCORE_VARIABLEPARSER_H
7
8 #include <string>
9 #include <vector>
10 namespace gd { class Layout; }
11 namespace gd { class Project; }
12 namespace gd { class Platform; }
13 namespace gd { class VariableParserCallbacks; }
14
15 namespace gd
16 {
17
44 class GD_CORE_API VariableParser
45 {
46 public:
47
52 VariableParser(const std::string & expressionPlainString_) : currentPosition(0), expression(expressionPlainString_) {};
53 virtual ~VariableParser();
54
61 bool Parse(VariableParserCallbacks & callbacks);
62
63 std::string firstErrorStr;
64 size_t firstErrorPos;
65
66 private:
67
68 void S();
69 void X();
70
75 std::string SkipStringExpression();
76
77 void ReadToken();
78
79 enum TokenType {
80 TS_PERIOD,
81 TS_OPENING_BRACKET,
82 TS_CLOSING_BRACKET,
83 TS_VARNAME,
84 TS_INVALID
85 };
86
87 TokenType currentTokenType;
88 std::string currentToken;
89 size_t currentPosition;
90 std::string expression;
91
92 VariableParserCallbacks * callbacks;
93 bool rootVariableParsed;
94 };
95
99 class GD_CORE_API VariableParserCallbacks
100 {
101 public:
106 virtual void OnRootVariable(std::string variableName) = 0;
107
112 virtual void OnChildVariable(std::string variableName) = 0;
113
120 virtual void OnChildSubscript(std::string stringExpression) = 0;
121 };
122
123 }
124
125 #endif // GDEXPRESSIONPARSER_H