Kea  2.3.2-git
dhcp4/parser_context.h
Go to the documentation of this file.
1 // Copyright (C) 2015-2021 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 <dhcp4/dhcp4_parser.h>
14 #include <exceptions/exceptions.h>
15 
16 // Tell Flex the lexer's prototype ...
17 #define YY_DECL isc::dhcp::Dhcp4Parser::symbol_type parser4_lex (Parser4Context& driver)
18 
19 // ... and declare it for the parser's sake.
21 
22 namespace isc {
23 namespace dhcp {
24 
29 public:
30  Dhcp4ParseError(const char* file, size_t line, const char* what) :
31  isc::Exception(file, line, what) { };
32 };
33 
36 {
37 public:
38 
49  typedef enum {
52 
56 
62 
65 
68 
71 
74 
77 
80 
83 
86 
89 
92  } ParserType;
93 
96 
98  virtual ~Parser4Context();
99 
101  std::vector<isc::data::ElementPtr> stack_;
102 
107  void scanStringBegin(const std::string& str, ParserType type);
108 
114  void scanFileBegin(FILE* f, const std::string& filename, ParserType type);
115 
117  void scanEnd();
118 
122  void includeFile(const std::string& filename);
123 
134  isc::data::ElementPtr parseString(const std::string& str,
135  ParserType parser_type);
136 
147  isc::data::ElementPtr parseFile(const std::string& filename,
148  ParserType parser_type);
149 
159  void error(const isc::dhcp::location& loc,
160  const std::string& what,
161  size_t pos = 0);
162 
170  void error(const std::string& what);
171 
179  static void fatal(const std::string& what);
180 
188  isc::data::Element::Position loc2pos(isc::dhcp::location& loc);
189 
199  void require(const std::string& name,
201  isc::data::Element::Position close_loc);
202 
211  void unique(const std::string& name,
213 
220  void warning(const isc::dhcp::location& loc, const std::string& what);
221 
227  void warnAboutExtraCommas(const isc::dhcp::location& loc);
228 
230  typedef enum {
232  NO_KEYWORD,
233 
235  CONFIG,
236 
239 
242 
245 
248 
251 
254 
257 
260 
263 
266 
269 
272 
275 
278 
281 
286 
289 
292 
295 
298 
301 
304 
307 
310 
313 
316 
319 
322 
325 
328 
331 
334 
337 
340 
341  } ParserContext;
342 
344  std::string file_;
345 
347  std::vector<std::string> files_;
348 
353  isc::dhcp::location loc_;
354 
356  std::vector<isc::dhcp::location> locs_;
357 
359  std::vector<struct yy_buffer_state*> states_;
360 
362  FILE* sfile_;
363 
369  std::vector<FILE*> sfiles_;
370 
372  ParserContext ctx_;
373 
386  void enter(const ParserContext& ctx);
387 
391  void leave();
392 
396  const std::string contextName();
397 
398  private:
400  bool trace_scanning_;
401 
403  bool trace_parsing_;
404 
406  std::vector<ParserContext> cstack_;
407 
411  isc::data::ElementPtr parseCommon();
412 };
413 
414 }; // end of isc::eval namespace
415 }; // end of isc namespace
416 
417 #endif
Used while parsing Dhcp4/hosts-database[s] structures.
Used while parsing Dhcp4/*-database/on-fail.
Used while parsing Dhcp4/dhcp-ddns/ncr-protocol.
This will parse the input as option data.
ParserContext
Defines syntactic contexts for lexical tie-ins.
Used while parsing Dhcp4/hooks-libraries.
Used while parsing Dhcp4/dhcp-ddns/ncr-format.
This will parse the input as option definition.
This parser will parse the content as Dhcp4 config wrapped in a map (that&#39;s the regular config file) ...
Used while parsing Dhcp4/interfaces/outbound-interface structures.
Used while parsing Dhcp4/client-classes structures.
Evaluation context, an interface to the expression evaluation.
Used while parsing Dhcp4/*-database/type.
std::vector< FILE * > sfiles_
sFile (aka FILE) stack
Used while parsing Dhcp4/host-reservation-identifiers.
This will parse the input as host-reservation.
Used while parsing Dhcp4/multi-threading structures.
This will parse the input as interfaces content.
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
Used while parsing Dhcp4/reservations structures.
isc::dhcp::location loc_
Location of the current token.
Used while parsing Dhcp4/lease-database structures.
Used while parsing Dhcp4/dhcp-ddns.
This will parse the input as config-control.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Used while parsing Dhcp4/interfaces/dhcp-socket-type structures.
Used while parsing Dhcp4/server-id structures.
Define the isc::dhcp::parser class.
Used while parsing Dhcp4/control-socket structures.
Used while parsing Dhcp4/subnet4/pools structures.
Used while parsing Dhcp4/dhcp-queue-control structures.
Used while parsing shared-networks structures.
Dhcp4ParseError(const char *file, size_t line, const char *what)
This will parse the input option definitions (for tests).
This will parse the input as hooks-library.
ParserContext ctx_
Current syntactic context.
std::vector< isc::data::ElementPtr > stack_
JSON elements being parsed.
Used while parsing Dhcp4/dhcp-ddns/replace-client-name.
This will parse the input as pool4 content.
Used while parsing Dhcp4/loggers/output_options structures.
std::vector< isc::dhcp::location > locs_
Location stack.
std::vector< std::string > files_
File name stack.
This parser will parse the content of Dhcp4 (without outer { } and without "Dhcp4").
ParserType
Defines currently supported scopes.
This parser will parse the content as generic JSON.
Used while parsing Dhcp4/Subnet4 structures.
Evaluation error exception raised when trying to parse.
Used while parsing Dhcp4/option-def structures.
Used while parsing Dhcp4/option-data, Dhcp4/subnet4/option-data or anywhere option-data is present (c...
Used while parsing Dhcp4/interfaces structures.
Represents the position of the data element within a configuration string.
Definition: data.h:92
Used while parsing Dhcp4/subnet4relay structures.
#define YY_DECL
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
This will parse the input as dhcp-ddns.
This will parse the input as Subnet4 content.
Used while parsing Dhcp4/loggers structures.
Used while parsing compatibility parameters.
Forward declaration of the ParserContext class.
FILE * sfile_
sFile (aka FILE)
Used while parsing Dhcp4/expired-leases-processing.
Used while parsing config-control/config-databases.
std::vector< struct yy_buffer_state * > states_
Lexer state stack.
Used while parsing Dhcp4/config-control.
std::string file_
File name.
Used while parsing Dhcp4/reservation-mode.