Commit 94938484 authored by Thomas Markwalder's avatar Thomas Markwalder

[5110] D2 now uses JSON parsing and SimpleParsers to handle D2 global scalars

new files:
    src/bin/d2/tests/
        d2_simple_parser_unittest.cc
        parser_unittest.cc
        parser_unittest.h

src/bin/d2/d2_cfg_mgr.h
src/bin/d2/d2_cfg_mgr.cc
    D2CfgMgr::parseElement() - overrides base class implementation,
    flag global parameters as parsed without pushing them to D2CfgContext
    value stores

    D2CfgMgr::setCfgDefaults() - overrides base class implementation,
    sets defaults for D2

    D2CfgMgr::buildParams() - revamped to pull parameters from the given
    element map instead of context value stores.  Removed checks that
    are now done by JSON parser.

src/bin/d2/d2_controller.cc
    D2Controller::parseFile() - instead of generic JSON parsing, parse
    file with PARSER_DHCPDDNS context

src/bin/d2/d2_lexer.ll
src/bin/d2/d2_parser.yy
    Changed namespace from dhcp to d2
    Added PARSER_SUB_DHCPDDNS and D2 global parameter parsing
    Added objects for forward-ddns, reverse-ddns, tsig-keys

src/bin/d2/parser_context.cc
src/bin/d2/parser_context.h
    Added PARSER_DHCPDDNS, PARSER_SUB_DHCPDDNS

src/bin/d2/tests/Makefile.am
    Added new test source files

src/bin/d2/tests/d2_cfg_mgr_unittests.cc
src/bin/d2/tests/testdata/d2_cfg_tests.json
    TEST_F(D2CfgMgrTest, configPermutations) - revamped to test JSON parsing
    as well as element parsing

src/bin/d2/tests/parser_unittest.h
src/bin/d2/tests/parser_unittest.cc
    New file that tests basic JSON parsing

src/lib/cc/data.h
    Added parens around TypeError position error text

src/lib/cc/simple_parser.cc
    SimpleParser::setDefaults() - added logic to detect bad lexical casts
    when handling integers
parent 1abb94ac
......@@ -8,6 +8,7 @@
#include <d2/d2_log.h>
#include <d2/d2_cfg_mgr.h>
#include <d2/d2_simple_parser.h>
#include <util/encode/hex.h>
#include <boost/foreach.hpp>
......@@ -197,96 +198,148 @@ D2CfgMgr::getConfigSummary(const uint32_t) {
return (getD2Params()->getConfigSummary());
}
void
D2CfgMgr::buildParams(isc::data::ConstElementPtr params_config) {
// Base class build creates parses and invokes build on each parser.
// This populate the context scalar stores with all of the parameters.
DCfgMgrBase::buildParams(params_config);
// Fetch and validate the parameters from the context to create D2Params.
// We validate them here rather than just relying on D2Param constructor
// so we can spit out config text position info with errors.
namespace {
// Fetch and validate ip_address.
D2CfgContextPtr context = getD2CfgContext();
isc::dhcp::StringStoragePtr strings = context->getStringStorage();
asiolink::IOAddress ip_address(D2Params::DFT_IP_ADDRESS);
template <typename int_type> int_type
getInt(const std::string& name, isc::data::ConstElementPtr value) {
int64_t val_int = value->intValue();
if ((val_int < std::numeric_limits<int_type>::min()) ||
(val_int > std::numeric_limits<int_type>::max())) {
isc_throw(D2CfgError, "out of range value (" << val_int
<< ") specified for parameter '" << name
<< "' (" << value->getPosition() << ")");
}
return (static_cast<int_type>(val_int));
}
std::string ip_address_str = strings->getOptionalParam("ip-address",
D2Params::
DFT_IP_ADDRESS);
isc::asiolink::IOAddress
getIOAddress(const std::string& name, isc::data::ConstElementPtr value) {
std::string str = value->stringValue();
try {
ip_address = asiolink::IOAddress(ip_address_str);
return (isc::asiolink::IOAddress(str));
} catch (const std::exception& ex) {
isc_throw(D2CfgError, "IP address invalid : \""
<< ip_address_str << "\" ("
<< strings->getPosition("ip-address") << ")");
isc_throw(D2CfgError, "invalid address (" << str
<< ") specified for parameter '" << name
<< "' (" << value->getPosition() << ")");
}
}
if ((ip_address.toText() == "0.0.0.0") || (ip_address.toText() == "::")) {
isc_throw(D2CfgError, "IP address cannot be \"" << ip_address << "\" ("
<< strings->getPosition("ip-address") << ")");
dhcp_ddns::NameChangeProtocol
getProtocol(const std::string& name, isc::data::ConstElementPtr value) {
std::string str = value->stringValue();
try {
return (dhcp_ddns::stringToNcrProtocol(str));
} catch (const std::exception& ex) {
isc_throw(D2CfgError,
"invalid NameChangeRequest protocol (" << str
<< ") specified for parameter '" << name
<< "' (" << value->getPosition() << ")");
}
}
// Fetch and validate port.
isc::dhcp::Uint32StoragePtr ints = context->getUint32Storage();
uint32_t port = ints->getOptionalParam("port", D2Params::DFT_PORT);
if (port == 0) {
isc_throw(D2CfgError, "port cannot be 0 ("
<< ints->getPosition("port") << ")");
dhcp_ddns::NameChangeFormat
getFormat(const std::string& name, isc::data::ConstElementPtr value) {
std::string str = value->stringValue();
try {
return (dhcp_ddns::stringToNcrFormat(str));
} catch (const std::exception& ex) {
isc_throw(D2CfgError,
"invalid NameChangeRequest format (" << str
<< ") specified for parameter '" << name
<< "' (" << value->getPosition() << ")");
}
}
// Fetch and validate dns_server_timeout.
uint32_t dns_server_timeout
= ints->getOptionalParam("dns-server-timeout",
D2Params::DFT_DNS_SERVER_TIMEOUT);
} // anon
if (dns_server_timeout < 1) {
isc_throw(D2CfgError, "DNS server timeout must be larger than 0 ("
<< ints->getPosition("dns-server-timeout") << ")");
}
bool
D2CfgMgr::parseElement(const std::string& element_id,
isc::data::ConstElementPtr element) {
// Fetch and validate ncr_protocol.
dhcp_ddns::NameChangeProtocol ncr_protocol;
// Get D2 specific context.
try {
ncr_protocol = dhcp_ddns::
stringToNcrProtocol(strings->
getOptionalParam("ncr-protocol",
D2Params::
DFT_NCR_PROTOCOL));
D2CfgContextPtr context = getD2CfgContext();
if ((element_id == "ip-address") ||
(element_id == "ncr-protocol") ||
(element_id == "ncr-format") ||
(element_id == "port") ||
(element_id == "dns-server-timeout")) {
// global scalar params require nothing extra
} else {
// not something we handle here
return (false);
}
} catch (const std::exception& ex) {
isc_throw(D2CfgError, "ncr-protocol : "
<< ex.what() << " ("
<< strings->getPosition("ncr-protocol") << ")");
isc_throw(D2CfgError, "element: " << element_id << " : " << ex.what()
<< element->getPosition());
}
if (ncr_protocol != dhcp_ddns::NCR_UDP) {
isc_throw(D2CfgError, "ncr-protocol : "
<< dhcp_ddns::ncrProtocolToString(ncr_protocol)
<< " is not yet supported ("
<< strings->getPosition("ncr-protocol") << ")");
}
return (true);
};
// Fetch and validate ncr_format.
dhcp_ddns::NameChangeFormat ncr_format;
try {
ncr_format = dhcp_ddns::
stringToNcrFormat(strings->
getOptionalParam("ncr-format",
D2Params::
DFT_NCR_FORMAT));
} catch (const std::exception& ex) {
isc_throw(D2CfgError, "ncr-format : "
<< ex.what() << " ("
<< strings->getPosition("ncr-format") << ")");
}
void
D2CfgMgr::setCfgDefaults(isc::data::ElementPtr mutable_config) {
D2SimpleParser::setAllDefaults(mutable_config);
}
void
D2CfgMgr::buildParams(isc::data::ConstElementPtr params_config) {
// Base class build creates parses and invokes build on each parser.
// This populate the context scalar stores with all of the parameters.
DCfgMgrBase::buildParams(params_config);
// Fetch the parameters in the config, performing any logcial
// validation required.
asiolink::IOAddress ip_address(0);
uint32_t port = 0;
uint32_t dns_server_timeout = 0;
dhcp_ddns::NameChangeProtocol ncr_protocol = dhcp_ddns::NCR_UDP;
dhcp_ddns::NameChangeFormat ncr_format = dhcp_ddns::FMT_JSON;
BOOST_FOREACH(isc::dhcp::ConfigPair param, params_config->mapValue()) {
std::string entry(param.first);
isc::data::ConstElementPtr value(param.second);
try {
if (entry == "ip-address") {
ip_address = getIOAddress(entry, value);
if ((ip_address.toText() == "0.0.0.0") ||
(ip_address.toText() == "::")) {
isc_throw(D2CfgError, "IP address cannot be \""
<< ip_address << "\""
<< " (" << value->getPosition() << ")");
}
} else if (entry == "port") {
port = getInt<uint32_t>(entry, value);
} else if (entry == "dns-server-timeout") {
dns_server_timeout = getInt<uint32_t>(entry, value);
} else if (entry == "ncr-protocol") {
ncr_protocol = getProtocol(entry, value);
if (ncr_protocol != dhcp_ddns::NCR_UDP) {
isc_throw(D2CfgError, "ncr-protocol : "
<< dhcp_ddns::ncrProtocolToString(ncr_protocol)
<< " is not yet supported "
<< " (" << value->getPosition() << ")");
}
} else if (entry == "ncr-format") {
ncr_format = getFormat(entry, value);
if (ncr_format != dhcp_ddns::FMT_JSON) {
isc_throw(D2CfgError, "NCR Format:"
<< dhcp_ddns::ncrFormatToString(ncr_format)
<< " is not yet supported"
<< " (" << value->getPosition() << ")");
}
} else {
isc_throw(D2CfgError,
"unsupported parameter '" << entry
<< " (" << value->getPosition() << ")");
}
} catch (const isc::data::TypeError&) {
isc_throw(D2CfgError,
"invalid value type specified for parameter '" << entry
<< " (" << value->getPosition() << ")");
}
if (ncr_format != dhcp_ddns::FMT_JSON) {
isc_throw(D2CfgError, "NCR Format:"
<< dhcp_ddns::ncrFormatToString(ncr_format)
<< " is not yet supported ("
<< strings->getPosition("ncr-format") << ")");
}
// Attempt to create the new client config. This ought to fly as
......@@ -294,7 +347,7 @@ D2CfgMgr::buildParams(isc::data::ConstElementPtr params_config) {
D2ParamsPtr params(new D2Params(ip_address, port, dns_server_timeout,
ncr_protocol, ncr_format));
context->getD2Params() = params;
getD2CfgContext()->getD2Params() = params;
}
isc::dhcp::ParserPtr
......
......@@ -239,6 +239,31 @@ public:
virtual std::string getConfigSummary(const uint32_t selection);
protected:
/// @brief Parses an element using alternate parsers
///
/// Each element to be parsed is passed first into this method to allow
/// it to be processed by SimpleParser derivations if they've been
/// implemented. The method should return true if it has processed the
/// element or false if the element should be passed onto the original
/// DhcpConfigParer mechanisms. This method is invoked in both
/// @c DCfgMgrBase::buildParams() and DCfgMgrBase::buildAndCommit().
///
/// @param element_id name of the element as it is expected in the cfg
/// @param element value of the element as ElementPtr
///
/// @return true if the element was parsed, false otherwise
virtual bool parseElement(const std::string& element_id,
isc::data::ConstElementPtr element);
/// @brief Adds default values to the given config
///
/// Adds the D2 default values to the configuration Element map. This
/// method is invoked by @c DCfgMgrBase::paserConfig().
///
/// @param mutable_config - configuration to which defaults should be added
virtual void setCfgDefaults(isc::data::ElementPtr mutable_config);
/// @brief Performs the parsing of the given "params" element.
///
/// Iterates over the set of parameters, creating a parser based on the
......
......@@ -61,7 +61,7 @@ D2Controller::parseFile(const std::string& file_name) {
// Read contents of the file and parse it as JSON
D2ParserContext parser;
elements = parser.parseFile(file_name, D2ParserContext::PARSER_JSON);
elements = parser.parseFile(file_name, D2ParserContext::PARSER_DHCPDDNS);
if (!elements) {
isc_throw(isc::BadValue, "no configuration found in file");
}
......
This diff is collapsed.
......@@ -25,13 +25,13 @@ namespace {
bool start_token_flag = false;
isc::dhcp::D2ParserContext::ParserType start_token_value;
isc::d2::D2ParserContext::ParserType start_token_value;
unsigned int comment_start_line = 0;
};
// To avoid the call to exit... oops!
#define YY_FATAL_ERROR(msg) isc::dhcp::D2ParserContext::fatal(msg)
#define YY_FATAL_ERROR(msg) isc::d2::D2ParserContext::fatal(msg)
%}
/* noyywrap disables automatic rewinding for the next file to parse. Since we
......@@ -104,9 +104,11 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
switch (start_token_value) {
case D2ParserContext::PARSER_JSON:
default:
return isc::dhcp::D2Parser::make_TOPLEVEL_JSON(driver.loc_);
return isc::d2::D2Parser::make_TOPLEVEL_JSON(driver.loc_);
case D2ParserContext::PARSER_DHCPDDNS:
return isc::dhcp::D2Parser::make_TOPLEVEL_DHCPDDNS(driver.loc_);
return isc::d2::D2Parser::make_TOPLEVEL_DHCPDDNS(driver.loc_);
case D2ParserContext::PARSER_SUB_DHCPDDNS:
return isc::d2::D2Parser::make_SUB_DHCPDDNS(driver.loc_);
}
}
%}
......@@ -154,126 +156,200 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
driver.loc_.step();
}
\"DhcpDdns\" {
switch(driver.ctx_) {
case isc::d2::D2ParserContext::CONFIG:
return isc::d2::D2Parser::make_DHCPDDNS(driver.loc_);
default:
return isc::d2::D2Parser::make_STRING("DhcpDdns", driver.loc_);
}
}
\"ip-address\" {
switch(driver.ctx_) {
case isc::dhcp::D2ParserContext::DHCPDDNS:
return isc::dhcp::D2Parser::make_IP_ADDRESS(driver.loc_);
case isc::d2::D2ParserContext::DHCPDDNS:
return isc::d2::D2Parser::make_IP_ADDRESS(driver.loc_);
default:
return isc::dhcp::D2Parser::make_STRING("ip-address", driver.loc_);
return isc::d2::D2Parser::make_STRING("ip-address", driver.loc_);
}
}
\"port\" {
switch(driver.ctx_) {
case isc::dhcp::D2ParserContext::DHCPDDNS:
return isc::dhcp::D2Parser::make_PORT(driver.loc_);
case isc::d2::D2ParserContext::DHCPDDNS:
return isc::d2::D2Parser::make_PORT(driver.loc_);
default:
return isc::dhcp::D2Parser::make_STRING("port", driver.loc_);
return isc::d2::D2Parser::make_STRING("port", driver.loc_);
}
}
\"dns-server-timeout\" {
switch(driver.ctx_) {
case isc::d2::D2ParserContext::DHCPDDNS:
return isc::d2::D2Parser::make_DNS_SERVER_TIMEOUT(driver.loc_);
default:
return isc::d2::D2Parser::make_STRING("dns-server-timeout", driver.loc_);
}
}
\"ncr-protocol\" {
switch(driver.ctx_) {
case isc::dhcp::D2ParserContext::DHCPDDNS:
return isc::dhcp::D2Parser::make_NCR_PROTOCOL(driver.loc_);
case isc::d2::D2ParserContext::DHCPDDNS:
return isc::d2::D2Parser::make_NCR_PROTOCOL(driver.loc_);
default:
return isc::dhcp::D2Parser::make_STRING("ncr-protocol", driver.loc_);
return isc::d2::D2Parser::make_STRING("ncr-protocol", driver.loc_);
}
}
\"ncr-format\" {
switch(driver.ctx_) {
case isc::dhcp::D2ParserContext::DHCPDDNS:
return isc::dhcp::D2Parser::make_NCR_FORMAT(driver.loc_);
case isc::d2::D2ParserContext::DHCPDDNS:
return isc::d2::D2Parser::make_NCR_FORMAT(driver.loc_);
default:
return isc::dhcp::D2Parser::make_STRING("ncr-format", driver.loc_);
return isc::d2::D2Parser::make_STRING("ncr-format", driver.loc_);
}
}
(?i:\"UDP\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::D2ParserContext::NCR_PROTOCOL) {
return isc::dhcp::D2Parser::make_UDP(driver.loc_);
if (driver.ctx_ == isc::d2::D2ParserContext::NCR_PROTOCOL) {
return isc::d2::D2Parser::make_UDP(driver.loc_);
}
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
return isc::dhcp::D2Parser::make_STRING(tmp, driver.loc_);
return isc::d2::D2Parser::make_STRING(tmp, driver.loc_);
}
(?i:\"TCP\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::D2ParserContext::NCR_PROTOCOL) {
return isc::dhcp::D2Parser::make_TCP(driver.loc_);
if (driver.ctx_ == isc::d2::D2ParserContext::NCR_PROTOCOL) {
return isc::d2::D2Parser::make_TCP(driver.loc_);
}
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
return isc::dhcp::D2Parser::make_STRING(tmp, driver.loc_);
return isc::d2::D2Parser::make_STRING(tmp, driver.loc_);
}
(?i:\"JSON\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::D2ParserContext::NCR_FORMAT) {
return isc::dhcp::D2Parser::make_JSON(driver.loc_);
if (driver.ctx_ == isc::d2::D2ParserContext::NCR_FORMAT) {
return isc::d2::D2Parser::make_JSON(driver.loc_);
}
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
return isc::dhcp::D2Parser::make_STRING(tmp, driver.loc_);
return isc::d2::D2Parser::make_STRING(tmp, driver.loc_);
}
\"forward-ddns\" {
switch(driver.ctx_) {
case isc::d2::D2ParserContext::DHCPDDNS:
return isc::d2::D2Parser::make_FORWARD_DDNS(driver.loc_);
default:
return isc::d2::D2Parser::make_STRING("forward-ddns", driver.loc_);
}
}
\"reverse-ddns\" {
switch(driver.ctx_) {
case isc::d2::D2ParserContext::DHCPDDNS:
return isc::d2::D2Parser::make_REVERSE_DDNS(driver.loc_);
default:
return isc::d2::D2Parser::make_STRING("reverse-ddns", driver.loc_);
}
}
\"tsig-keys\" {
switch(driver.ctx_) {
case isc::d2::D2ParserContext::DHCPDDNS:
return isc::d2::D2Parser::make_TSIG_KEYS(driver.loc_);
default:
return isc::d2::D2Parser::make_STRING("tsig-keys", driver.loc_);
}
}
\"Logging\" {
switch(driver.ctx_) {
case isc::dhcp::D2ParserContext::CONFIG:
return isc::dhcp::D2Parser::make_LOGGING(driver.loc_);
case isc::d2::D2ParserContext::CONFIG:
return isc::d2::D2Parser::make_LOGGING(driver.loc_);
default:
return isc::dhcp::D2Parser::make_STRING("Logging", driver.loc_);
return isc::d2::D2Parser::make_STRING("Logging", driver.loc_);
}
}
\"loggers\" {
switch(driver.ctx_) {
case isc::dhcp::D2ParserContext::LOGGING:
return isc::dhcp::D2Parser::make_LOGGERS(driver.loc_);
case isc::d2::D2ParserContext::LOGGING:
return isc::d2::D2Parser::make_LOGGERS(driver.loc_);
default:
return isc::dhcp::D2Parser::make_STRING("loggers", driver.loc_);
return isc::d2::D2Parser::make_STRING("loggers", driver.loc_);
}
}
\"output_options\" {
switch(driver.ctx_) {
case isc::dhcp::D2ParserContext::LOGGERS:
return isc::dhcp::D2Parser::make_OUTPUT_OPTIONS(driver.loc_);
case isc::d2::D2ParserContext::LOGGERS:
return isc::d2::D2Parser::make_OUTPUT_OPTIONS(driver.loc_);
default:
return isc::dhcp::D2Parser::make_STRING("output_options", driver.loc_);
return isc::d2::D2Parser::make_STRING("output_options", driver.loc_);
}
}
\"output\" {
switch(driver.ctx_) {
case isc::dhcp::D2ParserContext::OUTPUT_OPTIONS:
return isc::dhcp::D2Parser::make_OUTPUT(driver.loc_);
case isc::d2::D2ParserContext::OUTPUT_OPTIONS:
return isc::d2::D2Parser::make_OUTPUT(driver.loc_);
default:
return isc::dhcp::D2Parser::make_STRING("output", driver.loc_);
return isc::d2::D2Parser::make_STRING("output", driver.loc_);
}
}
\"name\" {
switch(driver.ctx_) {
case isc::d2::D2ParserContext::LOGGERS:
return isc::d2::D2Parser::make_NAME(driver.loc_);
default:
return isc::d2::D2Parser::make_STRING("name", driver.loc_);
}
}
\"debuglevel\" {
switch(driver.ctx_) {
case isc::dhcp::D2ParserContext::LOGGERS:
return isc::dhcp::D2Parser::make_DEBUGLEVEL(driver.loc_);
case isc::d2::D2ParserContext::LOGGERS:
return isc::d2::D2Parser::make_DEBUGLEVEL(driver.loc_);
default:
return isc::dhcp::D2Parser::make_STRING("debuglevel", driver.loc_);
return isc::d2::D2Parser::make_STRING("debuglevel", driver.loc_);
}
}
\"severity\" {
switch(driver.ctx_) {
case isc::dhcp::D2ParserContext::LOGGERS:
return isc::dhcp::D2Parser::make_SEVERITY(driver.loc_);
case isc::d2::D2ParserContext::LOGGERS:
return isc::d2::D2Parser::make_SEVERITY(driver.loc_);
default:
return isc::dhcp::D2Parser::make_STRING("severity", driver.loc_);
return isc::d2::D2Parser::make_STRING("severity", driver.loc_);
}
}
\"Dhcp4\" {
switch(driver.ctx_) {
case isc::d2::D2ParserContext::CONFIG:
return isc::d2::D2Parser::make_DHCP4(driver.loc_);
default:
return isc::d2::D2Parser::make_STRING("Dhcp4", driver.loc_);
}
}
\"Dhcp6\" {
switch(driver.ctx_) {
case isc::d2::D2ParserContext::CONFIG:
return isc::d2::D2Parser::make_DHCP6(driver.loc_);
default:
return isc::d2::D2Parser::make_STRING("Dhcp6", driver.loc_);
}
}
{JSONString} {
// A string has been matched. It contains the actual string and single quotes.
// We need to get those quotes out of the way and just use its content, e.g.
......@@ -369,7 +445,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
return isc::dhcp::D2Parser::make_STRING(decoded, driver.loc_);
return isc::d2::D2Parser::make_STRING(decoded, driver.loc_);
}
\"{JSONStringCharacter}*{ControlCharacter}{ControlCharacterFill}*\" {
......@@ -387,12 +463,12 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
driver.error(driver.loc_, "Overflow escape in " + std::string(yytext));
}
"[" { return isc::dhcp::D2Parser::make_LSQUARE_BRACKET(driver.loc_); }
"]" { return isc::dhcp::D2Parser::make_RSQUARE_BRACKET(driver.loc_); }
"{" { return isc::dhcp::D2Parser::make_LCURLY_BRACKET(driver.loc_); }
"}" { return isc::dhcp::D2Parser::make_RCURLY_BRACKET(driver.loc_); }
"," { return isc::dhcp::D2Parser::make_COMMA(driver.loc_); }
":" { return isc::dhcp::D2Parser::make_COLON(driver.loc_); }
"[" { return isc::d2::D2Parser::make_LSQUARE_BRACKET(driver.loc_); }
"]" { return isc::d2::D2Parser::make_RSQUARE_BRACKET(driver.loc_); }
"{" { return isc::d2::D2Parser::make_LCURLY_BRACKET(driver.loc_); }
"}" { return isc::d2::D2Parser::make_RCURLY_BRACKET(driver.loc_); }
"," { return isc::d2::D2Parser::make_COMMA(driver.loc_); }
":" { return isc::d2::D2Parser::make_COLON(driver.loc_); }
{int} {
// An integer was found.
......@@ -409,7 +485,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
// The parser needs the string form as double conversion is no lossless
return isc::dhcp::D2Parser::make_INTEGER(integer, driver.loc_);
return isc::d2::D2Parser::make_INTEGER(integer, driver.loc_);
}
[-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)? {
......@@ -422,16 +498,16 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
driver.error(driver.loc_, "Failed to convert " + tmp + " to a floating point.");
}
return isc::dhcp::D2Parser::make_FLOAT(fp, driver.loc_);
return isc::d2::D2Parser::make_FLOAT(fp, driver.loc_);
}
true|false {
string tmp(yytext);
return isc::dhcp::D2Parser::make_BOOLEAN(tmp == "true", driver.loc_);
return isc::d2::D2Parser::make_BOOLEAN(tmp == "true", driver.loc_);
}
null {
return isc::dhcp::D2Parser::make_NULL_TYPE(driver.loc_);
return isc::d2::D2Parser::make_NULL_TYPE(driver.loc_);
}
(?i:true) driver.error (driver.loc_, "JSON true reserved keyword is lower case only");
......@@ -444,7 +520,7 @@ null {
<<EOF>> {
if (driver.states_.empty()) {
return isc::dhcp::D2Parser::make_END(driver.loc_);
return isc::d2::D2Parser::make_END(driver.loc_);
}
driver.loc_ = driver.locs_.back();
driver.locs_.pop_back();
......
This diff is collapsed.
......@@ -32,7 +32,7 @@
/**
** \file d2_parser.h
** Define the isc::dhcp::parser class.
** Define the isc::d2::parser class.
*/
// C++ LALR(1) parser skeleton written by Akim Demaille.
......@@ -48,7 +48,7 @@
#include <boost/lexical_cast.hpp>
#include <d2/parser_context_decl.h>
using namespace isc::dhcp;
using namespace isc::d2;
using namespace isc::data;
using namespace std;
......@@ -136,7 +136,7 @@ using namespace std;
#endif /* ! defined D2_PARSER_DEBUG */
#line 14 "d2_parser.yy" // lalr1.cc:392
namespace isc { namespace dhcp {