Game Develop Core: ExpressionParser.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
ExpressionParser.h
Go to the documentation of this file.
1
5 #ifndef GDCORE_EXPRESSIONPARSER_H
6 #define GDCORE_EXPRESSIONPARSER_H
7
8 #include <string>
9 #include <vector>
10 namespace gd { class Expression; }
11 namespace gd { class ParserCallbacks; }
12 namespace gd { class Layout; }
13 namespace gd { class Project; }
14 namespace gd { class Platform; }
15 namespace gd { class ParameterMetadata; }
16 namespace gd { class ExpressionMetadata; }
17 namespace gd { class StrExpressionMetadata; }
18
19 namespace gd
20 {
21
27 class GD_CORE_API ExpressionParser
28 {
29 public:
30 ExpressionParser(const std::string & expressionPlainString_);
31 virtual ~ExpressionParser() {};
32
37 bool ParseMathExpression(const gd::Platform & platform, const gd::Project & project, const gd::Layout & layout, gd::ParserCallbacks & callbacks);
38
43 bool ParseStringExpression(const gd::Platform & platform, const gd::Project & project, const gd::Layout & layout, gd::ParserCallbacks & callbacks);
44
45 std::string firstErrorStr;
46 size_t firstErrorPos;
47
48 private:
49
53 bool AddParameterToList(const gd::Project & project, const gd::Layout & layout, ParserCallbacks &, std::vector < gd::Expression > & parameters, std::string parameterStr, std::vector < gd::ParameterMetadata > parametersInfos, const size_t positionInExpression);
54
58 bool PrepareParameter(const gd::Platform & platform,const gd::Project & project, const gd::Layout & layout, ParserCallbacks &, gd::Expression & parameter, const gd::ParameterMetadata & parametersInfo, const size_t positionInExpression);
59
63 size_t GetMinimalParametersNumber(const std::vector < gd::ParameterMetadata > & parametersInfos);
64
68 size_t GetMaximalParametersNumber(const std::vector < gd::ParameterMetadata > & parametersInfos);
69
70 bool ValidSyntax(const std::string & str);
71
72 std::string expressionPlainString;
73 static std::string parserSeparators;
74 };
75
81 class GD_CORE_API ParserCallbacks
82 {
83 public:
84
85 ParserCallbacks() {};
86 virtual ~ParserCallbacks() {};
87
88 virtual void OnConstantToken(std::string text) = 0;
89 virtual void OnNumber(std::string text) = 0;
90 virtual void OnOperator(std::string text) = 0;
91
92 virtual void OnStaticFunction(std::string functionName, const std::vector<gd::Expression> & parameters, const gd::ExpressionMetadata & expressionInfo) = 0;
93 virtual void OnStaticFunction(std::string functionName, const std::vector<gd::Expression> & parameters, const gd::StrExpressionMetadata & expressionInfo) = 0;
94
95 virtual void OnObjectFunction(std::string functionName, const std::vector<gd::Expression> & parameters, const gd::ExpressionMetadata & expressionInfo) = 0;
96 virtual void OnObjectFunction(std::string functionName, const std::vector<gd::Expression> & parameters, const gd::StrExpressionMetadata & expressionInfo) = 0;
97
98 virtual void OnObjectAutomatismFunction(std::string functionName, const std::vector<gd::Expression> & parameters, const gd::ExpressionMetadata & expressionInfo) = 0;
99 virtual void OnObjectAutomatismFunction(std::string functionName, const std::vector<gd::Expression> & parameters, const gd::StrExpressionMetadata & expressionInfo) = 0;
100
101 virtual bool OnSubMathExpression(const gd::Platform & platform, const gd::Project & project, const gd::Layout & layout, gd::Expression & expression) = 0;
102 virtual bool OnSubTextExpression(const gd::Platform & platform, const gd::Project & project, const gd::Layout & layout, gd::Expression & expression) = 0;
103
104 std::string firstErrorStr;
105 size_t firstErrorPos;
106 };
107
108 }
109
110 #endif // GDEXPRESSIONPARSER_H