11 #include "ExpressionParser2NodeWorker.h"
12 #include "GDCore/String.h"
16 class ObjectsContainer;
18 class ParameterMetadata;
19 class ExpressionMetadata;
20 struct FunctionCallNode;
28 : isValid(
true), startPosition(position), endPosition(position){};
31 startPosition(startPosition_),
32 endPosition(endPosition_){};
33 size_t GetStartPosition()
const {
return startPosition; }
34 size_t GetEndPosition()
const {
return endPosition; }
35 bool IsValid()
const {
return isValid; }
39 size_t startPosition = 0;
40 size_t endPosition = 0;
53 BracketsNotAllowedForObjects,
57 MalformedVariableParameter,
58 MalformedObjectParameter,
61 VariableNameCollision,
69 : type(type_), message(message_), location(location_),
70 actualValue(actualValue_), objectName(objectName_){};
73 : type(type_), message(message_), location(position_){};
75 const gd::String &message_,
size_t startPosition_,
77 : type(type_), message(message_),
78 location(startPosition_, endPosition_){};
81 gd::ExpressionParserError::ErrorType GetType() {
return type; }
82 const gd::String &GetMessage() {
return message; }
83 const gd::String &GetObjectName() {
return objectName; }
84 const gd::String &GetActualValue() {
return actualValue; }
85 size_t GetStartPosition() {
return location.GetStartPosition(); }
86 size_t GetEndPosition() {
return location.GetEndPosition(); }
89 gd::ExpressionParserError::ErrorType type;
105 std::unique_ptr<ExpressionParserError> diagnostic;
120 worker.OnVisitSubExpressionNode(*
this);
123 std::unique_ptr<ExpressionNode> expression;
134 worker.OnVisitOperatorNode(*
this);
137 std::unique_ptr<ExpressionNode> leftHandSide;
138 std::unique_ptr<ExpressionNode> rightHandSide;
139 gd::String::value_type op;
150 worker.OnVisitUnaryOperatorNode(*
this);
153 std::unique_ptr<ExpressionNode> factor;
154 gd::String::value_type op;
166 worker.OnVisitNumberNode(*
this);
181 worker.OnVisitTextNode(*
this);
208 identifierName(identifierName_),
209 childIdentifierName(
""){};
214 identifierName(identifierName_),
215 childIdentifierName(childIdentifierName_){};
218 worker.OnVisitIdentifierNode(*
this);
245 std::unique_ptr<VariableAccessorOrVariableBracketAccessorNode> child;
266 worker.OnVisitVariableNode(*
this);
271 std::unique_ptr<VariableAccessorOrVariableBracketAccessorNode>
287 worker.OnVisitVariableAccessorNode(*
this);
305 worker.OnVisitVariableBracketAccessorNode(*
this);
308 std::unique_ptr<ExpressionNode> expression;
323 const gd::String &objectFunctionOrBehaviorName_)
325 objectName(objectName_),
326 objectFunctionOrBehaviorName(objectFunctionOrBehaviorName_) {}
331 objectName(objectName_),
332 objectFunctionOrBehaviorName(behaviorName_),
333 behaviorFunctionName(behaviorFunctionName_) {}
336 worker.OnVisitObjectFunctionNameNode(*
this);
375 functionName(functionName_){};
381 objectName(objectName_),
382 functionName(functionName_){};
389 objectName(objectName_),
390 behaviorName(behaviorName_),
391 functionName(functionName_){};
393 virtual void Visit(ExpressionParser2NodeWorker &worker) {
394 worker.OnVisitFunctionCallNode(*
this);
399 std::vector<std::unique_ptr<ExpressionNode>> parameters;
402 ExpressionParserLocation
428 worker.OnVisitEmptyNode(*
this);
The interface for any worker class ("visitor" pattern) that want to interact with the nodes of a pars...
Definition: ExpressionParser2NodeWorker.h:36
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24
An empty node, used when parsing failed/a syntax error was encountered and any other node could not m...
Definition: ExpressionParser2Node.h:423
The base node, from which all nodes in the tree of an expression inherits from.
Definition: ExpressionParser2Node.h:100
ExpressionParserLocation location
Definition: ExpressionParser2Node.h:106
An error that can be attached to a gd::ExpressionNode.
Definition: ExpressionParser2Node.h:46
Definition: ExpressionParser2Node.h:25
A function call node (either free function, object function or object behavior function)....
Definition: ExpressionParser2Node.h:371
FunctionCallNode(const gd::String &objectName_, const gd::String &functionName_)
Construct an object function call node.
Definition: ExpressionParser2Node.h:378
ExpressionParserLocation objectNameLocation
Location of the object name, if any.
Definition: ExpressionParser2Node.h:405
FunctionCallNode(const gd::String &functionName_)
Construct a free function call node.
Definition: ExpressionParser2Node.h:373
FunctionCallNode(const gd::String &objectName_, const gd::String &behaviorName_, const gd::String &functionName_)
Construct a behavior function call node.
Definition: ExpressionParser2Node.h:385
ExpressionParserLocation objectNameDotLocation
Location of the "." after the object name.
Definition: ExpressionParser2Node.h:407
ExpressionParserLocation openingParenthesisLocation
Location of the "(".
Definition: ExpressionParser2Node.h:414
ExpressionParserLocation functionNameLocation
Location of the function name.
Definition: ExpressionParser2Node.h:403
ExpressionParserLocation behaviorNameNamespaceSeparatorLocation
Definition: ExpressionParser2Node.h:411
ExpressionParserLocation behaviorNameLocation
Location of the behavior name, if any.
Definition: ExpressionParser2Node.h:409
ExpressionParserLocation closingParenthesisLocation
Location of the ")".
Definition: ExpressionParser2Node.h:416
Definition: ExpressionParser2Node.h:235
An identifier node, usually representing an object or a variable with an optional function name or ch...
Definition: ExpressionParser2Node.h:204
ExpressionParserLocation identifierNameDotLocation
Location of the "." after the object or variable name.
Definition: ExpressionParser2Node.h:228
ExpressionParserLocation childIdentifierNameLocation
Definition: ExpressionParser2Node.h:229
ExpressionParserLocation identifierNameLocation
Location of the object or variable name.
Definition: ExpressionParser2Node.h:226
gd::String childIdentifierName
The object function or variable child name.
Definition: ExpressionParser2Node.h:222
gd::String identifierName
The object or variable name.
Definition: ExpressionParser2Node.h:219
Definition: ExpressionParser2Node.h:188
A number node. For example: "123". Its type is always "number".
Definition: ExpressionParser2Node.h:161
The name of a function to call on an object or the behavior For example: "MyObject....
Definition: ExpressionParser2Node.h:321
ExpressionParserLocation behaviorNameNamespaceSeparatorLocation
Definition: ExpressionParser2Node.h:358
gd::String objectFunctionOrBehaviorName
Definition: ExpressionParser2Node.h:340
ExpressionParserLocation objectNameLocation
Location of the object name.
Definition: ExpressionParser2Node.h:348
ExpressionParserLocation behaviorFunctionNameLocation
Definition: ExpressionParser2Node.h:360
ExpressionParserLocation objectNameDotLocation
Location of the "." after the object name.
Definition: ExpressionParser2Node.h:350
gd::String behaviorFunctionName
Definition: ExpressionParser2Node.h:343
ExpressionParserLocation objectFunctionOrBehaviorNameLocation
Definition: ExpressionParser2Node.h:351
An operator node. For example: "lhs + rhs".
Definition: ExpressionParser2Node.h:129
Definition: ExpressionParser2Node.h:115
A text node. For example: "Hello World". Its type is always "string".
Definition: ExpressionParser2Node.h:177
A unary operator node. For example: "-2".
Definition: ExpressionParser2Node.h:145
A direct accessor to a child variable. Example: MyChild in MyVariable.MyChild.
Definition: ExpressionParser2Node.h:282
Definition: ExpressionParser2Node.h:242
A bracket accessor to a child variable. Example: ["MyChild"] (in MyVariable["MyChild"]).
Definition: ExpressionParser2Node.h:300
A variable, or object variable, with bracket accessor or at least 2 "dot" accessors.
Definition: ExpressionParser2Node.h:261