Isis Developer Reference
|
A parser for converting equation strings to postfix. More...
#include <InlineInfixToPostfix.h>
Public Member Functions | |
InlineInfixToPostfix () | |
Constructs an InlineInfixToPostfix object. | |
virtual | ~InlineInfixToPostfix () |
Destroys the InlineInfixToPostfix object. | |
QString | convert (const QString &infix) |
This method converts infix to postfix. | |
QString | tokenizeEquation (const QString &equation) |
This method will add spaces between all operators and numbers, making it possible to get each element of the equation one by one. | |
Protected Member Functions | |
virtual bool | isKnownSymbol (QString representation) |
This method attempts to verify that the given argument is recognized as a valid function, operator, scalar, or variable. | |
virtual InfixOperator * | findOperator (QString element) |
This method will first search the recognized list of operators and functions for the given token. | |
Protected Attributes | |
QList< InfixOperator * > | p_operators |
A parser for converting equation strings to postfix.
This class converts infix equations to postfix for parsing.
Isis::InlineInfixToPostfix::InlineInfixToPostfix | ( | ) |
Constructs an InlineInfixToPostfix object.
The operators list is filled with string representations of known symbols, recognized by both this class and the parent class.
|
virtual |
Destroys the InlineInfixToPostfix object.
|
inherited |
This method converts infix to postfix.
It uses an enhanced verion of the algorithm found on page 159 of "Data Structures & Algorithms in Java" Second Edition by Robert Lafore. First, we prep the equation with TokenizeEquation and then parse through it using the known-good algorithm.
infix | The infix equation |
References _FILEINFO_, Isis::InfixToPostfix::findOperator(), Isis::InfixToPostfix::isKnownSymbol(), Isis::toDouble(), Isis::IString::Token(), Isis::InfixToPostfix::tokenizeEquation(), Isis::IString::ToQt(), and Isis::IException::User.
Referenced by Isis::InlineCalculator::toPostfix().
|
protectedvirtual |
This method will first search the recognized list of operators and functions for the given token.
If found, it will return a pointer to the represented operator or function. If not found, the method checks whether the given token is a variable. If it is a variable, a new operator is constructed from the given token and a pointer to the represented variable is returned. If the given token is neither an operator, a function nor a variable, then an exception is thrown.
token | The symbolic representation of the operator, function, or variable |
IException::User | "The token is not recognized as an operator, function or variable." |
Reimplemented from Isis::InfixToPostfix.
References _FILEINFO_, findOperator(), Isis::InfixToPostfix::findOperator(), and Isis::IException::User.
Referenced by findOperator().
|
protectedvirtual |
This method attempts to verify that the given argument is recognized as a valid function, operator, scalar, or variable.
representation | The symbolic representation of the operator |
Reimplemented from Isis::InfixToPostfix.
References Isis::InfixToPostfix::isKnownSymbol().
|
inherited |
This method will add spaces between all operators and numbers, making it possible to get each element of the equation one by one.
It will also parse out the function calls, adding parenthesis where needed so the user doesn't have to. The result is an equation ready for parsing (but NOT fully parenthesized, just enough to make sure our algorithm makes no mistakes).
equation | An unformatted infix equation |
Referenced by Isis::InfixToPostfix::convert().
|
protectedinherited |