21 : sfile_(0), ctx_(NO_KEYWORDS), trace_scanning_(false), trace_parsing_(false)
33 return (parseCommon());
38 FILE* f = fopen(filename.c_str(),
"r");
43 return (parseCommon());
47 ParserContext::parseCommon() {
51 parser.set_debug_level(trace_parsing_);
53 int res = parser.parse();
66 isc_throw(ParseError,
"Expected exactly one terminal Element expected, found "
73 const std::string& what,
98 const std::string& file = *loc.begin.filename;
99 const uint32_t line = loc.begin.line;
100 const uint32_t pos = loc.begin.column;
112 "missing parameter '" << name <<
"' ("
113 <<
stack_.back()->getPosition() <<
") ["
115 << open_loc <<
" and " << close_loc <<
"]");
128 <<
" map (previous at " << value->getPosition() <<
")");
131 <<
" entries in JSON"
132 <<
" map (previous at " << value->getPosition() <<
")");
140 cstack_.push_back(
ctx_);
147 if (cstack_.empty()) {
148 fatal(
"unbalanced syntactic context");
150 ctx_ = cstack_.back();
159 return (
"__no keywords__");
163 return (
"Control-agent");
165 return (
"authentication");
167 return (
"auth-type");
171 return (
"control-sockets");
173 return (
"xxx-server");
175 return (
"socket-type");
177 return (
"hooks-libraries");
181 return (
"output-options");
183 return (
"__unknown__");
Used while parsing Control-agent/Authentication/type.
Used while parsing content of Agent.
void unique(const std::string &name, isc::data::Element::Position loc)
Check if a parameter is already present.
static void fatal(const std::string &what)
Fatal error handler.
void enter(const LexerContext &ctx)
Enter a new syntactic context.
ParserType
Defines currently supported scopes.
LexerContext ctx_
Current syntactic context.
Used while parsing Control-agent/control-socket/*-server/socket-type.
boost::shared_ptr< Element > ElementPtr
std::vector< isc::data::ElementPtr > stack_
JSON elements being parsed.
Used while parsing Control-agent/loggers structures.
ParserContext()
Default constructor.
LexerContext
Defines syntactic contexts for lexical tie-ins.
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.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
isc::data::Element::Position loc2pos(isc::agent::location &loc)
Converts bison's position to one understandable by isc::data::Element.
const std::string contextName()
Get the syntactic context name.
Evaluation error exception raised when trying to parse.
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
boost::shared_ptr< const Element > ConstElementPtr
void leave()
Leave a syntactic context.
Used while parsing Control-agent/loggers/output_options structures.
void scanFileBegin(FILE *f, const std::string &filename, ParserType type)
Method called before scanning starts on a file.
Represents the position of the data element within a configuration string.
This one is used in pure JSON mode.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Define the isc::agent::parser class.
void scanStringBegin(const std::string &str, ParserType type)
Method called before scanning starts on a string.
void scanEnd()
Method called after the last tokens are scanned.
Used while parsing Control-agent/hooks-libraries.
Used while parsing Control-agent/control-sockets.
Used while parsing Control-agent/Authentication.
Used while parsing Control-agent/Authentication/clients.
isc::data::ElementPtr parseString(const std::string &str, ParserType parser_type)
Run the parser on the string specified.
Used while parsing Control-agent/control-socket/*-server.
virtual ~ParserContext()
destructor
void error(const isc::agent::location &loc, const std::string &what, size_t pos=0)
Error handler.