libd2_la_SOURCES += d2_process.cc d2_process.h
libd2_la_SOURCES += d2_config.cc d2_config.h
libd2_la_SOURCES += d2_cfg_mgr.cc d2_cfg_mgr.h
+libd2_la_SOURCES += d2_lexer.ll location.hh position.hh stack.hh
+libd2_la_SOURCES += d2_parser.cc d2_parser.h
libd2_la_SOURCES += d2_queue_mgr.cc d2_queue_mgr.h
+libd2_la_SOURCES += d2_simple_parser.cc d2_simple_parser.h
libd2_la_SOURCES += d2_update_message.cc d2_update_message.h
libd2_la_SOURCES += d2_update_mgr.cc d2_update_mgr.h
libd2_la_SOURCES += d2_zone.cc d2_zone.h
libd2_la_SOURCES += nc_remove.cc nc_remove.h
libd2_la_SOURCES += nc_trans.cc nc_trans.h
libd2_la_SOURCES += d2_controller.cc d2_controller.h
+libd2_la_SOURCES += parser_context.cc parser_context.h parser_context_decl.h
nodist_libd2_la_SOURCES = d2_messages.h d2_messages.cc
EXTRA_DIST += d2_messages.mes
kea_dhcp_ddnsdir = $(pkgdatadir)
kea_dhcp_ddns_DATA = dhcp-ddns.spec
+
+if GENERATE_PARSER
+
+parser: d2_lexer.cc location.hh position.hh stack.hh d2_parser.cc d2_parser.h
+ @echo "Flex/bison files regenerated"
+
+# --- Flex/Bison stuff below --------------------------------------------------
+# When debugging grammar issues, it's useful to add -v to bison parameters.
+# bison will generate parser.output file that explains the whole grammar.
+# It can be used to manually follow what's going on in the parser.
+# This is especially useful if yydebug_ is set to 1 as that variable
+# will cause parser to print out its internal state.
+# Call flex with -s to check that the default rule can be suppressed
+# Call bison with -W to get warnings like unmarked empty rules
+# Note C++11 deprecated register still used by flex < 2.6.0
+location.hh position.hh stack.hh d2_parser.cc d2_parser.h: d2_parser.yy
+ $(YACC) --defines=d2_parser.h --report=all --report-file=d2_parser.report -o d2_parser.cc d2_parser.yy
+
+d2_lexer.cc: d2_lexer.ll
+ $(LEX) --prefix d2_parser_ -o d2_lexer.cc d2_lexer.ll
+
+else
+
+parser location.hh position.hh stack.hh d2_parser.cc d2_parser.h d2_lexer.cc:
+ @echo Parser generation disabled. Configure with --enable-generate-parser to enable it.
+
+endif
+
#include <d2/d2_controller.h>
#include <d2/d2_process.h>
+#include <d2/parser_context.h>
#include <process/spec_config.h>
#include <stdlib.h>
}
}
+isc::data::ConstElementPtr
+D2Controller::parseFile(const std::string& file_name) {
+ isc::data::ConstElementPtr elements;
+
+ // Read contents of the file and parse it as JSON
+ D2ParserContext parser;
+ elements = parser.parseFile(file_name, D2ParserContext::PARSER_JSON);
+ if (!elements) {
+ isc_throw(isc::BadValue, "no configuration found in file");
+ }
+
+ return (elements);
+}
+
D2Controller::~D2Controller() {
}
/// pointer.
virtual process::DProcessBase* createProcess();
+ ///@brief Parse a given file into Elements
+ ///
+ /// Uses bison parsing to parse a JSON configruation file into an
+ /// a element map.
+ ///
+ /// @param file_name pathname of the file to parse
+ ///
+ /// @return pointer to the map of elements created
+ virtual isc::data::ConstElementPtr parseFile(const std::string& file_name);
+
/// @brief Constructor is declared private to maintain the integrity of
/// the singleton instance.
D2Controller();
--- /dev/null
+#line 1 "d2_lexer.cc"
+
+#line 3 "d2_lexer.cc"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+/* %not-for-header */
+/* %if-c-only */
+/* %if-not-reentrant */
+#define yy_create_buffer d2_parser__create_buffer
+#define yy_delete_buffer d2_parser__delete_buffer
+#define yy_flex_debug d2_parser__flex_debug
+#define yy_init_buffer d2_parser__init_buffer
+#define yy_flush_buffer d2_parser__flush_buffer
+#define yy_load_buffer_state d2_parser__load_buffer_state
+#define yy_switch_to_buffer d2_parser__switch_to_buffer
+#define yyin d2_parser_in
+#define yyleng d2_parser_leng
+#define yylex d2_parser_lex
+#define yylineno d2_parser_lineno
+#define yyout d2_parser_out
+#define yyrestart d2_parser_restart
+#define yytext d2_parser_text
+#define yywrap d2_parser_wrap
+#define yyalloc d2_parser_alloc
+#define yyrealloc d2_parser_realloc
+#define yyfree d2_parser_free
+
+/* %endif */
+/* %endif */
+/* %ok-for-header */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 6
+#define YY_FLEX_SUBMINOR_VERSION 3
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* %if-c++-only */
+/* %endif */
+
+/* %if-c-only */
+ #define yy_create_buffer d2_parser__create_buffer
+
+ #define yy_delete_buffer d2_parser__delete_buffer
+
+ #define yy_scan_buffer d2_parser__scan_buffer
+
+ #define yy_scan_string d2_parser__scan_string
+
+ #define yy_scan_bytes d2_parser__scan_bytes
+
+ #define yy_init_buffer d2_parser__init_buffer
+
+ #define yy_flush_buffer d2_parser__flush_buffer
+
+ #define yy_load_buffer_state d2_parser__load_buffer_state
+
+ #define yy_switch_to_buffer d2_parser__switch_to_buffer
+
+ #define yypush_buffer_state d2_parser_push_buffer_state
+
+ #define yypop_buffer_state d2_parser_pop_buffer_state
+
+ #define yyensure_buffer_stack d2_parser_ensure_buffer_stack
+
+ #define yylex d2_parser_lex
+
+ #define yyrestart d2_parser_restart
+
+ #define yylex_init d2_parser_lex_init
+
+ #define yylex_init_extra d2_parser_lex_init_extra
+
+ #define yylex_destroy d2_parser_lex_destroy
+
+ #define yyget_debug d2_parser_get_debug
+
+ #define yyset_debug d2_parser_set_debug
+
+ #define yyget_extra d2_parser_get_extra
+
+ #define yyset_extra d2_parser_set_extra
+
+ #define yyget_in d2_parser_get_in
+
+ #define yyset_in d2_parser_set_in
+
+ #define yyget_out d2_parser_get_out
+
+ #define yyset_out d2_parser_set_out
+
+ #define yyget_leng d2_parser_get_leng
+
+ #define yyget_text d2_parser_get_text
+
+ #define yyget_lineno d2_parser_get_lineno
+
+ #define yyset_lineno d2_parser_set_lineno
+
+ #define yywrap d2_parser_wrap
+
+/* %endif */
+
+ #define yyalloc d2_parser_alloc
+
+ #define yyrealloc d2_parser_realloc
+
+ #define yyfree d2_parser_free
+
+/* %if-c-only */
+
+ #define yytext d2_parser_text
+
+ #define yyleng d2_parser_leng
+
+ #define yyin d2_parser_in
+
+ #define yyout d2_parser_out
+
+ #define yy_flex_debug d2_parser__flex_debug
+
+ #define yylineno d2_parser_lineno
+
+/* %endif */
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+/* %if-c-only */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+/* %endif */
+
+/* %if-tables-serialization */
+/* %endif */
+/* end standard C headers. */
+
+/* %if-c-or-c++ */
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+/* %endif */
+
+/* %if-c++-only */
+/* %endif */
+
+/* TODO: this is always defined, so inline it */
+#define yyconst const
+
+#if defined(__GNUC__) && __GNUC__ >= 3
+#define yynoreturn __attribute__((__noreturn__))
+#else
+#define yynoreturn
+#endif
+
+/* %not-for-header */
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+/* %ok-for-header */
+
+/* %not-for-header */
+/* Promotes a possibly negative, possibly signed char to an
+ * integer in range [0..255] for use as an array index.
+ */
+#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
+/* %ok-for-header */
+
+/* %if-reentrant */
+/* %endif */
+
+/* %if-not-reentrant */
+
+/* %endif */
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE d2_parser_restart(d2_parser_in )
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
+#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+/* %if-not-reentrant */
+extern int d2_parser_leng;
+/* %endif */
+
+/* %if-c-only */
+/* %if-not-reentrant */
+extern FILE *d2_parser_in, *d2_parser_out;
+/* %endif */
+/* %endif */
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ #define YY_LESS_LINENO(n)
+ #define YY_LINENO_REWIND_TO(ptr)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up d2_parser_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = (yy_hold_char); \
+ YY_RESTORE_YY_MORE_OFFSET \
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up d2_parser_text again */ \
+ } \
+ while ( 0 )
+#define unput(c) yyunput( c, (yytext_ptr) )
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+/* %if-c-only */
+ FILE *yy_input_file;
+/* %endif */
+
+/* %if-c++-only */
+/* %endif */
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ int yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via d2_parser_restart()), so that the user can continue scanning by
+ * just pointing d2_parser_in at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* %if-c-only Standard (non-C++) definition */
+/* %not-for-header */
+/* %if-not-reentrant */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
+/* %endif */
+/* %ok-for-header */
+
+/* %endif */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* %if-c-only Standard (non-C++) definition */
+
+/* %if-not-reentrant */
+/* %not-for-header */
+/* yy_hold_char holds the character lost when d2_parser_text is formed. */
+static char yy_hold_char;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int d2_parser_leng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = NULL;
+static int yy_init = 0; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow d2_parser_wrap()'s to do buffer switches
+ * instead of setting up a fresh d2_parser_in. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+/* %ok-for-header */
+
+/* %endif */
+
+void d2_parser_restart ( FILE *input_file );
+void d2_parser__switch_to_buffer ( YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE d2_parser__create_buffer ( FILE *file, int size );
+void d2_parser__delete_buffer ( YY_BUFFER_STATE b );
+void d2_parser__flush_buffer ( YY_BUFFER_STATE b );
+void d2_parser_push_buffer_state ( YY_BUFFER_STATE new_buffer );
+void d2_parser_pop_buffer_state ( void );
+
+static void d2_parser_ensure_buffer_stack ( void );
+static void d2_parser__load_buffer_state ( void );
+static void d2_parser__init_buffer ( YY_BUFFER_STATE b, FILE *file );
+#define YY_FLUSH_BUFFER d2_parser__flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE d2_parser__scan_buffer ( char *base, yy_size_t size );
+YY_BUFFER_STATE d2_parser__scan_string ( const char *yy_str );
+YY_BUFFER_STATE d2_parser__scan_bytes ( const char *bytes, int len );
+
+/* %endif */
+
+void *d2_parser_alloc ( yy_size_t );
+void *d2_parser_realloc ( void *, yy_size_t );
+void d2_parser_free ( void * );
+
+#define yy_new_buffer d2_parser__create_buffer
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ d2_parser_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ d2_parser__create_buffer(d2_parser_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ d2_parser_ensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ d2_parser__create_buffer(d2_parser_in,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* %% [1.0] d2_parser_text/d2_parser_in/d2_parser_out/yy_state_type/d2_parser_lineno etc. def's & init go here */
+/* Begin user sect3 */
+
+#define d2_parser_wrap() (/*CONSTCOND*/1)
+#define YY_SKIP_YYWRAP
+
+#define FLEX_DEBUG
+typedef flex_uint8_t YY_CHAR;
+
+FILE *d2_parser_in = NULL, *d2_parser_out = NULL;
+
+typedef int yy_state_type;
+
+extern int d2_parser_lineno;
+int d2_parser_lineno = 1;
+
+extern char *d2_parser_text;
+#ifdef yytext_ptr
+#undef yytext_ptr
+#endif
+#define yytext_ptr d2_parser_text
+
+/* %% [1.5] DFA */
+
+/* %if-c-only Standard (non-C++) definition */
+
+static yy_state_type yy_get_previous_state ( void );
+static yy_state_type yy_try_NUL_trans ( yy_state_type current_state );
+static int yy_get_next_buffer ( void );
+static void yynoreturn yy_fatal_error ( const char* msg );
+
+/* %endif */
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up d2_parser_text.
+ */
+#define YY_DO_BEFORE_ACTION \
+ (yytext_ptr) = yy_bp; \
+/* %% [2.0] code to fiddle d2_parser_text and d2_parser_leng for yymore() goes here \ */\
+ d2_parser_leng = (int) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+/* %% [3.0] code to copy yytext_ptr to d2_parser_text[] goes here, if %array \ */\
+ (yy_c_buf_p) = yy_cp;
+/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
+#define YY_NUM_RULES 43
+#define YY_END_OF_BUFFER 44
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static const flex_int16_t yy_accept[207] =
+ { 0,
+ 36, 36, 0, 0, 0, 0, 0, 0, 0, 0,
+ 44, 42, 10, 11, 42, 1, 36, 33, 36, 36,
+ 42, 35, 34, 42, 42, 42, 42, 42, 29, 30,
+ 42, 42, 42, 31, 32, 5, 5, 5, 42, 42,
+ 42, 10, 11, 0, 0, 25, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 36,
+ 36, 0, 35, 36, 3, 2, 6, 0, 36, 0,
+ 0, 0, 0, 0, 0, 4, 0, 0, 9, 0,
+ 26, 0, 0, 0, 0, 0, 0, 28, 0, 0,
+ 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
+
+ 0, 0, 0, 0, 8, 0, 0, 0, 0, 0,
+ 0, 27, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 41, 39, 0, 38, 37, 0, 0, 0, 0,
+ 17, 16, 0, 0, 0, 0, 0, 0, 0, 0,
+ 40, 37, 0, 0, 18, 0, 0, 0, 0, 0,
+ 0, 0, 0, 13, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 7, 0, 0, 0, 0,
+ 0, 0, 22, 0, 0, 19, 0, 0, 20, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 24, 0,
+ 0, 0, 0, 0, 23, 12, 15, 0, 0, 0,
+
+ 0, 14, 0, 0, 21, 0
+ } ;
+
+static const YY_CHAR yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 4, 5, 6, 7, 5, 5, 5, 5, 5,
+ 5, 8, 9, 10, 11, 12, 13, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 15, 5, 16,
+ 5, 17, 18, 5, 19, 20, 21, 22, 23, 24,
+ 5, 5, 5, 25, 5, 26, 5, 27, 28, 29,
+ 5, 30, 31, 32, 33, 5, 5, 5, 5, 5,
+ 34, 35, 36, 5, 37, 5, 38, 39, 40, 41,
+
+ 42, 43, 44, 5, 45, 46, 5, 47, 48, 49,
+ 50, 51, 5, 52, 53, 54, 55, 56, 5, 5,
+ 57, 5, 58, 5, 59, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5
+ } ;
+
+static const YY_CHAR yy_meta[60] =
+ { 0,
+ 1, 1, 2, 3, 3, 4, 3, 3, 3, 3,
+ 3, 3, 5, 6, 3, 3, 3, 3, 6, 6,
+ 6, 6, 6, 6, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 5, 3, 3, 6, 7, 6,
+ 6, 6, 7, 3, 3, 3, 3, 3, 5, 3,
+ 3, 5, 3, 5, 5, 3, 3, 3, 3
+ } ;
+
+static const flex_int16_t yy_base[220] =
+ { 0,
+ 0, 0, 58, 61, 64, 0, 66, 75, 49, 50,
+ 280, 1144, 80, 268, 123, 0, 85, 1144, 89, 79,
+ 77, 105, 1144, 251, 121, 67, 59, 85, 1144, 1144,
+ 114, 83, 109, 1144, 1144, 1144, 132, 255, 209, 0,
+ 232, 138, 245, 140, 178, 1144, 184, 190, 196, 204,
+ 240, 221, 227, 241, 258, 249, 264, 271, 0, 140,
+ 273, 148, 274, 267, 1144, 0, 1144, 227, 221, 57,
+ 63, 110, 119, 124, 134, 1144, 194, 212, 1144, 177,
+ 1144, 156, 299, 316, 323, 330, 202, 336, 368, 344,
+ 361, 392, 367, 398, 411, 419, 0, 163, 162, 118,
+
+ 201, 174, 172, 157, 1144, 0, 429, 436, 442, 456,
+ 197, 1144, 478, 480, 487, 502, 525, 508, 538, 546,
+ 178, 1144, 1144, 215, 1144, 1144, 98, 0, 552, 560,
+ 1144, 1144, 592, 566, 583, 601, 574, 620, 636, 643,
+ 1144, 1144, 110, 0, 1144, 650, 686, 656, 663, 678,
+ 686, 713, 731, 1144, 737, 102, 0, 743, 749, 755,
+ 761, 767, 773, 791, 797, 1144, 803, 809, 815, 828,
+ 834, 840, 1144, 846, 852, 1144, 858, 870, 1144, 877,
+ 883, 889, 896, 919, 926, 933, 940, 946, 1144, 954,
+ 961, 968, 982, 989, 1144, 1144, 1144, 996, 1003, 1009,
+
+ 1017, 1144, 1024, 1034, 1144, 1144, 1077, 1084, 1091, 1098,
+ 1105, 1112, 1119, 1123, 1128, 1130, 1132, 1134, 1136
+ } ;
+
+static const flex_int16_t yy_def[220] =
+ { 0,
+ 206, 1, 207, 207, 1, 5, 5, 5, 5, 5,
+ 206, 206, 206, 206, 208, 209, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206, 210,
+ 206, 206, 206, 211, 208, 206, 208, 208, 208, 208,
+ 212, 208, 208, 208, 208, 208, 208, 208, 209, 206,
+ 206, 206, 206, 206, 206, 213, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 210, 206, 211,
+ 206, 214, 208, 208, 208, 208, 215, 208, 212, 208,
+ 208, 208, 208, 208, 208, 208, 213, 206, 206, 206,
+
+ 206, 206, 206, 206, 206, 216, 208, 208, 208, 208,
+ 215, 206, 212, 208, 208, 208, 208, 208, 208, 208,
+ 206, 206, 206, 206, 206, 206, 206, 217, 208, 208,
+ 206, 206, 212, 208, 208, 208, 208, 208, 208, 208,
+ 206, 206, 206, 218, 206, 208, 212, 208, 208, 208,
+ 208, 208, 208, 206, 208, 206, 219, 208, 208, 208,
+ 208, 208, 208, 208, 208, 206, 208, 208, 208, 208,
+ 208, 208, 206, 208, 208, 206, 208, 208, 206, 208,
+ 208, 208, 208, 208, 208, 208, 208, 208, 206, 208,
+ 208, 208, 208, 208, 206, 206, 206, 208, 208, 208,
+
+ 208, 206, 208, 208, 206, 0, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206
+ } ;
+
+static const flex_int16_t yy_nxt[1204] =
+ { 0,
+ 12, 13, 14, 13, 12, 15, 16, 12, 17, 18,
+ 19, 20, 21, 22, 23, 24, 12, 12, 12, 12,
+ 12, 12, 25, 26, 12, 12, 27, 12, 12, 12,
+ 12, 28, 12, 29, 12, 30, 12, 12, 12, 12,
+ 12, 25, 31, 12, 12, 12, 12, 12, 32, 12,
+ 12, 12, 12, 33, 12, 12, 12, 34, 35, 37,
+ 14, 37, 37, 14, 37, 38, 41, 41, 38, 12,
+ 12, 40, 12, 12, 12, 12, 12, 12, 12, 12,
+ 40, 42, 98, 42, 65, 70, 12, 12, 99, 66,
+ 12, 71, 64, 12, 12, 12, 60, 12, 61, 12,
+
+ 60, 62, 63, 98, 70, 12, 12, 62, 39, 99,
+ 12, 62, 12, 71, 72, 71, 60, 12, 63, 12,
+ 62, 12, 12, 44, 44, 44, 62, 62, 46, 68,
+ 62, 68, 70, 42, 69, 42, 72, 74, 72, 42,
+ 123, 42, 100, 166, 98, 81, 62, 47, 48, 99,
+ 156, 73, 143, 64, 49, 50, 68, 51, 68, 123,
+ 75, 69, 62, 52, 100, 101, 100, 53, 47, 54,
+ 102, 55, 56, 57, 82, 58, 49, 50, 44, 44,
+ 44, 62, 81, 46, 44, 44, 44, 122, 103, 46,
+ 44, 44, 44, 121, 123, 46, 44, 44, 44, 122,
+
+ 141, 46, 112, 127, 44, 44, 44, 112, 122, 46,
+ 106, 82, 51, 126, 83, 121, 85, 105, 51, 141,
+ 125, 44, 44, 44, 51, 86, 46, 44, 44, 44,
+ 51, 121, 46, 104, 69, 85, 83, 141, 51, 84,
+ 69, 44, 44, 44, 86, 88, 46, 43, 79, 44,
+ 44, 44, 45, 124, 46, 51, 142, 77, 44, 44,
+ 44, 51, 90, 46, 44, 44, 44, 76, 67, 46,
+ 43, 44, 44, 44, 45, 51, 46, 91, 45, 206,
+ 64, 206, 45, 51, 60, 60, 61, 63, 45, 62,
+ 92, 45, 51, 45, 89, 62, 62, 93, 51, 44,
+
+ 44, 44, 206, 94, 46, 51, 206, 206, 62, 206,
+ 206, 206, 96, 95, 62, 62, 44, 44, 44, 206,
+ 206, 46, 206, 44, 44, 44, 107, 206, 46, 206,
+ 44, 44, 44, 51, 206, 46, 44, 44, 44, 206,
+ 206, 46, 206, 206, 44, 44, 44, 206, 107, 46,
+ 51, 109, 206, 206, 206, 206, 206, 51, 110, 108,
+ 206, 44, 44, 44, 51, 206, 46, 44, 44, 44,
+ 51, 115, 46, 109, 206, 206, 206, 206, 51, 206,
+ 110, 113, 114, 206, 206, 206, 113, 113, 113, 113,
+ 113, 113, 44, 44, 44, 51, 206, 46, 44, 44,
+
+ 44, 51, 206, 46, 206, 113, 113, 113, 113, 113,
+ 113, 44, 44, 44, 206, 206, 46, 206, 117, 44,
+ 44, 44, 206, 206, 46, 206, 51, 206, 206, 44,
+ 44, 44, 51, 206, 46, 116, 44, 44, 44, 206,
+ 206, 46, 44, 44, 44, 51, 206, 131, 206, 206,
+ 206, 118, 206, 51, 206, 129, 44, 44, 44, 206,
+ 206, 132, 119, 51, 206, 206, 206, 206, 206, 206,
+ 51, 206, 206, 206, 120, 206, 51, 129, 206, 130,
+ 44, 44, 44, 206, 206, 46, 206, 44, 44, 44,
+ 51, 133, 46, 206, 206, 206, 133, 133, 133, 133,
+
+ 133, 133, 44, 44, 44, 206, 206, 46, 44, 44,
+ 44, 206, 206, 46, 51, 133, 133, 133, 133, 133,
+ 133, 51, 206, 206, 135, 44, 44, 44, 206, 206,
+ 46, 206, 206, 206, 134, 137, 51, 206, 44, 44,
+ 44, 206, 51, 46, 206, 136, 44, 44, 44, 206,
+ 206, 46, 44, 44, 44, 206, 206, 145, 138, 51,
+ 44, 44, 44, 206, 206, 46, 44, 44, 44, 206,
+ 206, 46, 51, 206, 44, 44, 44, 206, 206, 46,
+ 51, 206, 206, 44, 44, 44, 51, 140, 46, 206,
+ 206, 139, 206, 206, 51, 206, 206, 206, 206, 206,
+
+ 51, 44, 44, 44, 146, 147, 46, 206, 51, 148,
+ 147, 147, 147, 147, 147, 147, 151, 51, 206, 206,
+ 44, 44, 44, 149, 152, 46, 206, 206, 206, 147,
+ 147, 147, 147, 147, 147, 51, 44, 44, 44, 206,
+ 206, 154, 150, 44, 44, 44, 206, 206, 46, 206,
+ 44, 44, 44, 206, 51, 46, 44, 44, 44, 206,
+ 206, 46, 206, 44, 44, 44, 206, 206, 46, 206,
+ 51, 206, 206, 206, 153, 206, 206, 51, 44, 44,
+ 44, 206, 206, 46, 51, 206, 44, 44, 44, 206,
+ 51, 46, 206, 206, 155, 206, 206, 51, 158, 45,
+
+ 206, 206, 159, 160, 45, 45, 45, 45, 45, 45,
+ 206, 206, 51, 44, 44, 44, 206, 206, 46, 206,
+ 51, 206, 206, 45, 45, 45, 45, 45, 45, 161,
+ 206, 44, 44, 44, 206, 162, 46, 44, 44, 44,
+ 206, 206, 46, 44, 44, 44, 206, 51, 46, 44,
+ 44, 44, 206, 206, 46, 44, 44, 44, 206, 206,
+ 46, 44, 44, 44, 163, 51, 46, 44, 44, 44,
+ 206, 51, 46, 44, 44, 44, 206, 51, 46, 206,
+ 206, 165, 206, 51, 164, 206, 167, 206, 206, 51,
+ 168, 44, 44, 44, 206, 51, 173, 44, 44, 44,
+
+ 206, 51, 46, 44, 44, 44, 169, 51, 176, 44,
+ 44, 44, 206, 170, 46, 44, 44, 44, 171, 206,
+ 46, 206, 172, 206, 206, 51, 206, 174, 44, 44,
+ 44, 51, 206, 179, 44, 44, 44, 51, 206, 46,
+ 44, 44, 44, 51, 206, 46, 44, 44, 44, 51,
+ 175, 46, 44, 44, 44, 206, 178, 46, 44, 44,
+ 44, 206, 51, 46, 177, 206, 206, 206, 51, 206,
+ 44, 44, 44, 206, 51, 46, 206, 44, 44, 44,
+ 51, 180, 46, 44, 44, 44, 51, 206, 46, 44,
+ 44, 44, 51, 181, 46, 182, 44, 44, 44, 184,
+
+ 206, 189, 206, 206, 51, 206, 206, 206, 183, 206,
+ 206, 51, 206, 206, 186, 206, 206, 51, 206, 44,
+ 44, 44, 185, 51, 46, 206, 44, 44, 44, 206,
+ 51, 46, 187, 44, 44, 44, 206, 206, 46, 188,
+ 44, 44, 44, 206, 206, 46, 44, 44, 44, 206,
+ 206, 46, 206, 51, 44, 44, 44, 206, 206, 195,
+ 51, 44, 44, 44, 206, 190, 196, 51, 44, 44,
+ 44, 206, 206, 197, 51, 206, 206, 206, 191, 193,
+ 51, 206, 44, 44, 44, 206, 192, 46, 51, 44,
+ 44, 44, 206, 206, 46, 51, 44, 44, 44, 194,
+
+ 206, 46, 51, 44, 44, 44, 206, 206, 46, 44,
+ 44, 44, 206, 206, 202, 206, 51, 44, 44, 44,
+ 206, 206, 46, 51, 44, 44, 44, 206, 206, 46,
+ 51, 198, 206, 199, 44, 44, 44, 51, 206, 205,
+ 206, 206, 200, 51, 206, 206, 206, 206, 206, 206,
+ 206, 51, 201, 206, 206, 206, 206, 206, 51, 206,
+ 206, 206, 206, 206, 206, 203, 206, 206, 51, 206,
+ 206, 206, 206, 206, 206, 206, 204, 36, 36, 36,
+ 36, 36, 36, 36, 45, 45, 45, 45, 45, 45,
+ 45, 59, 206, 59, 59, 59, 59, 59, 78, 206,
+
+ 78, 206, 78, 78, 78, 80, 80, 80, 80, 80,
+ 80, 80, 87, 87, 87, 87, 87, 87, 87, 97,
+ 206, 97, 97, 97, 97, 97, 80, 80, 206, 80,
+ 111, 111, 111, 111, 111, 128, 128, 144, 144, 157,
+ 157, 80, 80, 11, 206, 206, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
+
+ 206, 206, 206
+ } ;
+
+static const flex_int16_t yy_chk[1204] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
+ 3, 3, 4, 4, 4, 3, 9, 10, 4, 5,
+ 5, 7, 5, 5, 5, 5, 5, 5, 5, 5,
+ 8, 13, 70, 13, 21, 26, 5, 5, 71, 21,
+ 5, 27, 20, 9, 10, 5, 17, 5, 17, 5,
+
+ 19, 20, 19, 70, 26, 5, 5, 17, 5, 71,
+ 7, 19, 5, 27, 28, 32, 22, 5, 22, 8,
+ 20, 5, 5, 15, 15, 15, 17, 22, 15, 25,
+ 19, 25, 31, 37, 25, 37, 28, 32, 33, 42,
+ 100, 42, 72, 156, 73, 44, 22, 15, 15, 74,
+ 143, 31, 127, 60, 15, 15, 62, 15, 62, 100,
+ 33, 62, 60, 15, 72, 73, 75, 15, 15, 15,
+ 74, 15, 15, 15, 44, 15, 15, 15, 45, 45,
+ 45, 60, 80, 45, 47, 47, 47, 99, 75, 47,
+ 48, 48, 48, 98, 103, 48, 49, 49, 49, 102,
+
+ 121, 49, 111, 104, 50, 50, 50, 87, 99, 50,
+ 82, 80, 45, 103, 47, 98, 49, 78, 47, 121,
+ 102, 52, 52, 52, 48, 50, 52, 53, 53, 53,
+ 49, 101, 53, 77, 69, 49, 47, 124, 50, 48,
+ 68, 54, 54, 54, 50, 51, 54, 43, 41, 56,
+ 56, 56, 51, 101, 56, 52, 124, 39, 55, 55,
+ 55, 53, 52, 55, 57, 57, 57, 38, 24, 57,
+ 14, 58, 58, 58, 51, 54, 58, 53, 51, 11,
+ 64, 0, 51, 56, 61, 63, 61, 63, 51, 64,
+ 54, 51, 55, 51, 51, 61, 63, 55, 57, 83,
+
+ 83, 83, 0, 56, 83, 58, 0, 0, 64, 0,
+ 0, 0, 58, 57, 61, 63, 84, 84, 84, 0,
+ 0, 84, 0, 85, 85, 85, 83, 0, 85, 0,
+ 86, 86, 86, 83, 0, 86, 88, 88, 88, 0,
+ 0, 88, 0, 0, 90, 90, 90, 0, 83, 90,
+ 84, 85, 0, 0, 0, 0, 0, 85, 86, 84,
+ 0, 91, 91, 91, 86, 0, 91, 93, 93, 93,
+ 88, 91, 93, 85, 0, 0, 0, 0, 90, 0,
+ 86, 89, 90, 0, 0, 0, 89, 89, 89, 89,
+ 89, 89, 92, 92, 92, 91, 0, 92, 94, 94,
+
+ 94, 93, 0, 94, 0, 89, 89, 89, 89, 89,
+ 89, 95, 95, 95, 0, 0, 95, 0, 93, 96,
+ 96, 96, 0, 0, 96, 0, 92, 0, 0, 107,
+ 107, 107, 94, 0, 107, 92, 108, 108, 108, 0,
+ 0, 108, 109, 109, 109, 95, 0, 109, 0, 0,
+ 0, 94, 0, 96, 0, 107, 110, 110, 110, 0,
+ 0, 110, 95, 107, 0, 0, 0, 0, 0, 0,
+ 108, 0, 0, 0, 96, 0, 109, 107, 0, 108,
+ 114, 114, 114, 0, 0, 114, 0, 115, 115, 115,
+ 110, 113, 115, 0, 0, 0, 113, 113, 113, 113,
+
+ 113, 113, 116, 116, 116, 0, 0, 116, 118, 118,
+ 118, 0, 0, 118, 114, 113, 113, 113, 113, 113,
+ 113, 115, 0, 0, 115, 117, 117, 117, 0, 0,
+ 117, 0, 0, 0, 114, 117, 116, 0, 119, 119,
+ 119, 0, 118, 119, 0, 116, 120, 120, 120, 0,
+ 0, 120, 129, 129, 129, 0, 0, 129, 118, 117,
+ 130, 130, 130, 0, 0, 130, 134, 134, 134, 0,
+ 0, 134, 119, 0, 137, 137, 137, 0, 0, 137,
+ 120, 0, 0, 135, 135, 135, 129, 120, 135, 0,
+ 0, 119, 0, 0, 130, 0, 0, 0, 0, 0,
+
+ 134, 136, 136, 136, 130, 133, 136, 0, 137, 134,
+ 133, 133, 133, 133, 133, 133, 137, 135, 0, 0,
+ 138, 138, 138, 135, 137, 138, 0, 0, 0, 133,
+ 133, 133, 133, 133, 133, 136, 139, 139, 139, 0,
+ 0, 139, 136, 140, 140, 140, 0, 0, 140, 0,
+ 146, 146, 146, 0, 138, 146, 148, 148, 148, 0,
+ 0, 148, 0, 149, 149, 149, 0, 0, 149, 0,
+ 139, 0, 0, 0, 138, 0, 0, 140, 150, 150,
+ 150, 0, 0, 150, 146, 0, 151, 151, 151, 0,
+ 148, 151, 0, 0, 140, 0, 0, 149, 146, 147,
+
+ 0, 0, 148, 149, 147, 147, 147, 147, 147, 147,
+ 0, 0, 150, 152, 152, 152, 0, 0, 152, 0,
+ 151, 0, 0, 147, 147, 147, 147, 147, 147, 150,
+ 0, 153, 153, 153, 0, 151, 153, 155, 155, 155,
+ 0, 0, 155, 158, 158, 158, 0, 152, 158, 159,
+ 159, 159, 0, 0, 159, 160, 160, 160, 0, 0,
+ 160, 161, 161, 161, 152, 153, 161, 162, 162, 162,
+ 0, 155, 162, 163, 163, 163, 0, 158, 163, 0,
+ 0, 155, 0, 159, 153, 0, 158, 0, 0, 160,
+ 159, 164, 164, 164, 0, 161, 164, 165, 165, 165,
+
+ 0, 162, 165, 167, 167, 167, 160, 163, 167, 168,
+ 168, 168, 0, 161, 168, 169, 169, 169, 162, 0,
+ 169, 0, 163, 0, 0, 164, 0, 164, 170, 170,
+ 170, 165, 0, 170, 171, 171, 171, 167, 0, 171,
+ 172, 172, 172, 168, 0, 172, 174, 174, 174, 169,
+ 165, 174, 175, 175, 175, 0, 169, 175, 177, 177,
+ 177, 0, 170, 177, 168, 0, 0, 0, 171, 0,
+ 178, 178, 178, 0, 172, 178, 0, 180, 180, 180,
+ 174, 171, 180, 181, 181, 181, 175, 0, 181, 182,
+ 182, 182, 177, 172, 182, 174, 183, 183, 183, 177,
+
+ 0, 183, 0, 0, 178, 0, 0, 0, 175, 0,
+ 0, 180, 0, 0, 180, 0, 0, 181, 0, 184,
+ 184, 184, 178, 182, 184, 0, 185, 185, 185, 0,
+ 183, 185, 181, 186, 186, 186, 0, 0, 186, 182,
+ 187, 187, 187, 0, 0, 187, 188, 188, 188, 0,
+ 0, 188, 0, 184, 190, 190, 190, 0, 0, 190,
+ 185, 191, 191, 191, 0, 184, 191, 186, 192, 192,
+ 192, 0, 0, 192, 187, 0, 0, 0, 185, 187,
+ 188, 0, 193, 193, 193, 0, 186, 193, 190, 194,
+ 194, 194, 0, 0, 194, 191, 198, 198, 198, 188,
+
+ 0, 198, 192, 199, 199, 199, 0, 0, 199, 200,
+ 200, 200, 0, 0, 200, 0, 193, 201, 201, 201,
+ 0, 0, 201, 194, 203, 203, 203, 0, 0, 203,
+ 198, 193, 0, 194, 204, 204, 204, 199, 0, 204,
+ 0, 0, 198, 200, 0, 0, 0, 0, 0, 0,
+ 0, 201, 199, 0, 0, 0, 0, 0, 203, 0,
+ 0, 0, 0, 0, 0, 201, 0, 0, 204, 0,
+ 0, 0, 0, 0, 0, 0, 203, 207, 207, 207,
+ 207, 207, 207, 207, 208, 208, 208, 208, 208, 208,
+ 208, 209, 0, 209, 209, 209, 209, 209, 210, 0,
+
+ 210, 0, 210, 210, 210, 211, 211, 211, 211, 211,
+ 211, 211, 212, 212, 212, 212, 212, 212, 212, 213,
+ 0, 213, 213, 213, 213, 213, 214, 214, 0, 214,
+ 215, 215, 215, 215, 215, 216, 216, 217, 217, 218,
+ 218, 219, 219, 206, 206, 206, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
+ 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
+
+ 206, 206, 206
+ } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int d2_parser__flex_debug;
+int d2_parser__flex_debug = 1;
+
+static const flex_int16_t yy_rule_linenum[43] =
+ { 0,
+ 115, 117, 119, 124, 125, 130, 131, 132, 144, 147,
+ 152, 158, 167, 176, 185, 194, 204, 214, 224, 233,
+ 242, 251, 260, 269, 278, 376, 381, 386, 391, 392,
+ 393, 394, 395, 396, 398, 416, 429, 434, 438, 440,
+ 442, 444
+ } ;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *d2_parser_text;
+#line 1 "d2_lexer.ll"
+/* Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#line 8 "d2_lexer.ll"
+#include <cerrno>
+#include <climits>
+#include <cstdlib>
+#include <string>
+#include <d2/parser_context.h>
+#include <asiolink/io_address.h>
+#include <boost/lexical_cast.hpp>
+#include <exceptions/exceptions.h>
+
+// Work around an incompatibility in flex (at least versions
+// 2.5.31 through 2.5.33): it generates code that does
+// not conform to C89. See Debian bug 333231
+// <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>.
+# undef yywrap
+# define yywrap() 1
+
+namespace {
+
+bool start_token_flag = false;
+
+isc::dhcp::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)
+#line 992 "d2_lexer.cc"
+/* noyywrap disables automatic rewinding for the next file to parse. Since we
+ always parse only a single string, there's no need to do any wraps. And
+ using yywrap requires linking with -lfl, which provides the default yywrap
+ implementation that always returns 1 anyway. */
+/* nounput simplifies the lexer, by removing support for putting a character
+ back into the input stream. We never use such capability anyway. */
+/* batch means that we'll never use the generated lexer interactively. */
+/* avoid to get static global variables to remain with C++. */
+/* in last resort %option reentrant */
+/* Enables debug mode. To see the debug messages, one needs to also set
+ yy_flex_debug to 1, then the debug messages will be printed on stderr. */
+/* I have no idea what this option does, except it was specified in the bison
+ examples and Postgres folks added it to remove gcc 4.3 warnings. Let's
+ be on the safe side and keep it. */
+#define YY_NO_INPUT 1
+
+/* These are not token expressions yet, just convenience expressions that
+ can be used during actual token definitions. Note some can match
+ incorrect inputs (e.g., IP addresses) which must be checked. */
+/* for errors */
+#line 86 "d2_lexer.ll"
+// This code run each time a pattern is matched. It updates the location
+// by moving it ahead by yyleng bytes. yyleng specifies the length of the
+// currently matched token.
+#define YY_USER_ACTION driver.loc_.columns(yyleng);
+#line 1018 "d2_lexer.cc"
+#line 1019 "d2_lexer.cc"
+
+#define INITIAL 0
+#define COMMENT 1
+#define DIR_ENTER 2
+#define DIR_INCLUDE 3
+#define DIR_EXIT 4
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+/* %if-c-only */
+#include <unistd.h>
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+/* %if-c-only Reentrant structure and macros (non-C++). */
+/* %if-reentrant */
+/* %if-c-only */
+
+static int yy_init_globals ( void );
+
+/* %endif */
+/* %if-reentrant */
+/* %endif */
+/* %endif End reentrant structures and macros. */
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int d2_parser_lex_destroy ( void );
+
+int d2_parser_get_debug ( void );
+
+void d2_parser_set_debug ( int debug_flag );
+
+YY_EXTRA_TYPE d2_parser_get_extra ( void );
+
+void d2_parser_set_extra ( YY_EXTRA_TYPE user_defined );
+
+FILE *d2_parser_get_in ( void );
+
+void d2_parser_set_in ( FILE * _in_str );
+
+FILE *d2_parser_get_out ( void );
+
+void d2_parser_set_out ( FILE * _out_str );
+
+ int d2_parser_get_leng ( void );
+
+char *d2_parser_get_text ( void );
+
+int d2_parser_get_lineno ( void );
+
+void d2_parser_set_lineno ( int _line_number );
+
+/* %if-bison-bridge */
+/* %endif */
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int d2_parser_wrap ( void );
+#else
+extern int d2_parser_wrap ( void );
+#endif
+#endif
+
+/* %not-for-header */
+#ifndef YY_NO_UNPUT
+
+#endif
+/* %ok-for-header */
+
+/* %endif */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy ( char *, const char *, int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen ( const char * );
+#endif
+
+#ifndef YY_NO_INPUT
+/* %if-c-only Standard (non-C++) definition */
+/* %not-for-header */
+#ifdef __cplusplus
+static int yyinput ( void );
+#else
+static int input ( void );
+#endif
+/* %ok-for-header */
+
+/* %endif */
+#endif
+
+/* %if-c-only */
+
+/* %endif */
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* %if-c-only Standard (non-C++) definition */
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( d2_parser_text, (size_t) d2_parser_leng, 1, d2_parser_out )) {} } while (0)
+/* %endif */
+/* %if-c++-only C++ definition */
+/* %endif */
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ int n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( d2_parser_in )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( d2_parser_in ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, d2_parser_in)) == 0 && ferror(d2_parser_in)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(d2_parser_in); \
+ } \
+ }\
+\
+/* %if-c++-only C++ definition \ */\
+/* %endif */
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+/* %if-c-only */
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+#endif
+
+/* %if-tables-serialization structures and prototypes */
+/* %not-for-header */
+/* %ok-for-header */
+
+/* %not-for-header */
+/* %tables-yydmap generated elements */
+/* %endif */
+/* end tables serialization structures and prototypes */
+
+/* %ok-for-header */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+/* %if-c-only Standard (non-C++) definition */
+
+extern int d2_parser_lex (void);
+
+#define YY_DECL int d2_parser_lex (void)
+/* %endif */
+/* %if-c++-only C++ definition */
+/* %endif */
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after d2_parser_text and d2_parser_leng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK /*LINTED*/break;
+#endif
+
+/* %% [6.0] YY_RULE_SETUP definition goes here */
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+/* %not-for-header */
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ yy_state_type yy_current_state;
+ char *yy_cp, *yy_bp;
+ int yy_act;
+
+ if ( !(yy_init) )
+ {
+ (yy_init) = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
+
+ if ( ! d2_parser_in )
+/* %if-c-only */
+ d2_parser_in = stdin;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+ if ( ! d2_parser_out )
+/* %if-c-only */
+ d2_parser_out = stdout;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ d2_parser_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ d2_parser__create_buffer(d2_parser_in,YY_BUF_SIZE );
+ }
+
+ d2_parser__load_buffer_state( );
+ }
+
+ {
+/* %% [7.0] user's declarations go here */
+#line 92 "d2_lexer.ll"
+
+
+
+#line 96 "d2_lexer.ll"
+ // This part of the code is copied over to the verbatim to the top
+ // of the generated yylex function. Explanation:
+ // http://www.gnu.org/software/bison/manual/html_node/Multiple-start_002dsymbols.html
+
+ // Code run each time yylex is called.
+ driver.loc_.step();
+
+ if (start_token_flag) {
+ start_token_flag = false;
+ switch (start_token_value) {
+ case D2ParserContext::PARSER_JSON:
+ default:
+ return isc::dhcp::D2Parser::make_TOPLEVEL_JSON(driver.loc_);
+ case D2ParserContext::PARSER_DHCPDDNS:
+ return isc::dhcp::D2Parser::make_TOPLEVEL_DHCPDDNS(driver.loc_);
+ }
+ }
+
+
+#line 1325 "d2_lexer.cc"
+
+ while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
+ {
+/* %% [8.0] yymore()-related code goes here */
+ yy_cp = (yy_c_buf_p);
+
+ /* Support of d2_parser_text. */
+ *yy_cp = (yy_hold_char);
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+/* %% [9.0] code to set up and find next match goes here */
+ yy_current_state = (yy_start);
+yy_match:
+ do
+ {
+ YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 207 )
+ yy_c = yy_meta[yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+ ++yy_cp;
+ }
+ while ( yy_current_state != 206 );
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+
+yy_find_action:
+/* %% [10.0] code to find the action number goes here */
+ yy_act = yy_accept[yy_current_state];
+
+ YY_DO_BEFORE_ACTION;
+
+/* %% [11.0] code for d2_parser_lineno update goes here */
+
+do_action: /* This label is used only to access EOF actions. */
+
+/* %% [12.0] debug code goes here */
+ if ( d2_parser__flex_debug )
+ {
+ if ( yy_act == 0 )
+ fprintf( stderr, "--scanner backing up\n" );
+ else if ( yy_act < 43 )
+ fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
+ (long)yy_rule_linenum[yy_act], d2_parser_text );
+ else if ( yy_act == 43 )
+ fprintf( stderr, "--accepting default rule (\"%s\")\n",
+ d2_parser_text );
+ else if ( yy_act == 44 )
+ fprintf( stderr, "--(end of buffer or a NUL)\n" );
+ else
+ fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
+ }
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+/* %% [13.0] actions go here */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 115 "d2_lexer.ll"
+;
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 117 "d2_lexer.ll"
+;
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 119 "d2_lexer.ll"
+{
+ BEGIN(COMMENT);
+ comment_start_line = driver.loc_.end.line;;
+}
+ YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 124 "d2_lexer.ll"
+BEGIN(INITIAL);
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 125 "d2_lexer.ll"
+;
+ YY_BREAK
+case YY_STATE_EOF(COMMENT):
+#line 126 "d2_lexer.ll"
+{
+ isc_throw(D2ParseError, "Comment not closed. (/* in line " << comment_start_line);
+}
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 130 "d2_lexer.ll"
+BEGIN(DIR_ENTER);
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 131 "d2_lexer.ll"
+BEGIN(DIR_INCLUDE);
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 132 "d2_lexer.ll"
+{
+ // Include directive.
+
+ // Extract the filename.
+ std::string tmp(yytext+1);
+ tmp.resize(tmp.size() - 1);
+
+ driver.includeFile(tmp);
+}
+ YY_BREAK
+case YY_STATE_EOF(DIR_ENTER):
+case YY_STATE_EOF(DIR_INCLUDE):
+case YY_STATE_EOF(DIR_EXIT):
+#line 141 "d2_lexer.ll"
+{
+ isc_throw(D2ParseError, "Directive not closed.");
+}
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 144 "d2_lexer.ll"
+BEGIN(INITIAL);
+ YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 147 "d2_lexer.ll"
+{
+ // Ok, we found a with space. Let's ignore it and update loc variable.
+ driver.loc_.step();
+}
+ YY_BREAK
+case 11:
+/* rule 11 can match eol */
+YY_RULE_SETUP
+#line 152 "d2_lexer.ll"
+{
+ // Newline found. Let's update the location and continue.
+ driver.loc_.lines(yyleng);
+ driver.loc_.step();
+}
+ YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 158 "d2_lexer.ll"
+{
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::DHCPDDNS:
+ return isc::dhcp::D2Parser::make_IP_ADDRESS(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("ip-address", driver.loc_);
+ }
+}
+ YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 167 "d2_lexer.ll"
+{
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::DHCPDDNS:
+ return isc::dhcp::D2Parser::make_PORT(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("port", driver.loc_);
+ }
+}
+ YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 176 "d2_lexer.ll"
+{
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::DHCPDDNS:
+ return isc::dhcp::D2Parser::make_NCR_PROTOCOL(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("ncr-protocol", driver.loc_);
+ }
+}
+ YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 185 "d2_lexer.ll"
+{
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::DHCPDDNS:
+ return isc::dhcp::D2Parser::make_NCR_FORMAT(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("ncr-format", driver.loc_);
+ }
+}
+ YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 194 "d2_lexer.ll"
+{
+ /* dhcp-ddns value keywords are case insensitive */
+ if (driver.ctx_ == isc::dhcp::D2ParserContext::NCR_PROTOCOL) {
+ return isc::dhcp::D2Parser::make_UDP(driver.loc_);
+ }
+ std::string tmp(yytext+1);
+ tmp.resize(tmp.size() - 1);
+ return isc::dhcp::D2Parser::make_STRING(tmp, driver.loc_);
+}
+ YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 204 "d2_lexer.ll"
+{
+ /* dhcp-ddns value keywords are case insensitive */
+ if (driver.ctx_ == isc::dhcp::D2ParserContext::NCR_PROTOCOL) {
+ return isc::dhcp::D2Parser::make_TCP(driver.loc_);
+ }
+ std::string tmp(yytext+1);
+ tmp.resize(tmp.size() - 1);
+ return isc::dhcp::D2Parser::make_STRING(tmp, driver.loc_);
+}
+ YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 214 "d2_lexer.ll"
+{
+ /* dhcp-ddns value keywords are case insensitive */
+ if (driver.ctx_ == isc::dhcp::D2ParserContext::NCR_FORMAT) {
+ return isc::dhcp::D2Parser::make_JSON(driver.loc_);
+ }
+ std::string tmp(yytext+1);
+ tmp.resize(tmp.size() - 1);
+ return isc::dhcp::D2Parser::make_STRING(tmp, driver.loc_);
+}
+ YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 224 "d2_lexer.ll"
+{
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::CONFIG:
+ return isc::dhcp::D2Parser::make_LOGGING(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("Logging", driver.loc_);
+ }
+}
+ YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 233 "d2_lexer.ll"
+{
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::LOGGING:
+ return isc::dhcp::D2Parser::make_LOGGERS(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("loggers", driver.loc_);
+ }
+}
+ YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 242 "d2_lexer.ll"
+{
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::LOGGERS:
+ return isc::dhcp::D2Parser::make_OUTPUT_OPTIONS(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("output_options", driver.loc_);
+ }
+}
+ YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 251 "d2_lexer.ll"
+{
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::OUTPUT_OPTIONS:
+ return isc::dhcp::D2Parser::make_OUTPUT(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("output", driver.loc_);
+ }
+}
+ YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 260 "d2_lexer.ll"
+{
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::LOGGERS:
+ return isc::dhcp::D2Parser::make_DEBUGLEVEL(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("debuglevel", driver.loc_);
+ }
+}
+ YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 269 "d2_lexer.ll"
+{
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::LOGGERS:
+ return isc::dhcp::D2Parser::make_SEVERITY(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("severity", driver.loc_);
+ }
+}
+ YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 278 "d2_lexer.ll"
+{
+ // 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.
+ // for 'foo' we should get foo
+ std::string raw(yytext+1);
+ size_t len = raw.size() - 1;
+ raw.resize(len);
+ std::string decoded;
+ decoded.reserve(len);
+ for (size_t pos = 0; pos < len; ++pos) {
+ int b = 0;
+ char c = raw[pos];
+ switch (c) {
+ case '"':
+ // impossible condition
+ driver.error(driver.loc_, "Bad quote in \"" + raw + "\"");
+ case '\\':
+ ++pos;
+ if (pos >= len) {
+ // impossible condition
+ driver.error(driver.loc_, "Overflow escape in \"" + raw + "\"");
+ }
+ c = raw[pos];
+ switch (c) {
+ case '"':
+ case '\\':
+ case '/':
+ decoded.push_back(c);
+ break;
+ case 'b':
+ decoded.push_back('\b');
+ break;
+ case 'f':
+ decoded.push_back('\f');
+ break;
+ case 'n':
+ decoded.push_back('\n');
+ break;
+ case 'r':
+ decoded.push_back('\r');
+ break;
+ case 't':
+ decoded.push_back('\t');
+ break;
+ case 'u':
+ // support only \u0000 to \u00ff
+ ++pos;
+ if (pos + 4 > len) {
+ // impossible condition
+ driver.error(driver.loc_,
+ "Overflow unicode escape in \"" + raw + "\"");
+ }
+ if ((raw[pos] != '0') || (raw[pos + 1] != '0')) {
+ driver.error(driver.loc_, "Unsupported unicode escape in \"" + raw + "\"");
+ }
+ pos += 2;
+ c = raw[pos];
+ if ((c >= '0') && (c <= '9')) {
+ b = (c - '0') << 4;
+ } else if ((c >= 'A') && (c <= 'F')) {
+ b = (c - 'A' + 10) << 4;
+ } else if ((c >= 'a') && (c <= 'f')) {
+ b = (c - 'a' + 10) << 4;
+ } else {
+ // impossible condition
+ driver.error(driver.loc_, "Not hexadecimal in unicode escape in \"" + raw + "\"");
+ }
+ pos++;
+ c = raw[pos];
+ if ((c >= '0') && (c <= '9')) {
+ b |= c - '0';
+ } else if ((c >= 'A') && (c <= 'F')) {
+ b |= c - 'A' + 10;
+ } else if ((c >= 'a') && (c <= 'f')) {
+ b |= c - 'a' + 10;
+ } else {
+ // impossible condition
+ driver.error(driver.loc_, "Not hexadecimal in unicode escape in \"" + raw + "\"");
+ }
+ decoded.push_back(static_cast<char>(b & 0xff));
+ break;
+ default:
+ // impossible condition
+ driver.error(driver.loc_, "Bad escape in \"" + raw + "\"");
+ }
+ break;
+ default:
+ if ((c >= 0) && (c < 0x20)) {
+ // impossible condition
+ driver.error(driver.loc_, "Invalid control in \"" + raw + "\"");
+ }
+ decoded.push_back(c);
+ }
+ }
+
+ return isc::dhcp::D2Parser::make_STRING(decoded, driver.loc_);
+}
+ YY_BREAK
+case 26:
+/* rule 26 can match eol */
+YY_RULE_SETUP
+#line 376 "d2_lexer.ll"
+{
+ // Bad string with a forbidden control character inside
+ driver.error(driver.loc_, "Invalid control in " + std::string(yytext));
+}
+ YY_BREAK
+case 27:
+/* rule 27 can match eol */
+YY_RULE_SETUP
+#line 381 "d2_lexer.ll"
+{
+ // Bad string with a bad escape inside
+ driver.error(driver.loc_, "Bad escape in " + std::string(yytext));
+}
+ YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 386 "d2_lexer.ll"
+{
+ // Bad string with an open escape at the end
+ driver.error(driver.loc_, "Overflow escape in " + std::string(yytext));
+}
+ YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 391 "d2_lexer.ll"
+{ return isc::dhcp::D2Parser::make_LSQUARE_BRACKET(driver.loc_); }
+ YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 392 "d2_lexer.ll"
+{ return isc::dhcp::D2Parser::make_RSQUARE_BRACKET(driver.loc_); }
+ YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 393 "d2_lexer.ll"
+{ return isc::dhcp::D2Parser::make_LCURLY_BRACKET(driver.loc_); }
+ YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 394 "d2_lexer.ll"
+{ return isc::dhcp::D2Parser::make_RCURLY_BRACKET(driver.loc_); }
+ YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 395 "d2_lexer.ll"
+{ return isc::dhcp::D2Parser::make_COMMA(driver.loc_); }
+ YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 396 "d2_lexer.ll"
+{ return isc::dhcp::D2Parser::make_COLON(driver.loc_); }
+ YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 398 "d2_lexer.ll"
+{
+ // An integer was found.
+ std::string tmp(yytext);
+ int64_t integer = 0;
+ try {
+ // In substring we want to use negative values (e.g. -1).
+ // In enterprise-id we need to use values up to 0xffffffff.
+ // To cover both of those use cases, we need at least
+ // int64_t.
+ integer = boost::lexical_cast<int64_t>(tmp);
+ } catch (const boost::bad_lexical_cast &) {
+ driver.error(driver.loc_, "Failed to convert " + tmp + " to an integer.");
+ }
+
+ // The parser needs the string form as double conversion is no lossless
+ return isc::dhcp::D2Parser::make_INTEGER(integer, driver.loc_);
+}
+ YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 416 "d2_lexer.ll"
+{
+ // A floating point was found.
+ std::string tmp(yytext);
+ double fp = 0.0;
+ try {
+ fp = boost::lexical_cast<double>(tmp);
+ } catch (const boost::bad_lexical_cast &) {
+ driver.error(driver.loc_, "Failed to convert " + tmp + " to a floating point.");
+ }
+
+ return isc::dhcp::D2Parser::make_FLOAT(fp, driver.loc_);
+}
+ YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 429 "d2_lexer.ll"
+{
+ string tmp(yytext);
+ return isc::dhcp::D2Parser::make_BOOLEAN(tmp == "true", driver.loc_);
+}
+ YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 434 "d2_lexer.ll"
+{
+ return isc::dhcp::D2Parser::make_NULL_TYPE(driver.loc_);
+}
+ YY_BREAK
+case 39:
+YY_RULE_SETUP
+#line 438 "d2_lexer.ll"
+driver.error (driver.loc_, "JSON true reserved keyword is lower case only");
+ YY_BREAK
+case 40:
+YY_RULE_SETUP
+#line 440 "d2_lexer.ll"
+driver.error (driver.loc_, "JSON false reserved keyword is lower case only");
+ YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 442 "d2_lexer.ll"
+driver.error (driver.loc_, "JSON null reserved keyword is lower case only");
+ YY_BREAK
+case 42:
+YY_RULE_SETUP
+#line 444 "d2_lexer.ll"
+driver.error (driver.loc_, "Invalid character: " + std::string(yytext));
+ YY_BREAK
+case YY_STATE_EOF(INITIAL):
+#line 446 "d2_lexer.ll"
+{
+ if (driver.states_.empty()) {
+ return isc::dhcp::D2Parser::make_END(driver.loc_);
+ }
+ driver.loc_ = driver.locs_.back();
+ driver.locs_.pop_back();
+ driver.file_ = driver.files_.back();
+ driver.files_.pop_back();
+ if (driver.sfile_) {
+ fclose(driver.sfile_);
+ driver.sfile_ = 0;
+ }
+ if (!driver.sfiles_.empty()) {
+ driver.sfile_ = driver.sfiles_.back();
+ driver.sfiles_.pop_back();
+ }
+ d2_parser__delete_buffer(YY_CURRENT_BUFFER);
+ d2_parser__switch_to_buffer(driver.states_.back());
+ driver.states_.pop_back();
+
+ BEGIN(DIR_EXIT);
+}
+ YY_BREAK
+case 43:
+YY_RULE_SETUP
+#line 469 "d2_lexer.ll"
+ECHO;
+ YY_BREAK
+#line 1907 "d2_lexer.cc"
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = (yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed d2_parser_in at a new source and called
+ * d2_parser_lex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+/* %if-c-only */
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = d2_parser_in;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ (yy_did_buffer_switch_on_eof) = 0;
+
+ if ( d2_parser_wrap( ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * d2_parser_text, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+ } /* end of user's declarations */
+} /* end of d2_parser_lex */
+/* %ok-for-header */
+
+/* %if-c++-only */
+/* %not-for-header */
+/* %ok-for-header */
+
+/* %endif */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+/* %if-c-only */
+static int yy_get_next_buffer (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+ char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ char *source = (yytext_ptr);
+ int number_to_move, i;
+ int ret_val;
+
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
+
+ int yy_c_buf_p_offset =
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ d2_parser_realloc((void *) b->yy_ch_buf,(yy_size_t) (b->yy_buf_size + 2) );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = NULL;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ (yy_n_chars), num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ if ( (yy_n_chars) == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ d2_parser_restart(d2_parser_in );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) d2_parser_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,(yy_size_t) new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
+ (yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+/* %if-c-only */
+/* %not-for-header */
+ static yy_state_type yy_get_previous_state (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+ yy_state_type yy_current_state;
+ char *yy_cp;
+
+/* %% [15.0] code to get the start state into yy_current_state goes here */
+ yy_current_state = (yy_start);
+
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+ {
+/* %% [16.0] code to find the next state goes here */
+ YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 207 )
+ yy_c = yy_meta[yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+/* %if-c-only */
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+ int yy_is_jam;
+ /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
+ char *yy_cp = (yy_c_buf_p);
+
+ YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 207 )
+ yy_c = yy_meta[yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+ yy_is_jam = (yy_current_state == 206);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_UNPUT
+/* %if-c-only */
+
+/* %endif */
+#endif
+
+/* %if-c-only */
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (void)
+#else
+ static int input (void)
+#endif
+
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
+
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ /* This was really a NUL. */
+ *(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
+ ++(yy_c_buf_p);
+
+ switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ d2_parser_restart(d2_parser_in );
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( d2_parser_wrap( ) )
+ return 0;
+
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) = (yytext_ptr) + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
+ *(yy_c_buf_p) = '\0'; /* preserve d2_parser_text */
+ (yy_hold_char) = *++(yy_c_buf_p);
+
+/* %% [19.0] update BOL and d2_parser_lineno */
+
+ return c;
+}
+/* %if-c-only */
+#endif /* ifndef YY_NO_INPUT */
+/* %endif */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+/* %if-c-only */
+ void d2_parser_restart (FILE * input_file )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ d2_parser_ensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ d2_parser__create_buffer(d2_parser_in,YY_BUF_SIZE );
+ }
+
+ d2_parser__init_buffer(YY_CURRENT_BUFFER,input_file );
+ d2_parser__load_buffer_state( );
+}
+
+/* %if-c++-only */
+/* %endif */
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+/* %if-c-only */
+ void d2_parser__switch_to_buffer (YY_BUFFER_STATE new_buffer )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * d2_parser_pop_buffer_state();
+ * d2_parser_push_buffer_state(new_buffer);
+ */
+ d2_parser_ensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ d2_parser__load_buffer_state( );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (d2_parser_wrap()) processing, but the only time this flag
+ * is looked at is after d2_parser_wrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/* %if-c-only */
+static void d2_parser__load_buffer_state (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+/* %if-c-only */
+ d2_parser_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+ (yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+/* %if-c-only */
+ YY_BUFFER_STATE d2_parser__create_buffer (FILE * file, int size )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) d2_parser_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in d2_parser__create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) d2_parser_alloc((yy_size_t) (b->yy_buf_size + 2) );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in d2_parser__create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ d2_parser__init_buffer(b,file );
+
+ return b;
+}
+
+/* %if-c++-only */
+/* %endif */
+
+/** Destroy the buffer.
+ * @param b a buffer created with d2_parser__create_buffer()
+ *
+ */
+/* %if-c-only */
+ void d2_parser__delete_buffer (YY_BUFFER_STATE b )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ d2_parser_free((void *) b->yy_ch_buf );
+
+ d2_parser_free((void *) b );
+}
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a d2_parser_restart() or at EOF.
+ */
+/* %if-c-only */
+ static void d2_parser__init_buffer (YY_BUFFER_STATE b, FILE * file )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+{
+ int oerrno = errno;
+
+ d2_parser__flush_buffer(b );
+
+/* %if-c-only */
+ b->yy_input_file = file;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then d2_parser__init_buffer was _probably_
+ * called from d2_parser_restart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+/* %if-c-only */
+
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+/* %if-c-only */
+ void d2_parser__flush_buffer (YY_BUFFER_STATE b )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ d2_parser__load_buffer_state( );
+}
+
+/* %if-c-or-c++ */
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+/* %if-c-only */
+void d2_parser_push_buffer_state (YY_BUFFER_STATE new_buffer )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+ if (new_buffer == NULL)
+ return;
+
+ d2_parser_ensure_buffer_stack();
+
+ /* This block is copied from d2_parser__switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from d2_parser__switch_to_buffer. */
+ d2_parser__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+/* %endif */
+
+/* %if-c-or-c++ */
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+/* %if-c-only */
+void d2_parser_pop_buffer_state (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ d2_parser__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ d2_parser__load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+/* %endif */
+
+/* %if-c-or-c++ */
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+/* %if-c-only */
+static void d2_parser_ensure_buffer_stack (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+ yy_size_t num_to_alloc;
+
+ if (!(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
+ (yy_buffer_stack) = (struct yy_buffer_state**)d2_parser_alloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in d2_parser_ensure_buffer_stack()" );
+
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ (yy_buffer_stack_max) = num_to_alloc;
+ (yy_buffer_stack_top) = 0;
+ return;
+ }
+
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ yy_size_t grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
+ (yy_buffer_stack) = (struct yy_buffer_state**)d2_parser_realloc
+ ((yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in d2_parser_ensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ (yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+/* %endif */
+
+/* %if-c-only */
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE d2_parser__scan_buffer (char * base, yy_size_t size )
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return NULL;
+
+ b = (YY_BUFFER_STATE) d2_parser_alloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in d2_parser__scan_buffer()" );
+
+ b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = NULL;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ d2_parser__switch_to_buffer(b );
+
+ return b;
+}
+/* %endif */
+
+/* %if-c-only */
+/** Setup the input buffer state to scan a string. The next call to d2_parser_lex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ *
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * d2_parser__scan_bytes() instead.
+ */
+YY_BUFFER_STATE d2_parser__scan_string (const char * yystr )
+{
+
+ return d2_parser__scan_bytes(yystr,(int) strlen(yystr) );
+}
+/* %endif */
+
+/* %if-c-only */
+/** Setup the input buffer state to scan the given bytes. The next call to d2_parser_lex() will
+ * scan from a @e copy of @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE d2_parser__scan_bytes (const char * yybytes, int _yybytes_len )
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = (yy_size_t) (_yybytes_len + 2);
+ buf = (char *) d2_parser_alloc(n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in d2_parser__scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = d2_parser__scan_buffer(buf,n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in d2_parser__scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+/* %endif */
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+/* %if-c-only */
+static void yynoreturn yy_fatal_error (const char* msg )
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up d2_parser_text. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ d2_parser_text[d2_parser_leng] = (yy_hold_char); \
+ (yy_c_buf_p) = d2_parser_text + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ d2_parser_leng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/* %if-c-only */
+/* %if-reentrant */
+/* %endif */
+
+/** Get the current line number.
+ *
+ */
+int d2_parser_get_lineno (void)
+{
+
+ return d2_parser_lineno;
+}
+
+/** Get the input stream.
+ *
+ */
+FILE *d2_parser_get_in (void)
+{
+ return d2_parser_in;
+}
+
+/** Get the output stream.
+ *
+ */
+FILE *d2_parser_get_out (void)
+{
+ return d2_parser_out;
+}
+
+/** Get the length of the current token.
+ *
+ */
+int d2_parser_get_leng (void)
+{
+ return d2_parser_leng;
+}
+
+/** Get the current token.
+ *
+ */
+
+char *d2_parser_get_text (void)
+{
+ return d2_parser_text;
+}
+
+/* %if-reentrant */
+/* %endif */
+
+/** Set the current line number.
+ * @param _line_number line number
+ *
+ */
+void d2_parser_set_lineno (int _line_number )
+{
+
+ d2_parser_lineno = _line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param _in_str A readable stream.
+ *
+ * @see d2_parser__switch_to_buffer
+ */
+void d2_parser_set_in (FILE * _in_str )
+{
+ d2_parser_in = _in_str ;
+}
+
+void d2_parser_set_out (FILE * _out_str )
+{
+ d2_parser_out = _out_str ;
+}
+
+int d2_parser_get_debug (void)
+{
+ return d2_parser__flex_debug;
+}
+
+void d2_parser_set_debug (int _bdebug )
+{
+ d2_parser__flex_debug = _bdebug ;
+}
+
+/* %endif */
+
+/* %if-reentrant */
+/* %if-bison-bridge */
+/* %endif */
+/* %endif if-c-only */
+
+/* %if-c-only */
+static int yy_init_globals (void)
+{
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from d2_parser_lex_destroy(), so don't allocate here.
+ */
+
+ (yy_buffer_stack) = NULL;
+ (yy_buffer_stack_top) = 0;
+ (yy_buffer_stack_max) = 0;
+ (yy_c_buf_p) = NULL;
+ (yy_init) = 0;
+ (yy_start) = 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ d2_parser_in = stdin;
+ d2_parser_out = stdout;
+#else
+ d2_parser_in = NULL;
+ d2_parser_out = NULL;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * d2_parser_lex_init()
+ */
+ return 0;
+}
+/* %endif */
+
+/* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */
+/* d2_parser_lex_destroy is for both reentrant and non-reentrant scanners. */
+int d2_parser_lex_destroy (void)
+{
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ d2_parser__delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ d2_parser_pop_buffer_state();
+ }
+
+ /* Destroy the stack itself. */
+ d2_parser_free((yy_buffer_stack) );
+ (yy_buffer_stack) = NULL;
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * d2_parser_lex() is called, initialization will occur. */
+ yy_init_globals( );
+
+/* %if-reentrant */
+/* %endif */
+ return 0;
+}
+/* %endif */
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, const char * s2, int n )
+{
+
+ int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (const char * s )
+{
+ int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *d2_parser_alloc (yy_size_t size )
+{
+ return malloc(size);
+}
+
+void *d2_parser_realloc (void * ptr, yy_size_t size )
+{
+
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return realloc(ptr, size);
+}
+
+void d2_parser_free (void * ptr )
+{
+ free( (char *) ptr ); /* see d2_parser_realloc() for (char *) cast */
+}
+
+/* %if-tables-serialization definitions */
+/* %define-yytables The name for this specific scanner's tables. */
+#define YYTABLES_NAME "yytables"
+/* %endif */
+
+/* %ok-for-header */
+
+#line 469 "d2_lexer.ll"
+
+
+using namespace isc::dhcp;
+
+void
+D2ParserContext::scanStringBegin(const std::string& str, ParserType parser_type)
+{
+ start_token_flag = true;
+ start_token_value = parser_type;
+
+ file_ = "<string>";
+ sfile_ = 0;
+ loc_.initialize(&file_);
+ yy_flex_debug = trace_scanning_;
+ YY_BUFFER_STATE buffer;
+ buffer = yy_scan_bytes(str.c_str(), str.size());
+ if (!buffer) {
+ fatal("cannot scan string");
+ // fatal() throws an exception so this can't be reached
+ }
+}
+
+void
+D2ParserContext::scanFileBegin(FILE * f,
+ const std::string& filename,
+ ParserType parser_type)
+{
+ start_token_flag = true;
+ start_token_value = parser_type;
+
+ file_ = filename;
+ sfile_ = f;
+ loc_.initialize(&file_);
+ yy_flex_debug = trace_scanning_;
+ YY_BUFFER_STATE buffer;
+
+ // See d2_lexer.cc header for available definitions
+ buffer = d2_parser__create_buffer(f, 65536 /*buffer size*/);
+ if (!buffer) {
+ fatal("cannot scan file " + filename);
+ }
+ d2_parser__switch_to_buffer(buffer);
+}
+
+void
+D2ParserContext::scanEnd() {
+ if (sfile_)
+ fclose(sfile_);
+ sfile_ = 0;
+ static_cast<void>(d2_parser_lex_destroy());
+ // Close files
+ while (!sfiles_.empty()) {
+ FILE* f = sfiles_.back();
+ if (f) {
+ fclose(f);
+ }
+ sfiles_.pop_back();
+ }
+ // Delete states
+ while (!states_.empty()) {
+ d2_parser__delete_buffer(states_.back());
+ states_.pop_back();
+ }
+}
+
+void
+D2ParserContext::includeFile(const std::string& filename) {
+ if (states_.size() > 10) {
+ fatal("Too many nested include.");
+ }
+
+ FILE* f = fopen(filename.c_str(), "r");
+ if (!f) {
+ fatal("Can't open include file " + filename);
+ }
+ if (sfile_) {
+ sfiles_.push_back(sfile_);
+ }
+ sfile_ = f;
+ states_.push_back(YY_CURRENT_BUFFER);
+ YY_BUFFER_STATE buffer;
+ buffer = d2_parser__create_buffer(f, 65536 /*buffer size*/);
+ if (!buffer) {
+ fatal( "Can't scan include file " + filename);
+ }
+ d2_parser__switch_to_buffer(buffer);
+ files_.push_back(file_);
+ file_ = filename;
+ locs_.push_back(loc_);
+ loc_.initialize(&file_);
+
+ BEGIN(INITIAL);
+}
+
+namespace {
+/// To avoid unused function error
+class Dummy {
+ // cppcheck-suppress unusedPrivateFunction
+ void dummy() { yy_fatal_error("Fix me: how to disable its definition?"); }
+};
+}
+
--- /dev/null
+/* Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+%{ /* -*- C++ -*- */
+#include <cerrno>
+#include <climits>
+#include <cstdlib>
+#include <string>
+#include <d2/parser_context.h>
+#include <asiolink/io_address.h>
+#include <boost/lexical_cast.hpp>
+#include <exceptions/exceptions.h>
+
+// Work around an incompatibility in flex (at least versions
+// 2.5.31 through 2.5.33): it generates code that does
+// not conform to C89. See Debian bug 333231
+// <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>.
+# undef yywrap
+# define yywrap() 1
+
+namespace {
+
+bool start_token_flag = false;
+
+isc::dhcp::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)
+%}
+
+/* noyywrap disables automatic rewinding for the next file to parse. Since we
+ always parse only a single string, there's no need to do any wraps. And
+ using yywrap requires linking with -lfl, which provides the default yywrap
+ implementation that always returns 1 anyway. */
+%option noyywrap
+
+/* nounput simplifies the lexer, by removing support for putting a character
+ back into the input stream. We never use such capability anyway. */
+%option nounput
+
+/* batch means that we'll never use the generated lexer interactively. */
+%option batch
+
+/* avoid to get static global variables to remain with C++. */
+/* in last resort %option reentrant */
+
+/* Enables debug mode. To see the debug messages, one needs to also set
+ yy_flex_debug to 1, then the debug messages will be printed on stderr. */
+%option debug
+
+/* I have no idea what this option does, except it was specified in the bison
+ examples and Postgres folks added it to remove gcc 4.3 warnings. Let's
+ be on the safe side and keep it. */
+%option noinput
+
+%x COMMENT
+%x DIR_ENTER DIR_INCLUDE DIR_EXIT
+
+/* These are not token expressions yet, just convenience expressions that
+ can be used during actual token definitions. Note some can match
+ incorrect inputs (e.g., IP addresses) which must be checked. */
+int \-?[0-9]+
+blank [ \t\r]
+
+UnicodeEscapeSequence u[0-9A-Fa-f]{4}
+JSONEscapeCharacter ["\\/bfnrt]
+JSONEscapeSequence {JSONEscapeCharacter}|{UnicodeEscapeSequence}
+JSONStandardCharacter [^\x00-\x1f"\\]
+JSONStringCharacter {JSONStandardCharacter}|\\{JSONEscapeSequence}
+JSONString \"{JSONStringCharacter}*\"
+
+/* for errors */
+
+BadUnicodeEscapeSequence u[0-9A-Fa-f]{0,3}[^0-9A-Fa-f]
+BadJSONEscapeSequence [^"\\/bfnrtu]|{BadUnicodeEscapeSequence}
+ControlCharacter [\x00-\x1f]
+ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
+
+%{
+// This code run each time a pattern is matched. It updates the location
+// by moving it ahead by yyleng bytes. yyleng specifies the length of the
+// currently matched token.
+#define YY_USER_ACTION driver.loc_.columns(yyleng);
+%}
+
+%%
+
+%{
+ // This part of the code is copied over to the verbatim to the top
+ // of the generated yylex function. Explanation:
+ // http://www.gnu.org/software/bison/manual/html_node/Multiple-start_002dsymbols.html
+
+ // Code run each time yylex is called.
+ driver.loc_.step();
+
+ if (start_token_flag) {
+ start_token_flag = false;
+ switch (start_token_value) {
+ case D2ParserContext::PARSER_JSON:
+ default:
+ return isc::dhcp::D2Parser::make_TOPLEVEL_JSON(driver.loc_);
+ case D2ParserContext::PARSER_DHCPDDNS:
+ return isc::dhcp::D2Parser::make_TOPLEVEL_DHCPDDNS(driver.loc_);
+ }
+ }
+%}
+
+#.* ;
+
+"//"(.*) ;
+
+"/*" {
+ BEGIN(COMMENT);
+ comment_start_line = driver.loc_.end.line;;
+}
+
+<COMMENT>"*/" BEGIN(INITIAL);
+<COMMENT>. ;
+<COMMENT><<EOF>> {
+ isc_throw(D2ParseError, "Comment not closed. (/* in line " << comment_start_line);
+}
+
+"<?" BEGIN(DIR_ENTER);
+<DIR_ENTER>"include" BEGIN(DIR_INCLUDE);
+<DIR_INCLUDE>\"([^\"\n])+\" {
+ // Include directive.
+
+ // Extract the filename.
+ std::string tmp(yytext+1);
+ tmp.resize(tmp.size() - 1);
+
+ driver.includeFile(tmp);
+}
+<DIR_ENTER,DIR_INCLUDE,DIR_EXIT><<EOF>> {
+ isc_throw(D2ParseError, "Directive not closed.");
+}
+<DIR_EXIT>"?>" BEGIN(INITIAL);
+
+
+<*>{blank}+ {
+ // Ok, we found a with space. Let's ignore it and update loc variable.
+ driver.loc_.step();
+}
+
+<*>[\n]+ {
+ // Newline found. Let's update the location and continue.
+ driver.loc_.lines(yyleng);
+ driver.loc_.step();
+}
+
+\"ip-address\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::DHCPDDNS:
+ return isc::dhcp::D2Parser::make_IP_ADDRESS(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("ip-address", driver.loc_);
+ }
+}
+
+\"port\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::DHCPDDNS:
+ return isc::dhcp::D2Parser::make_PORT(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("port", driver.loc_);
+ }
+}
+
+\"ncr-protocol\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::DHCPDDNS:
+ return isc::dhcp::D2Parser::make_NCR_PROTOCOL(driver.loc_);
+ default:
+ return isc::dhcp::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_);
+ default:
+ return isc::dhcp::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_);
+ }
+ std::string tmp(yytext+1);
+ tmp.resize(tmp.size() - 1);
+ return isc::dhcp::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_);
+ }
+ std::string tmp(yytext+1);
+ tmp.resize(tmp.size() - 1);
+ return isc::dhcp::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_);
+ }
+ std::string tmp(yytext+1);
+ tmp.resize(tmp.size() - 1);
+ return isc::dhcp::D2Parser::make_STRING(tmp, driver.loc_);
+}
+
+\"Logging\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::CONFIG:
+ return isc::dhcp::D2Parser::make_LOGGING(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("Logging", driver.loc_);
+ }
+}
+
+\"loggers\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::LOGGING:
+ return isc::dhcp::D2Parser::make_LOGGERS(driver.loc_);
+ default:
+ return isc::dhcp::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_);
+ default:
+ return isc::dhcp::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_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("output", driver.loc_);
+ }
+}
+
+\"debuglevel\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::LOGGERS:
+ return isc::dhcp::D2Parser::make_DEBUGLEVEL(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("debuglevel", driver.loc_);
+ }
+}
+
+\"severity\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::D2ParserContext::LOGGERS:
+ return isc::dhcp::D2Parser::make_SEVERITY(driver.loc_);
+ default:
+ return isc::dhcp::D2Parser::make_STRING("severity", 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.
+ // for 'foo' we should get foo
+ std::string raw(yytext+1);
+ size_t len = raw.size() - 1;
+ raw.resize(len);
+ std::string decoded;
+ decoded.reserve(len);
+ for (size_t pos = 0; pos < len; ++pos) {
+ int b = 0;
+ char c = raw[pos];
+ switch (c) {
+ case '"':
+ // impossible condition
+ driver.error(driver.loc_, "Bad quote in \"" + raw + "\"");
+ case '\\':
+ ++pos;
+ if (pos >= len) {
+ // impossible condition
+ driver.error(driver.loc_, "Overflow escape in \"" + raw + "\"");
+ }
+ c = raw[pos];
+ switch (c) {
+ case '"':
+ case '\\':
+ case '/':
+ decoded.push_back(c);
+ break;
+ case 'b':
+ decoded.push_back('\b');
+ break;
+ case 'f':
+ decoded.push_back('\f');
+ break;
+ case 'n':
+ decoded.push_back('\n');
+ break;
+ case 'r':
+ decoded.push_back('\r');
+ break;
+ case 't':
+ decoded.push_back('\t');
+ break;
+ case 'u':
+ // support only \u0000 to \u00ff
+ ++pos;
+ if (pos + 4 > len) {
+ // impossible condition
+ driver.error(driver.loc_,
+ "Overflow unicode escape in \"" + raw + "\"");
+ }
+ if ((raw[pos] != '0') || (raw[pos + 1] != '0')) {
+ driver.error(driver.loc_, "Unsupported unicode escape in \"" + raw + "\"");
+ }
+ pos += 2;
+ c = raw[pos];
+ if ((c >= '0') && (c <= '9')) {
+ b = (c - '0') << 4;
+ } else if ((c >= 'A') && (c <= 'F')) {
+ b = (c - 'A' + 10) << 4;
+ } else if ((c >= 'a') && (c <= 'f')) {
+ b = (c - 'a' + 10) << 4;
+ } else {
+ // impossible condition
+ driver.error(driver.loc_, "Not hexadecimal in unicode escape in \"" + raw + "\"");
+ }
+ pos++;
+ c = raw[pos];
+ if ((c >= '0') && (c <= '9')) {
+ b |= c - '0';
+ } else if ((c >= 'A') && (c <= 'F')) {
+ b |= c - 'A' + 10;
+ } else if ((c >= 'a') && (c <= 'f')) {
+ b |= c - 'a' + 10;
+ } else {
+ // impossible condition
+ driver.error(driver.loc_, "Not hexadecimal in unicode escape in \"" + raw + "\"");
+ }
+ decoded.push_back(static_cast<char>(b & 0xff));
+ break;
+ default:
+ // impossible condition
+ driver.error(driver.loc_, "Bad escape in \"" + raw + "\"");
+ }
+ break;
+ default:
+ if ((c >= 0) && (c < 0x20)) {
+ // impossible condition
+ driver.error(driver.loc_, "Invalid control in \"" + raw + "\"");
+ }
+ decoded.push_back(c);
+ }
+ }
+
+ return isc::dhcp::D2Parser::make_STRING(decoded, driver.loc_);
+}
+
+\"{JSONStringCharacter}*{ControlCharacter}{ControlCharacterFill}*\" {
+ // Bad string with a forbidden control character inside
+ driver.error(driver.loc_, "Invalid control in " + std::string(yytext));
+}
+
+\"{JSONStringCharacter}*\\{BadJSONEscapeSequence}[^\x00-\x1f"]*\" {
+ // Bad string with a bad escape inside
+ driver.error(driver.loc_, "Bad escape in " + std::string(yytext));
+}
+
+\"{JSONStringCharacter}*\\\" {
+ // Bad string with an open escape at the end
+ 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_); }
+
+{int} {
+ // An integer was found.
+ std::string tmp(yytext);
+ int64_t integer = 0;
+ try {
+ // In substring we want to use negative values (e.g. -1).
+ // In enterprise-id we need to use values up to 0xffffffff.
+ // To cover both of those use cases, we need at least
+ // int64_t.
+ integer = boost::lexical_cast<int64_t>(tmp);
+ } catch (const boost::bad_lexical_cast &) {
+ driver.error(driver.loc_, "Failed to convert " + tmp + " to an integer.");
+ }
+
+ // The parser needs the string form as double conversion is no lossless
+ return isc::dhcp::D2Parser::make_INTEGER(integer, driver.loc_);
+}
+
+[-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)? {
+ // A floating point was found.
+ std::string tmp(yytext);
+ double fp = 0.0;
+ try {
+ fp = boost::lexical_cast<double>(tmp);
+ } catch (const boost::bad_lexical_cast &) {
+ driver.error(driver.loc_, "Failed to convert " + tmp + " to a floating point.");
+ }
+
+ return isc::dhcp::D2Parser::make_FLOAT(fp, driver.loc_);
+}
+
+true|false {
+ string tmp(yytext);
+ return isc::dhcp::D2Parser::make_BOOLEAN(tmp == "true", driver.loc_);
+}
+
+null {
+ return isc::dhcp::D2Parser::make_NULL_TYPE(driver.loc_);
+}
+
+(?i:true) driver.error (driver.loc_, "JSON true reserved keyword is lower case only");
+
+(?i:false) driver.error (driver.loc_, "JSON false reserved keyword is lower case only");
+
+(?i:null) driver.error (driver.loc_, "JSON null reserved keyword is lower case only");
+
+<*>. driver.error (driver.loc_, "Invalid character: " + std::string(yytext));
+
+<<EOF>> {
+ if (driver.states_.empty()) {
+ return isc::dhcp::D2Parser::make_END(driver.loc_);
+ }
+ driver.loc_ = driver.locs_.back();
+ driver.locs_.pop_back();
+ driver.file_ = driver.files_.back();
+ driver.files_.pop_back();
+ if (driver.sfile_) {
+ fclose(driver.sfile_);
+ driver.sfile_ = 0;
+ }
+ if (!driver.sfiles_.empty()) {
+ driver.sfile_ = driver.sfiles_.back();
+ driver.sfiles_.pop_back();
+ }
+ d2_parser__delete_buffer(YY_CURRENT_BUFFER);
+ d2_parser__switch_to_buffer(driver.states_.back());
+ driver.states_.pop_back();
+
+ BEGIN(DIR_EXIT);
+}
+
+%%
+
+using namespace isc::dhcp;
+
+void
+D2ParserContext::scanStringBegin(const std::string& str, ParserType parser_type)
+{
+ start_token_flag = true;
+ start_token_value = parser_type;
+
+ file_ = "<string>";
+ sfile_ = 0;
+ loc_.initialize(&file_);
+ yy_flex_debug = trace_scanning_;
+ YY_BUFFER_STATE buffer;
+ buffer = yy_scan_bytes(str.c_str(), str.size());
+ if (!buffer) {
+ fatal("cannot scan string");
+ // fatal() throws an exception so this can't be reached
+ }
+}
+
+void
+D2ParserContext::scanFileBegin(FILE * f,
+ const std::string& filename,
+ ParserType parser_type)
+{
+ start_token_flag = true;
+ start_token_value = parser_type;
+
+ file_ = filename;
+ sfile_ = f;
+ loc_.initialize(&file_);
+ yy_flex_debug = trace_scanning_;
+ YY_BUFFER_STATE buffer;
+
+ // See d2_lexer.cc header for available definitions
+ buffer = d2_parser__create_buffer(f, 65536 /*buffer size*/);
+ if (!buffer) {
+ fatal("cannot scan file " + filename);
+ }
+ d2_parser__switch_to_buffer(buffer);
+}
+
+void
+D2ParserContext::scanEnd() {
+ if (sfile_)
+ fclose(sfile_);
+ sfile_ = 0;
+ static_cast<void>(d2_parser_lex_destroy());
+ // Close files
+ while (!sfiles_.empty()) {
+ FILE* f = sfiles_.back();
+ if (f) {
+ fclose(f);
+ }
+ sfiles_.pop_back();
+ }
+ // Delete states
+ while (!states_.empty()) {
+ d2_parser__delete_buffer(states_.back());
+ states_.pop_back();
+ }
+}
+
+void
+D2ParserContext::includeFile(const std::string& filename) {
+ if (states_.size() > 10) {
+ fatal("Too many nested include.");
+ }
+
+ FILE* f = fopen(filename.c_str(), "r");
+ if (!f) {
+ fatal("Can't open include file " + filename);
+ }
+ if (sfile_) {
+ sfiles_.push_back(sfile_);
+ }
+ sfile_ = f;
+ states_.push_back(YY_CURRENT_BUFFER);
+ YY_BUFFER_STATE buffer;
+ buffer = d2_parser__create_buffer(f, 65536 /*buffer size*/);
+ if (!buffer) {
+ fatal( "Can't scan include file " + filename);
+ }
+ d2_parser__switch_to_buffer(buffer);
+ files_.push_back(file_);
+ file_ = filename;
+ locs_.push_back(loc_);
+ loc_.initialize(&file_);
+
+ BEGIN(INITIAL);
+}
+
+namespace {
+/// To avoid unused function error
+class Dummy {
+ // cppcheck-suppress unusedPrivateFunction
+ void dummy() { yy_fatal_error("Fix me: how to disable its definition?"); }
+};
+}
--- /dev/null
+// A Bison parser, made by GNU Bison 3.0.4.
+
+// Skeleton implementation for Bison LALR(1) parsers in C++
+
+// Copyright (C) 2002-2015 Free Software Foundation, Inc.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+// As a special exception, you may create a larger work that contains
+// part or all of the Bison parser skeleton and distribute that work
+// under terms of your choice, so long as that work isn't itself a
+// parser generator using the skeleton or a modified version thereof
+// as a parser skeleton. Alternatively, if you modify or redistribute
+// the parser skeleton itself, you may (at your option) remove this
+// special exception, which will cause the skeleton and the resulting
+// Bison output files to be licensed under the GNU General Public
+// License without this special exception.
+
+// This special exception was added by the Free Software Foundation in
+// version 2.2 of Bison.
+
+// Take the name prefix into account.
+#define yylex d2_parser_lex
+
+// First part of user declarations.
+
+#line 39 "d2_parser.cc" // lalr1.cc:404
+
+# ifndef YY_NULLPTR
+# if defined __cplusplus && 201103L <= __cplusplus
+# define YY_NULLPTR nullptr
+# else
+# define YY_NULLPTR 0
+# endif
+# endif
+
+#include "d2_parser.h"
+
+// User implementation prologue.
+
+#line 53 "d2_parser.cc" // lalr1.cc:412
+// Unqualified %code blocks.
+#line 34 "d2_parser.yy" // lalr1.cc:413
+
+#include <d2/parser_context.h>
+
+#line 59 "d2_parser.cc" // lalr1.cc:413
+
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+# ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (N) \
+ { \
+ (Current).begin = YYRHSLOC (Rhs, 1).begin; \
+ (Current).end = YYRHSLOC (Rhs, N).end; \
+ } \
+ else \
+ { \
+ (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
+ } \
+ while (/*CONSTCOND*/ false)
+# endif
+
+
+// Suppress unused-variable warnings by "using" E.
+#define YYUSE(E) ((void) (E))
+
+// Enable debugging if requested.
+#if D2_PARSER_DEBUG
+
+// A pseudo ostream that takes yydebug_ into account.
+# define YYCDEBUG if (yydebug_) (*yycdebug_)
+
+# define YY_SYMBOL_PRINT(Title, Symbol) \
+ do { \
+ if (yydebug_) \
+ { \
+ *yycdebug_ << Title << ' '; \
+ yy_print_ (*yycdebug_, Symbol); \
+ *yycdebug_ << std::endl; \
+ } \
+ } while (false)
+
+# define YY_REDUCE_PRINT(Rule) \
+ do { \
+ if (yydebug_) \
+ yy_reduce_print_ (Rule); \
+ } while (false)
+
+# define YY_STACK_PRINT() \
+ do { \
+ if (yydebug_) \
+ yystack_print_ (); \
+ } while (false)
+
+#else // !D2_PARSER_DEBUG
+
+# define YYCDEBUG if (false) std::cerr
+# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol)
+# define YY_REDUCE_PRINT(Rule) static_cast<void>(0)
+# define YY_STACK_PRINT() static_cast<void>(0)
+
+#endif // !D2_PARSER_DEBUG
+
+#define yyerrok (yyerrstatus_ = 0)
+#define yyclearin (yyla.clear ())
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+#define YYRECOVERING() (!!yyerrstatus_)
+
+#line 14 "d2_parser.yy" // lalr1.cc:479
+namespace isc { namespace dhcp {
+#line 145 "d2_parser.cc" // lalr1.cc:479
+
+ /* Return YYSTR after stripping away unnecessary quotes and
+ backslashes, so that it's suitable for yyerror. The heuristic is
+ that double-quoting is unnecessary unless the string contains an
+ apostrophe, a comma, or backslash (other than backslash-backslash).
+ YYSTR is taken from yytname. */
+ std::string
+ D2Parser::yytnamerr_ (const char *yystr)
+ {
+ if (*yystr == '"')
+ {
+ std::string yyr = "";
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ // Fall through.
+ default:
+ yyr += *yyp;
+ break;
+
+ case '"':
+ return yyr;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ return yystr;
+ }
+
+
+ /// Build a parser object.
+ D2Parser::D2Parser (isc::dhcp::D2ParserContext& ctx_yyarg)
+ :
+#if D2_PARSER_DEBUG
+ yydebug_ (false),
+ yycdebug_ (&std::cerr),
+#endif
+ ctx (ctx_yyarg)
+ {}
+
+ D2Parser::~D2Parser ()
+ {}
+
+
+ /*---------------.
+ | Symbol types. |
+ `---------------*/
+
+
+
+ // by_state.
+ inline
+ D2Parser::by_state::by_state ()
+ : state (empty_state)
+ {}
+
+ inline
+ D2Parser::by_state::by_state (const by_state& other)
+ : state (other.state)
+ {}
+
+ inline
+ void
+ D2Parser::by_state::clear ()
+ {
+ state = empty_state;
+ }
+
+ inline
+ void
+ D2Parser::by_state::move (by_state& that)
+ {
+ state = that.state;
+ that.clear ();
+ }
+
+ inline
+ D2Parser::by_state::by_state (state_type s)
+ : state (s)
+ {}
+
+ inline
+ D2Parser::symbol_number_type
+ D2Parser::by_state::type_get () const
+ {
+ if (state == empty_state)
+ return empty_symbol;
+ else
+ return yystos_[state];
+ }
+
+ inline
+ D2Parser::stack_symbol_type::stack_symbol_type ()
+ {}
+
+
+ inline
+ D2Parser::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that)
+ : super_type (s, that.location)
+ {
+ switch (that.type_get ())
+ {
+ case 40: // value
+ case 67: // ncr_protocol_value
+ value.move< ElementPtr > (that.value);
+ break;
+
+ case 34: // "boolean"
+ value.move< bool > (that.value);
+ break;
+
+ case 33: // "floating point"
+ value.move< double > (that.value);
+ break;
+
+ case 32: // "integer"
+ value.move< int64_t > (that.value);
+ break;
+
+ case 31: // "constant string"
+ value.move< std::string > (that.value);
+ break;
+
+ default:
+ break;
+ }
+
+ // that is emptied.
+ that.type = empty_symbol;
+ }
+
+ inline
+ D2Parser::stack_symbol_type&
+ D2Parser::stack_symbol_type::operator= (const stack_symbol_type& that)
+ {
+ state = that.state;
+ switch (that.type_get ())
+ {
+ case 40: // value
+ case 67: // ncr_protocol_value
+ value.copy< ElementPtr > (that.value);
+ break;
+
+ case 34: // "boolean"
+ value.copy< bool > (that.value);
+ break;
+
+ case 33: // "floating point"
+ value.copy< double > (that.value);
+ break;
+
+ case 32: // "integer"
+ value.copy< int64_t > (that.value);
+ break;
+
+ case 31: // "constant string"
+ value.copy< std::string > (that.value);
+ break;
+
+ default:
+ break;
+ }
+
+ location = that.location;
+ return *this;
+ }
+
+
+ template <typename Base>
+ inline
+ void
+ D2Parser::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
+ {
+ if (yymsg)
+ YY_SYMBOL_PRINT (yymsg, yysym);
+ }
+
+#if D2_PARSER_DEBUG
+ template <typename Base>
+ void
+ D2Parser::yy_print_ (std::ostream& yyo,
+ const basic_symbol<Base>& yysym) const
+ {
+ std::ostream& yyoutput = yyo;
+ YYUSE (yyoutput);
+ symbol_number_type yytype = yysym.type_get ();
+ // Avoid a (spurious) G++ 4.8 warning about "array subscript is
+ // below array bounds".
+ if (yysym.empty ())
+ std::abort ();
+ yyo << (yytype < yyntokens_ ? "token" : "nterm")
+ << ' ' << yytname_[yytype] << " ("
+ << yysym.location << ": ";
+ switch (yytype)
+ {
+ case 31: // "constant string"
+
+#line 88 "d2_parser.yy" // lalr1.cc:636
+ { yyoutput << yysym.value.template as< std::string > (); }
+#line 354 "d2_parser.cc" // lalr1.cc:636
+ break;
+
+ case 32: // "integer"
+
+#line 88 "d2_parser.yy" // lalr1.cc:636
+ { yyoutput << yysym.value.template as< int64_t > (); }
+#line 361 "d2_parser.cc" // lalr1.cc:636
+ break;
+
+ case 33: // "floating point"
+
+#line 88 "d2_parser.yy" // lalr1.cc:636
+ { yyoutput << yysym.value.template as< double > (); }
+#line 368 "d2_parser.cc" // lalr1.cc:636
+ break;
+
+ case 34: // "boolean"
+
+#line 88 "d2_parser.yy" // lalr1.cc:636
+ { yyoutput << yysym.value.template as< bool > (); }
+#line 375 "d2_parser.cc" // lalr1.cc:636
+ break;
+
+ case 40: // value
+
+#line 88 "d2_parser.yy" // lalr1.cc:636
+ { yyoutput << yysym.value.template as< ElementPtr > (); }
+#line 382 "d2_parser.cc" // lalr1.cc:636
+ break;
+
+ case 67: // ncr_protocol_value
+
+#line 88 "d2_parser.yy" // lalr1.cc:636
+ { yyoutput << yysym.value.template as< ElementPtr > (); }
+#line 389 "d2_parser.cc" // lalr1.cc:636
+ break;
+
+
+ default:
+ break;
+ }
+ yyo << ')';
+ }
+#endif
+
+ inline
+ void
+ D2Parser::yypush_ (const char* m, state_type s, symbol_type& sym)
+ {
+ stack_symbol_type t (s, sym);
+ yypush_ (m, t);
+ }
+
+ inline
+ void
+ D2Parser::yypush_ (const char* m, stack_symbol_type& s)
+ {
+ if (m)
+ YY_SYMBOL_PRINT (m, s);
+ yystack_.push (s);
+ }
+
+ inline
+ void
+ D2Parser::yypop_ (unsigned int n)
+ {
+ yystack_.pop (n);
+ }
+
+#if D2_PARSER_DEBUG
+ std::ostream&
+ D2Parser::debug_stream () const
+ {
+ return *yycdebug_;
+ }
+
+ void
+ D2Parser::set_debug_stream (std::ostream& o)
+ {
+ yycdebug_ = &o;
+ }
+
+
+ D2Parser::debug_level_type
+ D2Parser::debug_level () const
+ {
+ return yydebug_;
+ }
+
+ void
+ D2Parser::set_debug_level (debug_level_type l)
+ {
+ yydebug_ = l;
+ }
+#endif // D2_PARSER_DEBUG
+
+ inline D2Parser::state_type
+ D2Parser::yy_lr_goto_state_ (state_type yystate, int yysym)
+ {
+ int yyr = yypgoto_[yysym - yyntokens_] + yystate;
+ if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
+ return yytable_[yyr];
+ else
+ return yydefgoto_[yysym - yyntokens_];
+ }
+
+ inline bool
+ D2Parser::yy_pact_value_is_default_ (int yyvalue)
+ {
+ return yyvalue == yypact_ninf_;
+ }
+
+ inline bool
+ D2Parser::yy_table_value_is_error_ (int yyvalue)
+ {
+ return yyvalue == yytable_ninf_;
+ }
+
+ int
+ D2Parser::parse ()
+ {
+ // State.
+ int yyn;
+ /// Length of the RHS of the rule being reduced.
+ int yylen = 0;
+
+ // Error handling.
+ int yynerrs_ = 0;
+ int yyerrstatus_ = 0;
+
+ /// The lookahead symbol.
+ symbol_type yyla;
+
+ /// The locations where the error started and ended.
+ stack_symbol_type yyerror_range[3];
+
+ /// The return value of parse ().
+ int yyresult;
+
+ // FIXME: This shoud be completely indented. It is not yet to
+ // avoid gratuitous conflicts when merging into the master branch.
+ try
+ {
+ YYCDEBUG << "Starting parse" << std::endl;
+
+
+ /* Initialize the stack. The initial state will be set in
+ yynewstate, since the latter expects the semantical and the
+ location values to have been already stored, initialize these
+ stacks with a primary value. */
+ yystack_.clear ();
+ yypush_ (YY_NULLPTR, 0, yyla);
+
+ // A new symbol was pushed on the stack.
+ yynewstate:
+ YYCDEBUG << "Entering state " << yystack_[0].state << std::endl;
+
+ // Accept?
+ if (yystack_[0].state == yyfinal_)
+ goto yyacceptlab;
+
+ goto yybackup;
+
+ // Backup.
+ yybackup:
+
+ // Try to take a decision without lookahead.
+ yyn = yypact_[yystack_[0].state];
+ if (yy_pact_value_is_default_ (yyn))
+ goto yydefault;
+
+ // Read a lookahead token.
+ if (yyla.empty ())
+ {
+ YYCDEBUG << "Reading a token: ";
+ try
+ {
+ symbol_type yylookahead (yylex (ctx));
+ yyla.move (yylookahead);
+ }
+ catch (const syntax_error& yyexc)
+ {
+ error (yyexc);
+ goto yyerrlab1;
+ }
+ }
+ YY_SYMBOL_PRINT ("Next token is", yyla);
+
+ /* If the proper action on seeing token YYLA.TYPE is to reduce or
+ to detect an error, take that action. */
+ yyn += yyla.type_get ();
+ if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type_get ())
+ goto yydefault;
+
+ // Reduce or error.
+ yyn = yytable_[yyn];
+ if (yyn <= 0)
+ {
+ if (yy_table_value_is_error_ (yyn))
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ // Count tokens shifted since error; after three, turn off error status.
+ if (yyerrstatus_)
+ --yyerrstatus_;
+
+ // Shift the lookahead token.
+ yypush_ ("Shifting", yyn, yyla);
+ goto yynewstate;
+
+ /*-----------------------------------------------------------.
+ | yydefault -- do the default action for the current state. |
+ `-----------------------------------------------------------*/
+ yydefault:
+ yyn = yydefact_[yystack_[0].state];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+ /*-----------------------------.
+ | yyreduce -- Do a reduction. |
+ `-----------------------------*/
+ yyreduce:
+ yylen = yyr2_[yyn];
+ {
+ stack_symbol_type yylhs;
+ yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);
+ /* Variants are always initialized to an empty instance of the
+ correct type. The default '$$ = $1' action is NOT applied
+ when using variants. */
+ switch (yyr1_[yyn])
+ {
+ case 40: // value
+ case 67: // ncr_protocol_value
+ yylhs.value.build< ElementPtr > ();
+ break;
+
+ case 34: // "boolean"
+ yylhs.value.build< bool > ();
+ break;
+
+ case 33: // "floating point"
+ yylhs.value.build< double > ();
+ break;
+
+ case 32: // "integer"
+ yylhs.value.build< int64_t > ();
+ break;
+
+ case 31: // "constant string"
+ yylhs.value.build< std::string > ();
+ break;
+
+ default:
+ break;
+ }
+
+
+ // Compute the default @$.
+ {
+ slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
+ YYLLOC_DEFAULT (yylhs.location, slice, yylen);
+ }
+
+ // Perform the reduction.
+ YY_REDUCE_PRINT (yyn);
+ try
+ {
+ switch (yyn)
+ {
+ case 2:
+#line 97 "d2_parser.yy" // lalr1.cc:859
+ { ctx.ctx_ = ctx.NO_KEYWORD; }
+#line 630 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 4:
+#line 98 "d2_parser.yy" // lalr1.cc:859
+ { ctx.ctx_ = ctx.CONFIG; }
+#line 636 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 6:
+#line 99 "d2_parser.yy" // lalr1.cc:859
+ { ctx.ctx_ = ctx.DHCPDDNS; }
+#line 642 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 8:
+#line 107 "d2_parser.yy" // lalr1.cc:859
+ { yylhs.value.as< ElementPtr > () = ElementPtr(new IntElement(yystack_[0].value.as< int64_t > (), ctx.loc2pos(yystack_[0].location))); }
+#line 648 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 9:
+#line 108 "d2_parser.yy" // lalr1.cc:859
+ { yylhs.value.as< ElementPtr > () = ElementPtr(new DoubleElement(yystack_[0].value.as< double > (), ctx.loc2pos(yystack_[0].location))); }
+#line 654 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 10:
+#line 109 "d2_parser.yy" // lalr1.cc:859
+ { yylhs.value.as< ElementPtr > () = ElementPtr(new BoolElement(yystack_[0].value.as< bool > (), ctx.loc2pos(yystack_[0].location))); }
+#line 660 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 11:
+#line 110 "d2_parser.yy" // lalr1.cc:859
+ { yylhs.value.as< ElementPtr > () = ElementPtr(new StringElement(yystack_[0].value.as< std::string > (), ctx.loc2pos(yystack_[0].location))); }
+#line 666 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 12:
+#line 111 "d2_parser.yy" // lalr1.cc:859
+ { yylhs.value.as< ElementPtr > () = ElementPtr(new NullElement(ctx.loc2pos(yystack_[0].location))); }
+#line 672 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 13:
+#line 112 "d2_parser.yy" // lalr1.cc:859
+ { yylhs.value.as< ElementPtr > () = ctx.stack_.back(); ctx.stack_.pop_back(); }
+#line 678 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 14:
+#line 113 "d2_parser.yy" // lalr1.cc:859
+ { yylhs.value.as< ElementPtr > () = ctx.stack_.back(); ctx.stack_.pop_back(); }
+#line 684 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 15:
+#line 116 "d2_parser.yy" // lalr1.cc:859
+ {
+ // Push back the JSON value on the stack
+ ctx.stack_.push_back(yystack_[0].value.as< ElementPtr > ());
+}
+#line 693 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 16:
+#line 121 "d2_parser.yy" // lalr1.cc:859
+ {
+ // This code is executed when we're about to start parsing
+ // the content of the map
+ ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.push_back(m);
+}
+#line 704 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 17:
+#line 126 "d2_parser.yy" // lalr1.cc:859
+ {
+ // map parsing completed. If we ever want to do any wrap up
+ // (maybe some sanity checking), this would be the best place
+ // for it.
+}
+#line 714 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 20:
+#line 137 "d2_parser.yy" // lalr1.cc:859
+ {
+ // map containing a single entry
+ ctx.stack_.back()->set(yystack_[2].value.as< std::string > (), yystack_[0].value.as< ElementPtr > ());
+ }
+#line 723 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 21:
+#line 141 "d2_parser.yy" // lalr1.cc:859
+ {
+ // map consisting of a shorter map followed by
+ // comma and string:value
+ ctx.stack_.back()->set(yystack_[2].value.as< std::string > (), yystack_[0].value.as< ElementPtr > ());
+ }
+#line 733 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 22:
+#line 148 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.push_back(l);
+}
+#line 742 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 23:
+#line 151 "d2_parser.yy" // lalr1.cc:859
+ {
+ // list parsing complete. Put any sanity checking here
+}
+#line 750 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 26:
+#line 167 "d2_parser.yy" // lalr1.cc:859
+ {
+ // List consisting of a single element.
+ ctx.stack_.back()->add(yystack_[0].value.as< ElementPtr > ());
+ }
+#line 759 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 27:
+#line 171 "d2_parser.yy" // lalr1.cc:859
+ {
+ // List ending with , and a value.
+ ctx.stack_.back()->add(yystack_[0].value.as< ElementPtr > ());
+ }
+#line 768 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 28:
+#line 182 "d2_parser.yy" // lalr1.cc:859
+ {
+ const std::string& where = ctx.contextName();
+ const std::string& keyword = yystack_[1].value.as< std::string > ();
+ error(yystack_[1].location,
+ "got unexpected keyword \"" + keyword + "\" in " + where + " map.");
+}
+#line 779 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 29:
+#line 192 "d2_parser.yy" // lalr1.cc:859
+ {
+ // This code is executed when we're about to start parsing
+ // the content of the map
+ ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.push_back(m);
+}
+#line 790 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 30:
+#line 197 "d2_parser.yy" // lalr1.cc:859
+ {
+ // map parsing completed. If we ever want to do any wrap up
+ // (maybe some sanity checking), this would be the best place
+ // for it.
+}
+#line 800 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 38:
+#line 218 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->set("DhcpDdns", m);
+ ctx.stack_.push_back(m);
+ ctx.enter(ctx.DHCPDDNS);
+}
+#line 811 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 39:
+#line 223 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.stack_.pop_back();
+ ctx.leave();
+}
+#line 820 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 40:
+#line 228 "d2_parser.yy" // lalr1.cc:859
+ {
+ // Parse the dhcpddns map
+ ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.push_back(m);
+}
+#line 830 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 41:
+#line 232 "d2_parser.yy" // lalr1.cc:859
+ {
+ // parsing completed
+}
+#line 838 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 50:
+#line 248 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.enter(ctx.NO_KEYWORD);
+}
+#line 846 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 51:
+#line 250 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr s(new StringElement(yystack_[0].value.as< std::string > (), ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->set("ip-address", s);
+ ctx.leave();
+}
+#line 856 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 52:
+#line 256 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr i(new IntElement(yystack_[0].value.as< int64_t > (), ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->set("port", i);
+}
+#line 865 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 53:
+#line 261 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr i(new IntElement(yystack_[0].value.as< int64_t > (), ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->set("dns-server-timeout", i);
+}
+#line 874 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 54:
+#line 266 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.enter(ctx.NCR_PROTOCOL);
+}
+#line 882 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 55:
+#line 268 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.stack_.back()->set("ncr-protocol", yystack_[0].value.as< ElementPtr > ());
+ ctx.leave();
+}
+#line 891 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 56:
+#line 274 "d2_parser.yy" // lalr1.cc:859
+ { yylhs.value.as< ElementPtr > () = ElementPtr(new StringElement("UDP", ctx.loc2pos(yystack_[0].location))); }
+#line 897 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 57:
+#line 275 "d2_parser.yy" // lalr1.cc:859
+ { yylhs.value.as< ElementPtr > () = ElementPtr(new StringElement("TCP", ctx.loc2pos(yystack_[0].location))); }
+#line 903 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 58:
+#line 278 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.enter(ctx.NCR_FORMAT);
+}
+#line 911 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 59:
+#line 280 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr json(new StringElement("JSON", ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->set("ncr-format", json);
+ ctx.leave();
+}
+#line 921 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 60:
+#line 286 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.enter(ctx.NO_KEYWORD);
+}
+#line 929 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 61:
+#line 288 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.stack_.back()->set("Dhcp6", yystack_[0].value.as< ElementPtr > ());
+ ctx.leave();
+}
+#line 938 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 62:
+#line 293 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.enter(ctx.NO_KEYWORD);
+}
+#line 946 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 63:
+#line 295 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.stack_.back()->set("Dhcp4", yystack_[0].value.as< ElementPtr > ());
+ ctx.leave();
+}
+#line 955 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 64:
+#line 305 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->set("Logging", m);
+ ctx.stack_.push_back(m);
+ ctx.enter(ctx.LOGGING);
+}
+#line 966 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 65:
+#line 310 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.stack_.pop_back();
+ ctx.leave();
+}
+#line 975 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 69:
+#line 327 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->set("loggers", l);
+ ctx.stack_.push_back(l);
+ ctx.enter(ctx.LOGGERS);
+}
+#line 986 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 70:
+#line 332 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.stack_.pop_back();
+ ctx.leave();
+}
+#line 995 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 73:
+#line 344 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr l(new MapElement(ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->add(l);
+ ctx.stack_.push_back(l);
+}
+#line 1005 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 74:
+#line 348 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.stack_.pop_back();
+}
+#line 1013 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 82:
+#line 363 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.enter(ctx.NO_KEYWORD);
+}
+#line 1021 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 83:
+#line 365 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr name(new StringElement(yystack_[0].value.as< std::string > (), ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->set("name", name);
+ ctx.leave();
+}
+#line 1031 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 84:
+#line 371 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr dl(new IntElement(yystack_[0].value.as< int64_t > (), ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->set("debuglevel", dl);
+}
+#line 1040 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 85:
+#line 375 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.enter(ctx.NO_KEYWORD);
+}
+#line 1048 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 86:
+#line 377 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr sev(new StringElement(yystack_[0].value.as< std::string > (), ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->set("severity", sev);
+ ctx.leave();
+}
+#line 1058 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 87:
+#line 383 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->set("output_options", l);
+ ctx.stack_.push_back(l);
+ ctx.enter(ctx.OUTPUT_OPTIONS);
+}
+#line 1069 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 88:
+#line 388 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.stack_.pop_back();
+ ctx.leave();
+}
+#line 1078 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 91:
+#line 397 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->add(m);
+ ctx.stack_.push_back(m);
+}
+#line 1088 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 92:
+#line 401 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.stack_.pop_back();
+}
+#line 1096 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 95:
+#line 409 "d2_parser.yy" // lalr1.cc:859
+ {
+ ctx.enter(ctx.NO_KEYWORD);
+}
+#line 1104 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+ case 96:
+#line 411 "d2_parser.yy" // lalr1.cc:859
+ {
+ ElementPtr sev(new StringElement(yystack_[0].value.as< std::string > (), ctx.loc2pos(yystack_[0].location)));
+ ctx.stack_.back()->set("output", sev);
+ ctx.leave();
+}
+#line 1114 "d2_parser.cc" // lalr1.cc:859
+ break;
+
+
+#line 1118 "d2_parser.cc" // lalr1.cc:859
+ default:
+ break;
+ }
+ }
+ catch (const syntax_error& yyexc)
+ {
+ error (yyexc);
+ YYERROR;
+ }
+ YY_SYMBOL_PRINT ("-> $$ =", yylhs);
+ yypop_ (yylen);
+ yylen = 0;
+ YY_STACK_PRINT ();
+
+ // Shift the result of the reduction.
+ yypush_ (YY_NULLPTR, yylhs);
+ }
+ goto yynewstate;
+
+ /*--------------------------------------.
+ | yyerrlab -- here on detecting error. |
+ `--------------------------------------*/
+ yyerrlab:
+ // If not already recovering from an error, report this error.
+ if (!yyerrstatus_)
+ {
+ ++yynerrs_;
+ error (yyla.location, yysyntax_error_ (yystack_[0].state, yyla));
+ }
+
+
+ yyerror_range[1].location = yyla.location;
+ if (yyerrstatus_ == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ // Return failure if at end of input.
+ if (yyla.type_get () == yyeof_)
+ YYABORT;
+ else if (!yyla.empty ())
+ {
+ yy_destroy_ ("Error: discarding", yyla);
+ yyla.clear ();
+ }
+ }
+
+ // Else will try to reuse lookahead token after shifting the error token.
+ goto yyerrlab1;
+
+
+ /*---------------------------------------------------.
+ | yyerrorlab -- error raised explicitly by YYERROR. |
+ `---------------------------------------------------*/
+ yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (false)
+ goto yyerrorlab;
+ yyerror_range[1].location = yystack_[yylen - 1].location;
+ /* Do not reclaim the symbols of the rule whose action triggered
+ this YYERROR. */
+ yypop_ (yylen);
+ yylen = 0;
+ goto yyerrlab1;
+
+ /*-------------------------------------------------------------.
+ | yyerrlab1 -- common code for both syntax error and YYERROR. |
+ `-------------------------------------------------------------*/
+ yyerrlab1:
+ yyerrstatus_ = 3; // Each real token shifted decrements this.
+ {
+ stack_symbol_type error_token;
+ for (;;)
+ {
+ yyn = yypact_[yystack_[0].state];
+ if (!yy_pact_value_is_default_ (yyn))
+ {
+ yyn += yyterror_;
+ if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
+ {
+ yyn = yytable_[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ // Pop the current state because it cannot handle the error token.
+ if (yystack_.size () == 1)
+ YYABORT;
+
+ yyerror_range[1].location = yystack_[0].location;
+ yy_destroy_ ("Error: popping", yystack_[0]);
+ yypop_ ();
+ YY_STACK_PRINT ();
+ }
+
+ yyerror_range[2].location = yyla.location;
+ YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
+
+ // Shift the error token.
+ error_token.state = yyn;
+ yypush_ ("Shifting", error_token);
+ }
+ goto yynewstate;
+
+ // Accept.
+ yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+ // Abort.
+ yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+ yyreturn:
+ if (!yyla.empty ())
+ yy_destroy_ ("Cleanup: discarding lookahead", yyla);
+
+ /* Do not reclaim the symbols of the rule whose action triggered
+ this YYABORT or YYACCEPT. */
+ yypop_ (yylen);
+ while (1 < yystack_.size ())
+ {
+ yy_destroy_ ("Cleanup: popping", yystack_[0]);
+ yypop_ ();
+ }
+
+ return yyresult;
+ }
+ catch (...)
+ {
+ YYCDEBUG << "Exception caught: cleaning lookahead and stack"
+ << std::endl;
+ // Do not try to display the values of the reclaimed symbols,
+ // as their printer might throw an exception.
+ if (!yyla.empty ())
+ yy_destroy_ (YY_NULLPTR, yyla);
+
+ while (1 < yystack_.size ())
+ {
+ yy_destroy_ (YY_NULLPTR, yystack_[0]);
+ yypop_ ();
+ }
+ throw;
+ }
+ }
+
+ void
+ D2Parser::error (const syntax_error& yyexc)
+ {
+ error (yyexc.location, yyexc.what());
+ }
+
+ // Generate an error message.
+ std::string
+ D2Parser::yysyntax_error_ (state_type yystate, const symbol_type& yyla) const
+ {
+ // Number of reported tokens (one for the "unexpected", one per
+ // "expected").
+ size_t yycount = 0;
+ // Its maximum.
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ // Arguments of yyformat.
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+
+ /* There are many possibilities here to consider:
+ - If this state is a consistent state with a default action, then
+ the only way this function was invoked is if the default action
+ is an error action. In that case, don't check for expected
+ tokens because there are none.
+ - The only way there can be no lookahead present (in yyla) is
+ if this state is a consistent state with a default action.
+ Thus, detecting the absence of a lookahead is sufficient to
+ determine that there is no unexpected or expected token to
+ report. In that case, just report a simple "syntax error".
+ - Don't assume there isn't a lookahead just because this state is
+ a consistent state with a default action. There might have
+ been a previous inconsistent state, consistent state with a
+ non-default action, or user semantic action that manipulated
+ yyla. (However, yyla is currently not documented for users.)
+ - Of course, the expected token list depends on states to have
+ correct lookahead information, and it depends on the parser not
+ to perform extra reductions after fetching a lookahead from the
+ scanner and before detecting a syntax error. Thus, state
+ merging (from LALR or IELR) and default reductions corrupt the
+ expected token list. However, the list is correct for
+ canonical LR with one exception: it will still contain any
+ token that will not be accepted due to an error action in a
+ later state.
+ */
+ if (!yyla.empty ())
+ {
+ int yytoken = yyla.type_get ();
+ yyarg[yycount++] = yytname_[yytoken];
+ int yyn = yypact_[yystate];
+ if (!yy_pact_value_is_default_ (yyn))
+ {
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. In other words, skip the first -YYN actions for
+ this state because they are default actions. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+ // Stay within bounds of both yycheck and yytname.
+ int yychecklim = yylast_ - yyn + 1;
+ int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
+ for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
+ && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ break;
+ }
+ else
+ yyarg[yycount++] = yytname_[yyx];
+ }
+ }
+ }
+
+ char const* yyformat = YY_NULLPTR;
+ switch (yycount)
+ {
+#define YYCASE_(N, S) \
+ case N: \
+ yyformat = S; \
+ break
+ YYCASE_(0, YY_("syntax error"));
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
+#undef YYCASE_
+ }
+
+ std::string yyres;
+ // Argument number.
+ size_t yyi = 0;
+ for (char const* yyp = yyformat; *yyp; ++yyp)
+ if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
+ {
+ yyres += yytnamerr_ (yyarg[yyi++]);
+ ++yyp;
+ }
+ else
+ yyres += *yyp;
+ return yyres;
+ }
+
+
+ const signed char D2Parser::yypact_ninf_ = -57;
+
+ const signed char D2Parser::yytable_ninf_ = -1;
+
+ const signed char
+ D2Parser::yypact_[] =
+ {
+ 22, -57, -57, -57, 5, -3, 41, 46, -57, -57,
+ -57, -57, -57, -57, -57, -57, -57, -57, -57, -57,
+ -57, -57, -57, -57, -3, -4, 1, 2, -57, 30,
+ 51, 52, 47, 54, -57, -57, -57, -57, 56, -57,
+ 0, -57, -57, -57, -57, -57, -57, 57, 58, -57,
+ -57, -57, 6, -57, -57, -57, -57, -57, -57, -57,
+ -3, -3, -57, 33, 59, 61, 62, 63, -57, 1,
+ -57, 64, 38, 39, 68, 69, 2, -57, -57, -57,
+ 70, -3, -3, 71, 72, -57, 44, -57, -57, 29,
+ 60, -57, -3, -57, -57, 2, 55, -57, -57, -57,
+ -57, -57, -57, 16, -57, 17, -57, -57, -57, 77,
+ 55, -57, 78, -57, 75, -57, 4, -57, 18, 75,
+ -57, -57, -57, 80, -57, -57, 31, -57, -57, -57,
+ -57, -57, -57, 81, 82, 65, 83, 18, -57, 45,
+ 84, -57, 67, -57, -57, 86, -57, -57, 20, -57,
+ 66, 86, -57, -57, 32, -57, -57, 90, 66, -57,
+ 73, -57, -57
+ };
+
+ const unsigned char
+ D2Parser::yydefact_[] =
+ {
+ 0, 2, 4, 6, 0, 0, 0, 0, 1, 22,
+ 16, 12, 11, 8, 9, 10, 15, 3, 13, 14,
+ 29, 5, 40, 7, 24, 18, 0, 0, 26, 0,
+ 25, 0, 0, 19, 60, 62, 38, 64, 0, 37,
+ 0, 31, 36, 33, 35, 34, 50, 0, 0, 54,
+ 58, 49, 0, 42, 44, 45, 46, 47, 48, 23,
+ 0, 0, 17, 0, 0, 0, 0, 0, 28, 0,
+ 30, 0, 0, 0, 0, 0, 0, 41, 27, 20,
+ 0, 0, 0, 0, 0, 32, 0, 52, 53, 0,
+ 0, 43, 0, 61, 63, 0, 0, 51, 56, 57,
+ 55, 59, 21, 0, 69, 0, 66, 68, 39, 0,
+ 0, 65, 0, 67, 0, 73, 0, 71, 0, 0,
+ 70, 82, 87, 0, 85, 81, 0, 75, 77, 79,
+ 80, 78, 72, 0, 0, 0, 0, 0, 74, 0,
+ 0, 84, 0, 76, 83, 0, 86, 91, 0, 89,
+ 0, 0, 88, 95, 0, 93, 90, 0, 0, 92,
+ 0, 94, 96
+ };
+
+ const signed char
+ D2Parser::yypgoto_[] =
+ {
+ -57, -57, -57, -57, -57, -23, -57, -57, -57, -57,
+ -57, -57, -57, -57, -57, -26, -57, -57, -57, 19,
+ -57, -57, -57, -57, -5, 23, -57, -57, -57, -57,
+ -57, -57, -57, -57, -57, -57, -57, -57, -57, -57,
+ -57, -57, -15, -57, -57, -57, -19, -57, -57, -41,
+ -57, -57, -57, -57, -57, -57, -57, -57, -50, -57,
+ -57, -56, -57
+ };
+
+ const short int
+ D2Parser::yydefgoto_[] =
+ {
+ -1, 4, 5, 6, 7, 16, 17, 18, 25, 32,
+ 33, 19, 24, 29, 30, 51, 21, 26, 40, 41,
+ 42, 66, 23, 27, 52, 53, 54, 71, 55, 56,
+ 57, 74, 100, 58, 75, 43, 64, 44, 65, 45,
+ 67, 105, 106, 107, 109, 116, 117, 118, 126, 127,
+ 128, 133, 129, 130, 136, 131, 134, 148, 149, 150,
+ 154, 155, 157
+ };
+
+ const unsigned char
+ D2Parser::yytable_[] =
+ {
+ 39, 28, 9, 69, 10, 8, 11, 119, 70, 76,
+ 120, 34, 35, 36, 77, 46, 47, 48, 49, 76,
+ 110, 50, 37, 151, 108, 111, 152, 31, 12, 13,
+ 14, 15, 38, 38, 137, 158, 59, 78, 79, 138,
+ 159, 121, 122, 39, 123, 124, 98, 99, 20, 38,
+ 1, 2, 3, 22, 60, 62, 61, 63, 93, 94,
+ 68, 72, 73, 81, 80, 82, 83, 84, 86, 102,
+ 87, 88, 89, 90, 92, 97, 144, 104, 95, 96,
+ 101, 112, 115, 114, 135, 139, 140, 142, 85, 145,
+ 103, 153, 125, 147, 160, 113, 143, 141, 146, 91,
+ 132, 156, 161, 0, 162, 0, 0, 0, 0, 0,
+ 0, 125
+ };
+
+ const short int
+ D2Parser::yycheck_[] =
+ {
+ 26, 24, 5, 3, 7, 0, 9, 3, 8, 3,
+ 6, 10, 11, 12, 8, 13, 14, 15, 16, 3,
+ 3, 19, 21, 3, 8, 8, 6, 31, 31, 32,
+ 33, 34, 31, 31, 3, 3, 6, 60, 61, 8,
+ 8, 23, 24, 69, 26, 27, 17, 18, 7, 31,
+ 28, 29, 30, 7, 3, 8, 4, 3, 81, 82,
+ 4, 4, 4, 4, 31, 4, 4, 4, 4, 92,
+ 32, 32, 4, 4, 4, 31, 31, 22, 7, 7,
+ 20, 4, 7, 5, 4, 4, 4, 4, 69, 5,
+ 95, 25, 118, 7, 4, 110, 137, 32, 31, 76,
+ 119, 151, 158, -1, 31, -1, -1, -1, -1, -1,
+ -1, 137
+ };
+
+ const unsigned char
+ D2Parser::yystos_[] =
+ {
+ 0, 28, 29, 30, 36, 37, 38, 39, 0, 5,
+ 7, 9, 31, 32, 33, 34, 40, 41, 42, 46,
+ 7, 51, 7, 57, 47, 43, 52, 58, 40, 48,
+ 49, 31, 44, 45, 10, 11, 12, 21, 31, 50,
+ 53, 54, 55, 70, 72, 74, 13, 14, 15, 16,
+ 19, 50, 59, 60, 61, 63, 64, 65, 68, 6,
+ 3, 4, 8, 3, 71, 73, 56, 75, 4, 3,
+ 8, 62, 4, 4, 66, 69, 3, 8, 40, 40,
+ 31, 4, 4, 4, 4, 54, 4, 32, 32, 4,
+ 4, 60, 4, 40, 40, 7, 7, 31, 17, 18,
+ 67, 20, 40, 59, 22, 76, 77, 78, 8, 79,
+ 3, 8, 4, 77, 5, 7, 80, 81, 82, 3,
+ 6, 23, 24, 26, 27, 50, 83, 84, 85, 87,
+ 88, 90, 81, 86, 91, 4, 89, 3, 8, 4,
+ 4, 32, 4, 84, 31, 5, 31, 7, 92, 93,
+ 94, 3, 6, 25, 95, 96, 93, 97, 3, 8,
+ 4, 96, 31
+ };
+
+ const unsigned char
+ D2Parser::yyr1_[] =
+ {
+ 0, 35, 37, 36, 38, 36, 39, 36, 40, 40,
+ 40, 40, 40, 40, 40, 41, 43, 42, 44, 44,
+ 45, 45, 47, 46, 48, 48, 49, 49, 50, 52,
+ 51, 53, 53, 54, 54, 54, 54, 54, 56, 55,
+ 58, 57, 59, 59, 60, 60, 60, 60, 60, 60,
+ 62, 61, 63, 64, 66, 65, 67, 67, 69, 68,
+ 71, 70, 73, 72, 75, 74, 76, 76, 77, 79,
+ 78, 80, 80, 82, 81, 83, 83, 84, 84, 84,
+ 84, 84, 86, 85, 87, 89, 88, 91, 90, 92,
+ 92, 94, 93, 95, 95, 97, 96
+ };
+
+ const unsigned char
+ D2Parser::yyr2_[] =
+ {
+ 0, 2, 0, 3, 0, 3, 0, 3, 1, 1,
+ 1, 1, 1, 1, 1, 1, 0, 4, 0, 1,
+ 3, 5, 0, 4, 0, 1, 1, 3, 2, 0,
+ 4, 1, 3, 1, 1, 1, 1, 1, 0, 6,
+ 0, 4, 1, 3, 1, 1, 1, 1, 1, 1,
+ 0, 4, 3, 3, 0, 4, 1, 1, 0, 4,
+ 0, 4, 0, 4, 0, 6, 1, 3, 1, 0,
+ 6, 1, 3, 0, 4, 1, 3, 1, 1, 1,
+ 1, 1, 0, 4, 3, 0, 4, 0, 6, 1,
+ 3, 0, 4, 1, 3, 0, 4
+ };
+
+
+
+ // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ // First, the terminals, then, starting at \a yyntokens_, nonterminals.
+ const char*
+ const D2Parser::yytname_[] =
+ {
+ "\"end of file\"", "error", "$undefined", "\",\"", "\":\"", "\"[\"",
+ "\"]\"", "\"{\"", "\"}\"", "\"null\"", "\"Dhcp6\"", "\"Dhcp4\"",
+ "\"DhcpDdns\"", "\"ip-address\"", "\"port\"", "\"dns-server-timeout\"",
+ "\"ncr-protocol\"", "\"UDP\"", "\"TCP\"", "\"ncr-format\"", "\"JSON\"",
+ "\"Logging\"", "\"loggers\"", "\"name\"", "\"output_options\"",
+ "\"output\"", "\"debuglevel\"", "\"severity\"", "TOPLEVEL_JSON",
+ "TOPLEVEL_DHCPDDNS", "SUB_DHCPDDNS", "\"constant string\"",
+ "\"integer\"", "\"floating point\"", "\"boolean\"", "$accept", "start",
+ "$@1", "$@2", "$@3", "value", "sub_json", "map2", "$@4", "map_content",
+ "not_empty_map", "list_generic", "$@5", "list_content", "not_empty_list",
+ "unknown_map_entry", "syntax_map", "$@6", "global_objects",
+ "global_object", "dhcpddns_object", "$@7", "sub_dhcpddns", "$@8",
+ "dhcpddns_params", "dhcpddns_param", "ip_address", "$@9", "port",
+ "dns_server_timeout", "ncr_protocol", "$@10", "ncr_protocol_value",
+ "ncr_format", "$@11", "dhcp6_json_object", "$@12", "dhcp4_json_object",
+ "$@13", "logging_object", "$@14", "logging_params", "logging_param",
+ "loggers", "$@15", "loggers_entries", "logger_entry", "$@16",
+ "logger_params", "logger_param", "name", "$@17", "debuglevel",
+ "severity", "$@18", "output_options_list", "$@19",
+ "output_options_list_content", "output_entry", "$@20", "output_params",
+ "output_param", "$@21", YY_NULLPTR
+ };
+
+#if D2_PARSER_DEBUG
+ const unsigned short int
+ D2Parser::yyrline_[] =
+ {
+ 0, 97, 97, 97, 98, 98, 99, 99, 107, 108,
+ 109, 110, 111, 112, 113, 116, 121, 121, 133, 134,
+ 137, 141, 148, 148, 163, 164, 167, 171, 182, 192,
+ 192, 204, 205, 209, 210, 211, 212, 213, 218, 218,
+ 228, 228, 236, 237, 240, 241, 242, 243, 244, 245,
+ 248, 248, 256, 261, 266, 266, 274, 275, 278, 278,
+ 286, 286, 293, 293, 305, 305, 318, 319, 323, 327,
+ 327, 339, 340, 344, 344, 352, 353, 356, 357, 358,
+ 359, 360, 363, 363, 371, 375, 375, 383, 383, 393,
+ 394, 397, 397, 405, 406, 409, 409
+ };
+
+ // Print the state stack on the debug stream.
+ void
+ D2Parser::yystack_print_ ()
+ {
+ *yycdebug_ << "Stack now";
+ for (stack_type::const_iterator
+ i = yystack_.begin (),
+ i_end = yystack_.end ();
+ i != i_end; ++i)
+ *yycdebug_ << ' ' << i->state;
+ *yycdebug_ << std::endl;
+ }
+
+ // Report on the debug stream that the rule \a yyrule is going to be reduced.
+ void
+ D2Parser::yy_reduce_print_ (int yyrule)
+ {
+ unsigned int yylno = yyrline_[yyrule];
+ int yynrhs = yyr2_[yyrule];
+ // Print the symbols being reduced, and their result.
+ *yycdebug_ << "Reducing stack by rule " << yyrule - 1
+ << " (line " << yylno << "):" << std::endl;
+ // The symbols being reduced.
+ for (int yyi = 0; yyi < yynrhs; yyi++)
+ YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
+ yystack_[(yynrhs) - (yyi + 1)]);
+ }
+#endif // D2_PARSER_DEBUG
+
+
+#line 14 "d2_parser.yy" // lalr1.cc:1167
+} } // isc::dhcp
+#line 1609 "d2_parser.cc" // lalr1.cc:1167
+#line 417 "d2_parser.yy" // lalr1.cc:1168
+
+
+void
+isc::dhcp::D2Parser::error(const location_type& loc,
+ const std::string& what)
+{
+ ctx.error(loc, what);
+}
--- /dev/null
+// A Bison parser, made by GNU Bison 3.0.4.
+
+// Skeleton interface for Bison LALR(1) parsers in C++
+
+// Copyright (C) 2002-2015 Free Software Foundation, Inc.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+// As a special exception, you may create a larger work that contains
+// part or all of the Bison parser skeleton and distribute that work
+// under terms of your choice, so long as that work isn't itself a
+// parser generator using the skeleton or a modified version thereof
+// as a parser skeleton. Alternatively, if you modify or redistribute
+// the parser skeleton itself, you may (at your option) remove this
+// special exception, which will cause the skeleton and the resulting
+// Bison output files to be licensed under the GNU General Public
+// License without this special exception.
+
+// This special exception was added by the Free Software Foundation in
+// version 2.2 of Bison.
+
+/**
+ ** \file d2_parser.h
+ ** Define the isc::dhcp::parser class.
+ */
+
+// C++ LALR(1) parser skeleton written by Akim Demaille.
+
+#ifndef YY_D2_PARSER_D2_PARSER_H_INCLUDED
+# define YY_D2_PARSER_D2_PARSER_H_INCLUDED
+// // "%code requires" blocks.
+#line 17 "d2_parser.yy" // lalr1.cc:392
+
+#include <string>
+#include <cc/data.h>
+#include <d2/d2_config.h>
+#include <boost/lexical_cast.hpp>
+#include <d2/parser_context_decl.h>
+
+using namespace isc::dhcp;
+using namespace isc::data;
+using namespace std;
+
+#line 56 "d2_parser.h" // lalr1.cc:392
+
+# include <cassert>
+# include <cstdlib> // std::abort
+# include <iostream>
+# include <stdexcept>
+# include <string>
+# include <vector>
+# include "stack.hh"
+# include "location.hh"
+#include <typeinfo>
+#ifndef YYASSERT
+# include <cassert>
+# define YYASSERT assert
+#endif
+
+
+#ifndef YY_ATTRIBUTE
+# if (defined __GNUC__ \
+ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
+ || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
+# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
+# else
+# define YY_ATTRIBUTE(Spec) /* empty */
+# endif
+#endif
+
+#ifndef YY_ATTRIBUTE_PURE
+# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
+#endif
+
+#ifndef YY_ATTRIBUTE_UNUSED
+# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
+#endif
+
+#if !defined _Noreturn \
+ && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
+# if defined _MSC_VER && 1200 <= _MSC_VER
+# define _Noreturn __declspec (noreturn)
+# else
+# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(E) ((void) (E))
+#else
+# define YYUSE(E) /* empty */
+#endif
+
+#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+/* Suppress an incorrect diagnostic about yylval being uninitialized. */
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
+ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
+ _Pragma ("GCC diagnostic pop")
+#else
+# define YY_INITIAL_VALUE(Value) Value
+#endif
+#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END
+#endif
+#ifndef YY_INITIAL_VALUE
+# define YY_INITIAL_VALUE(Value) /* Nothing. */
+#endif
+
+/* Debug traces. */
+#ifndef D2_PARSER_DEBUG
+# if defined YYDEBUG
+#if YYDEBUG
+# define D2_PARSER_DEBUG 1
+# else
+# define D2_PARSER_DEBUG 0
+# endif
+# else /* ! defined YYDEBUG */
+# define D2_PARSER_DEBUG 1
+# endif /* ! defined YYDEBUG */
+#endif /* ! defined D2_PARSER_DEBUG */
+
+#line 14 "d2_parser.yy" // lalr1.cc:392
+namespace isc { namespace dhcp {
+#line 141 "d2_parser.h" // lalr1.cc:392
+
+
+
+ /// A char[S] buffer to store and retrieve objects.
+ ///
+ /// Sort of a variant, but does not keep track of the nature
+ /// of the stored data, since that knowledge is available
+ /// via the current state.
+ template <size_t S>
+ struct variant
+ {
+ /// Type of *this.
+ typedef variant<S> self_type;
+
+ /// Empty construction.
+ variant ()
+ : yytypeid_ (YY_NULLPTR)
+ {}
+
+ /// Construct and fill.
+ template <typename T>
+ variant (const T& t)
+ : yytypeid_ (&typeid (T))
+ {
+ YYASSERT (sizeof (T) <= S);
+ new (yyas_<T> ()) T (t);
+ }
+
+ /// Destruction, allowed only if empty.
+ ~variant ()
+ {
+ YYASSERT (!yytypeid_);
+ }
+
+ /// Instantiate an empty \a T in here.
+ template <typename T>
+ T&
+ build ()
+ {
+ YYASSERT (!yytypeid_);
+ YYASSERT (sizeof (T) <= S);
+ yytypeid_ = & typeid (T);
+ return *new (yyas_<T> ()) T;
+ }
+
+ /// Instantiate a \a T in here from \a t.
+ template <typename T>
+ T&
+ build (const T& t)
+ {
+ YYASSERT (!yytypeid_);
+ YYASSERT (sizeof (T) <= S);
+ yytypeid_ = & typeid (T);
+ return *new (yyas_<T> ()) T (t);
+ }
+
+ /// Accessor to a built \a T.
+ template <typename T>
+ T&
+ as ()
+ {
+ YYASSERT (*yytypeid_ == typeid (T));
+ YYASSERT (sizeof (T) <= S);
+ return *yyas_<T> ();
+ }
+
+ /// Const accessor to a built \a T (for %printer).
+ template <typename T>
+ const T&
+ as () const
+ {
+ YYASSERT (*yytypeid_ == typeid (T));
+ YYASSERT (sizeof (T) <= S);
+ return *yyas_<T> ();
+ }
+
+ /// Swap the content with \a other, of same type.
+ ///
+ /// Both variants must be built beforehand, because swapping the actual
+ /// data requires reading it (with as()), and this is not possible on
+ /// unconstructed variants: it would require some dynamic testing, which
+ /// should not be the variant's responsability.
+ /// Swapping between built and (possibly) non-built is done with
+ /// variant::move ().
+ template <typename T>
+ void
+ swap (self_type& other)
+ {
+ YYASSERT (yytypeid_);
+ YYASSERT (*yytypeid_ == *other.yytypeid_);
+ std::swap (as<T> (), other.as<T> ());
+ }
+
+ /// Move the content of \a other to this.
+ ///
+ /// Destroys \a other.
+ template <typename T>
+ void
+ move (self_type& other)
+ {
+ build<T> ();
+ swap<T> (other);
+ other.destroy<T> ();
+ }
+
+ /// Copy the content of \a other to this.
+ template <typename T>
+ void
+ copy (const self_type& other)
+ {
+ build<T> (other.as<T> ());
+ }
+
+ /// Destroy the stored \a T.
+ template <typename T>
+ void
+ destroy ()
+ {
+ as<T> ().~T ();
+ yytypeid_ = YY_NULLPTR;
+ }
+
+ private:
+ /// Prohibit blind copies.
+ self_type& operator=(const self_type&);
+ variant (const self_type&);
+
+ /// Accessor to raw memory as \a T.
+ template <typename T>
+ T*
+ yyas_ ()
+ {
+ void *yyp = yybuffer_.yyraw;
+ return static_cast<T*> (yyp);
+ }
+
+ /// Const accessor to raw memory as \a T.
+ template <typename T>
+ const T*
+ yyas_ () const
+ {
+ const void *yyp = yybuffer_.yyraw;
+ return static_cast<const T*> (yyp);
+ }
+
+ union
+ {
+ /// Strongest alignment constraints.
+ long double yyalign_me;
+ /// A buffer large enough to store any of the semantic values.
+ char yyraw[S];
+ } yybuffer_;
+
+ /// Whether the content is built: if defined, the name of the stored type.
+ const std::type_info *yytypeid_;
+ };
+
+
+ /// A Bison parser.
+ class D2Parser
+ {
+ public:
+#ifndef D2_PARSER_STYPE
+ /// An auxiliary type to compute the largest semantic type.
+ union union_type
+ {
+ // value
+ // ncr_protocol_value
+ char dummy1[sizeof(ElementPtr)];
+
+ // "boolean"
+ char dummy2[sizeof(bool)];
+
+ // "floating point"
+ char dummy3[sizeof(double)];
+
+ // "integer"
+ char dummy4[sizeof(int64_t)];
+
+ // "constant string"
+ char dummy5[sizeof(std::string)];
+};
+
+ /// Symbol semantic values.
+ typedef variant<sizeof(union_type)> semantic_type;
+#else
+ typedef D2_PARSER_STYPE semantic_type;
+#endif
+ /// Symbol locations.
+ typedef location location_type;
+
+ /// Syntax errors thrown from user actions.
+ struct syntax_error : std::runtime_error
+ {
+ syntax_error (const location_type& l, const std::string& m);
+ location_type location;
+ };
+
+ /// Tokens.
+ struct token
+ {
+ enum yytokentype
+ {
+ TOKEN_END = 0,
+ TOKEN_COMMA = 258,
+ TOKEN_COLON = 259,
+ TOKEN_LSQUARE_BRACKET = 260,
+ TOKEN_RSQUARE_BRACKET = 261,
+ TOKEN_LCURLY_BRACKET = 262,
+ TOKEN_RCURLY_BRACKET = 263,
+ TOKEN_NULL_TYPE = 264,
+ TOKEN_DHCP6 = 265,
+ TOKEN_DHCP4 = 266,
+ TOKEN_DHCPDDNS = 267,
+ TOKEN_IP_ADDRESS = 268,
+ TOKEN_PORT = 269,
+ TOKEN_DNS_SERVER_TIMEOUT = 270,
+ TOKEN_NCR_PROTOCOL = 271,
+ TOKEN_UDP = 272,
+ TOKEN_TCP = 273,
+ TOKEN_NCR_FORMAT = 274,
+ TOKEN_JSON = 275,
+ TOKEN_LOGGING = 276,
+ TOKEN_LOGGERS = 277,
+ TOKEN_NAME = 278,
+ TOKEN_OUTPUT_OPTIONS = 279,
+ TOKEN_OUTPUT = 280,
+ TOKEN_DEBUGLEVEL = 281,
+ TOKEN_SEVERITY = 282,
+ TOKEN_TOPLEVEL_JSON = 283,
+ TOKEN_TOPLEVEL_DHCPDDNS = 284,
+ TOKEN_SUB_DHCPDDNS = 285,
+ TOKEN_STRING = 286,
+ TOKEN_INTEGER = 287,
+ TOKEN_FLOAT = 288,
+ TOKEN_BOOLEAN = 289
+ };
+ };
+
+ /// (External) token type, as returned by yylex.
+ typedef token::yytokentype token_type;
+
+ /// Symbol type: an internal symbol number.
+ typedef int symbol_number_type;
+
+ /// The symbol type number to denote an empty symbol.
+ enum { empty_symbol = -2 };
+
+ /// Internal symbol number for tokens (subsumed by symbol_number_type).
+ typedef unsigned char token_number_type;
+
+ /// A complete symbol.
+ ///
+ /// Expects its Base type to provide access to the symbol type
+ /// via type_get().
+ ///
+ /// Provide access to semantic value and location.
+ template <typename Base>
+ struct basic_symbol : Base
+ {
+ /// Alias to Base.
+ typedef Base super_type;
+
+ /// Default constructor.
+ basic_symbol ();
+
+ /// Copy constructor.
+ basic_symbol (const basic_symbol& other);
+
+ /// Constructor for valueless symbols, and symbols from each type.
+
+ basic_symbol (typename Base::kind_type t, const location_type& l);
+
+ basic_symbol (typename Base::kind_type t, const ElementPtr v, const location_type& l);
+
+ basic_symbol (typename Base::kind_type t, const bool v, const location_type& l);
+
+ basic_symbol (typename Base::kind_type t, const double v, const location_type& l);
+
+ basic_symbol (typename Base::kind_type t, const int64_t v, const location_type& l);
+
+ basic_symbol (typename Base::kind_type t, const std::string v, const location_type& l);
+
+
+ /// Constructor for symbols with semantic value.
+ basic_symbol (typename Base::kind_type t,
+ const semantic_type& v,
+ const location_type& l);
+
+ /// Destroy the symbol.
+ ~basic_symbol ();
+
+ /// Destroy contents, and record that is empty.
+ void clear ();
+
+ /// Whether empty.
+ bool empty () const;
+
+ /// Destructive move, \a s is emptied into this.
+ void move (basic_symbol& s);
+
+ /// The semantic value.
+ semantic_type value;
+
+ /// The location.
+ location_type location;
+
+ private:
+ /// Assignment operator.
+ basic_symbol& operator= (const basic_symbol& other);
+ };
+
+ /// Type access provider for token (enum) based symbols.
+ struct by_type
+ {
+ /// Default constructor.
+ by_type ();
+
+ /// Copy constructor.
+ by_type (const by_type& other);
+
+ /// The symbol type as needed by the constructor.
+ typedef token_type kind_type;
+
+ /// Constructor from (external) token numbers.
+ by_type (kind_type t);
+
+ /// Record that this symbol is empty.
+ void clear ();
+
+ /// Steal the symbol type from \a that.
+ void move (by_type& that);
+
+ /// The (internal) type number (corresponding to \a type).
+ /// \a empty when empty.
+ symbol_number_type type_get () const;
+
+ /// The token.
+ token_type token () const;
+
+ /// The symbol type.
+ /// \a empty_symbol when empty.
+ /// An int, not token_number_type, to be able to store empty_symbol.
+ int type;
+ };
+
+ /// "External" symbols: returned by the scanner.
+ typedef basic_symbol<by_type> symbol_type;
+
+ // Symbol constructors declarations.
+ static inline
+ symbol_type
+ make_END (const location_type& l);
+
+ static inline
+ symbol_type
+ make_COMMA (const location_type& l);
+
+ static inline
+ symbol_type
+ make_COLON (const location_type& l);
+
+ static inline
+ symbol_type
+ make_LSQUARE_BRACKET (const location_type& l);
+
+ static inline
+ symbol_type
+ make_RSQUARE_BRACKET (const location_type& l);
+
+ static inline
+ symbol_type
+ make_LCURLY_BRACKET (const location_type& l);
+
+ static inline
+ symbol_type
+ make_RCURLY_BRACKET (const location_type& l);
+
+ static inline
+ symbol_type
+ make_NULL_TYPE (const location_type& l);
+
+ static inline
+ symbol_type
+ make_DHCP6 (const location_type& l);
+
+ static inline
+ symbol_type
+ make_DHCP4 (const location_type& l);
+
+ static inline
+ symbol_type
+ make_DHCPDDNS (const location_type& l);
+
+ static inline
+ symbol_type
+ make_IP_ADDRESS (const location_type& l);
+
+ static inline
+ symbol_type
+ make_PORT (const location_type& l);
+
+ static inline
+ symbol_type
+ make_DNS_SERVER_TIMEOUT (const location_type& l);
+
+ static inline
+ symbol_type
+ make_NCR_PROTOCOL (const location_type& l);
+
+ static inline
+ symbol_type
+ make_UDP (const location_type& l);
+
+ static inline
+ symbol_type
+ make_TCP (const location_type& l);
+
+ static inline
+ symbol_type
+ make_NCR_FORMAT (const location_type& l);
+
+ static inline
+ symbol_type
+ make_JSON (const location_type& l);
+
+ static inline
+ symbol_type
+ make_LOGGING (const location_type& l);
+
+ static inline
+ symbol_type
+ make_LOGGERS (const location_type& l);
+
+ static inline
+ symbol_type
+ make_NAME (const location_type& l);
+
+ static inline
+ symbol_type
+ make_OUTPUT_OPTIONS (const location_type& l);
+
+ static inline
+ symbol_type
+ make_OUTPUT (const location_type& l);
+
+ static inline
+ symbol_type
+ make_DEBUGLEVEL (const location_type& l);
+
+ static inline
+ symbol_type
+ make_SEVERITY (const location_type& l);
+
+ static inline
+ symbol_type
+ make_TOPLEVEL_JSON (const location_type& l);
+
+ static inline
+ symbol_type
+ make_TOPLEVEL_DHCPDDNS (const location_type& l);
+
+ static inline
+ symbol_type
+ make_SUB_DHCPDDNS (const location_type& l);
+
+ static inline
+ symbol_type
+ make_STRING (const std::string& v, const location_type& l);
+
+ static inline
+ symbol_type
+ make_INTEGER (const int64_t& v, const location_type& l);
+
+ static inline
+ symbol_type
+ make_FLOAT (const double& v, const location_type& l);
+
+ static inline
+ symbol_type
+ make_BOOLEAN (const bool& v, const location_type& l);
+
+
+ /// Build a parser object.
+ D2Parser (isc::dhcp::D2ParserContext& ctx_yyarg);
+ virtual ~D2Parser ();
+
+ /// Parse.
+ /// \returns 0 iff parsing succeeded.
+ virtual int parse ();
+
+#if D2_PARSER_DEBUG
+ /// The current debugging stream.
+ std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
+ /// Set the current debugging stream.
+ void set_debug_stream (std::ostream &);
+
+ /// Type for debugging levels.
+ typedef int debug_level_type;
+ /// The current debugging level.
+ debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
+ /// Set the current debugging level.
+ void set_debug_level (debug_level_type l);
+#endif
+
+ /// Report a syntax error.
+ /// \param loc where the syntax error is found.
+ /// \param msg a description of the syntax error.
+ virtual void error (const location_type& loc, const std::string& msg);
+
+ /// Report a syntax error.
+ void error (const syntax_error& err);
+
+ private:
+ /// This class is not copyable.
+ D2Parser (const D2Parser&);
+ D2Parser& operator= (const D2Parser&);
+
+ /// State numbers.
+ typedef int state_type;
+
+ /// Generate an error message.
+ /// \param yystate the state where the error occurred.
+ /// \param yyla the lookahead token.
+ virtual std::string yysyntax_error_ (state_type yystate,
+ const symbol_type& yyla) const;
+
+ /// Compute post-reduction state.
+ /// \param yystate the current state
+ /// \param yysym the nonterminal to push on the stack
+ state_type yy_lr_goto_state_ (state_type yystate, int yysym);
+
+ /// Whether the given \c yypact_ value indicates a defaulted state.
+ /// \param yyvalue the value to check
+ static bool yy_pact_value_is_default_ (int yyvalue);
+
+ /// Whether the given \c yytable_ value indicates a syntax error.
+ /// \param yyvalue the value to check
+ static bool yy_table_value_is_error_ (int yyvalue);
+
+ static const signed char yypact_ninf_;
+ static const signed char yytable_ninf_;
+
+ /// Convert a scanner token number \a t to a symbol number.
+ static token_number_type yytranslate_ (token_type t);
+
+ // Tables.
+ // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ // STATE-NUM.
+ static const signed char yypact_[];
+
+ // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
+ // Performed when YYTABLE does not specify something else to do. Zero
+ // means the default is an error.
+ static const unsigned char yydefact_[];
+
+ // YYPGOTO[NTERM-NUM].
+ static const signed char yypgoto_[];
+
+ // YYDEFGOTO[NTERM-NUM].
+ static const short int yydefgoto_[];
+
+ // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
+ // positive, shift that token. If negative, reduce the rule whose
+ // number is the opposite. If YYTABLE_NINF, syntax error.
+ static const unsigned char yytable_[];
+
+ static const short int yycheck_[];
+
+ // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ // symbol of state STATE-NUM.
+ static const unsigned char yystos_[];
+
+ // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
+ static const unsigned char yyr1_[];
+
+ // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
+ static const unsigned char yyr2_[];
+
+
+ /// Convert the symbol name \a n to a form suitable for a diagnostic.
+ static std::string yytnamerr_ (const char *n);
+
+
+ /// For a symbol, its name in clear.
+ static const char* const yytname_[];
+#if D2_PARSER_DEBUG
+ // YYRLINE[YYN] -- Source line where rule number YYN was defined.
+ static const unsigned short int yyrline_[];
+ /// Report on the debug stream that the rule \a r is going to be reduced.
+ virtual void yy_reduce_print_ (int r);
+ /// Print the state stack on the debug stream.
+ virtual void yystack_print_ ();
+
+ // Debugging.
+ int yydebug_;
+ std::ostream* yycdebug_;
+
+ /// \brief Display a symbol type, value and location.
+ /// \param yyo The output stream.
+ /// \param yysym The symbol.
+ template <typename Base>
+ void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
+#endif
+
+ /// \brief Reclaim the memory associated to a symbol.
+ /// \param yymsg Why this token is reclaimed.
+ /// If null, print nothing.
+ /// \param yysym The symbol.
+ template <typename Base>
+ void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
+
+ private:
+ /// Type access provider for state based symbols.
+ struct by_state
+ {
+ /// Default constructor.
+ by_state ();
+
+ /// The symbol type as needed by the constructor.
+ typedef state_type kind_type;
+
+ /// Constructor.
+ by_state (kind_type s);
+
+ /// Copy constructor.
+ by_state (const by_state& other);
+
+ /// Record that this symbol is empty.
+ void clear ();
+
+ /// Steal the symbol type from \a that.
+ void move (by_state& that);
+
+ /// The (internal) type number (corresponding to \a state).
+ /// \a empty_symbol when empty.
+ symbol_number_type type_get () const;
+
+ /// The state number used to denote an empty symbol.
+ enum { empty_state = -1 };
+
+ /// The state.
+ /// \a empty when empty.
+ state_type state;
+ };
+
+ /// "Internal" symbol: element of the stack.
+ struct stack_symbol_type : basic_symbol<by_state>
+ {
+ /// Superclass.
+ typedef basic_symbol<by_state> super_type;
+ /// Construct an empty symbol.
+ stack_symbol_type ();
+ /// Steal the contents from \a sym to build this.
+ stack_symbol_type (state_type s, symbol_type& sym);
+ /// Assignment, needed by push_back.
+ stack_symbol_type& operator= (const stack_symbol_type& that);
+ };
+
+ /// Stack type.
+ typedef stack<stack_symbol_type> stack_type;
+
+ /// The stack.
+ stack_type yystack_;
+
+ /// Push a new state on the stack.
+ /// \param m a debug message to display
+ /// if null, no trace is output.
+ /// \param s the symbol
+ /// \warning the contents of \a s.value is stolen.
+ void yypush_ (const char* m, stack_symbol_type& s);
+
+ /// Push a new look ahead token on the state on the stack.
+ /// \param m a debug message to display
+ /// if null, no trace is output.
+ /// \param s the state
+ /// \param sym the symbol (for its value and location).
+ /// \warning the contents of \a s.value is stolen.
+ void yypush_ (const char* m, state_type s, symbol_type& sym);
+
+ /// Pop \a n symbols the three stacks.
+ void yypop_ (unsigned int n = 1);
+
+ /// Constants.
+ enum
+ {
+ yyeof_ = 0,
+ yylast_ = 111, ///< Last index in yytable_.
+ yynnts_ = 63, ///< Number of nonterminal symbols.
+ yyfinal_ = 8, ///< Termination state number.
+ yyterror_ = 1,
+ yyerrcode_ = 256,
+ yyntokens_ = 35 ///< Number of tokens.
+ };
+
+
+ // User arguments.
+ isc::dhcp::D2ParserContext& ctx;
+ };
+
+ // Symbol number corresponding to token number t.
+ inline
+ D2Parser::token_number_type
+ D2Parser::yytranslate_ (token_type t)
+ {
+ static
+ const token_number_type
+ translate_table[] =
+ {
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34
+ };
+ const unsigned int user_token_number_max_ = 289;
+ const token_number_type undef_token_ = 2;
+
+ if (static_cast<int>(t) <= yyeof_)
+ return yyeof_;
+ else if (static_cast<unsigned int> (t) <= user_token_number_max_)
+ return translate_table[t];
+ else
+ return undef_token_;
+ }
+
+ inline
+ D2Parser::syntax_error::syntax_error (const location_type& l, const std::string& m)
+ : std::runtime_error (m)
+ , location (l)
+ {}
+
+ // basic_symbol.
+ template <typename Base>
+ inline
+ D2Parser::basic_symbol<Base>::basic_symbol ()
+ : value ()
+ {}
+
+ template <typename Base>
+ inline
+ D2Parser::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
+ : Base (other)
+ , value ()
+ , location (other.location)
+ {
+ switch (other.type_get ())
+ {
+ case 40: // value
+ case 67: // ncr_protocol_value
+ value.copy< ElementPtr > (other.value);
+ break;
+
+ case 34: // "boolean"
+ value.copy< bool > (other.value);
+ break;
+
+ case 33: // "floating point"
+ value.copy< double > (other.value);
+ break;
+
+ case 32: // "integer"
+ value.copy< int64_t > (other.value);
+ break;
+
+ case 31: // "constant string"
+ value.copy< std::string > (other.value);
+ break;
+
+ default:
+ break;
+ }
+
+ }
+
+
+ template <typename Base>
+ inline
+ D2Parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const semantic_type& v, const location_type& l)
+ : Base (t)
+ , value ()
+ , location (l)
+ {
+ (void) v;
+ switch (this->type_get ())
+ {
+ case 40: // value
+ case 67: // ncr_protocol_value
+ value.copy< ElementPtr > (v);
+ break;
+
+ case 34: // "boolean"
+ value.copy< bool > (v);
+ break;
+
+ case 33: // "floating point"
+ value.copy< double > (v);
+ break;
+
+ case 32: // "integer"
+ value.copy< int64_t > (v);
+ break;
+
+ case 31: // "constant string"
+ value.copy< std::string > (v);
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+ // Implementation of basic_symbol constructor for each type.
+
+ template <typename Base>
+ D2Parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const location_type& l)
+ : Base (t)
+ , value ()
+ , location (l)
+ {}
+
+ template <typename Base>
+ D2Parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const ElementPtr v, const location_type& l)
+ : Base (t)
+ , value (v)
+ , location (l)
+ {}
+
+ template <typename Base>
+ D2Parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const bool v, const location_type& l)
+ : Base (t)
+ , value (v)
+ , location (l)
+ {}
+
+ template <typename Base>
+ D2Parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const double v, const location_type& l)
+ : Base (t)
+ , value (v)
+ , location (l)
+ {}
+
+ template <typename Base>
+ D2Parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const int64_t v, const location_type& l)
+ : Base (t)
+ , value (v)
+ , location (l)
+ {}
+
+ template <typename Base>
+ D2Parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const std::string v, const location_type& l)
+ : Base (t)
+ , value (v)
+ , location (l)
+ {}
+
+
+ template <typename Base>
+ inline
+ D2Parser::basic_symbol<Base>::~basic_symbol ()
+ {
+ clear ();
+ }
+
+ template <typename Base>
+ inline
+ void
+ D2Parser::basic_symbol<Base>::clear ()
+ {
+ // User destructor.
+ symbol_number_type yytype = this->type_get ();
+ basic_symbol<Base>& yysym = *this;
+ (void) yysym;
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+
+ // Type destructor.
+ switch (yytype)
+ {
+ case 40: // value
+ case 67: // ncr_protocol_value
+ value.template destroy< ElementPtr > ();
+ break;
+
+ case 34: // "boolean"
+ value.template destroy< bool > ();
+ break;
+
+ case 33: // "floating point"
+ value.template destroy< double > ();
+ break;
+
+ case 32: // "integer"
+ value.template destroy< int64_t > ();
+ break;
+
+ case 31: // "constant string"
+ value.template destroy< std::string > ();
+ break;
+
+ default:
+ break;
+ }
+
+ Base::clear ();
+ }
+
+ template <typename Base>
+ inline
+ bool
+ D2Parser::basic_symbol<Base>::empty () const
+ {
+ return Base::type_get () == empty_symbol;
+ }
+
+ template <typename Base>
+ inline
+ void
+ D2Parser::basic_symbol<Base>::move (basic_symbol& s)
+ {
+ super_type::move(s);
+ switch (this->type_get ())
+ {
+ case 40: // value
+ case 67: // ncr_protocol_value
+ value.move< ElementPtr > (s.value);
+ break;
+
+ case 34: // "boolean"
+ value.move< bool > (s.value);
+ break;
+
+ case 33: // "floating point"
+ value.move< double > (s.value);
+ break;
+
+ case 32: // "integer"
+ value.move< int64_t > (s.value);
+ break;
+
+ case 31: // "constant string"
+ value.move< std::string > (s.value);
+ break;
+
+ default:
+ break;
+ }
+
+ location = s.location;
+ }
+
+ // by_type.
+ inline
+ D2Parser::by_type::by_type ()
+ : type (empty_symbol)
+ {}
+
+ inline
+ D2Parser::by_type::by_type (const by_type& other)
+ : type (other.type)
+ {}
+
+ inline
+ D2Parser::by_type::by_type (token_type t)
+ : type (yytranslate_ (t))
+ {}
+
+ inline
+ void
+ D2Parser::by_type::clear ()
+ {
+ type = empty_symbol;
+ }
+
+ inline
+ void
+ D2Parser::by_type::move (by_type& that)
+ {
+ type = that.type;
+ that.clear ();
+ }
+
+ inline
+ int
+ D2Parser::by_type::type_get () const
+ {
+ return type;
+ }
+
+ inline
+ D2Parser::token_type
+ D2Parser::by_type::token () const
+ {
+ // YYTOKNUM[NUM] -- (External) token number corresponding to the
+ // (internal) symbol number NUM (which must be that of a token). */
+ static
+ const unsigned short int
+ yytoken_number_[] =
+ {
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
+ 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
+ 285, 286, 287, 288, 289
+ };
+ return static_cast<token_type> (yytoken_number_[type]);
+ }
+ // Implementation of make_symbol for each symbol type.
+ D2Parser::symbol_type
+ D2Parser::make_END (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_END, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_COMMA (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_COMMA, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_COLON (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_COLON, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_LSQUARE_BRACKET (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_LSQUARE_BRACKET, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_RSQUARE_BRACKET (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_RSQUARE_BRACKET, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_LCURLY_BRACKET (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_LCURLY_BRACKET, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_RCURLY_BRACKET (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_RCURLY_BRACKET, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_NULL_TYPE (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_NULL_TYPE, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_DHCP6 (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_DHCP6, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_DHCP4 (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_DHCP4, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_DHCPDDNS (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_DHCPDDNS, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_IP_ADDRESS (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_IP_ADDRESS, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_PORT (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_PORT, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_DNS_SERVER_TIMEOUT (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_DNS_SERVER_TIMEOUT, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_NCR_PROTOCOL (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_NCR_PROTOCOL, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_UDP (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_UDP, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_TCP (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_TCP, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_NCR_FORMAT (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_NCR_FORMAT, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_JSON (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_JSON, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_LOGGING (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_LOGGING, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_LOGGERS (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_LOGGERS, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_NAME (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_NAME, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_OUTPUT_OPTIONS (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_OUTPUT_OPTIONS, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_OUTPUT (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_OUTPUT, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_DEBUGLEVEL (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_DEBUGLEVEL, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_SEVERITY (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_SEVERITY, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_TOPLEVEL_JSON (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_TOPLEVEL_JSON, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_TOPLEVEL_DHCPDDNS (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_TOPLEVEL_DHCPDDNS, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_SUB_DHCPDDNS (const location_type& l)
+ {
+ return symbol_type (token::TOKEN_SUB_DHCPDDNS, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_STRING (const std::string& v, const location_type& l)
+ {
+ return symbol_type (token::TOKEN_STRING, v, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_INTEGER (const int64_t& v, const location_type& l)
+ {
+ return symbol_type (token::TOKEN_INTEGER, v, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_FLOAT (const double& v, const location_type& l)
+ {
+ return symbol_type (token::TOKEN_FLOAT, v, l);
+ }
+
+ D2Parser::symbol_type
+ D2Parser::make_BOOLEAN (const bool& v, const location_type& l)
+ {
+ return symbol_type (token::TOKEN_BOOLEAN, v, l);
+ }
+
+
+#line 14 "d2_parser.yy" // lalr1.cc:392
+} } // isc::dhcp
+#line 1378 "d2_parser.h" // lalr1.cc:392
+
+
+
+
+#endif // !YY_D2_PARSER_D2_PARSER_H_INCLUDED
--- /dev/null
+/* Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+%skeleton "lalr1.cc" /* -*- C++ -*- */
+%require "3.0.0"
+%defines
+%define parser_class_name {D2Parser}
+%define api.prefix {d2_parser_}
+%define api.token.constructor
+%define api.value.type variant
+%define api.namespace {isc::dhcp}
+%define parse.assert
+%code requires
+{
+#include <string>
+#include <cc/data.h>
+#include <d2/d2_config.h>
+#include <boost/lexical_cast.hpp>
+#include <d2/parser_context_decl.h>
+
+using namespace isc::dhcp;
+using namespace isc::data;
+using namespace std;
+}
+// The parsing context.
+%param { isc::dhcp::D2ParserContext& ctx }
+%locations
+%define parse.trace
+%define parse.error verbose
+%code
+{
+#include <d2/parser_context.h>
+}
+
+
+%define api.token.prefix {TOKEN_}
+// Tokens in an order which makes sense and related to the intented use.
+// Actual regexps for tokens are defined in dhcp6_lexer.ll.
+%token
+ END 0 "end of file"
+ COMMA ","
+ COLON ":"
+ LSQUARE_BRACKET "["
+ RSQUARE_BRACKET "]"
+ LCURLY_BRACKET "{"
+ RCURLY_BRACKET "}"
+ NULL_TYPE "null"
+
+ DHCP6 "Dhcp6"
+ DHCP4 "Dhcp4"
+
+ DHCPDDNS "DhcpDdns"
+ IP_ADDRESS "ip-address"
+ PORT "port"
+ DNS_SERVER_TIMEOUT "dns-server-timeout"
+ NCR_PROTOCOL "ncr-protocol"
+ UDP "UDP"
+ TCP "TCP"
+ NCR_FORMAT "ncr-format"
+ JSON "JSON"
+
+ LOGGING "Logging"
+ LOGGERS "loggers"
+ NAME "name"
+ OUTPUT_OPTIONS "output_options"
+ OUTPUT "output"
+ DEBUGLEVEL "debuglevel"
+ SEVERITY "severity"
+
+ // Not real tokens, just a way to signal what the parser is expected to
+ // parse.
+ TOPLEVEL_JSON
+ TOPLEVEL_DHCPDDNS
+ SUB_DHCPDDNS
+;
+
+%token <std::string> STRING "constant string"
+%token <int64_t> INTEGER "integer"
+%token <double> FLOAT "floating point"
+%token <bool> BOOLEAN "boolean"
+
+%type <ElementPtr> value
+%type <ElementPtr> ncr_protocol_value
+
+%printer { yyoutput << $$; } <*>;
+
+%%
+
+// The whole grammar starts with a map, because the config file
+// constists of Dhcp, Logger and DhcpDdns entries in one big { }.
+// We made the same for subparsers at the exception of the JSON value.
+%start start;
+
+start: TOPLEVEL_JSON { ctx.ctx_ = ctx.NO_KEYWORD; } sub_json
+ | TOPLEVEL_DHCPDDNS { ctx.ctx_ = ctx.CONFIG; } syntax_map
+ | SUB_DHCPDDNS { ctx.ctx_ = ctx.DHCPDDNS; } sub_dhcpddns
+ ;
+
+// ---- generic JSON parser ---------------------------------
+
+// Note that ctx_ is NO_KEYWORD here
+
+// Values rule
+value: INTEGER { $$ = ElementPtr(new IntElement($1, ctx.loc2pos(@1))); }
+ | FLOAT { $$ = ElementPtr(new DoubleElement($1, ctx.loc2pos(@1))); }
+ | BOOLEAN { $$ = ElementPtr(new BoolElement($1, ctx.loc2pos(@1))); }
+ | STRING { $$ = ElementPtr(new StringElement($1, ctx.loc2pos(@1))); }
+ | NULL_TYPE { $$ = ElementPtr(new NullElement(ctx.loc2pos(@1))); }
+ | map2 { $$ = ctx.stack_.back(); ctx.stack_.pop_back(); }
+ | list_generic { $$ = ctx.stack_.back(); ctx.stack_.pop_back(); }
+ ;
+
+sub_json: value {
+ // Push back the JSON value on the stack
+ ctx.stack_.push_back($1);
+};
+
+map2: LCURLY_BRACKET {
+ // This code is executed when we're about to start parsing
+ // the content of the map
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.push_back(m);
+} map_content RCURLY_BRACKET {
+ // map parsing completed. If we ever want to do any wrap up
+ // (maybe some sanity checking), this would be the best place
+ // for it.
+};
+
+// Assignments rule
+map_content: %empty // empty map
+ | not_empty_map
+ ;
+
+not_empty_map: STRING COLON value {
+ // map containing a single entry
+ ctx.stack_.back()->set($1, $3);
+ }
+ | not_empty_map COMMA STRING COLON value {
+ // map consisting of a shorter map followed by
+ // comma and string:value
+ ctx.stack_.back()->set($3, $5);
+ }
+ ;
+
+list_generic: LSQUARE_BRACKET {
+ ElementPtr l(new ListElement(ctx.loc2pos(@1)));
+ ctx.stack_.push_back(l);
+} list_content RSQUARE_BRACKET {
+ // list parsing complete. Put any sanity checking here
+};
+
+//// This one is used in syntax parser.
+//list2: LSQUARE_BRACKET {
+// // List parsing about to start
+//} list_content RSQUARE_BRACKET {
+// // list parsing complete. Put any sanity checking here
+// //ctx.stack_.pop_back();
+//};
+
+list_content: %empty // Empty list
+ | not_empty_list
+ ;
+
+not_empty_list: value {
+ // List consisting of a single element.
+ ctx.stack_.back()->add($1);
+ }
+ | not_empty_list COMMA value {
+ // List ending with , and a value.
+ ctx.stack_.back()->add($3);
+ }
+ ;
+
+// ---- generic JSON parser ends here ----------------------------------
+
+// ---- syntax checking parser starts here -----------------------------
+
+// Unknown keyword in a map
+unknown_map_entry: STRING COLON {
+ const std::string& where = ctx.contextName();
+ const std::string& keyword = $1;
+ error(@1,
+ "got unexpected keyword \"" + keyword + "\" in " + where + " map.");
+};
+
+
+// This defines the top-level { } that holds Dhcp6, Dhcp4, DhcpDdns or Logging
+// objects.
+syntax_map: LCURLY_BRACKET {
+ // This code is executed when we're about to start parsing
+ // the content of the map
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.push_back(m);
+} global_objects RCURLY_BRACKET {
+ // map parsing completed. If we ever want to do any wrap up
+ // (maybe some sanity checking), this would be the best place
+ // for it.
+};
+
+// This represents top-level entries: Dhcp6, Dhcp4, DhcpDdns, Logging
+global_objects: global_object
+ | global_objects COMMA global_object
+ ;
+
+// This represents a single top level entry, e.g. Dhcp6 or DhcpDdns.
+global_object: dhcp6_json_object
+ | logging_object
+ | dhcp4_json_object
+ | dhcpddns_object
+ | unknown_map_entry
+ ;
+
+// --- dhcp ddns ---------------------------------------------
+
+dhcpddns_object: DHCPDDNS {
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.back()->set("DhcpDdns", m);
+ ctx.stack_.push_back(m);
+ ctx.enter(ctx.DHCPDDNS);
+} COLON LCURLY_BRACKET dhcpddns_params RCURLY_BRACKET {
+ ctx.stack_.pop_back();
+ ctx.leave();
+};
+
+sub_dhcpddns: LCURLY_BRACKET {
+ // Parse the dhcpddns map
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.push_back(m);
+} dhcpddns_params RCURLY_BRACKET {
+ // parsing completed
+};
+
+dhcpddns_params: dhcpddns_param
+ | dhcpddns_params COMMA dhcpddns_param
+ ;
+// These are teh top-level parameters allowed for DhcpDdns
+dhcpddns_param: ip_address
+ | port
+ | dns_server_timeout
+ | ncr_protocol
+ | ncr_format
+ | unknown_map_entry
+ ;
+
+ip_address: IP_ADDRESS {
+ ctx.enter(ctx.NO_KEYWORD);
+} COLON STRING {
+ ElementPtr s(new StringElement($4, ctx.loc2pos(@4)));
+ ctx.stack_.back()->set("ip-address", s);
+ ctx.leave();
+};
+
+port: PORT COLON INTEGER {
+ ElementPtr i(new IntElement($3, ctx.loc2pos(@3)));
+ ctx.stack_.back()->set("port", i);
+};
+
+dns_server_timeout: DNS_SERVER_TIMEOUT COLON INTEGER {
+ ElementPtr i(new IntElement($3, ctx.loc2pos(@3)));
+ ctx.stack_.back()->set("dns-server-timeout", i);
+};
+
+ncr_protocol: NCR_PROTOCOL {
+ ctx.enter(ctx.NCR_PROTOCOL);
+} COLON ncr_protocol_value {
+ ctx.stack_.back()->set("ncr-protocol", $4);
+ ctx.leave();
+};
+
+ncr_protocol_value:
+ UDP { $$ = ElementPtr(new StringElement("UDP", ctx.loc2pos(@1))); }
+ | TCP { $$ = ElementPtr(new StringElement("TCP", ctx.loc2pos(@1))); }
+ ;
+
+ncr_format: NCR_FORMAT {
+ ctx.enter(ctx.NCR_FORMAT);
+} COLON JSON {
+ ElementPtr json(new StringElement("JSON", ctx.loc2pos(@4)));
+ ctx.stack_.back()->set("ncr-format", json);
+ ctx.leave();
+};
+
+dhcp6_json_object: DHCP6 {
+ ctx.enter(ctx.NO_KEYWORD);
+} COLON value {
+ ctx.stack_.back()->set("Dhcp6", $4);
+ ctx.leave();
+};
+
+dhcp4_json_object: DHCP4 {
+ ctx.enter(ctx.NO_KEYWORD);
+} COLON value {
+ ctx.stack_.back()->set("Dhcp4", $4);
+ ctx.leave();
+};
+
+// --- logging entry -----------------------------------------
+
+// This defines the top level "Logging" object. It parses
+// the following "Logging": { ... }. The ... is defined
+// by logging_params
+logging_object: LOGGING {
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.back()->set("Logging", m);
+ ctx.stack_.push_back(m);
+ ctx.enter(ctx.LOGGING);
+} COLON LCURLY_BRACKET logging_params RCURLY_BRACKET {
+ ctx.stack_.pop_back();
+ ctx.leave();
+};
+
+// This defines the list of allowed parameters that may appear
+// in the top-level Logging object. It can either be a single
+// parameter or several parameters separated by commas.
+logging_params: logging_param
+ | logging_params COMMA logging_param
+ ;
+
+// There's currently only one parameter defined, which is "loggers".
+logging_param: loggers;
+
+// "loggers", the only parameter currently defined in "Logging" object,
+// is "Loggers": [ ... ].
+loggers: LOGGERS {
+ ElementPtr l(new ListElement(ctx.loc2pos(@1)));
+ ctx.stack_.back()->set("loggers", l);
+ ctx.stack_.push_back(l);
+ ctx.enter(ctx.LOGGERS);
+} COLON LSQUARE_BRACKET loggers_entries RSQUARE_BRACKET {
+ ctx.stack_.pop_back();
+ ctx.leave();
+};
+
+// These are the parameters allowed in loggers: either one logger
+// entry or multiple entries separate by commas.
+loggers_entries: logger_entry
+ | loggers_entries COMMA logger_entry
+ ;
+
+// This defines a single entry defined in loggers in Logging.
+logger_entry: LCURLY_BRACKET {
+ ElementPtr l(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.back()->add(l);
+ ctx.stack_.push_back(l);
+} logger_params RCURLY_BRACKET {
+ ctx.stack_.pop_back();
+};
+
+logger_params: logger_param
+ | logger_params COMMA logger_param
+ ;
+
+logger_param: name
+ | output_options_list
+ | debuglevel
+ | severity
+ | unknown_map_entry
+ ;
+
+name: NAME {
+ ctx.enter(ctx.NO_KEYWORD);
+} COLON STRING {
+ ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
+ ctx.stack_.back()->set("name", name);
+ ctx.leave();
+};
+
+debuglevel: DEBUGLEVEL COLON INTEGER {
+ ElementPtr dl(new IntElement($3, ctx.loc2pos(@3)));
+ ctx.stack_.back()->set("debuglevel", dl);
+};
+severity: SEVERITY {
+ ctx.enter(ctx.NO_KEYWORD);
+} COLON STRING {
+ ElementPtr sev(new StringElement($4, ctx.loc2pos(@4)));
+ ctx.stack_.back()->set("severity", sev);
+ ctx.leave();
+};
+
+output_options_list: OUTPUT_OPTIONS {
+ ElementPtr l(new ListElement(ctx.loc2pos(@1)));
+ ctx.stack_.back()->set("output_options", l);
+ ctx.stack_.push_back(l);
+ ctx.enter(ctx.OUTPUT_OPTIONS);
+} COLON LSQUARE_BRACKET output_options_list_content RSQUARE_BRACKET {
+ ctx.stack_.pop_back();
+ ctx.leave();
+};
+
+output_options_list_content: output_entry
+ | output_options_list_content COMMA output_entry
+ ;
+
+output_entry: LCURLY_BRACKET {
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.back()->add(m);
+ ctx.stack_.push_back(m);
+} output_params RCURLY_BRACKET {
+ ctx.stack_.pop_back();
+};
+
+output_params: output_param
+ | output_params COMMA output_param
+ ;
+
+output_param: OUTPUT {
+ ctx.enter(ctx.NO_KEYWORD);
+} COLON STRING {
+ ElementPtr sev(new StringElement($4, ctx.loc2pos(@4)));
+ ctx.stack_.back()->set("output", sev);
+ ctx.leave();
+};
+
+%%
+
+void
+isc::dhcp::D2Parser::error(const location_type& loc,
+ const std::string& what)
+{
+ ctx.error(loc, what);
+}
--- /dev/null
+// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <d2/d2_simple_parser.h>
+#include <cc/data.h>
+#include <boost/foreach.hpp>
+
+using namespace isc::data;
+
+namespace isc {
+namespace dhcp {
+/// @brief This sets of arrays define the default values and
+/// values inherited (derived) between various scopes.
+///
+/// Each of those is documented in @file d2_simple_parser.cc. This
+/// is different than most other comments in Kea code. The reason
+/// for placing those in .cc rather than .h file is that it
+/// is expected to be one centralized place to look at for
+/// the default values. This is expected to be looked at also by
+/// people who are not skilled in C or C++, so they may be
+/// confused with the differences between declaration and definition.
+/// As such, there's one file to look at that hopefully is readable
+/// without any C or C++ skills.
+///
+/// @{
+
+/// @brief This table defines default global values for D2
+///
+/// Some of the global parameters defined in the global scope (i.e. directly
+/// in DhcpDdns) are optional. If not defined, the following values will be
+/// used.
+const SimpleDefaults D2SimpleParser::D2_GLOBAL_DEFAULTS = {
+ { "ip-address", Element::string, "127.0.0.1" },
+ { "port", Element::integer, "53001" },
+ { "dns-server-timeout", Element::integer, "100" },
+ { "ncr-protocol", Element::integer, "UDP" },
+ { "ncr-format", Element::integer, "JSON" }
+};
+
+/// @}
+
+/// ---------------------------------------------------------------------------
+/// --- end of default values -------------------------------------------------
+/// ---------------------------------------------------------------------------
+
+size_t D2SimpleParser::setAllDefaults(isc::data::ElementPtr global) {
+ size_t cnt = 0;
+
+ // Set global defaults first.
+ cnt = setDefaults(global, D2_GLOBAL_DEFAULTS);
+ return (cnt);
+}
+
+};
+};
--- /dev/null
+// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef D2_SIMPLE_PARSER_H
+#define D2_SIMPLE_PARSER_H
+
+#include <cc/simple_parser.h>
+
+namespace isc {
+namespace dhcp {
+
+/// @brief SimpleParser specialized for D2
+///
+/// This class is a @ref isc::data::SimpleParser dedicated to D2.
+/// In particular, it contains all the default values and names of the
+/// parameters that are to be derived (inherited) between scopes.
+/// For the actual values, see @file d2_simple_parser.cc
+class D2SimpleParser : public isc::data::SimpleParser {
+public:
+
+ /// @brief Sets all defaults for D2 configuration
+ ///
+ /// This method sets global and element defaults.
+ ///
+ /// @param global scope to be filled in with defaults.
+ /// @return number of default values added
+ static size_t setAllDefaults(isc::data::ElementPtr global);
+
+ // see d2_simple_parser.cc for comments for those parameters
+ static const isc::data::SimpleDefaults D2_GLOBAL_DEFAULTS;
+};
+
+};
+};
+
+#endif
--- /dev/null
+// A Bison parser, made by GNU Bison 3.0.4.
+
+// Locations for Bison parsers in C++
+
+// Copyright (C) 2002-2015 Free Software Foundation, Inc.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+// As a special exception, you may create a larger work that contains
+// part or all of the Bison parser skeleton and distribute that work
+// under terms of your choice, so long as that work isn't itself a
+// parser generator using the skeleton or a modified version thereof
+// as a parser skeleton. Alternatively, if you modify or redistribute
+// the parser skeleton itself, you may (at your option) remove this
+// special exception, which will cause the skeleton and the resulting
+// Bison output files to be licensed under the GNU General Public
+// License without this special exception.
+
+// This special exception was added by the Free Software Foundation in
+// version 2.2 of Bison.
+
+/**
+ ** \file location.hh
+ ** Define the isc::dhcp::location class.
+ */
+
+#ifndef YY_D2_PARSER_LOCATION_HH_INCLUDED
+# define YY_D2_PARSER_LOCATION_HH_INCLUDED
+
+# include "position.hh"
+
+#line 14 "d2_parser.yy" // location.cc:337
+namespace isc { namespace dhcp {
+#line 46 "location.hh" // location.cc:337
+ /// Abstract a location.
+ class location
+ {
+ public:
+
+ /// Construct a location from \a b to \a e.
+ location (const position& b, const position& e)
+ : begin (b)
+ , end (e)
+ {
+ }
+
+ /// Construct a 0-width location in \a p.
+ explicit location (const position& p = position ())
+ : begin (p)
+ , end (p)
+ {
+ }
+
+ /// Construct a 0-width location in \a f, \a l, \a c.
+ explicit location (std::string* f,
+ unsigned int l = 1u,
+ unsigned int c = 1u)
+ : begin (f, l, c)
+ , end (f, l, c)
+ {
+ }
+
+
+ /// Initialization.
+ void initialize (std::string* f = YY_NULLPTR,
+ unsigned int l = 1u,
+ unsigned int c = 1u)
+ {
+ begin.initialize (f, l, c);
+ end = begin;
+ }
+
+ /** \name Line and Column related manipulators
+ ** \{ */
+ public:
+ /// Reset initial location to final location.
+ void step ()
+ {
+ begin = end;
+ }
+
+ /// Extend the current location to the COUNT next columns.
+ void columns (int count = 1)
+ {
+ end += count;
+ }
+
+ /// Extend the current location to the COUNT next lines.
+ void lines (int count = 1)
+ {
+ end.lines (count);
+ }
+ /** \} */
+
+
+ public:
+ /// Beginning of the located region.
+ position begin;
+ /// End of the located region.
+ position end;
+ };
+
+ /// Join two locations, in place.
+ inline location& operator+= (location& res, const location& end)
+ {
+ res.end = end.end;
+ return res;
+ }
+
+ /// Join two locations.
+ inline location operator+ (location res, const location& end)
+ {
+ return res += end;
+ }
+
+ /// Add \a width columns to the end position, in place.
+ inline location& operator+= (location& res, int width)
+ {
+ res.columns (width);
+ return res;
+ }
+
+ /// Add \a width columns to the end position.
+ inline location operator+ (location res, int width)
+ {
+ return res += width;
+ }
+
+ /// Subtract \a width columns to the end position, in place.
+ inline location& operator-= (location& res, int width)
+ {
+ return res += -width;
+ }
+
+ /// Subtract \a width columns to the end position.
+ inline location operator- (location res, int width)
+ {
+ return res -= width;
+ }
+
+ /// Compare two location objects.
+ inline bool
+ operator== (const location& loc1, const location& loc2)
+ {
+ return loc1.begin == loc2.begin && loc1.end == loc2.end;
+ }
+
+ /// Compare two location objects.
+ inline bool
+ operator!= (const location& loc1, const location& loc2)
+ {
+ return !(loc1 == loc2);
+ }
+
+ /** \brief Intercept output stream redirection.
+ ** \param ostr the destination output stream
+ ** \param loc a reference to the location to redirect
+ **
+ ** Avoid duplicate information.
+ */
+ template <typename YYChar>
+ inline std::basic_ostream<YYChar>&
+ operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
+ {
+ unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
+ ostr << loc.begin;
+ if (loc.end.filename
+ && (!loc.begin.filename
+ || *loc.begin.filename != *loc.end.filename))
+ ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col;
+ else if (loc.begin.line < loc.end.line)
+ ostr << '-' << loc.end.line << '.' << end_col;
+ else if (loc.begin.column < end_col)
+ ostr << '-' << end_col;
+ return ostr;
+ }
+
+#line 14 "d2_parser.yy" // location.cc:337
+} } // isc::dhcp
+#line 192 "location.hh" // location.cc:337
+#endif // !YY_D2_PARSER_LOCATION_HH_INCLUDED
--- /dev/null
+// Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <d2/d2_parser.h>
+#include <d2/parser_context.h>
+#include <exceptions/exceptions.h>
+#include <cc/data.h>
+#include <boost/lexical_cast.hpp>
+#include <fstream>
+#include <limits>
+
+namespace isc {
+namespace dhcp {
+
+D2ParserContext::D2ParserContext()
+ : ctx_(NO_KEYWORD), trace_scanning_(false), trace_parsing_(false)
+{
+}
+
+D2ParserContext::~D2ParserContext()
+{
+}
+
+isc::data::ElementPtr
+D2ParserContext::parseString(const std::string& str, ParserType parser_type)
+{
+ scanStringBegin(str, parser_type);
+ return (parseCommon());
+}
+
+isc::data::ElementPtr
+D2ParserContext::parseFile(const std::string& filename, ParserType parser_type) {
+ FILE* f = fopen(filename.c_str(), "r");
+ if (!f) {
+ isc_throw(D2ParseError, "Unable to open file " << filename);
+ }
+ scanFileBegin(f, filename, parser_type);
+ return (parseCommon());
+}
+
+isc::data::ElementPtr
+D2ParserContext::parseCommon() {
+ isc::dhcp::D2Parser parser(*this);
+ // Uncomment this to get detailed parser logs.
+ // trace_parsing_ = true;
+ parser.set_debug_level(trace_parsing_);
+ try {
+ int res = parser.parse();
+ if (res != 0) {
+ isc_throw(D2ParseError, "Parser abort");
+ }
+ scanEnd();
+ }
+ catch (...) {
+ scanEnd();
+ throw;
+ }
+ if (stack_.size() == 1) {
+ return (stack_[0]);
+ } else {
+ isc_throw(D2ParseError, "Expected exactly one terminal Element expected, found "
+ << stack_.size());
+ }
+}
+
+
+void
+D2ParserContext::error(const isc::dhcp::location& loc, const std::string& what)
+{
+ isc_throw(D2ParseError, loc << ": " << what);
+}
+
+void
+D2ParserContext::error (const std::string& what)
+{
+ isc_throw(D2ParseError, what);
+}
+
+void
+D2ParserContext::fatal (const std::string& what)
+{
+ isc_throw(D2ParseError, what);
+}
+
+isc::data::Element::Position
+D2ParserContext::loc2pos(isc::dhcp::location& loc)
+{
+ const std::string& file = *loc.begin.filename;
+ const uint32_t line = loc.begin.line;
+ const uint32_t pos = loc.begin.column;
+ return (isc::data::Element::Position(file, line, pos));
+}
+
+void
+D2ParserContext::enter(const ParserContext& ctx)
+{
+ cstack_.push_back(ctx_);
+ ctx_ = ctx;
+}
+
+void
+D2ParserContext::leave()
+{
+#if 1
+ if (cstack_.empty()) {
+ fatal("unbalanced syntactic context");
+ }
+#endif
+ ctx_ = cstack_.back();
+ cstack_.pop_back();
+}
+
+const std::string
+D2ParserContext::contextName()
+{
+ switch (ctx_) {
+ case NO_KEYWORD:
+ return ("__no keyword__");
+ case CONFIG:
+ return ("toplevel");
+ case DHCPDDNS:
+ return ("DhcpDdns");
+ case LOGGING:
+ return ("Logging");
+ case LOGGERS:
+ return ("loggers");
+ case OUTPUT_OPTIONS:
+ return ("output-options");
+ case NCR_PROTOCOL:
+ return ("ncr-protocol");
+ case NCR_FORMAT:
+ return ("ncr-format");
+ default:
+ return ("__unknown__");
+ }
+}
+
+};
+};
--- /dev/null
+// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef PARSER_CONTEXT_H
+#define PARSER_CONTEXT_H
+#include <string>
+#include <map>
+#include <vector>
+#include <d2/d2_parser.h>
+#include <d2/parser_context_decl.h>
+#include <exceptions/exceptions.h>
+
+// Tell Flex the lexer's prototype ...
+#define YY_DECL isc::dhcp::D2Parser::symbol_type d2_parser_lex (D2ParserContext& driver)
+
+// ... and declare it for the parser's sake.
+YY_DECL;
+
+namespace isc {
+namespace dhcp {
+
+/// @brief Evaluation error exception raised when trying to parse.
+///
+/// @todo: This probably should be common for Dhcp4 and Dhcp6.
+class D2ParseError : public isc::Exception {
+public:
+ D2ParseError(const char* file, size_t line, const char* what) :
+ isc::Exception(file, line, what) { };
+};
+
+
+/// @brief Evaluation context, an interface to the expression evaluation.
+class D2ParserContext
+{
+public:
+
+ /// @brief Defines currently supported scopes
+ ///
+ /// D2Parser may eventually support multiple levels of parsing scope.
+ /// Currently it supports only the D2 module scope which expects the data
+ /// to be parsed to be a map containing the DhcpDdns element and its
+ /// constituents.
+ ///
+ typedef enum {
+ /// This parser will parse the content as generic JSON.
+ PARSER_JSON,
+
+ ///< Used while parsing top level (contains DhcpDdns, Logging, others)
+ PARSER_CONFIG,
+
+ ///< Used while parsing content of DhcpDdns.
+ PARSER_DHCPDDNS
+ } ParserType;
+
+ /// @brief Default constructor.
+ D2ParserContext();
+
+ /// @brief destructor
+ virtual ~D2ParserContext();
+
+ /// @brief JSON elements being parsed.
+ std::vector<isc::data::ElementPtr> stack_;
+
+ /// @brief Method called before scanning starts on a string.
+ ///
+ /// @param str string to be parsed
+ /// @param type specifies expected content
+ void scanStringBegin(const std::string& str, ParserType type);
+
+ /// @brief Method called before scanning starts on a file.
+ ///
+ /// @param f stdio FILE pointer
+ /// @param filename file to be parsed
+ /// @param type specifies expected content
+ void scanFileBegin(FILE* f, const std::string& filename, ParserType type);
+
+ /// @brief Method called after the last tokens are scanned.
+ void scanEnd();
+
+ /// @brief Divert input to an include file.
+ ///
+ /// @param filename file to be included
+ void includeFile(const std::string& filename);
+
+ /// @brief Run the parser on the string specified.
+ ///
+ /// This method parses specified string. Depending on the value of
+ /// parser_type, parser may either check only that the input is valid
+ /// JSON, or may do more specific syntax checking. See @ref ParserType
+ /// for supported syntax checkers.
+ ///
+ /// @param str string to be parsed
+ /// @param parser_type specifies expected content
+ /// @return Element structure representing parsed text.
+ isc::data::ElementPtr parseString(const std::string& str,
+ ParserType parser_type);
+
+ /// @brief Run the parser on the file specified.
+ ///
+ /// This method parses specified file. Depending on the value of
+ /// parser_type, parser may either check only that the input is valid
+ /// JSON, or may do more specific syntax checking. See @ref ParserType
+ /// for supported syntax checkers.
+ ///
+ /// @param filename file to be parsed
+ /// @param parser_type specifies expected content
+ /// @return Element structure representing parsed text.
+ isc::data::ElementPtr parseFile(const std::string& filename,
+ ParserType parser_type);
+
+ /// @brief Error handler
+ ///
+ /// @param loc location within the parsed file when experienced a problem.
+ /// @param what string explaining the nature of the error.
+ /// @throw D2ParseError
+ void error(const isc::dhcp::location& loc, const std::string& what);
+
+ /// @brief Error handler
+ ///
+ /// This is a simplified error reporting tool for reporting
+ /// parsing errors.
+ ///
+ /// @param what string explaining the nature of the error.
+ /// @throw D2ParseError
+ void error(const std::string& what);
+
+ /// @brief Fatal error handler
+ ///
+ /// This is for should not happen but fatal errors.
+ /// Used by YY_FATAL_ERROR macro so required to be static.
+ ///
+ /// @param what string explaining the nature of the error.
+ /// @throw D2ParseError
+ static void fatal(const std::string& what);
+
+ /// @brief Converts bison's position to one understood by isc::data::Element
+ ///
+ /// Convert a bison location into an element position
+ /// (take the begin, the end is lost)
+ ///
+ /// @param loc location in bison format
+ /// @return Position in format accepted by Element
+ isc::data::Element::Position loc2pos(isc::dhcp::location& loc);
+
+ /// @brief Defines syntactic contexts for lexical tie-ins
+ typedef enum {
+ ///< This one is used in pure JSON mode.
+ NO_KEYWORD,
+
+ ///< Used while parsing top level (contains DhcpDdns, Logging, ...)
+ CONFIG,
+
+ ///< Used while parsing content of DhcpDdns.
+ DHCPDDNS,
+
+ ///< Used while parsing content of Logging
+ LOGGING,
+
+ /// Used while parsing Logging/loggers structures.
+ LOGGERS,
+
+ /// Used while parsing Logging/loggers/output_options structures.
+ OUTPUT_OPTIONS,
+
+ /// Used while parsing Dhcp6/dhcp-ddns/ncr-protocol
+ NCR_PROTOCOL,
+
+ /// Used while parsing Dhcp6/dhcp-ddns/ncr-format
+ NCR_FORMAT
+
+ } ParserContext;
+
+ /// @brief File name
+ std::string file_;
+
+ /// @brief File name stack
+ std::vector<std::string> files_;
+
+ /// @brief Location of the current token
+ ///
+ /// The lexer will keep updating it. This variable will be useful
+ /// for logging errors.
+ isc::dhcp::location loc_;
+
+ /// @brief Location stack
+ std::vector<isc::dhcp::location> locs_;
+
+ /// @brief Lexer state stack
+ std::vector<struct yy_buffer_state*> states_;
+
+ /// @brief sFile (aka FILE)
+ FILE* sfile_;
+
+ /// @brief sFile (aka FILE) stack
+ ///
+ /// This is a stack of files. Typically there's only one file (the
+ /// one being currently parsed), but there may be more if one
+ /// file includes another.
+ std::vector<FILE*> sfiles_;
+
+ /// @brief Current syntactic context
+ ParserContext ctx_;
+
+ /// @brief Enter a new syntactic context
+ ///
+ /// Entering a new syntactic context is useful in several ways.
+ /// First, it allows the parser to avoid conflicts. Second, it
+ /// allows the lexer to return different tokens depending on
+ /// context (e.g. if "renew-timer" string is detected, the lexer
+ /// will return STRING token if in JSON mode or RENEW_TIMER if
+ /// in DHCP6 mode. Finally, the syntactic context allows the
+ /// error message to be more descriptive if the input string
+ /// does not parse properly.
+ ///
+ /// @param ctx the syntactic context to enter into
+ void enter(const ParserContext& ctx);
+
+ /// @brief Leave a syntactic context
+ ///
+ /// @throw isc::Unexpected if unbalanced
+ void leave();
+
+ /// @brief Get the syntactix context name
+ ///
+ /// @return printable name of the context.
+ const std::string contextName();
+
+ private:
+ /// @brief Flag determining scanner debugging.
+ bool trace_scanning_;
+
+ /// @brief Flag determing parser debugging.
+ bool trace_parsing_;
+
+ /// @brief Syntactic context stack
+ std::vector<ParserContext> cstack_;
+
+ /// @brief Common part of parseXXX
+ ///
+ /// @return Element structure representing parsed text.
+ isc::data::ElementPtr parseCommon();
+};
+
+}; // end of isc::eval namespace
+}; // end of isc namespace
+
+#endif
--- /dev/null
+// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef D2_PARSER_CONTEXT_DECL_H
+#define D2_PARSER_CONTEXT_DECL_H
+
+/// @file d2/parser_context_decl.h Forward declaration of the ParserContext class
+
+namespace isc {
+namespace dhcp {
+
+class D2ParserContext;
+
+}; // end of isc::dhcp namespace
+}; // end of isc namespace
+
+#endif
--- /dev/null
+// A Bison parser, made by GNU Bison 3.0.4.
+
+// Positions for Bison parsers in C++
+
+// Copyright (C) 2002-2015 Free Software Foundation, Inc.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+// As a special exception, you may create a larger work that contains
+// part or all of the Bison parser skeleton and distribute that work
+// under terms of your choice, so long as that work isn't itself a
+// parser generator using the skeleton or a modified version thereof
+// as a parser skeleton. Alternatively, if you modify or redistribute
+// the parser skeleton itself, you may (at your option) remove this
+// special exception, which will cause the skeleton and the resulting
+// Bison output files to be licensed under the GNU General Public
+// License without this special exception.
+
+// This special exception was added by the Free Software Foundation in
+// version 2.2 of Bison.
+
+/**
+ ** \file position.hh
+ ** Define the isc::dhcp::position class.
+ */
+
+#ifndef YY_D2_PARSER_POSITION_HH_INCLUDED
+# define YY_D2_PARSER_POSITION_HH_INCLUDED
+
+# include <algorithm> // std::max
+# include <iostream>
+# include <string>
+
+# ifndef YY_NULLPTR
+# if defined __cplusplus && 201103L <= __cplusplus
+# define YY_NULLPTR nullptr
+# else
+# define YY_NULLPTR 0
+# endif
+# endif
+
+#line 14 "d2_parser.yy" // location.cc:337
+namespace isc { namespace dhcp {
+#line 56 "position.hh" // location.cc:337
+ /// Abstract a position.
+ class position
+ {
+ public:
+ /// Construct a position.
+ explicit position (std::string* f = YY_NULLPTR,
+ unsigned int l = 1u,
+ unsigned int c = 1u)
+ : filename (f)
+ , line (l)
+ , column (c)
+ {
+ }
+
+
+ /// Initialization.
+ void initialize (std::string* fn = YY_NULLPTR,
+ unsigned int l = 1u,
+ unsigned int c = 1u)
+ {
+ filename = fn;
+ line = l;
+ column = c;
+ }
+
+ /** \name Line and Column related manipulators
+ ** \{ */
+ /// (line related) Advance to the COUNT next lines.
+ void lines (int count = 1)
+ {
+ if (count)
+ {
+ column = 1u;
+ line = add_ (line, count, 1);
+ }
+ }
+
+ /// (column related) Advance to the COUNT next columns.
+ void columns (int count = 1)
+ {
+ column = add_ (column, count, 1);
+ }
+ /** \} */
+
+ /// File name to which this position refers.
+ std::string* filename;
+ /// Current line number.
+ unsigned int line;
+ /// Current column number.
+ unsigned int column;
+
+ private:
+ /// Compute max(min, lhs+rhs) (provided min <= lhs).
+ static unsigned int add_ (unsigned int lhs, int rhs, unsigned int min)
+ {
+ return (0 < rhs || -static_cast<unsigned int>(rhs) < lhs
+ ? rhs + lhs
+ : min);
+ }
+ };
+
+ /// Add \a width columns, in place.
+ inline position&
+ operator+= (position& res, int width)
+ {
+ res.columns (width);
+ return res;
+ }
+
+ /// Add \a width columns.
+ inline position
+ operator+ (position res, int width)
+ {
+ return res += width;
+ }
+
+ /// Subtract \a width columns, in place.
+ inline position&
+ operator-= (position& res, int width)
+ {
+ return res += -width;
+ }
+
+ /// Subtract \a width columns.
+ inline position
+ operator- (position res, int width)
+ {
+ return res -= width;
+ }
+
+ /// Compare two position objects.
+ inline bool
+ operator== (const position& pos1, const position& pos2)
+ {
+ return (pos1.line == pos2.line
+ && pos1.column == pos2.column
+ && (pos1.filename == pos2.filename
+ || (pos1.filename && pos2.filename
+ && *pos1.filename == *pos2.filename)));
+ }
+
+ /// Compare two position objects.
+ inline bool
+ operator!= (const position& pos1, const position& pos2)
+ {
+ return !(pos1 == pos2);
+ }
+
+ /** \brief Intercept output stream redirection.
+ ** \param ostr the destination output stream
+ ** \param pos a reference to the position to redirect
+ */
+ template <typename YYChar>
+ inline std::basic_ostream<YYChar>&
+ operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
+ {
+ if (pos.filename)
+ ostr << *pos.filename << ':';
+ return ostr << pos.line << '.' << pos.column;
+ }
+
+#line 14 "d2_parser.yy" // location.cc:337
+} } // isc::dhcp
+#line 180 "position.hh" // location.cc:337
+#endif // !YY_D2_PARSER_POSITION_HH_INCLUDED
--- /dev/null
+// A Bison parser, made by GNU Bison 3.0.4.
+
+// Stack handling for Bison parsers in C++
+
+// Copyright (C) 2002-2015 Free Software Foundation, Inc.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+// As a special exception, you may create a larger work that contains
+// part or all of the Bison parser skeleton and distribute that work
+// under terms of your choice, so long as that work isn't itself a
+// parser generator using the skeleton or a modified version thereof
+// as a parser skeleton. Alternatively, if you modify or redistribute
+// the parser skeleton itself, you may (at your option) remove this
+// special exception, which will cause the skeleton and the resulting
+// Bison output files to be licensed under the GNU General Public
+// License without this special exception.
+
+// This special exception was added by the Free Software Foundation in
+// version 2.2 of Bison.
+
+/**
+ ** \file stack.hh
+ ** Define the isc::dhcp::stack class.
+ */
+
+#ifndef YY_D2_PARSER_STACK_HH_INCLUDED
+# define YY_D2_PARSER_STACK_HH_INCLUDED
+
+# include <vector>
+
+#line 14 "d2_parser.yy" // stack.hh:151
+namespace isc { namespace dhcp {
+#line 46 "stack.hh" // stack.hh:151
+ template <class T, class S = std::vector<T> >
+ class stack
+ {
+ public:
+ // Hide our reversed order.
+ typedef typename S::reverse_iterator iterator;
+ typedef typename S::const_reverse_iterator const_iterator;
+
+ stack ()
+ : seq_ ()
+ {
+ seq_.reserve (200);
+ }
+
+ stack (unsigned int n)
+ : seq_ (n)
+ {}
+
+ inline
+ T&
+ operator[] (unsigned int i)
+ {
+ return seq_[seq_.size () - 1 - i];
+ }
+
+ inline
+ const T&
+ operator[] (unsigned int i) const
+ {
+ return seq_[seq_.size () - 1 - i];
+ }
+
+ /// Steal the contents of \a t.
+ ///
+ /// Close to move-semantics.
+ inline
+ void
+ push (T& t)
+ {
+ seq_.push_back (T());
+ operator[](0).move (t);
+ }
+
+ inline
+ void
+ pop (unsigned int n = 1)
+ {
+ for (; n; --n)
+ seq_.pop_back ();
+ }
+
+ void
+ clear ()
+ {
+ seq_.clear ();
+ }
+
+ inline
+ typename S::size_type
+ size () const
+ {
+ return seq_.size ();
+ }
+
+ inline
+ const_iterator
+ begin () const
+ {
+ return seq_.rbegin ();
+ }
+
+ inline
+ const_iterator
+ end () const
+ {
+ return seq_.rend ();
+ }
+
+ private:
+ stack (const stack&);
+ stack& operator= (const stack&);
+ /// The wrapped container.
+ S seq_;
+ };
+
+ /// Present a slice of the top of a stack.
+ template <class T, class S = stack<T> >
+ class slice
+ {
+ public:
+ slice (const S& stack, unsigned int range)
+ : stack_ (stack)
+ , range_ (range)
+ {}
+
+ inline
+ const T&
+ operator [] (unsigned int i) const
+ {
+ return stack_[range_ - i];
+ }
+
+ private:
+ const S& stack_;
+ unsigned int range_;
+ };
+
+#line 14 "d2_parser.yy" // stack.hh:151
+} } // isc::dhcp
+#line 156 "stack.hh" // stack.hh:151
+
+#endif // !YY_D2_PARSER_STACK_HH_INCLUDED