14#include <boost/lexical_cast.hpp> 
   35    return (parseCommon());
 
 
   40    FILE* f = fopen(filename.c_str(), 
"r");
 
   45    return (parseCommon());
 
 
   49D2ParserContext::parseCommon() {
 
   53    parser.set_debug_level(trace_parsing_);
 
   55        int res = parser.parse();
 
   67        isc_throw(D2ParseError, 
"Expected exactly one terminal Element, found " 
   74                       const std::string& what,
 
 
   99    const std::string& 
file = *loc.begin.filename;
 
  100    const uint32_t line = loc.begin.line;
 
  101    const uint32_t pos = loc.begin.column;
 
 
  113                  "missing parameter '" << 
name << 
"' (" 
  114                  << 
stack_.back()->getPosition() << 
") [" 
  116                  << open_loc << 
" and " << close_loc << 
"]");
 
 
  129                      << 
" map (previous at " << value->getPosition() << 
")");
 
  132                      << 
" entries in JSON" 
  133                  << 
" map (previous at " << value->getPosition() << 
")");
 
 
  141    cstack_.push_back(
ctx_);
 
 
  148    if (cstack_.empty()) {
 
  149        fatal(
"unbalanced syntactic context");
 
  152    ctx_ = cstack_.back();
 
 
  161        return (
"__no keyword__");
 
  169        return (
"tsig-keys");
 
  171        return (
"algorithm");
 
  173        return (
"digest-bits");
 
  177        return (
"forward-ddns");
 
  179        return (
"reverse-ddns");
 
  181        return (
"ddns-domain");
 
  183        return (
"ddns-domains");
 
  185        return (
"dns-server");
 
  187        return (
"dns-servers");
 
  189        return (
"control-socket");
 
  191        return (
"control-socket-type");
 
  193        return (
"authentication");
 
  195        return (
"auth-type");
 
  201        return (
"output-options");
 
  203        return (
"ncr-protocol");
 
  205        return (
"ncr-format");
 
  207        return (
"hooks-libraries");
 
  209        return (
"__unknown__");
 
 
  215                         const std::string& what) {
 
  216    std::ostringstream msg;
 
  217    msg << loc << 
": " << what;
 
 
  224    warning(loc, 
"Extraneous comma. A piece of configuration may have been omitted.");
 
 
Evaluation error exception raised when trying to parse.
ParserType
Defines currently supported scopes.
isc::data::ElementPtr parseString(const std::string &str, ParserType parser_type)
Run the parser on the string specified.
D2ParserContext()
Default constructor.
ParserContext
Defines syntactic contexts for lexical tie-ins.
@ AUTHENTICATION
Used while parsing content of an authentication type.
@ DDNS_DOMAIN
Used while parsing a list of ddns-domains.
@ DNS_SERVERS
Used while parsing content of a control-socket.
@ DDNS_DOMAINS
Used while parsing content of a dns-server.
@ AUTH_TYPE
Used while parsing content of a client.
@ NCR_FORMAT
Used while parsing DhcpDdns/ncr-format.
@ NCR_PROTOCOL
Used while parsing DhcpDdns/ncr-protocol.
@ NO_KEYWORD
This one is used in pure JSON mode.
@ DHCPDDNS
Used while parsing content of a tsig-key.
@ SECRET
Used while parsing content of DhcpDdns/forward-ddns.
@ ALGORITHM
Used while parsing content of DhcpDdns/tsig-keys/digest-bits.
@ OUTPUT_OPTIONS
Used while parsing DhcpDdns/loggers/output-options structures.
@ FORWARD_DDNS
Used while parsing content of DhcpDdns/reverse-ddns.
@ CONTROL_SOCKET_TYPE
Used while parsing content of an authentication.
@ TSIG_KEY
Used while parsing a list of tsig-keys.
@ REVERSE_DDNS
Used while parsing content of a ddns-domain.
@ LOGGERS
Used while parsing DhcpDdns/loggers structures.
@ HOOKS_LIBRARIES
Used while parsing DhcpDdns/hooks-libraries.
@ TSIG_KEYS
Used while parsing content of DhcpDdns/tsig-keys/algorithm.
@ CONTROL_SOCKET
Used while parsing content of a socket-type.
@ DIGEST_BITS
Used while parsing content of DhcpDdns/tsig-keys/secret.
@ CONFIG
Used while parsing content of DhcpDdns.
@ DNS_SERVER
Used while parsing content of list of dns-servers.
void warning(const isc::d2::location &loc, const std::string &what)
Warning handler.
FILE * sfile_
sFile (aka FILE)
const std::string contextName()
Get the syntax context name.
void error(const isc::d2::location &loc, const std::string &what, size_t pos=0)
Error handler.
void leave()
Leave a syntactic context.
void scanStringBegin(const std::string &str, ParserType type)
Method called before scanning starts on a string.
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
void warnAboutExtraCommas(const isc::d2::location &loc)
Warning for extra commas.
void scanFileBegin(FILE *f, const std::string &filename, ParserType type)
Method called before scanning starts on a file.
void unique(const std::string &name, isc::data::Element::Position loc)
Check if a parameter is already present.
virtual ~D2ParserContext()
destructor.
ParserContext ctx_
Current syntactic context.
void require(const std::string &name, isc::data::Element::Position open_loc, isc::data::Element::Position close_loc)
Check if a required parameter is present.
std::vector< isc::data::ElementPtr > stack_
JSON elements being parsed.
void enter(const ParserContext &ctx)
Enter a new syntactic context.
static void fatal(const std::string &what)
Fatal error handler.
void scanEnd()
Method called after the last tokens are scanned.
isc::data::Element::Position loc2pos(isc::d2::location &loc)
Converts bison's position to one understood by isc::data::Element.
Define the isc::d2::parser class.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
isc::log::Logger d2_to_dns_logger("d2-to-dns")
const isc::log::MessageID DHCP_DDNS_CONFIG_SYNTAX_WARNING
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
Defines the logger used by the top-level component of kea-lfc.
Represents the position of the data element within a configuration string.