#line 2 "diam_dict.c"
/* Include this before everything else, for various large-file definitions */
#include "config.h"

#line 6 "diam_dict.c"

#define  YY_INT_ALIGNED short int

/* A lexical scanner generated by flex */

#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
#define YY_FLEX_SUBMINOR_VERSION 0
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif

/* First, we deal with  platform-specific or compiler-specific issues. */

/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>

/* end standard C headers. */

/* 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 */

#ifdef __cplusplus

/* The "const" storage-class-modifier is valid. */
#define YY_USE_CONST

#else	/* ! __cplusplus */

/* C99 requires __STDC__ to be defined as 1. */
#if defined (__STDC__)

#define YY_USE_CONST

#endif	/* defined (__STDC__) */
#endif	/* ! __cplusplus */

#ifdef YY_USE_CONST
#define yyconst const
#else
#define yyconst
#endif

/* Returned upon end-of-file. */
#define YY_NULL 0

/* Promotes a possibly negative, possibly signed char to an unsigned
 * integer for use as an array index.  If the signed char is negative,
 * we want to instead treat it as an 8-bit unsigned char, hence the
 * double cast.
 */
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)

/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void* yyscan_t;
#endif

/* For convenience, these vars (plus the bison vars far below)
   are macros in the reentrant scanner. */
#define yyin yyg->yyin_r
#define yyout yyg->yyout_r
#define yyextra yyg->yyextra_r
#define yyleng yyg->yyleng_r
#define yytext yyg->yytext_r
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r

/* 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 yyg->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 ((yyg->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 DiamDict_restart(yyin ,yyscanner )

#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

#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 yytext. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
		*yy_cp = yyg->yy_hold_char; \
		YY_RESTORE_YY_MORE_OFFSET \
		yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
		} \
	while ( 0 )

#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )

#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
	{
	FILE *yy_input_file;

	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.
	 */
	yy_size_t 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 DiamDict_restart()), so that the user can continue scanning by
	 * just pointing yyin at a new input file.
	 */
#define YY_BUFFER_EOF_PENDING 2

	};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */

/* 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 ( yyg->yy_buffer_stack \
                          ? yyg->yy_buffer_stack[yyg->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 yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]

void DiamDict_restart (FILE *input_file ,yyscan_t yyscanner );
void DiamDict__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
YY_BUFFER_STATE DiamDict__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
void DiamDict__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void DiamDict__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void DiamDict_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
void DiamDict_pop_buffer_state (yyscan_t yyscanner );

static void DiamDict_ensure_buffer_stack (yyscan_t yyscanner );
static void DiamDict__load_buffer_state (yyscan_t yyscanner );
static void DiamDict__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );

#define YY_FLUSH_BUFFER DiamDict__flush_buffer(YY_CURRENT_BUFFER ,yyscanner)

YY_BUFFER_STATE DiamDict__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE DiamDict__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE DiamDict__scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );

void *DiamDict_alloc (yy_size_t ,yyscan_t yyscanner );
void *DiamDict_realloc (void *,yy_size_t ,yyscan_t yyscanner );
void DiamDict_free (void * ,yyscan_t yyscanner );

#define yy_new_buffer DiamDict__create_buffer

#define yy_set_interactive(is_interactive) \
	{ \
	if ( ! YY_CURRENT_BUFFER ){ \
        DiamDict_ensure_buffer_stack (yyscanner); \
		YY_CURRENT_BUFFER_LVALUE =    \
            DiamDict__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
	} \
	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
	}

#define yy_set_bol(at_bol) \
	{ \
	if ( ! YY_CURRENT_BUFFER ){\
        DiamDict_ensure_buffer_stack (yyscanner); \
		YY_CURRENT_BUFFER_LVALUE =    \
            DiamDict__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
	} \
	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
	}

#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)

/* Begin user sect3 */

#define DiamDict_wrap(yyscanner) (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP

typedef unsigned char YY_CHAR;

typedef int yy_state_type;

#define yytext_ptr yytext_r

static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state  ,yyscan_t yyscanner);
static int yy_get_next_buffer (yyscan_t yyscanner );
#if defined(__GNUC__) && __GNUC__ >= 3
__attribute__((__noreturn__))
#endif
static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );

/* Done after the current pattern has been matched and before the
 * corresponding action - sets up yytext.
 */
#define YY_DO_BEFORE_ACTION \
	yyg->yytext_ptr = yy_bp; \
	yyleng = (size_t) (yy_cp - yy_bp); \
	yyg->yy_hold_char = *yy_cp; \
	*yy_cp = '\0'; \
	yyg->yy_c_buf_p = yy_cp;

#define YY_NUM_RULES 85
#define YY_END_OF_BUFFER 86
/* 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 yyconst flex_int16_t yy_accept[482] =
    {   0,
        0,    0,   24,   24,    0,    0,    7,    7,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,   30,   30,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,   86,   85,   27,   24,
       24,   27,   27,   27,   20,   26,   21,   27,    4,    4,
       85,    4,    7,    8,   16,   85,   85,   18,   85,   29,
       30,   30,   31,   84,   84,   85,   85,   85,   85,   85,
       85,   39,   85,   85,   32,   32,   85,   75,   85,   85,

       85,   85,   85,   64,   85,   85,   85,   85,   85,   52,
       85,   85,   85,   85,   46,   85,   85,   85,   85,   57,
       85,   13,   13,   85,   13,   13,   13,   10,   12,   24,
        0,   20,   26,   21,    0,    0,   25,    0,   22,   20,
        0,   23,    6,   26,   21,    0,    2,    0,    0,    0,
        7,    8,   16,    0,    0,    0,   18,    0,   19,   29,
       30,    0,    0,    0,    0,    0,   79,    0,    0,    0,
        0,    0,    0,    0,    0,    0,   83,   40,    0,    0,
        0,   33,   76,    0,    0,    0,    0,   65,    0,    0,
        0,    0,   53,    0,    0,    0,   47,    0,    0,    0,

       58,    0,    0,    0,    0,    0,   14,    0,    0,   10,
       12,   28,   22,    0,    0,    0,   23,    6,    2,    5,
        0,   19,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
       83,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,   14,    0,    0,
        3,    0,    0,    5,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,   59,    0,    0,    0,    0,    0,
        0,    0,    0,   38,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,

        0,    0,    0,    3,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
       72,   70,    0,   68,   83,    0,   83,   83,   83,   83,
        0,   83,    0,   83,   83,    0,   83,   83,    0,    0,
        0,    9,    0,    0,    0,    0,    0,    0,    0,    0,
       35,    0,    0,    0,    0,    0,    0,    0,   77,    0,
        0,   37,    0,   71,   74,   73,   63,    0,   60,    0,
       51,   49,    0,   45,   43,    0,    0,    0,    0,    0,
        0,    0,    0,   17,    0,    0,    0,   48,    0,   81,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,

        0,    0,    0,    0,   11,    0,   15,    0,    0,    0,
        0,    0,    0,   42,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,   15,    0,    0,    0,    0,
        0,   80,   54,    0,   66,    0,    0,    0,    0,    0,
        0,    0,    0,    1,    0,    0,    0,    0,   41,   67,
       83,    0,   83,   83,   83,   83,    0,    1,    0,    0,
        0,    0,   69,    0,   62,   50,   44,   55,    0,   34,
        0,   36,    0,   83,   83,   82,    0,   61,   56,   78,
        0
    } ;

static yyconst 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,    2,    4,    5,    1,    1,    1,    6,    1,    1,
        1,    7,    1,    1,    8,    1,    9,   10,   10,   10,
       10,   10,   10,   10,   10,   10,   10,    1,   11,   12,
       13,   14,   15,    1,   16,   17,   18,   19,   20,   21,
       22,   23,   24,   23,   25,   26,   27,   28,   29,   30,
       23,   31,   32,   33,   34,   35,   23,   23,   36,   23,
       37,    1,   38,    1,    1,    1,   39,   40,   41,   42,

       43,   44,   45,   23,   46,   23,   47,   48,   49,   50,
       51,   52,   23,   53,   54,   55,   56,   57,   23,   23,
       58,   23,    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,    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,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1
    } ;

static yyconst YY_CHAR yy_meta[59] =
    {   0,
        1,    1,    1,    1,    2,    1,    3,    4,    1,    4,
        1,    1,    5,    1,    1,    4,    4,    4,    4,    4,
        4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
        4,    4,    4,    4,    4,    4,    1,    1,    4,    4,
        4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
        4,    4,    4,    4,    4,    4,    4,    4
    } ;

static yyconst flex_uint16_t yy_base[507] =
    {   0,
        0,    0,    0,   37,    8,   15,   75,  113,  151,  189,
        5,   29, 1179, 1178, 1177, 1176, 1175, 1174,   11,   12,
     1173, 1172,   12,   22, 1164, 1163,   17,   18, 1162, 1161,
      227,  277,   30,   42,  284,  285,   46,  121,  319,  327,
      369,    0,  418,  467,  516,  565,  339,  362,  210,  272,
     1160, 1154, 1149, 1137,    0,    0, 1137, 1185, 1185,   55,
       95, 1058,    0, 1048,  166,   50,   60,   92, 1185,   63,
       97, 1053,   70,    0,    0,  129,   65,    0,  134,    0,
     1050, 1049, 1185, 1185,   92,  383, 1043,  341,  164, 1040,
     1037, 1185,  163,  198, 1185, 1045, 1035, 1185,  186,  204,

      195,  237, 1034, 1185,  234,  167,  256,  283, 1032, 1185,
      287,  336,  341, 1031, 1185,  291,  385,  396, 1030, 1185,
      308, 1185,  426,  432, 1005,  101,  232,    0,    0,  485,
      992,  440,  100,  136,  256,  969, 1185,  953,  138,  140,
      450,  144,  175,  213,  258,  308,  322,  463,  929,  881,
      400,    0,    0,  418,  355,  398,    0,  460,  403,    0,
      820,  432,  337,  452,  342,  405, 1185,  497,  449,  461,
      460,  494,  472,  489,  471,  815, 1185, 1185,  750,  513,
      750, 1185, 1185,  518,  514,  530,  532, 1185,  533,  537,
      540,  548, 1185,  552,  555,  564, 1185,  567,  572,  574,

     1185,  565,  608,  732,  411,  464,  553,  554,  570,    0,
        0, 1185,  617,  705,  574,  577,  626,  628,  632,  634,
      583,  637,  608,  608,  611,  610,  616,  615,  630,  619,
      630,  622,  626,  626,  622,  627,  625,  625,  632,  632,
      698,  672,  673,  674,  675,  676,  677,  658,  678,  687,
      688,  689,  691,  692,  694,  709,  710,  722,  736,  692,
      738,  693,  703,  740,  707,  711,  727,  721,  732,  735,
      726,  725,  732,  732, 1185,  734,  742,  734,  736,  740,
      740,  737,  752, 1185,  664,   28,  659,  655,  638,  634,
      760,  600,  761,  595,  588,  767,  584,  575,  771,  166,

      795,  799,  756,  803,  755,  770,  776,  783,  776,  787,
      550,  785,  789,  797,  792,  801,  805,  804,  546,  792,
     1185, 1185,  797, 1185,  542,  811,  516,  514,  506,  496,
      821,  486,  819,  472,  459,  822,  440,  409,  825,  829,
      849, 1185,  860,  811,  822,  863,  829,  836,  846,  393,
     1185,  839,  847,  356,  858,  847,  855,  864, 1185,  856,
      868, 1185,  878, 1185, 1185, 1185, 1185,  872, 1185,  210,
     1185, 1185,  241, 1185, 1185,  425,  883,  887,  907,  910,
      871,  870,  916, 1185,  886,  887,  888, 1185,  907, 1185,
      901,  899,  912,  911,  913,  915,  922,  926,  929,  934,

      937,  933,  931,  938, 1185,  925,  887,  947,  937,  933,
      951,  950,  350, 1185,  944,  951,  348,  965,  976,  960,
      978,  982,  983,  985,  309,  974,  968,  988,  983,  976,
      318, 1185, 1185,  292, 1185,  289, 1001,  255,  253,  249,
      243,  997,  215, 1009,  977,  984,  987,  993, 1185, 1185,
      216, 1005,  201,  180,  167,  154, 1010, 1038,  115,  996,
     1006, 1007, 1185,   97, 1185, 1185, 1185, 1185,   78, 1185,
       71, 1185, 1014,   51,   49, 1185,   34, 1185, 1185, 1185,
     1185, 1065, 1070, 1075, 1080, 1085, 1090, 1095, 1100, 1105,
     1110, 1115, 1120, 1125, 1130,   40,   24,    0, 1135, 1140,

     1142, 1147, 1152, 1157, 1162, 1167
    } ;

static yyconst flex_int16_t yy_def[507] =
    {   0,
      482,  482,  483,  483,  484,  484,  485,  485,  486,  486,
      482,  482,  487,  487,  482,  482,  488,  488,  482,  482,
      482,  482,  489,  489,  482,  482,  482,  482,  482,  482,
      490,  490,  491,  491,   32,   32,   32,   32,   32,   32,
       32,   41,   41,   41,   41,   41,   32,   32,  492,  492,
      493,  493,  494,  494,  482,  482,  481,  481,  481,  481,
      481,  495,  496,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  497,  498,  481,  481,  499,  481,  500,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  501,
      481,  481,  501,  501,  481,  502,  481,  481,  501,  501,

      501,  501,  481,  481,  501,  501,  501,  501,  481,  481,
      501,  501,  501,  481,  481,  501,  501,  501,  481,  481,
      501,  481,  481,  481,  481,  481,  481,  503,  504,  481,
      481,  481,  481,  481,  481,  495,  481,  496,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  497,  498,  481,  481,  481,  499,  481,  481,  500,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  501,  481,  481,  501,  501,
      502,  481,  481,  501,  501,  501,  501,  481,  501,  501,
      501,  501,  481,  501,  501,  501,  481,  501,  501,  501,

      481,  501,  481,  481,  481,  481,  481,  481,  481,  503,
      504,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  501,  501,  501,  501,  501,  501,  501,  501,  501,
      501,  501,  501,  501,  501,  501,  501,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  501,  501,  501,  501,  501,  501,
      501,  501,  501,  501,  501,  501,  501,  501,  501,  501,

      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      505,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  501,  481,  481,  481,  481,
      501,  481,  501,  481,  481,  501,  481,  481,  501,  501,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  505,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  501,  481,  481,  481,  481,  501,  481,  501,
      481,  481,  501,  481,  481,  501,  501,  501,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  501,  501,  501,  501,

      501,  501,  501,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  501,  501,  501,
      501,  501,  501,  501,  506,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  501,  501,  501,  501,  501,
      501,  501,  506,  481,  481,  481,  481,  481,  481,  481,
      481,  501,  481,  481,  481,  481,  501,  481,  481,  481,
      481,  481,  481,  501,  481,  481,  481,  481,  501,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
        0,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,

      481,  481,  481,  481,  481,  481
    } ;

static yyconst flex_uint16_t yy_nxt[1244] =
    {   0,
      481,   60,   61,  153,   62,   63,   76,   76,   64,   70,
       71,   65,   66,   67,   58,   72,   70,   71,   81,   81,
       82,   82,   72,   85,   58,   87,   87,  152,   88,   88,
       76,   76,   58,   85,   96,  326,   77,   68,   60,   61,
      177,   62,   63,  138,   58,   64,   96,  480,   65,   66,
       67,  144,  144,  479,   97,  478,  130,  130,   77,   98,
       77,  145,  145,  131,  148,  148,  132,  133,  134,   90,
      149,  151,  151,  100,   68,   58,   73,   73,   58,   58,
       58,   58,   77,   58,  476,   58,   58,   58,   58,   58,
      475,   90,  135,  146,  146,  100,  130,  130,  148,  148,

      156,  144,  144,  131,  149,  147,  132,  133,  134,  474,
      162,   58,   58,   58,   73,   73,   58,   58,   58,   58,
      208,   58,  156,   58,   58,   58,   58,   58,  470,   97,
      154,  154,  135,  162,   98,  158,  158,  145,  145,  213,
      213,  140,  140,  208,   90,  217,  217,  159,  100,   58,
       58,   58,   58,   58,   58,   58,   58,   58,  468,   58,
      155,   58,   58,   58,   58,   58,   90,  140,  140,  141,
      100,  467,  172,  340,  142,  177,  218,  218,  177,  177,
      143,  179,  155,  173,  466,  174,  190,   58,   58,   58,
       58,   58,   58,   58,   58,   58,  175,   58,  177,   58,

       58,   58,   58,   58,  179,  465,  173,  177,  174,  190,
      177,  123,  124,  180,  144,  144,  177,  399,  175,  185,
      463,  184,  177,  186,  125,   58,   58,   58,   58,   58,
       58,   58,   58,   58,  126,   91,  180,   58,   58,   58,
       92,   58,  185,  184,  127,  186,  177,  209,  400,  177,
       93,  444,  187,  177,   94,  456,  126,  146,  146,  145,
      145,  455,  189,   58,   58,  454,  127,  453,  177,  147,
      209,  191,   93,  123,  124,  187,   94,   58,   58,   58,
       58,   58,   58,   58,  189,   91,  125,   58,   58,   58,
       92,   58,   97,   97,  191,  177,  126,   98,   98,  177,

       93,  451,  192,  177,   94,  450,  127,   90,   90,  146,
      146,   90,   90,   58,   58,  194,   99,   99,  126,  198,
      177,  147,   93,  219,  219,  192,   94,   97,  127,   90,
       90,  449,   98,   90,   90,   97,  101,  194,   99,   99,
       98,  198,   90,  202,  101,  444,  102,  119,  177,  168,
       90,  195,  120,  177,  102,  224,  169,  226,  170,  101,
      196,  435,   90,  432,   90,  202,   90,  101,  102,  390,
      119,  121,   90,  171,  195,  120,  102,  103,  224,  169,
      226,  170,  104,  196,   90,   90,  105,  106,   90,   90,
      156,  163,   90,  121,  121,  171,  107,  177,  164,  165,

      199,  151,  151,  108,  222,  222,  351,   90,  177,  105,
      106,   90,  156,  375,   90,  200,  121,  166,  107,  154,
      154,  164,  165,  199,  227,  108,  109,  203,  203,  221,
      208,  110,  401,  203,  203,  111,   90,  177,  200,  166,
      204,  140,  140,  141,  374,  112,  204,  227,  142,  155,
      205,  221,  113,  208,  143,  223,  205,  214,  111,   90,
      206,  158,  158,  372,  148,  148,  206,  112,  215,  216,
      149,  155,  205,  159,  113,  109,  371,  223,  205,  209,
      110,  225,  206,  232,  111,   90,  130,  130,  206,  233,
      369,  215,  216,  131,  112,  234,  132,  133,  134,  237,

      367,  113,  209,  225,  238,  232,  240,  111,   90,  235,
      366,  233,  228,  229,  230,  236,  112,  234,  365,  239,
      364,  237,  135,  113,  114,  177,  177,  238,  240,  115,
      177,  231,  235,  116,   90,  228,  229,  230,  236,  242,
      244,  239,  177,  117,  177,  177,  362,  243,  245,  177,
      118,  247,  177,  231,  258,  258,  116,   90,  246,  359,
      177,  242,  244,  351,  177,  117,  249,  177,  248,  243,
      251,  245,  118,  114,  247,  250,  177,  177,  115,  177,
      246,  252,  116,   90,  177,  254,  177,  338,  249,  259,
      248,  253,  117,  251,  257,  260,  337,  250,  255,  118,

      335,  256,  262,  252,  263,  116,   90,  334,  254,  203,
      203,  259,  332,  253,  117,  265,  257,  260,  213,  213,
      255,  118,  204,  256,  262,  266,  263,  217,  217,  218,
      218,  267,  205,  219,  219,  264,  264,  265,  222,  222,
      268,  269,  206,  270,  271,  272,  330,  273,  266,  274,
      329,  275,  276,  267,  205,  277,  278,  279,  280,  281,
      282,  283,  268,  269,  206,  270,  271,  328,  272,  273,
      177,  327,  274,  275,  276,  291,  325,  277,  278,  279,
      280,  281,  282,  283,  177,  177,  177,  177,  177,  177,
      177,  285,  286,  287,  288,  289,  290,  292,  291,  177,

      177,  177,  284,  177,  177,  293,  177,  294,  295,  296,
      305,  297,  261,  298,  285,  286,  287,  288,  289,  290,
      292,  177,  177,  258,  258,  303,  307,  299,  293,  300,
      294,  295,  296,  305,  297,  306,  298,  301,  301,  304,
      304,  264,  264,  308,  309,  207,  310,  303,  302,  307,
      299,  311,  300,  312,  182,  313,  314,  306,  315,  316,
      317,  318,  241,  319,  320,  308,  321,  309,  310,  322,
      323,  324,  177,  177,  311,  343,  312,  313,  314,  177,
      315,  316,  317,  177,  318,  319,  320,  344,  321,  333,
      331,  322,  323,  345,  324,  336,  301,  301,  343,  339,

      341,  341,  346,  342,  304,  304,  347,  302,  348,  344,
      349,  333,  331,  352,  353,  345,  354,  336,  355,  356,
      357,  339,  358,  177,  346,  360,  361,  177,  347,  161,
      348,  177,  349,  177,  177,  352,  353,  177,  363,  354,
      355,  177,  356,  357,  368,  358,  381,  360,  361,  370,
      341,  341,  373,  342,  382,  376,  377,  385,  378,  386,
      363,  379,  379,  387,  383,  383,  368,  384,  381,  388,
      389,  370,  380,  391,  373,  392,  382,  376,  377,  385,
      378,  386,  393,  394,  177,  395,  387,  396,  426,  426,
      177,  388,  389,  397,  220,  177,  391,  392,  402,  177,

      406,  398,  403,  410,  393,  407,  394,  395,  379,  379,
      396,  404,  404,  408,  405,  409,  397,  383,  383,  380,
      384,  402,  406,  398,  411,  403,  410,  407,  412,  413,
      414,  415,  416,  417,  177,  408,  150,  409,  177,  404,
      404,  177,  405,  177,  425,  177,  177,  411,  418,  177,
      412,  413,  420,  414,  415,  416,  417,  421,  419,  423,
      422,  424,  427,  212,  428,  429,  430,  425,  431,  434,
      418,  433,  177,  137,  420,  426,  426,  177,  438,  421,
      419,  423,  422,  424,  436,  427,  428,  429,  177,  430,
      177,  431,  434,  433,  177,  177,  439,  177,  445,  437,

      440,  438,  441,  446,  442,  139,  447,  436,  448,  177,
      458,  458,  459,  177,  460,  461,  462,  177,  207,  439,
      445,  437,  177,  440,  457,  441,  446,  442,  447,  452,
      448,  471,  464,  472,  459,  473,  460,  461,  462,  458,
      458,  477,  469,  201,  197,  193,  457,  188,  183,  182,
      178,  452,  177,  471,  464,  472,  167,  473,  161,  161,
      150,  139,  137,  477,  469,   58,   58,   58,   58,   58,
       59,   59,   59,   59,   59,   69,   69,   69,   69,   69,
       74,   74,   74,   74,   74,   75,   75,   75,   75,   75,
       78,   78,   78,   78,   78,   80,   80,   80,   80,   80,

       84,   84,   84,   84,   84,   90,   90,   90,   90,   90,
       95,   95,   95,   95,   95,  122,  122,  122,  122,  122,
      128,  128,  128,  128,  128,  129,  129,  129,  129,  129,
      136,  136,  136,  136,  136,  157,  481,  157,  157,  157,
      160,   58,  160,  160,  160,  176,  176,  181,  181,  181,
      181,  181,  210,   58,  210,  210,  210,  211,   58,  211,
      211,  211,  350,  350,   58,  350,  350,  443,  443,  443,
      443,  443,   89,   89,   86,   86,   83,   83,   58,   58,
       79,   79,   58,   58,   57,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,

      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481
    } ;

static yyconst flex_int16_t yy_chk[1244] =
    {   0,
        0,    3,    3,  498,    3,    3,   11,   11,    3,    5,
        5,    3,    3,    3,   23,    5,    6,    6,   19,   20,
       19,   20,    6,   23,   24,   27,   28,  497,   27,   28,
       12,   12,   33,   24,   33,  286,   11,    3,    4,    4,
      286,    4,    4,  496,   34,    4,   34,  477,    4,    4,
        4,   66,   66,  475,   37,  474,   60,   60,   11,   37,
       12,   67,   67,   60,   70,   70,   60,   60,   60,   37,
       70,   73,   73,   37,    4,    7,    7,    7,    7,    7,
        7,    7,   12,    7,  471,    7,    7,    7,    7,    7,
      469,   37,   60,   68,   68,   37,   61,   61,   71,   71,

       77,  133,  133,   61,   71,   68,   61,   61,   61,  464,
       85,    7,    7,    8,    8,    8,    8,    8,    8,    8,
      126,    8,   77,    8,    8,    8,    8,    8,  459,   38,
       76,   76,   61,   85,   38,   79,   79,  134,  134,  139,
      139,  140,  140,  126,   38,  142,  142,   79,   38,    8,
        8,    9,    9,    9,    9,    9,    9,    9,  456,    9,
       76,    9,    9,    9,    9,    9,   38,   65,   65,   65,
       38,  455,   89,  300,   65,   93,  143,  143,  300,  106,
       65,   93,   76,   89,  454,   89,  106,    9,    9,   10,
       10,   10,   10,   10,   10,   10,   89,   10,   99,   10,

       10,   10,   10,   10,   93,  453,   89,  101,   89,  106,
       94,   49,   49,   94,  144,  144,  100,  370,   89,  100,
      451,   99,  370,  101,   49,   10,   10,   31,   31,   31,
       31,   31,   31,   31,   49,   31,   94,   31,   31,   31,
       31,   31,  100,   99,   49,  101,  105,  127,  373,  102,
       31,  443,  102,  373,   31,  441,   49,  135,  135,  145,
      145,  440,  105,   31,   31,  439,   49,  438,  107,  135,
      127,  107,   31,   50,   50,  102,   31,   32,   32,   32,
       32,   32,   32,   32,  105,   32,   50,   32,   32,   32,
       32,   32,   35,   36,  107,  108,   50,   35,   36,  111,

       32,  436,  108,  116,   32,  434,   50,   35,   36,  146,
      146,   35,   36,   32,   32,  111,   35,   36,   50,  116,
      121,  146,   32,  147,  147,  108,   32,   39,   50,   35,
       36,  431,   39,   35,   36,   40,   39,  111,   35,   36,
       40,  116,   39,  121,   40,  425,   39,   47,  112,   88,
       40,  112,   47,  113,   40,  163,   88,  165,   88,   39,
      113,  417,   47,  413,   39,  121,   47,   40,   39,  354,
       48,   47,   40,   88,  112,   48,   40,   41,  163,   88,
      165,   88,   41,  113,   47,   48,   41,   41,   47,   48,
      155,   86,   41,   47,   48,   88,   41,  117,   86,   86,

      117,  151,  151,   41,  159,  159,  350,   48,  118,   41,
       41,   48,  155,  338,   41,  118,   48,   86,   41,  154,
      154,   86,   86,  117,  166,   41,   43,  123,  123,  156,
      205,   43,  376,  124,  124,   43,   43,  376,  118,   86,
      123,  132,  132,  132,  337,   43,  124,  166,  132,  154,
      123,  156,   43,  205,  132,  162,  124,  141,   43,   43,
      123,  158,  158,  335,  148,  148,  124,   43,  141,  141,
      148,  154,  123,  158,   43,   44,  334,  162,  124,  206,
       44,  164,  123,  169,   44,   44,  130,  130,  124,  170,
      332,  141,  141,  130,   44,  171,  130,  130,  130,  173,

      330,   44,  206,  164,  174,  169,  175,   44,   44,  172,
      329,  170,  168,  168,  168,  172,   44,  171,  328,  174,
      327,  173,  130,   44,   45,  180,  185,  174,  175,   45,
      184,  168,  172,   45,   45,  168,  168,  168,  172,  180,
      185,  174,  186,   45,  187,  189,  325,  184,  186,  190,
       45,  189,  191,  168,  207,  207,   45,   45,  187,  319,
      192,  180,  185,  311,  194,   45,  191,  195,  190,  184,
      194,  186,   45,   46,  189,  192,  196,  202,   46,  198,
      187,  195,   46,   46,  199,  198,  200,  298,  191,  208,
      190,  196,   46,  194,  202,  209,  297,  192,  199,   46,

      295,  200,  215,  195,  216,   46,   46,  294,  198,  203,
      203,  208,  292,  196,   46,  221,  202,  209,  213,  213,
      199,   46,  203,  200,  215,  223,  216,  217,  217,  218,
      218,  224,  203,  219,  219,  220,  220,  221,  222,  222,
      225,  226,  203,  227,  228,  229,  290,  230,  223,  231,
      289,  232,  233,  224,  203,  234,  235,  236,  237,  238,
      239,  240,  225,  226,  203,  227,  228,  288,  229,  230,
      248,  287,  231,  232,  233,  248,  285,  234,  235,  236,
      237,  238,  239,  240,  242,  243,  244,  245,  246,  247,
      249,  242,  243,  244,  245,  246,  247,  249,  248,  250,

      251,  252,  241,  253,  254,  250,  255,  251,  252,  253,
      262,  254,  214,  255,  242,  243,  244,  245,  246,  247,
      249,  256,  257,  258,  258,  260,  265,  256,  250,  257,
      251,  252,  253,  262,  254,  263,  255,  259,  259,  261,
      261,  264,  264,  266,  267,  204,  268,  260,  259,  265,
      256,  269,  257,  270,  181,  271,  272,  263,  273,  274,
      276,  277,  179,  278,  279,  266,  280,  267,  268,  281,
      282,  283,  291,  293,  269,  303,  270,  271,  272,  296,
      273,  274,  276,  299,  277,  278,  279,  305,  280,  293,
      291,  281,  282,  306,  283,  296,  301,  301,  303,  299,

      302,  302,  307,  302,  304,  304,  308,  301,  309,  305,
      310,  293,  291,  312,  313,  306,  314,  296,  315,  316,
      317,  299,  318,  326,  307,  320,  323,  176,  308,  161,
      309,  333,  310,  331,  336,  312,  313,  339,  326,  314,
      315,  340,  316,  317,  331,  318,  344,  320,  323,  333,
      341,  341,  336,  341,  345,  339,  340,  347,  340,  348,
      326,  343,  343,  349,  346,  346,  331,  346,  344,  352,
      353,  333,  343,  355,  336,  356,  345,  339,  340,  347,
      340,  348,  357,  358,  368,  360,  349,  361,  407,  407,
      363,  352,  353,  363,  150,  377,  355,  356,  377,  378,

      381,  368,  378,  387,  357,  382,  358,  360,  379,  379,
      361,  380,  380,  385,  380,  386,  363,  383,  383,  379,
      383,  377,  381,  368,  389,  378,  387,  382,  391,  392,
      393,  394,  395,  396,  397,  385,  149,  386,  398,  404,
      404,  399,  404,  403,  406,  402,  400,  389,  397,  401,
      391,  392,  399,  393,  394,  395,  396,  400,  398,  402,
      401,  403,  408,  138,  409,  410,  411,  406,  412,  416,
      397,  415,  420,  136,  399,  426,  426,  418,  420,  400,
      398,  402,  401,  403,  418,  408,  409,  410,  419,  411,
      421,  412,  416,  415,  422,  423,  421,  424,  427,  419,

      422,  420,  423,  428,  424,  131,  429,  418,  430,  442,
      444,  444,  445,  437,  446,  447,  448,  452,  125,  421,
      427,  419,  457,  422,  442,  423,  428,  424,  429,  437,
      430,  460,  452,  461,  445,  462,  446,  447,  448,  458,
      458,  473,  457,  119,  114,  109,  442,  103,   97,   96,
       91,  437,   90,  460,  452,  461,   87,  462,   82,   81,
       72,   64,   62,  473,  457,  482,  482,  482,  482,  482,
      483,  483,  483,  483,  483,  484,  484,  484,  484,  484,
      485,  485,  485,  485,  485,  486,  486,  486,  486,  486,
      487,  487,  487,  487,  487,  488,  488,  488,  488,  488,

      489,  489,  489,  489,  489,  490,  490,  490,  490,  490,
      491,  491,  491,  491,  491,  492,  492,  492,  492,  492,
      493,  493,  493,  493,  493,  494,  494,  494,  494,  494,
      495,  495,  495,  495,  495,  499,   57,  499,  499,  499,
      500,   54,  500,  500,  500,  501,  501,  502,  502,  502,
      502,  502,  503,   53,  503,  503,  503,  504,   52,  504,
      504,  504,  505,  505,   51,  505,  505,  506,  506,  506,
      506,  506,   30,   29,   26,   25,   22,   21,   18,   17,
       16,   15,   14,   13,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,

      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481,  481,  481,  481,  481,  481,  481,  481,
      481,  481,  481
    } ;

/* 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
#line 1 "diam_dict.l"

/*
 * We want a reentrant scanner.
 */
/*
 * We don't use input, so don't generate code for it.
 */
#define YY_NO_INPUT 1
/*
 * We don't use unput, so don't generate code for it.
 */
/*
 * We don't read interactively from the terminal.
 */
/*
 * The language we're scanning is case-insensitive.
 */
/*
 * We use start condition stacks.
 */
/*
 * We want to stop processing when we get to the end of the input.
 */
/*
 * The type for the state we keep for a scanner.
 */
/*
 * Prefix scanner routines with "DiamDict_" rather than "yy", so this scanner
 * can coexist with other scanners.
 */
/*
 * We have to override the memory allocators so that we don't get
 * "unused argument" warnings from the yyscanner argument (which
 * we don't use, as we have a global memory allocator).
 *
 * We provide, as macros, our own versions of the routines generated by Flex,
 * which just call malloc()/realloc()/free() (as the Flex versions do),
 * discarding the extra argument.
 */
#line 68 "diam_dict.l"
	/*
	 ** diam_dict.h
	 ** Diameter Dictionary Import Routines
	 **
	 ** (c) 2007, Luis E. Garcia Ontanon <luis@ontanon.org>
	 **
	 ** This library is free software; you can redistribute it and/or
	 ** modify it under the terms of the GNU Library General Public
	 ** License as published by the Free Software Foundation; either
	 ** version 2 of the License, or (at your option) any later version.
	 **
	 ** This library 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
	 ** Library General Public License for more details.
	 **
	 ** You should have received a copy of the GNU Library General Public
	 ** License along with this library; if not, write to the Free Software
	 ** Foundation, Inc., 51 Franklin Street, Fifth Floor,
	 ** Boston, MA  02110-1301, USA.
	 */

#include <glib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
#include "diam_dict.h"
#include <epan/to_str.h>
#include <wsutil/file_util.h>

typedef struct entity_t {
	char* name;
	char* file;
	struct entity_t* next;
} entity_t;

#define ATTR_UINT(cont) do { D(("attr_uint " #cont "\t" )); yyextra->attr_uint = &(cont); yy_push_state(GET_UINT_ATTR, yyscanner); } while(0)
#define ATTR_STR(cont) do { D(("attr_str " #cont "\t" )); yyextra->attr_str = &(cont); yy_push_state(GET_ATTR, yyscanner); } while(0)
#define IGNORE() do { D(("ignore: %s\t",yytext)); yy_push_state(IGNORE_ATTR, yyscanner); } while(0)

#define D(args) ddict_debug args

#define MAX_INCLUDE_DEPTH 10
#define YY_INPUT(buf,result,max_size) { result = yyextra->current_yyinput(buf,max_size,yyscanner); }
#define YY_USER_INIT { \
	DiamDict_scanner_state_t *scanner_state = DiamDict_get_extra(yyscanner); \
	BEGIN(scanner_state->start_state); \
}
#define ECHO
#define APPEND(txt,len) append_to_buffer(txt,len,yyextra)

typedef struct {
	const char* sys_dir;

	char* write_ptr;
	char* read_ptr;

	char* strbuf;
	unsigned size_strbuf;
	unsigned len_strbuf;

	ddict_t* dict;

	ddict_application_t* appl;
	ddict_avp_t* avp;
	ddict_enum_t* enumitem;
	ddict_gavp_t* gavp;
	ddict_typedefn_t* typedefn;
	ddict_cmd_t* cmd;
	ddict_vendor_t* vnd;
	ddict_xmlpi_t* xmlpi;

	ddict_application_t* last_appl;
	ddict_avp_t* last_avp;
	ddict_enum_t* last_enumitem;
	ddict_gavp_t* last_gavp;
	ddict_typedefn_t* last_typedefn;
	ddict_cmd_t* last_cmd;
	ddict_vendor_t* last_vnd;
	ddict_xmlpi_t* last_xmlpi;

	entity_t *ents;

	char** attr_str;
	unsigned* attr_uint;

	size_t (*current_yyinput)(char*,size_t,yyscan_t);

	YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
	int include_stack_ptr;

	int start_state;
} DiamDict_scanner_state_t;

static void ddict_debug(const char* fmt, ...) G_GNUC_PRINTF(1, 2);
static void append_to_buffer(const char* txt, unsigned len, DiamDict_scanner_state_t *statep);
static FILE* ddict_open(const char*, const char*);

/*
 * Sleazy hack to suppress compiler warnings in yy_fatal_error().
 */
#define YY_EXIT_FAILURE ((void)yyscanner, 2)

/*
 * Macros for the allocators, to discard the extra argument.
 */
#define DiamDict_alloc(size, yyscanner)		(void *)malloc(size)
#define DiamDict_realloc(ptr, size, yyscanner)	(void *)realloc((char *)(ptr), (size))
#define DiamDict_free(ptr, yyscanner)		free((char *)ptr)





#line 1042 "diam_dict.c"

#define INITIAL 0
#define LOADING 1
#define LOADING_COMMENT 2
#define LOADING_XMLPI 3
#define ENTITY 4
#define GET_SYSTEM 5
#define GET_FILE 6
#define END_ENTITY 7
#define GET_ATTR 8
#define GET_UINT_ATTR 9
#define END_ATTR 10
#define OUTSIDE 11
#define IN_DICT 12
#define IN_APPL 13
#define IN_AVP 14
#define APPL_ATTRS 15
#define IGNORE_ATTR 16
#define TYPE_ATTRS 17
#define GAVP_ATTRS 18
#define ENUM_ATTRS 19
#define AVP_ATTRS 20
#define VENDOR_ATTRS 21
#define COMMAND_ATTRS 22
#define TYPEDEFN_ATTRS 23
#define XMLPI_ATTRS 24
#define XMLPI_GETKEY 25
#define XMLPI_GETVAL 26
#define XMLPI_ENDATTR 27

#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.
 */
#include <unistd.h>
#endif

#define YY_EXTRA_TYPE DiamDict_scanner_state_t *

/* Holds the entire state of the reentrant scanner. */
struct yyguts_t
    {

    /* User-defined. Not touched by flex. */
    YY_EXTRA_TYPE yyextra_r;

    /* The rest are the same as the globals declared in the non-reentrant scanner. */
    FILE *yyin_r, *yyout_r;
    size_t yy_buffer_stack_top; /**< index of top of stack. */
    size_t yy_buffer_stack_max; /**< capacity of stack. */
    YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
    char yy_hold_char;
    int yy_n_chars;
    yy_size_t yyleng_r;
    char *yy_c_buf_p;
    int yy_init;
    int yy_start;
    int yy_did_buffer_switch_on_eof;
    int yy_start_stack_ptr;
    int yy_start_stack_depth;
    int *yy_start_stack;
    yy_state_type yy_last_accepting_state;
    char* yy_last_accepting_cpos;

    int yylineno_r;
    int yy_flex_debug_r;

    char *yytext_r;
    int yy_more_flag;
    int yy_more_len;

    }; /* end struct yyguts_t */

static int yy_init_globals (yyscan_t yyscanner );

int DiamDict_lex_init (yyscan_t* scanner);

int DiamDict_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);

/* Accessor methods to globals.
   These are made visible to non-reentrant scanners for convenience. */

int DiamDict_lex_destroy (yyscan_t yyscanner );

int DiamDict_get_debug (yyscan_t yyscanner );

void DiamDict_set_debug (int debug_flag ,yyscan_t yyscanner );

YY_EXTRA_TYPE DiamDict_get_extra (yyscan_t yyscanner );

void DiamDict_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );

FILE *DiamDict_get_in (yyscan_t yyscanner );

void DiamDict_set_in  (FILE * _in_str ,yyscan_t yyscanner );

FILE *DiamDict_get_out (yyscan_t yyscanner );

void DiamDict_set_out  (FILE * _out_str ,yyscan_t yyscanner );

yy_size_t DiamDict_get_leng (yyscan_t yyscanner );

char *DiamDict_get_text (yyscan_t yyscanner );

int DiamDict_get_lineno (yyscan_t yyscanner );

void DiamDict_set_lineno (int _line_number ,yyscan_t yyscanner );

int DiamDict_get_column  (yyscan_t yyscanner );

void DiamDict_set_column (int _column_no ,yyscan_t yyscanner );

/* Macros after this point can all be overridden by user definitions in
 * section 1.
 */

#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int DiamDict_wrap (yyscan_t yyscanner );
#else
extern int DiamDict_wrap (yyscan_t yyscanner );
#endif
#endif

#ifndef YY_NO_UNPUT
    
#endif

#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif

#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#endif

#ifndef YY_NO_INPUT

#ifdef __cplusplus
static int yyinput (yyscan_t yyscanner );
#else
static int input (yyscan_t yyscanner );
#endif

#endif

    static void yy_push_state (int _new_state ,yyscan_t yyscanner);
    
    static void yy_pop_state (yyscan_t yyscanner );
    
    static int yy_top_state (yyscan_t yyscanner );
    
/* 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
/* This used to be an fputs(), but since the string might contain NUL's,
 * we now use fwrite().
 */
#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
#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) \
	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
		{ \
		int c = '*'; \
		size_t n; \
		for ( n = 0; n < max_size && \
			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
			buf[n] = (char) c; \
		if ( c == '\n' ) \
			buf[n++] = (char) c; \
		if ( c == EOF && ferror( yyin ) ) \
			YY_FATAL_ERROR( "input in flex scanner failed" ); \
		result = n; \
		} \
	else \
		{ \
		errno=0; \
		while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
			{ \
			if( errno != EINTR) \
				{ \
				YY_FATAL_ERROR( "input in flex scanner failed" ); \
				break; \
				} \
			errno=0; \
			clearerr(yyin); \
			} \
		}\
\

#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
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
#endif

/* end tables serialization structures and prototypes */

/* Default declaration of generated scanner - a define so the user can
 * easily add parameters.
 */
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1

extern int DiamDict_lex (yyscan_t yyscanner);

#define YY_DECL int DiamDict_lex (yyscan_t yyscanner)
#endif /* !YY_DECL */

/* Code executed at the beginning of each rule, after yytext and yyleng
 * 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

#define YY_RULE_SETUP \
	YY_USER_ACTION

/** 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;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	if ( !yyg->yy_init )
		{
		yyg->yy_init = 1;

#ifdef YY_USER_INIT
		YY_USER_INIT;
#endif

		if ( ! yyg->yy_start )
			yyg->yy_start = 1;	/* first start state */

		if ( ! yyin )
			yyin = stdin;

		if ( ! yyout )
			yyout = stdout;

		if ( ! YY_CURRENT_BUFFER ) {
			DiamDict_ensure_buffer_stack (yyscanner);
			YY_CURRENT_BUFFER_LVALUE =
				DiamDict__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
		}

		DiamDict__load_buffer_state(yyscanner );
		}

	{
#line 264 "diam_dict.l"

#line 1334 "diam_dict.c"

	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
		{
		yy_cp = yyg->yy_c_buf_p;

		/* Support of yytext. */
		*yy_cp = yyg->yy_hold_char;

		/* yy_bp points to the position in yy_ch_buf of the start of
		 * the current run.
		 */
		yy_bp = yy_cp;

		yy_current_state = yyg->yy_start;
yy_match:
		do
			{
			YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
			if ( yy_accept[yy_current_state] )
				{
				yyg->yy_last_accepting_state = yy_current_state;
				yyg->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 >= 482 )
					yy_c = yy_meta[(unsigned int) yy_c];
				}
			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
			++yy_cp;
			}
		while ( yy_current_state != 481 );
		yy_cp = yyg->yy_last_accepting_cpos;
		yy_current_state = yyg->yy_last_accepting_state;

yy_find_action:
		yy_act = yy_accept[yy_current_state];

		YY_DO_BEFORE_ACTION;

do_action:	/* This label is used only to access EOF actions. */

		switch ( yy_act )
	{ /* beginning of action switch */
			case 0: /* must back up */
			/* undo the effects of YY_DO_BEFORE_ACTION */
			*yy_cp = yyg->yy_hold_char;
			yy_cp = yyg->yy_last_accepting_cpos;
			yy_current_state = yyg->yy_last_accepting_state;
			goto yy_find_action;

case 1:
/* rule 1 can match eol */
YY_RULE_SETUP
#line 265 "diam_dict.l"
;
	YY_BREAK
case 2:
/* rule 2 can match eol */
YY_RULE_SETUP
#line 266 "diam_dict.l"
;
	YY_BREAK
case 3:
/* rule 3 can match eol */
YY_RULE_SETUP
#line 268 "diam_dict.l"
BEGIN LOADING_COMMENT;
	YY_BREAK
case 4:
YY_RULE_SETUP
#line 269 "diam_dict.l"
;
	YY_BREAK
case 5:
/* rule 5 can match eol */
YY_RULE_SETUP
#line 270 "diam_dict.l"
BEGIN LOADING;
	YY_BREAK
case 6:
/* rule 6 can match eol */
YY_RULE_SETUP
#line 272 "diam_dict.l"
BEGIN LOADING_XMLPI;
	YY_BREAK
case 7:
/* rule 7 can match eol */
YY_RULE_SETUP
#line 273 "diam_dict.l"
;
	YY_BREAK
case 8:
YY_RULE_SETUP
#line 274 "diam_dict.l"
{
	yyextra->xmlpi = g_new(ddict_xmlpi_t,1);
	yyextra->xmlpi->name = g_strdup(yytext);
	yyextra->xmlpi->key = NULL;
	yyextra->xmlpi->value = NULL;
	yyextra->xmlpi->next = NULL;

	if (!yyextra->dict->xmlpis)
		yyextra->last_xmlpi = yyextra->dict->xmlpis = yyextra->xmlpi;
	else
		yyextra->last_xmlpi = yyextra->last_xmlpi->next = yyextra->xmlpi;

	BEGIN XMLPI_ATTRS;
}
	YY_BREAK
case 9:
/* rule 9 can match eol */
YY_RULE_SETUP
#line 289 "diam_dict.l"
BEGIN XMLPI_GETKEY;
	YY_BREAK
case 10:
/* rule 10 can match eol */
YY_RULE_SETUP
#line 290 "diam_dict.l"
{ yyextra->xmlpi->key = g_strdup(yytext); BEGIN XMLPI_ATTRS; }
	YY_BREAK
case 11:
/* rule 11 can match eol */
YY_RULE_SETUP
#line 292 "diam_dict.l"
BEGIN XMLPI_GETVAL;
	YY_BREAK
case 12:
/* rule 12 can match eol */
YY_RULE_SETUP
#line 293 "diam_dict.l"
{ yyextra->xmlpi->value = g_strdup(yytext); BEGIN XMLPI_ATTRS; }
	YY_BREAK
case 13:
YY_RULE_SETUP
#line 295 "diam_dict.l"

	YY_BREAK
case 14:
/* rule 14 can match eol */
YY_RULE_SETUP
#line 296 "diam_dict.l"
BEGIN LOADING;
	YY_BREAK
case 15:
/* rule 15 can match eol */
YY_RULE_SETUP
#line 299 "diam_dict.l"
BEGIN ENTITY;
	YY_BREAK
case 16:
YY_RULE_SETUP
#line 300 "diam_dict.l"
{
	entity_t* e = g_new(entity_t,1);
	e->name = g_strdup(yytext);
	e->next = yyextra->ents;
	yyextra->ents = e;
	BEGIN GET_SYSTEM;
	};
	YY_BREAK
case 17:
/* rule 17 can match eol */
YY_RULE_SETUP
#line 307 "diam_dict.l"
BEGIN GET_FILE;
	YY_BREAK
case 18:
/* rule 18 can match eol */
YY_RULE_SETUP
#line 308 "diam_dict.l"
{
		yyextra->ents->file = g_strdup(yytext);
		BEGIN END_ENTITY;
	}
	YY_BREAK
case 19:
/* rule 19 can match eol */
YY_RULE_SETUP
#line 312 "diam_dict.l"
BEGIN LOADING;
	YY_BREAK
case 20:
/* rule 20 can match eol */
YY_RULE_SETUP
#line 314 "diam_dict.l"
APPEND("<",1);
	YY_BREAK
case 21:
/* rule 21 can match eol */
YY_RULE_SETUP
#line 316 "diam_dict.l"
APPEND(">",1);
	YY_BREAK
case 22:
/* rule 22 can match eol */
YY_RULE_SETUP
#line 318 "diam_dict.l"
APPEND("/>",2);
	YY_BREAK
case 23:
/* rule 23 can match eol */
YY_RULE_SETUP
#line 320 "diam_dict.l"
APPEND("</",2);
	YY_BREAK
case 24:
/* rule 24 can match eol */
YY_RULE_SETUP
#line 322 "diam_dict.l"
APPEND(" ",1);
	YY_BREAK
case 25:
/* rule 25 can match eol */
YY_RULE_SETUP
#line 324 "diam_dict.l"
APPEND(yytext, (unsigned) yyleng);
	YY_BREAK
case 26:
/* rule 26 can match eol */
YY_RULE_SETUP
#line 326 "diam_dict.l"
APPEND("=",1);
	YY_BREAK
case 27:
YY_RULE_SETUP
#line 328 "diam_dict.l"
APPEND(yytext, (unsigned) yyleng);
	YY_BREAK
case 28:
YY_RULE_SETUP
#line 330 "diam_dict.l"
{
	char* p = ++yytext;
	entity_t* e;

	while(*p != ';') p++;

	*p = '\0';

	D(("looking for entity: %s\n",yytext));

	if ( yyextra->include_stack_ptr >= MAX_INCLUDE_DEPTH ) {
		fprintf(stderr, "included files nested to deeply\n");
		yyterminate();
	}

	for (e = yyextra->ents; e; e = e->next) {
		if (strcmp(e->name,yytext) == 0) {
			yyin = ddict_open(yyextra->sys_dir,e->file);
			D(("entity: %s filename: %s yyin: %p\n",e->name,e->file,(void*)yyin));
			if (!yyin) {
				if (errno)
					fprintf(stderr, "Could not open file: '%s', error: %s\n", e->file, g_strerror(errno) );
				else
					fprintf(stderr, "Could not open file: '%s', error unknown (errno == 0)\n", e->file );
				yyterminate();
			} else {
				yyextra->include_stack[yyextra->include_stack_ptr++] = YY_CURRENT_BUFFER;
				DiamDict__switch_to_buffer(DiamDict__create_buffer(yyin,YY_BUF_SIZE,yyscanner),yyscanner);
				BEGIN LOADING;
			}
			break;
		}
	}

	if (!e) {
		fprintf(stderr, "Could not find entity: '%s'\n", yytext );
		yyterminate();
	}

}
	YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(LOADING):
case YY_STATE_EOF(LOADING_COMMENT):
case YY_STATE_EOF(LOADING_XMLPI):
case YY_STATE_EOF(ENTITY):
case YY_STATE_EOF(GET_SYSTEM):
case YY_STATE_EOF(GET_FILE):
case YY_STATE_EOF(END_ENTITY):
case YY_STATE_EOF(GET_ATTR):
case YY_STATE_EOF(GET_UINT_ATTR):
case YY_STATE_EOF(END_ATTR):
case YY_STATE_EOF(OUTSIDE):
case YY_STATE_EOF(IN_DICT):
case YY_STATE_EOF(IN_APPL):
case YY_STATE_EOF(IN_AVP):
case YY_STATE_EOF(APPL_ATTRS):
case YY_STATE_EOF(IGNORE_ATTR):
case YY_STATE_EOF(TYPE_ATTRS):
case YY_STATE_EOF(GAVP_ATTRS):
case YY_STATE_EOF(ENUM_ATTRS):
case YY_STATE_EOF(AVP_ATTRS):
case YY_STATE_EOF(VENDOR_ATTRS):
case YY_STATE_EOF(COMMAND_ATTRS):
case YY_STATE_EOF(TYPEDEFN_ATTRS):
case YY_STATE_EOF(XMLPI_ATTRS):
case YY_STATE_EOF(XMLPI_GETKEY):
case YY_STATE_EOF(XMLPI_GETVAL):
case YY_STATE_EOF(XMLPI_ENDATTR):
#line 371 "diam_dict.l"
{
	if (!yyin) yyterminate();

	fclose(yyin);
	D(("closing: %p %i\n",(void*)yyin,yyextra->include_stack_ptr));

	if ( --yyextra->include_stack_ptr < 0 ) {
		D(("DONE READING\n"));
		yyin = NULL;
		yyterminate();
	} else {
		DiamDict__delete_buffer(YY_CURRENT_BUFFER,yyscanner);
		DiamDict__switch_to_buffer(yyextra->include_stack[yyextra->include_stack_ptr],yyscanner);
		BEGIN LOADING;
	}
}
	YY_BREAK
case 29:
/* rule 29 can match eol */
YY_RULE_SETUP
#line 389 "diam_dict.l"
{
	*(yyextra->attr_str) = g_strdup(yytext);
	D(("%s\n",yytext));
	yyextra->attr_str = NULL;
	BEGIN END_ATTR;
}
	YY_BREAK
case 30:
YY_RULE_SETUP
#line 396 "diam_dict.l"
{
	*(yyextra->attr_uint) = (unsigned) strtoul(yytext,NULL,10);
	D(("%s\n",yytext););
	yyextra->attr_uint = NULL;
	BEGIN END_ATTR;
}
	YY_BREAK
case 31:
YY_RULE_SETUP
#line 403 "diam_dict.l"
{	yy_pop_state(yyscanner); }
	YY_BREAK
case 32:
YY_RULE_SETUP
#line 405 "diam_dict.l"
{
	/* XXX: should go?*/
	D(("{%s}",yytext));
}
	YY_BREAK
case 33:
/* rule 33 can match eol */
YY_RULE_SETUP
#line 410 "diam_dict.l"
{
	D(("=>%s<=\n",yytext));
	yy_pop_state(yyscanner);
}
	YY_BREAK
case 34:
YY_RULE_SETUP
#line 415 "diam_dict.l"
{
	D(("dictionary_start\n"));

	BEGIN IN_DICT;
}
	YY_BREAK
case 35:
/* rule 35 can match eol */
YY_RULE_SETUP
#line 421 "diam_dict.l"
{
	D(("base_start\n"));
	BEGIN IN_APPL;
}
	YY_BREAK
case 36:
YY_RULE_SETUP
#line 426 "diam_dict.l"
{
	D(("application_start\n"));

	yyextra->appl = g_new(ddict_application_t,1);
	yyextra->appl->name = NULL;
	yyextra->appl->code = 0;
	yyextra->appl->next = NULL;

	if (!yyextra->dict->applications)
		yyextra->last_appl = yyextra->dict->applications = yyextra->appl;
	else
		yyextra->last_appl = yyextra->last_appl->next = yyextra->appl;

	BEGIN APPL_ATTRS;
}
	YY_BREAK
case 37:
YY_RULE_SETUP
#line 442 "diam_dict.l"
{ ATTR_STR(yyextra->appl->name); }
	YY_BREAK
case 38:
YY_RULE_SETUP
#line 443 "diam_dict.l"
{ ATTR_UINT(yyextra->appl->code); }
	YY_BREAK
case 39:
YY_RULE_SETUP
#line 445 "diam_dict.l"
BEGIN IN_APPL;
	YY_BREAK
case 40:
YY_RULE_SETUP
#line 446 "diam_dict.l"
BEGIN IN_DICT;
	YY_BREAK
case 41:
YY_RULE_SETUP
#line 448 "diam_dict.l"
;
	YY_BREAK
case 42:
YY_RULE_SETUP
#line 450 "diam_dict.l"
{
	D(("command_start\n"));

	yyextra->cmd = g_new(ddict_cmd_t,1);
	yyextra->cmd->name = NULL;
	yyextra->cmd->vendor = NULL;
	yyextra->cmd->code = 0;
	yyextra->cmd->next = NULL;

	if (!yyextra->dict->cmds)
		yyextra->last_cmd = yyextra->dict->cmds = yyextra->cmd;
	else
		yyextra->last_cmd = yyextra->last_cmd->next = yyextra->cmd;

	BEGIN COMMAND_ATTRS;
}
	YY_BREAK
case 43:
YY_RULE_SETUP
#line 467 "diam_dict.l"
{ ATTR_STR(yyextra->cmd->name); }
	YY_BREAK
case 44:
YY_RULE_SETUP
#line 468 "diam_dict.l"
{ ATTR_STR(yyextra->cmd->vendor); }
	YY_BREAK
case 45:
YY_RULE_SETUP
#line 469 "diam_dict.l"
{ ATTR_UINT(yyextra->cmd->code); }
	YY_BREAK
case 46:
#line 471 "diam_dict.l"
case 47:
YY_RULE_SETUP
#line 471 "diam_dict.l"
{ BEGIN IN_APPL; }
	YY_BREAK
case 48:
YY_RULE_SETUP
#line 473 "diam_dict.l"
{
	D(("vendor_start\n"));

	yyextra->vnd = g_new(ddict_vendor_t,1);
	yyextra->vnd->name = NULL;
	yyextra->vnd->code = 0;
	yyextra->vnd->next = NULL;

	if (!yyextra->dict->vendors)
		yyextra->last_vnd = yyextra->dict->vendors = yyextra->vnd;
	else
		yyextra->last_vnd = yyextra->last_vnd->next = yyextra->vnd;

	BEGIN VENDOR_ATTRS;
}
	YY_BREAK
case 49:
YY_RULE_SETUP
#line 489 "diam_dict.l"
{ ATTR_STR(yyextra->vnd->desc); }
	YY_BREAK
case 50:
YY_RULE_SETUP
#line 490 "diam_dict.l"
{ ATTR_STR(yyextra->vnd->name); }
	YY_BREAK
case 51:
YY_RULE_SETUP
#line 491 "diam_dict.l"
{ ATTR_UINT(yyextra->vnd->code); }
	YY_BREAK
case 52:
YY_RULE_SETUP
#line 492 "diam_dict.l"
{ BEGIN IN_APPL; }
	YY_BREAK
case 53:
YY_RULE_SETUP
#line 493 "diam_dict.l"
{ BEGIN IN_DICT; }
	YY_BREAK
case 54:
YY_RULE_SETUP
#line 495 "diam_dict.l"
{
	D(("typedefn_start\n"));

	yyextra->typedefn = g_new(ddict_typedefn_t,1);
	yyextra->typedefn->name = NULL;
	yyextra->typedefn->parent = NULL;
	yyextra->typedefn->next = NULL;

	if (!yyextra->dict->typedefns)
		yyextra->last_typedefn = yyextra->dict->typedefns = yyextra->typedefn;
	else
		yyextra->last_typedefn = yyextra->last_typedefn->next = yyextra->typedefn;

	BEGIN TYPEDEFN_ATTRS;
}
	YY_BREAK
case 55:
YY_RULE_SETUP
#line 511 "diam_dict.l"
{ ATTR_STR(yyextra->typedefn->name); }
	YY_BREAK
case 56:
YY_RULE_SETUP
#line 512 "diam_dict.l"
{ ATTR_STR(yyextra->typedefn->parent); }
	YY_BREAK
case 57:
#line 514 "diam_dict.l"
case 58:
YY_RULE_SETUP
#line 514 "diam_dict.l"
{ BEGIN IN_APPL; }
	YY_BREAK
case 59:
YY_RULE_SETUP
#line 517 "diam_dict.l"
{
	D(("avp_start\n"));

	yyextra->avp = g_new(ddict_avp_t,1);
	yyextra->avp->name = NULL;
	yyextra->avp->description = NULL;
	yyextra->avp->vendor = NULL;
	yyextra->avp->code = 0;
	yyextra->avp->type = NULL;
	yyextra->avp->enums = NULL;
	yyextra->avp->gavps = NULL;
	yyextra->avp->next = NULL;

	if (! yyextra->dict->avps )
		yyextra->last_avp = yyextra->dict->avps = yyextra->avp;
	else
		yyextra->last_avp = yyextra->last_avp->next = yyextra->avp;

	BEGIN AVP_ATTRS;
}
	YY_BREAK
case 60:
YY_RULE_SETUP
#line 538 "diam_dict.l"
{ ATTR_STR(yyextra->avp->name); }
	YY_BREAK
case 61:
YY_RULE_SETUP
#line 539 "diam_dict.l"
{ ATTR_STR(yyextra->avp->description); }
	YY_BREAK
case 62:
YY_RULE_SETUP
#line 540 "diam_dict.l"
{ ATTR_STR(yyextra->avp->vendor); }
	YY_BREAK
case 63:
YY_RULE_SETUP
#line 541 "diam_dict.l"
{ ATTR_UINT(yyextra->avp->code); }
	YY_BREAK
case 64:
YY_RULE_SETUP
#line 542 "diam_dict.l"
{ BEGIN IN_AVP;  }
	YY_BREAK
case 65:
YY_RULE_SETUP
#line 543 "diam_dict.l"
{ BEGIN IN_APPL; }
	YY_BREAK
case 66:
YY_RULE_SETUP
#line 546 "diam_dict.l"
{ yyextra->avp->type = g_strdup("Grouped"); };
	YY_BREAK
case 67:
YY_RULE_SETUP
#line 547 "diam_dict.l"
;
	YY_BREAK
case 68:
YY_RULE_SETUP
#line 549 "diam_dict.l"
{ BEGIN TYPE_ATTRS; }
	YY_BREAK
case 69:
YY_RULE_SETUP
#line 550 "diam_dict.l"
{ ATTR_STR(yyextra->avp->type); }
	YY_BREAK
case 70:
YY_RULE_SETUP
#line 552 "diam_dict.l"
{
	D(("gavp_start\n"));

	yyextra->gavp = g_new(ddict_gavp_t,1);
	yyextra->gavp->name = NULL;
	yyextra->gavp->code = 0;
	yyextra->gavp->next = NULL;

	if (!yyextra->avp->gavps)
		yyextra->last_gavp = yyextra->avp->gavps = yyextra->gavp;
	else
		yyextra->last_gavp = yyextra->last_gavp->next = yyextra->gavp;

	BEGIN GAVP_ATTRS;
}
	YY_BREAK
case 71:
YY_RULE_SETUP
#line 569 "diam_dict.l"
{ ATTR_STR(yyextra->gavp->name); }
	YY_BREAK
case 72:
YY_RULE_SETUP
#line 572 "diam_dict.l"
{
	D(("enum_start\n"));

	yyextra->enumitem = g_new(ddict_enum_t,1);
	yyextra->enumitem->name = NULL;
	yyextra->enumitem->code = 0;
	yyextra->enumitem->next = NULL;

	if (!yyextra->avp->enums)
		yyextra->last_enumitem = yyextra->avp->enums = yyextra->enumitem;
	else
		yyextra->last_enumitem = yyextra->last_enumitem->next = yyextra->enumitem;

	BEGIN ENUM_ATTRS;
}
	YY_BREAK
case 73:
YY_RULE_SETUP
#line 589 "diam_dict.l"
{ ATTR_STR(yyextra->enumitem->name); }
	YY_BREAK
case 74:
YY_RULE_SETUP
#line 590 "diam_dict.l"
{ ATTR_UINT(yyextra->enumitem->code); }
	YY_BREAK
case 75:
YY_RULE_SETUP
#line 592 "diam_dict.l"
{ BEGIN IN_AVP; }
	YY_BREAK
case 76:
YY_RULE_SETUP
#line 593 "diam_dict.l"
{ BEGIN IN_AVP; }
	YY_BREAK
case 77:
YY_RULE_SETUP
#line 595 "diam_dict.l"
{ D(("avp_end\n")); BEGIN IN_APPL; }
	YY_BREAK
case 78:
YY_RULE_SETUP
#line 597 "diam_dict.l"
{
	D(("application_end\n")); BEGIN IN_DICT;
}
	YY_BREAK
case 79:
YY_RULE_SETUP
#line 600 "diam_dict.l"
{
	D(("application_stop_end\n")); BEGIN IN_DICT;
}
	YY_BREAK
case 80:
YY_RULE_SETUP
#line 603 "diam_dict.l"
{
	D(("vendor_end\n")); BEGIN IN_DICT;
}
	YY_BREAK
case 81:
YY_RULE_SETUP
#line 606 "diam_dict.l"
{
	D(("base_end\n")); BEGIN IN_DICT;
}
	YY_BREAK
case 82:
YY_RULE_SETUP
#line 610 "diam_dict.l"
{
	yyterminate();
}
	YY_BREAK
case 83:
YY_RULE_SETUP
#line 614 "diam_dict.l"
IGNORE();
	YY_BREAK
case 84:
YY_RULE_SETUP
#line 616 "diam_dict.l"
;
	YY_BREAK
case 85:
YY_RULE_SETUP
#line 623 "diam_dict.l"
ECHO;
	YY_BREAK
#line 2075 "diam_dict.c"

	case YY_END_OF_BUFFER:
		{
		/* Amount of text matched not including the EOB char. */
		int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;

		/* Undo the effects of YY_DO_BEFORE_ACTION. */
		*yy_cp = yyg->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 yyin at a new source and called
			 * DiamDict_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.
			 */
			yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
			YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
			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 ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
			{ /* This was really a NUL. */
			yy_state_type yy_next_state;

			yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;

			yy_current_state = yy_get_previous_state( yyscanner );

			/* 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 , yyscanner);

			yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;

			if ( yy_next_state )
				{
				/* Consume the NUL. */
				yy_cp = ++yyg->yy_c_buf_p;
				yy_current_state = yy_next_state;
				goto yy_match;
				}

			else
				{
				yy_cp = yyg->yy_last_accepting_cpos;
				yy_current_state = yyg->yy_last_accepting_state;
				goto yy_find_action;
				}
			}

		else switch ( yy_get_next_buffer( yyscanner ) )
			{
			case EOB_ACT_END_OF_FILE:
				{
				yyg->yy_did_buffer_switch_on_eof = 0;

				if ( DiamDict_wrap(yyscanner ) )
					{
					/* Note: because we've taken care in
					 * yy_get_next_buffer() to have set up
					 * yytext, 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.
					 */
					yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;

					yy_act = YY_STATE_EOF(YY_START);
					goto do_action;
					}

				else
					{
					if ( ! yyg->yy_did_buffer_switch_on_eof )
						YY_NEW_FILE;
					}
				break;
				}

			case EOB_ACT_CONTINUE_SCAN:
				yyg->yy_c_buf_p =
					yyg->yytext_ptr + yy_amount_of_matched_text;

				yy_current_state = yy_get_previous_state( yyscanner );

				yy_cp = yyg->yy_c_buf_p;
				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
				goto yy_match;

			case EOB_ACT_LAST_MATCH:
				yyg->yy_c_buf_p =
				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];

				yy_current_state = yy_get_previous_state( yyscanner );

				yy_cp = yyg->yy_c_buf_p;
				yy_bp = yyg->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 DiamDict_lex */

/* 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
 */
static int yy_get_next_buffer (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
	char *source = yyg->yytext_ptr;
	yy_size_t number_to_move, i;
	int ret_val;

	if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->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 ( yyg->yy_c_buf_p - yyg->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 = (yy_size_t) (yyg->yy_c_buf_p - yyg->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 = yyg->yy_n_chars = 0;

	else
		{
			yy_size_t 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) (yyg->yy_c_buf_p - b->yy_ch_buf);

			if ( b->yy_is_our_buffer )
				{
				yy_size_t 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. */
					DiamDict_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
				}
			else
				/* Can't grow it, we don't own it. */
				b->yy_ch_buf = 0;

			if ( ! b->yy_ch_buf )
				YY_FATAL_ERROR(
				"fatal error - scanner input buffer overflow" );

			yyg->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]),
			yyg->yy_n_chars, num_to_read );

		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
		}

	if ( yyg->yy_n_chars == 0 )
		{
		if ( number_to_move == YY_MORE_ADJ )
			{
			ret_val = EOB_ACT_END_OF_FILE;
			DiamDict_restart(yyin  ,yyscanner);
			}

		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 ((int) (yyg->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 = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) DiamDict_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
	}

	yyg->yy_n_chars += number_to_move;
	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;

	yyg->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 */

    static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
{
	yy_state_type yy_current_state;
	char *yy_cp;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	yy_current_state = yyg->yy_start;

	for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
		{
		YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
		if ( yy_accept[yy_current_state] )
			{
			yyg->yy_last_accepting_state = yy_current_state;
			yyg->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 >= 482 )
				yy_c = yy_meta[(unsigned int) yy_c];
			}
		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) 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 );
 */
    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
{
	int yy_is_jam;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
	char *yy_cp = yyg->yy_c_buf_p;

	YY_CHAR yy_c = 1;
	if ( yy_accept[yy_current_state] )
		{
		yyg->yy_last_accepting_state = yy_current_state;
		yyg->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 >= 482 )
			yy_c = yy_meta[(unsigned int) yy_c];
		}
	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
	yy_is_jam = (yy_current_state == 481);

	(void)yyg;
	return yy_is_jam ? 0 : yy_current_state;
}

#ifndef YY_NO_UNPUT

#endif

#ifndef YY_NO_INPUT
#ifdef __cplusplus
    static int yyinput (yyscan_t yyscanner)
#else
    static int input  (yyscan_t yyscanner)
#endif

{
	int c;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	*yyg->yy_c_buf_p = yyg->yy_hold_char;

	if ( *yyg->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 ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
			/* This was really a NUL. */
			*yyg->yy_c_buf_p = '\0';

		else
			{ /* need more input */
			yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
			++yyg->yy_c_buf_p;

			switch ( yy_get_next_buffer( yyscanner ) )
				{
				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. */
					DiamDict_restart(yyin ,yyscanner);

					/*FALLTHROUGH*/

				case EOB_ACT_END_OF_FILE:
					{
					if ( DiamDict_wrap(yyscanner ) )
						return EOF;

					if ( ! yyg->yy_did_buffer_switch_on_eof )
						YY_NEW_FILE;
#ifdef __cplusplus
					return yyinput(yyscanner);
#else
					return input(yyscanner);
#endif
					}

				case EOB_ACT_CONTINUE_SCAN:
					yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
					break;
				}
			}
		}

	c = *(unsigned char *) yyg->yy_c_buf_p;	/* cast for 8-bit char's */
	*yyg->yy_c_buf_p = '\0';	/* preserve yytext */
	yyg->yy_hold_char = *++yyg->yy_c_buf_p;

	return c;
}
#endif	/* ifndef YY_NO_INPUT */

/** Immediately switch to a different input stream.
 * @param input_file A readable stream.
 * @param yyscanner The scanner object.
 * @note This function does not reset the start condition to @c INITIAL .
 */
    void DiamDict_restart  (FILE * input_file , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	if ( ! YY_CURRENT_BUFFER ){
        DiamDict_ensure_buffer_stack (yyscanner);
		YY_CURRENT_BUFFER_LVALUE =
            DiamDict__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
	}

	DiamDict__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
	DiamDict__load_buffer_state(yyscanner );
}

/** Switch to a different input buffer.
 * @param new_buffer The new input buffer.
 * @param yyscanner The scanner object.
 */
    void DiamDict__switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	/* TODO. We should be able to replace this entire function body
	 * with
	 *		DiamDict_pop_buffer_state();
	 *		DiamDict_push_buffer_state(new_buffer);
     */
	DiamDict_ensure_buffer_stack (yyscanner);
	if ( YY_CURRENT_BUFFER == new_buffer )
		return;

	if ( YY_CURRENT_BUFFER )
		{
		/* Flush out information for old buffer. */
		*yyg->yy_c_buf_p = yyg->yy_hold_char;
		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
		}

	YY_CURRENT_BUFFER_LVALUE = new_buffer;
	DiamDict__load_buffer_state(yyscanner );

	/* We don't actually know whether we did this switch during
	 * EOF (DiamDict_wrap()) processing, but the only time this flag
	 * is looked at is after DiamDict_wrap() is called, so it's safe
	 * to go ahead and always set it.
	 */
	yyg->yy_did_buffer_switch_on_eof = 1;
}

static void DiamDict__load_buffer_state  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
	yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
	yyg->yy_hold_char = *yyg->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.
 * @param yyscanner The scanner object.
 * @return the allocated buffer state.
 */
    YY_BUFFER_STATE DiamDict__create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
{
	YY_BUFFER_STATE b;
    
	b = (YY_BUFFER_STATE) DiamDict_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
	if ( ! b )
		YY_FATAL_ERROR( "out of dynamic memory in DiamDict__create_buffer()" );

	b->yy_buf_size = (yy_size_t)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 *) DiamDict_alloc(b->yy_buf_size + 2 ,yyscanner );
	if ( ! b->yy_ch_buf )
		YY_FATAL_ERROR( "out of dynamic memory in DiamDict__create_buffer()" );

	b->yy_is_our_buffer = 1;

	DiamDict__init_buffer(b,file ,yyscanner);

	return b;
}

/** Destroy the buffer.
 * @param b a buffer created with DiamDict__create_buffer()
 * @param yyscanner The scanner object.
 */
    void DiamDict__delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	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 )
		DiamDict_free((void *) b->yy_ch_buf ,yyscanner );

	DiamDict_free((void *) b ,yyscanner );
}

/* Initializes or reinitializes a buffer.
 * This function is sometimes called more than once on the same buffer,
 * such as during a DiamDict_restart() or at EOF.
 */
    static void DiamDict__init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)

{
	int oerrno = errno;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	DiamDict__flush_buffer(b ,yyscanner);

	b->yy_input_file = file;
	b->yy_fill_buffer = 1;

    /* If b is the current buffer, then DiamDict__init_buffer was _probably_
     * called from DiamDict_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;
    }

        b->yy_is_interactive = 0;
    
	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.
 * @param yyscanner The scanner object.
 */
    void DiamDict__flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	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 )
		DiamDict__load_buffer_state(yyscanner );
}

/** 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.
 *  @param yyscanner The scanner object.
 */
void DiamDict_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	if (new_buffer == NULL)
		return;

	DiamDict_ensure_buffer_stack(yyscanner);

	/* This block is copied from DiamDict__switch_to_buffer. */
	if ( YY_CURRENT_BUFFER )
		{
		/* Flush out information for old buffer. */
		*yyg->yy_c_buf_p = yyg->yy_hold_char;
		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
		}

	/* Only push if top exists. Otherwise, replace top. */
	if (YY_CURRENT_BUFFER)
		yyg->yy_buffer_stack_top++;
	YY_CURRENT_BUFFER_LVALUE = new_buffer;

	/* copied from DiamDict__switch_to_buffer. */
	DiamDict__load_buffer_state(yyscanner );
	yyg->yy_did_buffer_switch_on_eof = 1;
}

/** Removes and deletes the top of the stack, if present.
 *  The next element becomes the new top.
 *  @param yyscanner The scanner object.
 */
void DiamDict_pop_buffer_state (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	if (!YY_CURRENT_BUFFER)
		return;

	DiamDict__delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
	YY_CURRENT_BUFFER_LVALUE = NULL;
	if (yyg->yy_buffer_stack_top > 0)
		--yyg->yy_buffer_stack_top;

	if (YY_CURRENT_BUFFER) {
		DiamDict__load_buffer_state(yyscanner );
		yyg->yy_did_buffer_switch_on_eof = 1;
	}
}

/* Allocates the stack if it does not exist.
 *  Guarantees space for at least one push.
 */
static void DiamDict_ensure_buffer_stack (yyscan_t yyscanner)
{
	yy_size_t num_to_alloc;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	if (!yyg->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... */
		yyg->yy_buffer_stack = (struct yy_buffer_state**)DiamDict_alloc
								(num_to_alloc * sizeof(struct yy_buffer_state*)
								, yyscanner);
		if ( ! yyg->yy_buffer_stack )
			YY_FATAL_ERROR( "out of dynamic memory in DiamDict_ensure_buffer_stack()" );
								  
		memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
				
		yyg->yy_buffer_stack_max = num_to_alloc;
		yyg->yy_buffer_stack_top = 0;
		return;
	}

	if (yyg->yy_buffer_stack_top >= (yyg->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 = yyg->yy_buffer_stack_max + grow_size;
		yyg->yy_buffer_stack = (struct yy_buffer_state**)DiamDict_realloc
								(yyg->yy_buffer_stack,
								num_to_alloc * sizeof(struct yy_buffer_state*)
								, yyscanner);
		if ( ! yyg->yy_buffer_stack )
			YY_FATAL_ERROR( "out of dynamic memory in DiamDict_ensure_buffer_stack()" );

		/* zero only the new slots.*/
		memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
		yyg->yy_buffer_stack_max = num_to_alloc;
	}
}

/** 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
 * @param yyscanner The scanner object.
 * @return the newly allocated buffer state object. 
 */
YY_BUFFER_STATE DiamDict__scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
{
	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 0;

	b = (YY_BUFFER_STATE) DiamDict_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
	if ( ! b )
		YY_FATAL_ERROR( "out of dynamic memory in DiamDict__scan_buffer()" );

	b->yy_buf_size = 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 = 0;
	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;

	DiamDict__switch_to_buffer(b ,yyscanner );

	return b;
}

/** Setup the input buffer state to scan a string. The next call to DiamDict_lex() will
 * scan from a @e copy of @a str.
 * @param yystr a NUL-terminated string to scan
 * @param yyscanner The scanner object.
 * @return the newly allocated buffer state object.
 * @note If you want to scan bytes that may contain NUL values, then use
 *       DiamDict__scan_bytes() instead.
 */
YY_BUFFER_STATE DiamDict__scan_string (yyconst char * yystr , yyscan_t yyscanner)
{
    
	return DiamDict__scan_bytes(yystr,strlen(yystr) ,yyscanner);
}

/** Setup the input buffer state to scan the given bytes. The next call to DiamDict_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.
 * @param yyscanner The scanner object.
 * @return the newly allocated buffer state object.
 */
YY_BUFFER_STATE DiamDict__scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len , yyscan_t yyscanner)
{
	YY_BUFFER_STATE b;
	char *buf;
	yy_size_t n;
	yy_size_t i;
    
	/* Get memory for full buffer, including space for trailing EOB's. */
	n = _yybytes_len + 2;
	buf = (char *) DiamDict_alloc(n ,yyscanner );
	if ( ! buf )
		YY_FATAL_ERROR( "out of dynamic memory in DiamDict__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 = DiamDict__scan_buffer(buf,n ,yyscanner);
	if ( ! b )
		YY_FATAL_ERROR( "bad buffer in DiamDict__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;
}

    static void yy_push_state (int  _new_state , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth )
		{
		yy_size_t new_size;

		yyg->yy_start_stack_depth += YY_START_STACK_INCR;
		new_size = yyg->yy_start_stack_depth * sizeof( int );

		if ( ! yyg->yy_start_stack )
			yyg->yy_start_stack = (int *) DiamDict_alloc(new_size ,yyscanner );

		else
			yyg->yy_start_stack = (int *) DiamDict_realloc((void *) yyg->yy_start_stack,new_size ,yyscanner );

		if ( ! yyg->yy_start_stack )
			YY_FATAL_ERROR( "out of memory expanding start-condition stack" );
		}

	yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START;

	BEGIN(_new_state);
}

    static void yy_pop_state  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	if ( --yyg->yy_start_stack_ptr < 0 )
		YY_FATAL_ERROR( "start-condition stack underflow" );

	BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]);
}

    static int yy_top_state  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	return yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1];
}

#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif

static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
{
	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	(void)yyg;
	(void) fprintf( stderr, "%s\n", msg );
	exit( YY_EXIT_FAILURE );
}

/* Redefine yyless() so it works in section 3 code. */

#undef yyless
#define yyless(n) \
	do \
		{ \
		/* Undo effects of setting up yytext. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
		yytext[yyleng] = yyg->yy_hold_char; \
		yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
		yyg->yy_hold_char = *yyg->yy_c_buf_p; \
		*yyg->yy_c_buf_p = '\0'; \
		yyleng = yyless_macro_arg; \
		} \
	while ( 0 )

/* Accessor  methods (get/set functions) to struct members. */

/** Get the user-defined data for this scanner.
 * @param yyscanner The scanner object.
 */
YY_EXTRA_TYPE DiamDict_get_extra  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yyextra;
}

/** Get the current line number.
 * @param yyscanner The scanner object.
 */
int DiamDict_get_lineno  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
        if (! YY_CURRENT_BUFFER)
            return 0;
    
    return yylineno;
}

/** Get the current column number.
 * @param yyscanner The scanner object.
 */
int DiamDict_get_column  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
        if (! YY_CURRENT_BUFFER)
            return 0;
    
    return yycolumn;
}

/** Get the input stream.
 * @param yyscanner The scanner object.
 */
FILE *DiamDict_get_in  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yyin;
}

/** Get the output stream.
 * @param yyscanner The scanner object.
 */
FILE *DiamDict_get_out  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yyout;
}

/** Get the length of the current token.
 * @param yyscanner The scanner object.
 */
yy_size_t DiamDict_get_leng  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yyleng;
}

/** Get the current token.
 * @param yyscanner The scanner object.
 */

char *DiamDict_get_text  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yytext;
}

/** Set the user-defined data. This data is never touched by the scanner.
 * @param user_defined The data to be associated with this scanner.
 * @param yyscanner The scanner object.
 */
void DiamDict_set_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yyextra = user_defined ;
}

/** Set the current line number.
 * @param _line_number line number
 * @param yyscanner The scanner object.
 */
void DiamDict_set_lineno (int  _line_number , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

        /* lineno is only valid if an input buffer exists. */
        if (! YY_CURRENT_BUFFER )
           YY_FATAL_ERROR( "DiamDict_set_lineno called with no buffer" );
    
    yylineno = _line_number;
}

/** Set the current column.
 * @param _column_no column number
 * @param yyscanner The scanner object.
 */
void DiamDict_set_column (int  _column_no , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

        /* column is only valid if an input buffer exists. */
        if (! YY_CURRENT_BUFFER )
           YY_FATAL_ERROR( "DiamDict_set_column called with no buffer" );
    
    yycolumn = _column_no;
}

/** Set the input stream. This does not discard the current
 * input buffer.
 * @param _in_str A readable stream.
 * @param yyscanner The scanner object.
 * @see DiamDict__switch_to_buffer
 */
void DiamDict_set_in (FILE *  _in_str , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yyin = _in_str ;
}

void DiamDict_set_out (FILE *  _out_str , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yyout = _out_str ;
}

int DiamDict_get_debug  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yy_flex_debug;
}

void DiamDict_set_debug (int  _bdebug , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yy_flex_debug = _bdebug ;
}

/* Accessor methods for yylval and yylloc */

/* User-visible API */

/* DiamDict_lex_init is special because it creates the scanner itself, so it is
 * the ONLY reentrant function that doesn't take the scanner as the last argument.
 * That's why we explicitly handle the declaration, instead of using our macros.
 */

int DiamDict_lex_init(yyscan_t* ptr_yy_globals)

{
    if (ptr_yy_globals == NULL){
        errno = EINVAL;
        return 1;
    }

    *ptr_yy_globals = (yyscan_t) DiamDict_alloc ( sizeof( struct yyguts_t ), NULL );

    if (*ptr_yy_globals == NULL){
        errno = ENOMEM;
        return 1;
    }

    /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));

    return yy_init_globals ( *ptr_yy_globals );
}

/* DiamDict_lex_init_extra has the same functionality as DiamDict_lex_init, but follows the
 * convention of taking the scanner as the last argument. Note however, that
 * this is a *pointer* to a scanner, as it will be allocated by this call (and
 * is the reason, too, why this function also must handle its own declaration).
 * The user defined value in the first argument will be available to DiamDict_alloc in
 * the yyextra field.
 */

int DiamDict_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )

{
    struct yyguts_t dummy_yyguts;

    DiamDict_set_extra (yy_user_defined, &dummy_yyguts);

    if (ptr_yy_globals == NULL){
        errno = EINVAL;
        return 1;
    }
	
    *ptr_yy_globals = (yyscan_t) DiamDict_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
	
    if (*ptr_yy_globals == NULL){
        errno = ENOMEM;
        return 1;
    }
    
    /* By setting to 0xAA, we expose bugs in
    yy_init_globals. Leave at 0x00 for releases. */
    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
    
    DiamDict_set_extra (yy_user_defined, *ptr_yy_globals);
    
    return yy_init_globals ( *ptr_yy_globals );
}

static int yy_init_globals (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    /* Initialization is the same as for the non-reentrant scanner.
     * This function is called from DiamDict_lex_destroy(), so don't allocate here.
     */

    yyg->yy_buffer_stack = 0;
    yyg->yy_buffer_stack_top = 0;
    yyg->yy_buffer_stack_max = 0;
    yyg->yy_c_buf_p = (char *) 0;
    yyg->yy_init = 0;
    yyg->yy_start = 0;

    yyg->yy_start_stack_ptr = 0;
    yyg->yy_start_stack_depth = 0;
    yyg->yy_start_stack =  NULL;

/* Defined in main.c */
#ifdef YY_STDINIT
    yyin = stdin;
    yyout = stdout;
#else
    yyin = (FILE *) 0;
    yyout = (FILE *) 0;
#endif

    /* For future reference: Set errno on error, since we are called by
     * DiamDict_lex_init()
     */
    return 0;
}

/* DiamDict_lex_destroy is for both reentrant and non-reentrant scanners. */
int DiamDict_lex_destroy  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

    /* Pop the buffer stack, destroying each element. */
	while(YY_CURRENT_BUFFER){
		DiamDict__delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
		YY_CURRENT_BUFFER_LVALUE = NULL;
		DiamDict_pop_buffer_state(yyscanner);
	}

	/* Destroy the stack itself. */
	DiamDict_free(yyg->yy_buffer_stack ,yyscanner);
	yyg->yy_buffer_stack = NULL;

    /* Destroy the start condition stack. */
        DiamDict_free(yyg->yy_start_stack ,yyscanner );
        yyg->yy_start_stack = NULL;

    /* Reset the globals. This is important in a non-reentrant scanner so the next time
     * DiamDict_lex() is called, initialization will occur. */
    yy_init_globals( yyscanner);

    /* Destroy the main struct (reentrant only). */
    DiamDict_free ( yyscanner , yyscanner );
    yyscanner = NULL;
    return 0;
}

/*
 * Internal utility routines.
 */

#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
{
	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	(void)yyg;

	int i;
	for ( i = 0; i < n; ++i )
		s1[i] = s2[i];
}
#endif

#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
{
	int n;
	for ( n = 0; s[n]; ++n )
		;

	return n;
}
#endif

#define YYTABLES_NAME "yytables"

#line 623 "diam_dict.l"



static int debugging  = 0;

static void ddict_debug(const char* fmt, ...) {
	va_list ap;

	va_start(ap, fmt);
	if (debugging) vfprintf(stderr, fmt, ap);
	va_end(ap);

	fflush(stderr);
}

/*
 * Sleazy hack to avoid unused function warnings for yy_top_state.
 */
extern void ddict_unused(yyscan_t yyscanner);

void
ddict_unused(yyscan_t yyscanner)
{
	yy_top_state(yyscanner);
}

static void
append_to_buffer(const char* txt, unsigned len, DiamDict_scanner_state_t *statep)
{

	if (statep->strbuf == NULL) {
		statep->strbuf = (char*)g_malloc(statep->size_strbuf);
		statep->read_ptr = statep->strbuf;
		statep->write_ptr = statep->strbuf;
	}

	if ( (statep->len_strbuf + len) >= statep->size_strbuf ) {
		statep->strbuf = (char*)g_realloc(statep->strbuf,statep->size_strbuf *= 2);
		statep->read_ptr = statep->strbuf;
	}

	statep->write_ptr = statep->strbuf + statep->len_strbuf;
	strncpy(statep->write_ptr,txt,len);
	statep->len_strbuf += len;
}

static size_t
file_input(char* buf, size_t max, yyscan_t scanner)
{
	FILE *in = DiamDict_get_in(scanner);
	size_t read_cnt;

	read_cnt = fread(buf,1,max,in);

	if ( read_cnt == max ) {
		return max;
	} else if (read_cnt > 0) {
		return read_cnt;
	} else {
		return YY_NULL;
	}
}


static size_t
string_input(char* buf, size_t max, yyscan_t scanner)
{
	DiamDict_scanner_state_t *statep = DiamDict_get_extra(scanner);

	if (statep->read_ptr >= statep->write_ptr ) {
		return YY_NULL;
	} else if ( statep->read_ptr + max > statep->write_ptr ) {
		max = statep->write_ptr - statep->read_ptr;
	}

	memcpy(buf,statep->read_ptr,max);
	statep->read_ptr += max;

	return max;
}

static FILE *
ddict_open(const char* system_directory, const char* filename)
{
	FILE* fh;
	char* fname;
	if (system_directory) {
		fname = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
		    system_directory,filename);
	} else {
		fname = g_strdup(filename);
	}

	fh = ws_fopen(fname,"r");

	D(("fname: %s fh: %p\n",fname,(void*)fh));

	g_free(fname);


	return fh;
}

ddict_t *
ddict_scan(const char* system_directory, const char* filename, int dbg)
{
	DiamDict_scanner_state_t state;
	FILE *in;
	yyscan_t scanner;

	debugging = dbg;

	state.sys_dir = system_directory;

	state.write_ptr = NULL;
	state.read_ptr = NULL;

	state.strbuf = NULL;
	state.size_strbuf = 8192;
	state.len_strbuf = 0;

	state.dict = g_new(ddict_t,1);
	state.dict->applications = NULL;
	state.dict->vendors = NULL;
	state.dict->cmds = NULL;
	state.dict->typedefns = NULL;
	state.dict->avps = NULL;
	state.dict->xmlpis = NULL;

	state.appl = NULL;
	state.avp = NULL;
	state.enumitem = NULL;
	state.gavp = NULL;
	state.typedefn = NULL;
	state.cmd = NULL;
	state.vnd = NULL;
	state.xmlpi = NULL;

	state.last_appl = NULL;
	state.last_avp = NULL;
	state.last_enumitem = NULL;
	state.last_gavp = NULL;
	state.last_typedefn = NULL;
	state.last_cmd = NULL;
	state.last_vnd = NULL;
	state.last_xmlpi = NULL;

	state.ents = NULL;

	state.attr_str = NULL;
	state.attr_uint = NULL;

	/*
	 * Pass 1.
	 *
	 * Reads the file, does some work, and stores a modified version
	 * of the file contents in memory.
	 */
	state.current_yyinput = file_input;
	state.include_stack_ptr = 0;

	in = ddict_open(system_directory,filename);

	if (in == NULL) {
		D(("unable to open %s: %s\n", filename, g_strerror(errno)));
		g_free(state.dict);
		return NULL;
	}

	if (DiamDict_lex_init(&scanner) != 0) {
		/* Note: cannot be reached since memory allocation failure terminates early */
		D(("Can't initialize scanner: %s\n", g_strerror(errno)));
		fclose(in);
		g_free(state.dict);
		return NULL;
	}

	DiamDict_set_in(in, scanner);

	/* Associate the state with the scanner */
	DiamDict_set_extra(&state, scanner);

	state.start_state = LOADING;
	DiamDict_lex(scanner);

	DiamDict_lex_destroy(scanner);
	/*
	 * XXX - can the lexical analyzer terminate without closing
	 * all open input files?
	 */

	D(("\n---------------\n%s\n------- %u -------\n",state.strbuf,state.len_strbuf));

	/*
	 * Pass 2.
	 *
	 * Reads the modified version of the file contents and does the
	 * rest of the work.
	 */
	state.current_yyinput = string_input;

	if (DiamDict_lex_init(&scanner) != 0) {
		/* Note: cannot be reached since memory allocation failure terminates early */
		D(("Can't initialize scanner: %s\n", g_strerror(errno)));
		g_free(state.dict);
		g_free(state.strbuf);
		return NULL;
	}

	/* Associate the state with the scanner */
	DiamDict_set_extra(&state, scanner);

	state.start_state = OUTSIDE;
	DiamDict_lex(scanner);

	DiamDict_lex_destroy(scanner);
	{
		entity_t *e, *en;

		for (e = state.ents; e; e = en) {
			en = e->next;
			g_free(e->name);
			g_free(e->file);
			g_free(e);
		}
	}
	g_free(state.strbuf);

	return state.dict;
}

void
ddict_free(ddict_t* d)
{
	ddict_application_t *p, *pn;
	ddict_vendor_t *v, *vn;
	ddict_cmd_t *c, *cn;
	ddict_typedefn_t *t, *tn;
	ddict_avp_t *a, *an;
	ddict_xmlpi_t *x, *xn;

#define FREE_NAMEANDOBJ(n) do { g_free(n->name); g_free(n); } while(0)

	for (p = d->applications; p; p = pn ) {
		pn = p->next;
		FREE_NAMEANDOBJ(p);
	}

	for (v = d->vendors; v; v = vn) {
		vn = v->next;
		g_free(v->desc);
		FREE_NAMEANDOBJ(v);
	}

	for (c = d->cmds; c; c = cn ) {
		cn = c->next;
		g_free(c->vendor);
		FREE_NAMEANDOBJ(c);
	}

	for (t = d->typedefns; t; t = tn) {
		tn = t->next;
		g_free(t->parent);
		FREE_NAMEANDOBJ(t);
	}

	for (a = d->avps; a; a = an) {
		ddict_gavp_t* g, *gn;
		ddict_enum_t* e, *en;
		an = a->next;

		for (g = a->gavps; g; g = gn) {
			gn = g->next;
			FREE_NAMEANDOBJ(g);
		}

		for (e = a->enums; e; e = en) {
			en = e->next;
			FREE_NAMEANDOBJ(e);
		}

		g_free(a->vendor);
		g_free(a->type);
		g_free(a->description);
		FREE_NAMEANDOBJ(a);
	}

	for (x = d->xmlpis; x; x = xn) {
		xn = x->next;
		g_free(x->key);
		g_free(x->value);
		FREE_NAMEANDOBJ(x);
	}

	g_free(d);
}

void
ddict_print(FILE* fh, ddict_t* d)
{
	ddict_application_t* p;
	ddict_vendor_t* v;
	ddict_cmd_t* c;
	ddict_typedefn_t* t;
	ddict_avp_t* a;


	for (p = d->applications; p; p = p->next) {
		fprintf(fh,"Application: %s[%u]:\n",
				p->name ? p->name : "-",
				p->code);
	}

	for (v = d->vendors; v; v = v->next) {
		fprintf(fh,"Vendor: %s[%u]:\n",
				v->name ? v->name : "-",
				v->code);
	}

	for (c = d->cmds; c; c = c->next) {
		fprintf(fh,"Command: %s[%u] \n",
				c->name ? c->name : "-",
				c->code);
	}

	for (t = d->typedefns; t; t = t->next) {
		fprintf(fh,"Type: %s -> %s \n",
				t->name ? t->name : "-",
				t->parent ? t->parent : "" );
	}

	for (a = d->avps; a; a = a->next) {
		ddict_gavp_t* g;
		ddict_enum_t* e;
		fprintf(fh,"AVP: %s[%u:%s] %s %s\n",
				a->name ? a->name : "-",
				a->code,
				a->vendor ? a->vendor : "None",
				a->type ? a->type : "-",
				a->description ? a->description : "");

		for (g = a->gavps; g; g = g->next) {
			fprintf(fh,"\tGAVP: %s\n",
					g->name ? g->name : "-" );
		}

		for (e = a->enums; e; e = e->next) {
			fprintf(fh,"\tEnum: %s[%u]\n",
					e->name ? e->name : "-",
					e->code);
		}
	}
}

#ifdef TEST_DIAM_DICT_STANDALONE
int
main(int argc, char** argv)
{
	ddict_t* d;
	char* dname = NULL;
	char* fname;
	int i = 1;

	switch (argc) {
		case 3:
			dname = argv[i++];
		case 2:
			fname = argv[i];
			break;
		default:
			fprintf(stderr,"%s: usage [dictionary_dir] dictionary_filename\n",argv[0]);
			return 1;
	}

	d = ddict_scan(dname,fname,1);
	if (d == NULL) {
		fprintf(stderr, "Can't open dictionary\n");
		return 2;
	}

	ddict_print(stdout, d);

	return 0;
}
#endif

