1 #ifndef H_FUNCTION_PARSER 2 #define H_FUNCTION_PARSER 25 const std::vector<Token> &
Tokens()
const;
57 std::size_t
FindClose(std::size_t i_open_token)
const;
59 void CondenseTokens(std::size_t i_start, std::size_t i_end,
const Token &replacement)
const;
std::vector< Token > tokens_
List of tokens generated in parsing process.
NamedFunc ResolveAsNamedFunc() const
Parses provided string into a single NamedFunc.
Token ResolveAsToken() const
Parses provided string into a single Token.
void ApplySubscripts() const
Merges subscript (bracket) Tokens with the contents.
void CleanupName() const
Restores string representation to initially provided string.
void Solve() const
Runs full parse from start to finish, caching result.
void AddAndSubtract() const
Merges binary "+" and "-" Tokens with their operands.
FunctionParser & operator=(const FunctionParser &)=default
void DisambiguatePlusMinus() const
Determines whether "+" and "-" Tokens correspond to unary or binary operators.
Combines a callable function taking a Baby and returning a scalar or vector with its string represent...
void ResolveVariables() const
Generates NamedFunc for each Token representing a constant or Baby variable.
void LessGreater() const
Merges "<", "<=", ">", and ">=" Tokens with their operands.
void ApplyUnary() const
Merges unary operator Tokens with their operands.
void EqualOrNot() const
Merges "==" and "!=" Tokens with their operands.
~FunctionParser()=default
void EvaluateGroupings() const
Recursively evaluates contents of parenthesis and brackets.
const std::vector< Token > & Tokens() const
Get list of tokens as is at current stage of parsing.
std::string input_string_
String being parsed.
void CheckSolved() const
Check that we have a single Token with a valid NamedFun.
void MultiplyAndDivide() const
Merges "*" and "/" Tokens with their operands.
std::size_t FindClose(std::size_t i_open_token) const
Find position of closing parenthesis/bracket corresponding to given opening partner.
void Or() const
Merges "||" Tokens with their operands.
void MergeParentheses() const
Merges parenthesis Tokens with the contents.
void And() const
Merges "&&" Tokens with their operands.
void CheckForUnknowns() const
Checks that all Tokens were understood.
bool solved_
String parsed into tokens, and all tokens succesfully merged.
bool tokenized_
String has been parsed into tokens.
void Tokenize() const
Parses the string into a list of Tokens.
std::ostream & operator<<(std::ostream &stream, const FunctionParser &fp)
Print FunctionParser to output stream.
std::string ConcatenateTokenStrings(std::size_t i_start, std::size_t i_end) const
Concatenates string representation of Tokens in range [i_start, i_end)
const std::string & FunctionString() const
Get string being parsed.
void CondenseTokens(std::size_t i_start, std::size_t i_end, const Token &replacement) const
Replace Tokens in range [i_start, i_end) with replacement.
Converts a string into a NamedFunc.