ArgScript::Lexer class

This class is used to read and process expressions in ArgScript.

It contains a map of functions that can be used on expressions (for example, one could have 'sin', 'cos', etc).

Public functions

void AddFunction(const char* pFunctionName, IFunction* pFunction)
Adds a function to this lexer, that will be used when processing expresions.
void ExpectChar(LexerString& lexerString, char c)
Reads one character in the lexer string, which is expected to be the one specified.
auto OptionalExpectChar(LexerString& lexerString, char c) -> bool
Reads one character in the lexer string, only if the end of the string has not been reached.
void NextParameter(LexerString& lexerString, string& dst)
Reads the next parameter in the string, which is all the characters until a comma, a space, or a closing parenthesis is found.

Protected variables

hash_map<string, IFunction*> mFunctions

Function documentation

void ArgScript::Lexer::AddFunction(const char* pFunctionName, IFunction* pFunction)

Adds a function to this lexer, that will be used when processing expresions.

Parameters
pFunctionName The name that will be used to call the function. @para pFuncion The IFunction that gets executed when the function is called.
pFunction

void ArgScript::Lexer::ExpectChar(LexerString& lexerString, char c)

Reads one character in the lexer string, which is expected to be the one specified.

Parameters
lexerString The string pointer where the character will be read.
c The character expected.
Exceptions
ArgScriptException If the current character in the string is not the one required.

If it is not, an exception is thrown.

bool ArgScript::Lexer::OptionalExpectChar(LexerString& lexerString, char c)

Reads one character in the lexer string, only if the end of the string has not been reached.

Parameters
lexerString The string pointer where the character will be read.
c The character expected.
Returns True if the character was read, false if the end of the string was reached.
Exceptions
ArgScriptException If the current character in the string is not the one required.

The character is expected to be the one specified, otherwise an exception is thrown.

void ArgScript::Lexer::NextParameter(LexerString& lexerString, string& dst)

Reads the next parameter in the string, which is all the characters until a comma, a space, or a closing parenthesis is found.

Exceptions
ArgScriptException If the format is incorrect (i.e. '(' with no ')', '"' with no closing '"', etc).

A parameter can also be surrounded by parenthesis.