summaryrefslogtreecommitdiffstats
path: root/src/lib/eval
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2018-04-07 15:15:41 +0200
committerFrancis Dupont <fdupont@isc.org>2018-04-07 15:15:41 +0200
commit6418fa8a42500af085816fb1283ff28f283f44db (patch)
tree4b23c2c88b3e5f1f186a695761f43e6c349ea539 /src/lib/eval
parent[trac5374] regen flex/bison (diff)
downloadkea-6418fa8a42500af085816fb1283ff28f283f44db.tar.xz
kea-6418fa8a42500af085816fb1283ff28f283f44db.zip
[5374] Checkpoint for regen before tests
Diffstat (limited to 'src/lib/eval')
-rw-r--r--src/lib/eval/eval.dox2
-rw-r--r--src/lib/eval/eval_context.cc10
-rw-r--r--src/lib/eval/eval_context.h20
-rw-r--r--src/lib/eval/parser.cc6
-rw-r--r--src/lib/eval/parser.yy8
-rw-r--r--src/lib/eval/tests/context_unittest.cc22
6 files changed, 34 insertions, 34 deletions
diff --git a/src/lib/eval/eval.dox b/src/lib/eval/eval.dox
index 64efbb4c87..4f7d814273 100644
--- a/src/lib/eval/eval.dox
+++ b/src/lib/eval/eval.dox
@@ -24,7 +24,7 @@
Parameters to the @ref isc::eval::EvalContext class constructor are
the universe to choose between DHCPv4 and DHCPv6 for DHCP version
dependent expressions, and a function used
- by the parser to accept only already known or built-in client
+ by the parser to accept only already defined or built-in client
class names in client class membership expressions. This function defaults
to accept all client class names.
diff --git a/src/lib/eval/eval_context.cc b/src/lib/eval/eval_context.cc
index 72570dffb0..5deeb5fe24 100644
--- a/src/lib/eval/eval_context.cc
+++ b/src/lib/eval/eval_context.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -17,9 +17,9 @@
#include <limits>
EvalContext::EvalContext(const Option::Universe& option_universe,
- std::function<bool(const ClientClass&)> check_known)
+ CheckDefined check_defined)
: trace_scanning_(false), trace_parsing_(false),
- option_universe_(option_universe), check_known_(check_known)
+ option_universe_(option_universe), check_defined_(check_defined)
{
}
@@ -190,8 +190,8 @@ EvalContext::fromUint32(const uint32_t integer) {
}
bool
-EvalContext::isClientClassKnown(const ClientClass& client_class) {
- return (check_known_(client_class));
+EvalContext::isClientClassDefined(const ClientClass& client_class) {
+ return (check_defined_(client_class));
}
void
diff --git a/src/lib/eval/eval_context.h b/src/lib/eval/eval_context.h
index dac140510d..bd47ae791e 100644
--- a/src/lib/eval/eval_context.h
+++ b/src/lib/eval/eval_context.h
@@ -41,19 +41,19 @@ public:
PARSER_STRING ///< expression is expected to evaluate to string
} ParserType;
- /// @brief Type of the check known function.
- typedef std::function<bool(const ClientClass&)> CheckKnown;
+ /// @brief Type of the check defined function.
+ typedef std::function<bool(const ClientClass&)> CheckDefined;
/// @brief Default constructor.
///
/// @param option_universe Option universe: DHCPv4 or DHCPv6. This is used
/// by the parser to determine which option definitions set should be used
/// to map option names to option codes.
- /// @param check_known A function called to check if a client class
- /// used for membership is already known. If it is not the parser
+ /// @param check_defined A function called to check if a client class
+ /// used for membership is already defined. If it is not the parser
/// will fail: only backward or built-in references are accepted.
EvalContext(const Option::Universe& option_universe,
- CheckKnown check_known = acceptAll);
+ CheckDefined check_defined = acceptAll);
/// @brief destructor
virtual ~EvalContext();
@@ -181,11 +181,11 @@ public:
return (option_universe_);
}
- /// @brief Check if a client class is already known
+ /// @brief Check if a client class is already defined
///
/// @param client_class the client class name to check
- /// @return true if the client class is known, false if not
- bool isClientClassKnown(const ClientClass& client_class);
+ /// @return true if the client class is defined, false if not
+ bool isClientClassDefined(const ClientClass& client_class);
private:
/// @brief Flag determining scanner debugging.
@@ -200,8 +200,8 @@ public:
/// set should be used to map option name to option code.
Option::Universe option_universe_;
- /// @brief Function to check if a client class is already known
- CheckKnown check_known_;
+ /// @brief Function to check if a client class is already defined.
+ CheckDefined check_defined_;
};
diff --git a/src/lib/eval/parser.cc b/src/lib/eval/parser.cc
index 5e65909e5e..7f6290134a 100644
--- a/src/lib/eval/parser.cc
+++ b/src/lib/eval/parser.cc
@@ -873,11 +873,11 @@ namespace isc { namespace eval {
//
// This token will check if the packet is a member of
// the specified client class.
- // To avoid loops at evaluation only already known and
+ // To avoid loops at evaluation only already defined and
// built-in classes are allowed.
std::string cc = yystack_[1].value.as< std::string > ();
- if (!ctx.isClientClassKnown(cc)) {
- error(yystack_[1].location, "Unknown client class '" + cc + "'");
+ if (!ctx.isClientClassDefined(cc)) {
+ error(yystack_[1].location, "Not defined client class '" + cc + "'");
}
TokenPtr member(new TokenMember(cc));
ctx.expression.push_back(member);
diff --git a/src/lib/eval/parser.yy b/src/lib/eval/parser.yy
index b7d52a9af5..f9f0261627 100644
--- a/src/lib/eval/parser.yy
+++ b/src/lib/eval/parser.yy
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -219,11 +219,11 @@ bool_expr : "(" bool_expr ")"
//
// This token will check if the packet is a member of
// the specified client class.
- // To avoid loops at evaluation only already known and
+ // To avoid loops at evaluation only already defined and
// built-in classes are allowed.
std::string cc = $3;
- if (!ctx.isClientClassKnown(cc)) {
- error(@3, "Unknown client class '" + cc + "'");
+ if (!ctx.isClientClassDefined(cc)) {
+ error(@3, "Not defined client class '" + cc + "'");
}
TokenPtr member(new TokenMember(cc));
ctx.expression.push_back(member);
diff --git a/src/lib/eval/tests/context_unittest.cc b/src/lib/eval/tests/context_unittest.cc
index f4a6d71334..ab487cc138 100644
--- a/src/lib/eval/tests/context_unittest.cc
+++ b/src/lib/eval/tests/context_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -409,14 +409,14 @@ public:
/// expected.
///
/// @param expr expression to be parsed
- /// @param check_known closure checking if the client class is known
+ /// @param check_defined closure checking if the client class is defined
/// @param exp_client_class expected client class name to be parsed
/// @param exp_tokens expected number of tokens
void testMember(const std::string& expr,
- std::function<bool(const ClientClass&)> check_known,
+ EvalContext::CheckDefined check_defined,
const std::string& exp_client_class,
int exp_tokens) {
- EvalContext eval(Option::V6, check_known);
+ EvalContext eval(Option::V6, check_defined);
// parse the expression
try {
@@ -1119,23 +1119,23 @@ TEST_F(EvalContextTest, relay6FieldError) {
"<string>:1.8: Nest level invalid for DHCPv4 packets");
}
-// Tests parsing of member with known class
+// Tests parsing of member with defined class
TEST_F(EvalContextTest, member) {
- auto check_known = [](const ClientClass& cc) { return (cc == "foo"); };
- testMember("member('foo')", check_known, "foo", 1);
+ auto check_defined = [](const ClientClass& cc) { return (cc == "foo"); };
+ testMember("member('foo')", check_defined, "foo", 1);
}
-// Test parsing of member with unknown class
+// Test parsing of member with not defined class
TEST_F(EvalContextTest, memberError) {
- auto check_known = [](const ClientClass& cc) { return (cc == "foo"); };
- EvalContext eval(Option::V6, check_known);
+ auto check_defined = [](const ClientClass& cc) { return (cc == "foo"); };
+ EvalContext eval(Option::V6, check_defined);
parsed_ = false;
try {
parsed_ = eval.parseString("member('bar')");
FAIL() << "Expected EvalParseError but nothing was raised";
}
catch (const EvalParseError& ex) {
- EXPECT_EQ("<string>:1.8-12: Unknown client class 'bar'",
+ EXPECT_EQ("<string>:1.8-12: Not defined client class 'bar'",
std::string(ex.what()));
EXPECT_FALSE(parsed_);
}