Game Develop Core: gd::VariableParser Class Reference

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

- Main Page
- Modules
- Classes

- Class List
- Class Index
- Class Hierarchy

All Classes Files Functions Variables Typedefs Enumerations Macros Groups Pages
Public Member Functions | Public Attributes | List of all members
gd::VariableParser Class Reference

Parse a variable expression. More...

`#include <VariableParser.h>`

## Public Member Functions

| VariableParser (const std::string &expressionPlainString_)
| Default constructor. More...
bool | Parse (VariableParserCallbacks &callbacks)

## Public Attributes

std::string | firstErrorStr
size_t | firstErrorPos

## Detailed Description

Parse a variable expression.

Parse an variable expression ( like myVariable.child["subchild"+ToString(i)].subsubchild ), calling callbacks when a token is reached.

Usage example:

//...
//VariableCodeGenerationCallbacks is a class inheriting from gd::VariableParserCallbacks
VariableCodeGenerationCallbacks callbacks(output, *this, context, VariableCodeGenerationCallbacks::PROJECT_VARIABLE);
gd::VariableParser parser(parameter);
if ( !parser.Parse(callbacks) )
cout << "Error :" << parser.firstErrorStr << " in: "<< parameter << endl;

Here is the parsed grammar:
S -> VarName X
X -> e | . S | [StringExpression] X

where e = nothing ( end of expression ), StringExpression = A valid string expression and S is the start.

See Also
  gd::VariableParserCallbacks

## Constructor & Destructor Documentation

gd::VariableParser::VariableParser | ( | const std::string & | expressionPlainString_) |  |

inline

Default constructor.

Parameters

  expressionPlainString | The string representing the expression to be parsed.

## Member Function Documentation

bool gd::VariableParser::Parse | ( | VariableParserCallbacks & | callbacks) |  |

Parse the expression, calling each callback when necessary.

Parameters

  callbacks | The callbacks to be called.

Returns
  true if expression was correctly parsed.

See Also
  gd::VariableParserCallbacks

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

- VariableParser.h
- VariableParser.cpp