mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Bug
- Fixed bug in named entity lookup. - Removed obsolete failing test.
This commit is contained in:
parent
62eafb6639
commit
05c90b1779
2 changed files with 40 additions and 9 deletions
21
src/Eval.cpp
21
src/Eval.cpp
|
@ -28,6 +28,7 @@
|
|||
#include <time.h>
|
||||
#include <Eval.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Supported operators, borrowed from C++, particularly the precedence.
|
||||
// Note: table is sorted by length of operator string, so searches match
|
||||
// longest first.
|
||||
|
@ -78,11 +79,25 @@ static struct
|
|||
|
||||
#define NUM_OPERATORS (sizeof (operators) / sizeof (operators[0]))
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Built-in support for some named constants.
|
||||
static bool namedConstants (const std::string& name, Variant& value)
|
||||
{
|
||||
if (name == "true") value = Variant (true);
|
||||
else if (name == "false") value = Variant (false);
|
||||
else if (name == "pi") value = Variant (3.14159165);
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Eval::Eval ()
|
||||
: _ambiguity (true)
|
||||
, _debug (false)
|
||||
{
|
||||
addSource (namedConstants);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -233,6 +248,8 @@ void Eval::evaluatePostfixStack (
|
|||
|
||||
values.push_back (left);
|
||||
}
|
||||
|
||||
// Literals and identifiers.
|
||||
else
|
||||
{
|
||||
Variant v (token->first);
|
||||
|
@ -253,6 +270,7 @@ void Eval::evaluatePostfixStack (
|
|||
|
||||
case Lexer::typeIdentifier:
|
||||
{
|
||||
bool found = false;
|
||||
std::vector <bool (*)(const std::string&, Variant&)>::const_iterator source;
|
||||
for (source = _sources.begin (); source != _sources.end (); ++source)
|
||||
{
|
||||
|
@ -260,12 +278,13 @@ void Eval::evaluatePostfixStack (
|
|||
{
|
||||
if (_debug)
|
||||
std::cout << "# [" << values.size () << "] eval source '" << token->first << "' --> '" << (std::string) v << "'\n";
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// An identifier that fails lookup is a string.
|
||||
if (source == _sources.end ())
|
||||
if (!found)
|
||||
{
|
||||
v.cast (Variant::type_string);
|
||||
if (_debug)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue