Eval
- Added Eval::getOperators to expose suported operator symbols.
This commit is contained in:
25
src/Eval.cpp
25
src/Eval.cpp
@@ -50,17 +50,17 @@ static struct
|
||||
{ "_hastag_", 14, 'b', 'l'}, // +tag [Pseudo-op]
|
||||
{ "_notag_", 14, 'b', 'l'}, // -tag [Pseudo-op]
|
||||
|
||||
{ "*", 13, 'b', 'l' }, // Multiplication
|
||||
{ "/", 13, 'b', 'l' }, // Division
|
||||
{ "%", 13, 'b', 'l' }, // Modulus
|
||||
{ "*", 13, 'b', 'l' }, // Multiplication
|
||||
{ "/", 13, 'b', 'l' }, // Division
|
||||
{ "%", 13, 'b', 'l' }, // Modulus
|
||||
|
||||
{ "+", 12, 'b', 'l' }, // Addition
|
||||
{ "-", 12, 'b', 'l' }, // Subtraction
|
||||
{ "+", 12, 'b', 'l' }, // Addition
|
||||
{ "-", 12, 'b', 'l' }, // Subtraction
|
||||
|
||||
{ "<=", 10, 'b', 'l' }, // Less than or equal
|
||||
{ ">=", 10, 'b', 'l' }, // Greater than or equal
|
||||
{ ">", 10, 'b', 'l' }, // Greater than
|
||||
{ "<", 10, 'b', 'l' }, // Less than
|
||||
{ "<", 10, 'b', 'l' }, // Less than
|
||||
|
||||
{ "=", 9, 'b', 'l' }, // Equal
|
||||
{ "==", 9, 'b', 'l' }, // Equal
|
||||
@@ -73,8 +73,8 @@ static struct
|
||||
{ "or", 4, 'b', 'l' }, // Disjunction
|
||||
{ "xor", 3, 'b', 'l' }, // Disjunction
|
||||
|
||||
{ "(", 0, 'b', 'l' }, // Precedence start
|
||||
{ ")", 0, 'b', 'l' }, // Precedence end
|
||||
{ "(", 0, 'b', 'l' }, // Precedence start
|
||||
{ ")", 0, 'b', 'l' }, // Precedence end
|
||||
};
|
||||
|
||||
#define NUM_OPERATORS (sizeof (operators) / sizeof (operators[0]))
|
||||
@@ -171,6 +171,15 @@ void Eval::debug ()
|
||||
_debug = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Static.
|
||||
void Eval::getOperators (std::vector <std::string>& all)
|
||||
{
|
||||
all.clear ();
|
||||
for (unsigned int i = 0; i < NUM_OPERATORS; ++i)
|
||||
all.push_back (operators[i].op);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Eval::evaluatePostfixStack (
|
||||
const std::vector <std::pair <std::string, Lexer::Type> >& tokens,
|
||||
|
||||
Reference in New Issue
Block a user