Kea  1.5.0
dhcp6/parser_context.h
Go to the documentation of this file.
1 // Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef PARSER_CONTEXT_H
8 #define PARSER_CONTEXT_H
9 #include <string>
10 #include <map>
11 #include <vector>
12 #include <dhcp6/dhcp6_parser.h>
14 #include <exceptions/exceptions.h>
15 
16 // Tell Flex the lexer's prototype ...
17 #define YY_DECL isc::dhcp::Dhcp6Parser::symbol_type parser6_lex (Parser6Context& driver)
18 
19 // ... and declare it for the parser's sake.
21 
22 namespace isc {
23 namespace dhcp {
24 
29 public:
30  Dhcp6ParseError(const char* file, size_t line, const char* what) :
31  isc::Exception(file, line, what) { };
32 };
33 
34 
37 {
38 public:
39 
50  typedef enum {
53 
57 
63 
66 
69 
72 
75 
78 
81 
84 
87 
90 
93 
96 
99 
100  } ParserType;
101 
103  Parser6Context();
104 
106  virtual ~Parser6Context();
107 
109  std::vector<isc::data::ElementPtr> stack_;
110 
115  void scanStringBegin(const std::string& str, ParserType type);
116 
122  void scanFileBegin(FILE* f, const std::string& filename, ParserType type);
123 
125  void scanEnd();
126 
130  void includeFile(const std::string& filename);
131 
142  isc::data::ElementPtr parseString(const std::string& str,
143  ParserType parser_type);
144 
155  isc::data::ElementPtr parseFile(const std::string& filename,
156  ParserType parser_type);
157 
163  void error(const isc::dhcp::location& loc, const std::string& what);
164 
172  void error(const std::string& what);
173 
181  static void fatal(const std::string& what);
182 
190  isc::data::Element::Position loc2pos(isc::dhcp::location& loc);
191 
201  void require(const std::string& name,
203  isc::data::Element::Position close_loc);
204 
206  typedef enum {
209 
212 
215 
216  // not yet Dhcp4, DhcpDdns,
217 
220 
223 
226 
229 
232 
235 
238 
241 
244 
247 
250 
253 
256 
261 
264 
267 
270 
273 
276 
279 
282 
285 
288 
291 
294 
297 
300 
303 
306 
309 
312 
315 
316  } ParserContext;
317 
319  std::string file_;
320 
322  std::vector<std::string> files_;
323 
328  isc::dhcp::location loc_;
329 
331  std::vector<isc::dhcp::location> locs_;
332 
334  std::vector<struct yy_buffer_state*> states_;
335 
337  FILE* sfile_;
338 
344  std::vector<FILE*> sfiles_;
345 
348 
361  void enter(const ParserContext& ctx);
362 
366  void leave();
367 
371  const std::string contextName();
372 
373  private:
375  bool trace_scanning_;
376 
378  bool trace_parsing_;
379 
381  std::vector<ParserContext> cstack_;
382 
386  isc::data::ElementPtr parseCommon();
387 };
388 
389 }; // end of isc::eval namespace
390 }; // end of isc namespace
391 
392 #endif
Used while parsing Dhcp6/lease-database structures.
ParserContext ctx_
Current syntactic context.
This will parse the content of Logging.
Used while parsing Dhcp6/option-def structures.
Define the isc::dhcp::parser class.
Used while parsing config-control/config-databases.
This will parse the input as hooks-library.
void enter(const ParserContext &ctx)
Enter a new syntactic context.
Used while parsing Dhcp6/client-classes structures.
Used while parsing Dhcp4/dhcp-queue-control structures.
This will parse the input as option definition.
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
Used while parsing Dhcp6/reservations structures.
isc::data::Element::Position loc2pos(isc::dhcp::location &loc)
Converts bison's position to one understandable by isc::data::Element.
This one is used in pure JSON mode.
Used while parsing Dhcp4/config-control.
This will parse the input as option data.
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
Evaluation context, an interface to the expression evaluation.
Used while parsing Dhcp6/dhcp-ddns/ncr-protocol.
std::vector< std::string > files_
File name stack.
Used while parsing Dhcp6/dhcp-ddns/ncr-format.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
virtual ~Parser6Context()
destructor
void scanStringBegin(const std::string &str, ParserType type)
Method called before scanning starts on a string.
std::vector< isc::data::ElementPtr > stack_
JSON elements being parsed.
Used while parsing Dhcp6/server-id/type structures.
Used while parsing content of Logging.
Used while parsing Dhcp6/expired-leases-processing.
static void fatal(const std::string &what)
Fatal error handler.
Used while parsing Dhcp6/mac-sources structures.
Evaluation error exception raised when trying to parse.
Used while parsing Logging/loggers/output_options structures.
This parser will parse the content as generic JSON.
Dhcp6ParseError(const char *file, size_t line, const char *what)
Used while parsing content of Dhcp6.
ParserType
Defines currently supported scopes.
void leave()
Leave a syntactic context.
FILE * sfile_
sFile (aka FILE)
Used while parsing Dhcp6/*-database/type.
This will parse the input as pool6 content.
const std::string contextName()
Get the syntactic context name.
Used while parsing Dhcp6/subnet6/pd-pools structures.
Used while parsing Dhcp6/option-data, Dhcp6/subnet6/option-data or anywhere option-data is present (c...
This will parse the input option definitions (for tests).
isc::dhcp::location loc_
Location of the current token.
Used while parsing Dhcp6/hosts-database[s] structures.
Used while parsing Logging/loggers structures.
std::vector< FILE * > sfiles_
sFile (aka FILE) stack
void scanEnd()
Method called after the last tokens are scanned.
isc::data::ElementPtr parseString(const std::string &str, ParserType parser_type)
Run the parser on the string specified.
Parser6Context()
Default constructor.
This will parse the input as Subnet6 content.
This parser will parse the content as Dhcp6 config wrapped in a map (that's the regular config file)
Represents the position of the data element within a configuration string.
Definition: data.h:88
This will parse the input as interfaces content.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Used while parsing Dhcp6/interfaces structures.
This will parse the input as dhcp-ddns. (D2 client config)
ParserContext
Defines syntactic contexts for lexical tie-ins.
Used while parsing shared-networks structures.
Used while parsing Dhcp6/dhcp-ddns/replace-client-name.
This parser will parse the content of Dhcp6 (without outer { } and without "Dhcp6").
This will parse the input as host-reservation.
Used while parsing Dhcp6/control-socket structures.
void includeFile(const std::string &filename)
Divert input to an include file.
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.
Used while parsing Dhcp6/host-reservation-identifiers.
Forward declaration of the ParserContext class.
This will parse the input as config-control.
std::string file_
File name.
std::vector< isc::dhcp::location > locs_
Location stack.
Used while parsing Dhcp6/subnet6/relay structures.
void error(const isc::dhcp::location &loc, const std::string &what)
Error handler.
Used while parsing Dhcp6/subnet6/pools structures.
This will parse the input as pd-pool content.
Used while parsing Dhcp6/reservation-mode.
Used while parsing Dhcp6/hooks-libraries.
#define YY_DECL
Used while parsing Dhcp6/Subnet6 structures.
Used while parsing Dhcp6/dhcp-ddns.
Used while parsing Dhcp6/server-id structures.
std::vector< struct yy_buffer_state * > states_
Lexer state stack.
void scanFileBegin(FILE *f, const std::string &filename, ParserType type)
Method called before scanning starts on a file.