GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
Classes | Public Member Functions | Static Public Member Functions | List of all members
gd::ExpressionParser2 Class Reference

Parse an expression, returning a tree of node corresponding to the parsed expression. More...

#include <ExpressionParser2.h>

Public Member Functions

std::unique_ptr< ExpressionNodeParseExpression (const gd::String &expression_)
 

Static Public Member Functions

static size_t WrittenParametersFirstIndex (const gd::String &objectName, const gd::String &behaviorName)
 

Detailed Description

Parse an expression, returning a tree of node corresponding to the parsed expression.

This is a LL(1) parser. This could be extracted to a generic/reusable parser by refactoring out the dependency on gd::MetadataProvider (injecting instead functions to be called to query supported functions).

See also
gd::ExpressionParserDiagnostic
gd::ExpressionNode

Member Function Documentation

◆ ParseExpression()

std::unique_ptr<ExpressionNode> gd::ExpressionParser2::ParseExpression ( const gd::String expression_)
inline

Parse the given expression into a tree of nodes.

Parameters
expressionThe expression to parse.
Returns
The node representing the expression as a parsed tree.

◆ WrittenParametersFirstIndex()

static size_t gd::ExpressionParser2::WrittenParametersFirstIndex ( const gd::String objectName,
const gd::String behaviorName 
)
inlinestatic

Given an object name (or empty if none) and a behavior name (or empty if none), return the index of the first parameter that is inside the parenthesis: 0, 1 or 2.

For example, in an expression like Object.MyBehavior::Method("hello"), the parameter "hello" is the second parameter (the first being by convention Object, and the second MyBehavior, also by convention).


The documentation for this class was generated from the following files: