#line 2 "diam_dict.c"

#line 4 "diam_dict.c"

#define  YY_INT_ALIGNED short int

/* A lexical scanner generated by flex */

#define yy_create_buffer DiamDict_create_buffer
#define yy_delete_buffer DiamDict_delete_buffer
#define yy_flex_debug DiamDict_flex_debug
#define yy_init_buffer DiamDict_init_buffer
#define yy_flush_buffer DiamDict_flush_buffer
#define yy_load_buffer_state DiamDict_load_buffer_state
#define yy_switch_to_buffer DiamDict_switch_to_buffer
#define yyin DiamDictin
#define yyleng DiamDictleng
#define yylex DiamDictlex
#define yylineno DiamDictlineno
#define yyout DiamDictout
#define yyrestart DiamDictrestart
#define yytext DiamDicttext
#define yywrap DiamDictwrap
#define yyalloc DiamDictalloc
#define yyrealloc DiamDictrealloc
#define yyfree DiamDictfree

#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35
#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)

/* Enter a start condition.  This macro really ought to take a parameter,
 * but we do it the disgusting crufty way forced on us by the ()-less
 * definition of BEGIN.
 */
#define BEGIN (yy_start) = 1 + 2 *

/* Translate the current start state into a value that can be later handed
 * to BEGIN to return to the state.  The YYSTATE alias is for lex
 * compatibility.
 */
#define YY_START (((yy_start) - 1) / 2)
#define YYSTATE YY_START

/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)

/* Special action meaning "start processing a new file". */
#define YY_NEW_FILE DiamDictrestart(DiamDictin  )

#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

extern int DiamDictleng;

extern FILE *DiamDictin, *DiamDictout;

#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2

    #define YY_LESS_LINENO(n)
    
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
	do \
		{ \
		/* Undo effects of setting up DiamDicttext. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
		*yy_cp = (yy_hold_char); \
		YY_RESTORE_YY_MORE_OFFSET \
		(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
		YY_DO_BEFORE_ACTION; /* set up DiamDicttext again */ \
		} \
	while ( 0 )

#define unput(c) yyunput( c, (yytext_ptr)  )

#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif

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

	};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */

/* Stack of input buffers. */
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */

/* We provide macros for accessing buffer states in case in the
 * future we want to put the buffer states in a more general
 * "scanner state".
 *
 * Returns the top of the stack, or NULL.
 */
#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
                          ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
                          : NULL)

/* Same as previous macro, but useful when we know that the buffer stack is not
 * NULL or when we need an lvalue. For internal use only.
 */
#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]

/* yy_hold_char holds the character lost when DiamDicttext is formed. */
static char yy_hold_char;
static int yy_n_chars;		/* number of characters read into yy_ch_buf */
int DiamDictleng;

/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
static int yy_init = 0;		/* whether we need to initialize */
static int yy_start = 0;	/* start state number */

/* Flag which is used to allow DiamDictwrap()'s to do buffer switches
 * instead of setting up a fresh DiamDictin.  A bit of a hack ...
 */
static int yy_did_buffer_switch_on_eof;

void DiamDictrestart (FILE *input_file  );
void DiamDict_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
YY_BUFFER_STATE DiamDict_create_buffer (FILE *file,int size  );
void DiamDict_delete_buffer (YY_BUFFER_STATE b  );
void DiamDict_flush_buffer (YY_BUFFER_STATE b  );
void DiamDictpush_buffer_state (YY_BUFFER_STATE new_buffer  );
void DiamDictpop_buffer_state (void );

static void DiamDictensure_buffer_stack (void );
static void DiamDict_load_buffer_state (void );
static void DiamDict_init_buffer (YY_BUFFER_STATE b,FILE *file  );

#define YY_FLUSH_BUFFER DiamDict_flush_buffer(YY_CURRENT_BUFFER )

YY_BUFFER_STATE DiamDict_scan_buffer (char *base,yy_size_t size  );
YY_BUFFER_STATE DiamDict_scan_string (yyconst char *yy_str  );
YY_BUFFER_STATE DiamDict_scan_bytes (yyconst char *bytes,int len  );

void *DiamDictalloc (yy_size_t  );
void *DiamDictrealloc (void *,yy_size_t  );
void DiamDictfree (void *  );

#define yy_new_buffer DiamDict_create_buffer

#define yy_set_interactive(is_interactive) \
	{ \
	if ( ! YY_CURRENT_BUFFER ){ \
        DiamDictensure_buffer_stack (); \
		YY_CURRENT_BUFFER_LVALUE =    \
            DiamDict_create_buffer(DiamDictin,YY_BUF_SIZE ); \
	} \
	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
	}

#define yy_set_bol(at_bol) \
	{ \
	if ( ! YY_CURRENT_BUFFER ){\
        DiamDictensure_buffer_stack (); \
		YY_CURRENT_BUFFER_LVALUE =    \
            DiamDict_create_buffer(DiamDictin,YY_BUF_SIZE ); \
	} \
	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
	}

#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)

/* Begin user sect3 */

typedef unsigned char YY_CHAR;

FILE *DiamDictin = (FILE *) 0, *DiamDictout = (FILE *) 0;

typedef int yy_state_type;

extern int DiamDictlineno;

int DiamDictlineno = 1;

extern char *DiamDicttext;
#define yytext_ptr DiamDicttext

static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
static int yy_get_next_buffer (void );
static void yy_fatal_error (yyconst char msg[]  );

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

#define YY_NUM_RULES 83
#define YY_END_OF_BUFFER 84
/* 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[473] =
    {   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,   84,   83,   27,   24,
       24,   27,   27,   27,   20,   26,   21,   27,    4,    4,
       83,    4,    7,    8,   16,   83,   83,   18,   83,   29,
       30,   30,   31,   82,   82,   83,   83,   83,   83,   83,
       39,   83,   83,   32,   32,   83,   75,   83,   83,   83,

       83,   83,   64,   83,   83,   83,   83,   83,   52,   83,
       83,   83,   83,   46,   83,   83,   83,   83,   57,   83,
       13,   13,   83,   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,    0,    0,    0,    0,    0,
        0,    0,    0,    0,   81,   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,   81,    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,   59,
        0,    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,   72,   70,    0,   68,   81,
        0,   81,   81,   81,   81,    0,   81,    0,   81,   81,
        0,   81,   81,    0,    0,    0,    9,    0,    0,    0,
        0,    0,    0,    0,    0,   35,    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,    0,   79,    0,    0,    0,   48,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,   11,    0,   15,

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

static yyconst flex_int32_t 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 flex_int32_t 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_int16_t yy_base[498] =
    {   0,
        0,    0,    0,   37,    8,   15,   75,  113,  151,  189,
        5,   29, 1163, 1162, 1161, 1160, 1159, 1158,   11,   12,
     1157, 1156,   12,   22, 1148, 1147, 1146, 1145, 1144, 1143,
      227,  277,   23,   24,  284,  285,   46,  121,  319,  327,
      369,    0,  418,  467,  516,  565,  339,  362,  210,  272,
     1149, 1148, 1147, 1146,    0,    0, 1150, 1169, 1169,   55,
       95, 1144,    0, 1134,  166,   33,   42,   51, 1169,   92,
      103, 1139,   45,    0,    0,   69,    5,    0,  129,    0,
     1136, 1128, 1169, 1169,   14,  167,  614,  337, 1119, 1113,
     1169,  166,  198, 1169, 1110, 1096, 1169,  161,  204,  108,

      205, 1023, 1169,  148,  167,  233,  282, 1022, 1169,  234,
      237,  283, 1021, 1169,  287,  336,  341, 1020, 1169,  308,
     1169,  398,  426, 1019,   42,  166,    0,    0,  475, 1015,
      454,  100,  136,  256, 1022, 1169, 1015,  138,  144,  401,
      170,  213,  220,  258,  308,  266,  422, 1017, 1010,  396,
        0,    0,  447,  284,  342,    0,  400,  403,    0, 1012,
        6,  167,  386,  232,  475,  383,  413,  412,  336,  458,
      444,  451,  460, 1008, 1169, 1169, 1007,  492, 1014, 1169,
     1169,  493,  494,  507,  515, 1169,  514,  499,  519,  509,
     1169,  535,  523,  539, 1169,  550,  548,  552, 1169,  557,

      579, 1004,  338,  415,  432,  502,  514,    0,    0, 1169,
      463, 1007,  547,  558,  496,  508,  588,  593,  555,  609,
      421,  575,  573,  573,  583,  539,  587,  587,  591,  589,
      592,  589,  597,  595,  599,  608,  613, 1009,  632,  641,
      644,  647,  650,  653,  659,  661,  649,  663,  665,  667,
      669,  675,  679,  681,  700,  712,  663,  708,  681,  672,
      714,  687,  680,  702,  697,  706,  698,  697,  704, 1169,
      705,  713,  715,  706,  708,  711,  709,  706,  721, 1169,
      998,  121,  897,  820,  782,  735,  734,  733,  739,  731,
      729,  742,  666,  645,  750,  439,  764,  767,  753,  772,

      743,  754,  753,  757,  749,  759,  634,  758,  765,  761,
      770,  770,  762,  630,  758, 1169, 1169,  764, 1169,  628,
      794,  626,  596,  580,  566,  802,  542,  786,  534,  524,
      798,  495,  466,  805,  807,  822, 1169,  828,  761,  788,
      844,  794,  804,  814,  408, 1169,  810,  393,  822,  812,
      822,  821, 1169,  823,  834, 1169,  847, 1169, 1169, 1169,
     1169,  851, 1169,  858, 1169, 1169,  859, 1169, 1169,  860,
      863,  867,  882,  885,  839,  834,  891, 1169,  850,  853,
      873,  879, 1169,  871,  882,  884, 1169,  887,  889,  896,
      885,  898,  901,  902,  900,  903,  930, 1169,  899,  934,

      913,  889,  905,  925,  924, 1169,  918,  931,  377,  938,
      941,  940,  942,  944,  949,  954,  327,  968,  941,  959,
      953,  945,  348, 1169,  336, 1169,  319,  966,  311,  293,
      291,  253,  963,  225,  986,  944,  952,  956,  966, 1169,
     1169,  251,  980,  249,  247,  219,  173,  983, 1001,  134,
      965,  978,  980, 1169,  131, 1169, 1169, 1169, 1169,  129,
     1169,  122, 1169,  982,  105,   94, 1169,   77, 1169, 1169,
     1169, 1169, 1038, 1043, 1048, 1053, 1058, 1063, 1068, 1073,
     1078, 1083, 1088, 1093, 1098, 1103,   69,   62,    0, 1108,
     1113, 1115, 1120, 1125, 1130, 1135, 1140

    } ;

static yyconst flex_int16_t yy_def[498] =
    {   0,
      473,  473,  474,  474,  475,  475,  476,  476,  477,  477,
      473,  473,  478,  478,  473,  473,  479,  479,  473,  473,
      473,  473,  480,  480,  473,  473,  473,  473,  473,  473,
      481,  481,  482,  482,   32,   32,   32,   32,   32,   32,
       32,   41,   41,   41,   41,   41,   32,   32,  483,  483,
      484,  484,  485,  485,  473,  473,  472,  472,  472,  472,
      472,  486,  487,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  488,  489,  472,  472,  490,  472,  491,
      472,  472,  472,  472,  472,  472,  472,  472,  492,  472,
      472,  492,  492,  472,  493,  472,  472,  492,  492,  492,

      492,  472,  472,  492,  492,  492,  492,  472,  472,  492,
      492,  492,  472,  472,  492,  492,  492,  472,  472,  492,
      472,  472,  472,  472,  472,  472,  494,  495,  472,  472,
      472,  472,  472,  472,  486,  472,  487,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      488,  489,  472,  472,  472,  490,  472,  472,  491,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  492,  472,  472,  492,  492,  493,  472,
      472,  492,  492,  492,  492,  472,  492,  492,  492,  492,
      472,  492,  492,  492,  472,  492,  492,  492,  472,  492,

      472,  472,  472,  472,  472,  472,  472,  494,  495,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  492,  492,
      492,  492,  492,  492,  492,  492,  492,  492,  492,  492,
      492,  492,  492,  492,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      492,  492,  492,  492,  492,  492,  492,  492,  492,  492,
      492,  492,  492,  492,  492,  492,  472,  472,  472,  472,

      472,  472,  472,  472,  472,  472,  496,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      492,  472,  472,  472,  472,  492,  472,  492,  472,  472,
      492,  472,  472,  492,  492,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  496,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  492,  472,  472,  472,
      472,  492,  472,  492,  472,  472,  492,  472,  472,  492,
      492,  492,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  492,
      492,  492,  492,  492,  492,  492,  472,  472,  472,  472,

      472,  472,  472,  472,  472,  472,  472,  472,  472,  492,
      492,  492,  492,  492,  492,  492,  497,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  492,  492,  492,  492,
      492,  492,  492,  497,  472,  472,  472,  472,  472,  472,
      472,  472,  492,  472,  472,  472,  472,  492,  472,  472,
      472,  472,  472,  472,  492,  472,  472,  472,  472,  492,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,    0,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472

    } ;

static yyconst flex_int16_t yy_nxt[1228] =
    {   0,
      472,   60,   61,  152,   62,   63,   76,   76,   64,   70,
       71,   65,   66,   67,   58,   72,   70,   71,   81,   81,
       82,   82,   72,   85,   58,   58,   58,   95,   95,  221,
       76,   76,  161,   85,  143,  143,   77,   68,   60,   61,
      155,   62,   63,  144,  144,   64,  150,  150,   65,   66,
       67,  221,  145,  145,   96,  161,  129,  129,   77,   97,
       77,  206,  155,  130,  146,  151,  131,  132,  133,   89,
      153,  153,  137,   99,   68,   58,   73,   73,   58,   58,
       58,   58,   77,   58,  206,   58,   58,   58,   58,   58,
      471,   89,  134,  147,  147,   99,  129,  129,  470,  148,

      154,  143,  143,  130,  147,  147,  131,  132,  133,  469,
      148,   58,   58,   58,   73,   73,   58,   58,   58,   58,
      175,   58,  154,   58,   58,   58,   58,   58,  321,   96,
      157,  157,  134,  175,   97,  467,  184,  144,  144,  211,
      211,  466,  158,  465,   89,  139,  139,  461,   99,   58,
       58,   58,   58,   58,   58,   58,   58,   58,  184,   58,
      175,   58,   58,   58,   58,   58,   89,  139,  139,  140,
       99,  215,  215,  175,  141,  162,  187,  459,  175,  175,
      142,  207,  163,  164,  177,  222,  188,   58,   58,   58,
       58,   58,   58,   58,   58,   58,  182,   58,  187,   58,

       58,   58,   58,   58,  207,  163,  164,  177,  222,  188,
      175,  122,  123,  178,  216,  216,  175,  175,  182,  183,
      185,  143,  143,  458,  124,   58,   58,   58,   58,   58,
       58,   58,   58,   58,  125,   90,  178,   58,   58,   58,
       91,   58,  183,  185,  126,  175,  175,  224,  189,  175,
       92,  457,  193,  456,   93,  454,  125,  145,  145,  144,
      144,  435,  192,   58,   58,  447,  126,  217,  217,  146,
      224,  189,   92,  122,  123,  193,   93,   58,   58,   58,
       58,   58,   58,   58,  192,   90,  124,   58,   58,   58,
       91,   58,   96,   96,  175,  175,  125,   97,   97,  175,

       92,  190,  194,  446,   93,  445,  126,   89,   89,  145,
      145,   89,   89,   58,   58,  196,   98,   98,  125,  155,
      175,  146,   92,  444,  190,  194,   93,   96,  126,   89,
       89,  442,   97,   89,   89,   96,  100,  196,   98,   98,
       97,  155,   89,  200,  100,  170,  101,  118,  175,  441,
       89,  197,  119,  175,  101,  231,  171,  206,  172,  100,
      198,  440,   89,  435,   89,  200,   89,  100,  101,  173,
      118,  120,   89,  219,  197,  119,  101,  102,  231,  171,
      206,  172,  103,  198,   89,   89,  104,  105,   89,   89,
      426,  173,   89,  120,  120,  219,  106,  150,  150,  201,

      201,  157,  157,  107,  220,  220,  383,   89,  212,  104,
      105,   89,  202,  158,   89,  223,  120,  228,  106,  213,
      214,  346,  203,  147,  147,  107,  108,  201,  201,  148,
      207,  109,  204,  255,  255,  110,   89,  223,  263,  228,
      202,  229,  213,  214,  203,  111,  335,  230,  153,  153,
      203,  175,  112,  207,  204,  139,  139,  140,  110,   89,
      204,  263,  141,  229,  211,  211,  235,  111,  142,  230,
      369,  234,  203,  232,  112,  108,  129,  129,  154,  233,
      109,  236,  204,  130,  110,   89,  131,  132,  133,  235,
      225,  226,  227,  234,  111,  237,  232,  215,  215,  368,

      154,  112,  233,  236,  175,  175,  175,  110,   89,  216,
      216,  175,  134,  225,  226,  227,  111,  237,  239,  175,
      241,  175,  240,  112,  113,  242,  175,  175,  366,  114,
      245,  175,  244,  115,   89,  175,  247,  256,  365,  257,
      239,  243,  241,  116,  240,  246,  363,  175,  242,  249,
      117,  175,  245,  248,  268,  244,  115,   89,  247,  256,
      175,  257,  175,  243,  175,  116,  250,  246,  251,  175,
      361,  249,  117,  113,  252,  259,  248,  268,  114,  253,
      201,  201,  115,   89,  360,  260,  254,  262,  250,  217,
      217,  251,  116,  202,  261,  261,  252,  259,  264,  117,

      359,  253,  265,  203,  266,  115,   89,  260,  254,  262,
      220,  220,  267,  204,  116,  269,  270,  271,  272,  273,
      264,  117,  165,  274,  265,  203,  266,  275,  276,  166,
      358,  167,  356,  277,  267,  204,  278,  269,  270,  271,
      272,  273,  279,  353,  175,  274,  168,  346,  169,  275,
      276,  281,  166,  175,  167,  277,  175,  333,  278,  175,
      282,  175,  175,  283,  279,  175,  284,  289,  168,  285,
      169,  175,  286,  175,  281,  175,  287,  175,  332,  175,
      288,  175,  290,  282,  291,  292,  283,  175,  293,  284,
      289,  175,  285,  175,  294,  286,  299,  295,  301,  287,

      296,  255,  255,  288,  302,  290,  303,  291,  292,  300,
      300,  293,  304,  297,  297,  261,  261,  294,  299,  305,
      295,  301,  306,  296,  298,  307,  302,  308,  309,  303,
      310,  311,  312,  313,  304,  314,  315,  316,  317,  318,
      319,  330,  305,  329,  306,  327,  175,  325,  307,  308,
      309,  175,  310,  311,  175,  312,  313,  314,  315,  316,
      317,  318,  175,  319,  326,  297,  297,  328,  336,  336,
      331,  337,  338,  300,  300,  339,  298,  340,  334,  341,
      342,  343,  344,  347,  348,  350,  326,  349,  351,  328,
      352,  354,  331,  355,  324,  338,  375,  339,  175,  340,

      334,  341,  342,  343,  344,  347,  175,  348,  350,  349,
      175,  351,  352,  354,  175,  355,  364,  175,  375,  175,
      376,  357,  379,  336,  336,  362,  337,  380,  367,  373,
      373,  381,  323,  382,  371,  370,  372,  384,  364,  385,
      374,  386,  376,  357,  379,  377,  377,  362,  378,  380,
      367,  387,  388,  389,  381,  382,  371,  370,  372,  175,
      384,  385,  390,  175,  386,  392,  393,  394,  399,  400,
      175,  175,  175,  387,  388,  175,  389,  401,  395,  175,
      391,  402,  396,  373,  373,  390,  397,  397,  403,  398,
      399,  400,  377,  377,  374,  378,  404,  175,  405,  401,

      406,  395,  391,  402,  407,  396,  408,  409,  175,  322,
      175,  403,  175,  175,  175,  175,  420,  411,  417,  404,
      405,  412,  410,  406,  413,  414,  415,  407,  419,  408,
      409,  397,  397,  416,  398,  418,  418,  421,  420,  411,
      422,  417,  423,  412,  410,  424,  413,  414,  415,  425,
      175,  419,  175,  175,  175,  416,  175,  427,  429,  421,
      430,  175,  431,  422,  428,  423,  175,  424,  432,  418,
      418,  436,  425,  433,  437,  175,  438,  439,  175,  450,
      427,  429,  451,  430,  452,  431,  428,  449,  449,  453,
      448,  432,  175,  436,  443,  175,  433,  437,  438,  439,

      462,  450,  449,  449,  451,  463,  452,  455,  464,  468,
      320,  453,  448,  280,  258,  460,  443,  205,  180,  238,
      175,  160,  462,  218,  149,  210,  136,  463,  138,  455,
      464,  468,  205,  199,  195,  191,  186,  460,   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,   89,   89,
       89,   89,   89,   94,   94,   94,   94,   94,  121,  121,
      121,  121,  121,  127,  127,  127,  127,  127,  128,  128,

      128,  128,  128,  135,  135,  135,  135,  135,  156,  181,
      156,  156,  156,  159,  180,  159,  159,  159,  174,  174,
      179,  179,  179,  179,  179,  208,  176,  208,  208,  208,
      209,  175,  209,  209,  209,  345,  345,  160,  345,  345,
      434,  434,  434,  434,  434,  160,  149,  138,  136,  472,
       58,   58,   58,   58,   88,   88,   87,   87,   86,   86,
       83,   83,   58,   58,   79,   79,   58,   58,   57,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,

      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472
    } ;

static yyconst flex_int16_t yy_chk[1228] =
    {   0,
        0,    3,    3,  489,    3,    3,   11,   11,    3,    5,
        5,    3,    3,    3,   23,    5,    6,    6,   19,   20,
       19,   20,    6,   23,   24,   33,   34,   33,   34,  161,
       12,   12,   85,   24,   66,   66,   11,    3,    4,    4,
       77,    4,    4,   67,   67,    4,   73,   73,    4,    4,
        4,  161,   68,   68,   37,   85,   60,   60,   11,   37,
       12,  125,   77,   60,   68,  488,   60,   60,   60,   37,
       76,   76,  487,   37,    4,    7,    7,    7,    7,    7,
        7,    7,   12,    7,  125,    7,    7,    7,    7,    7,
      468,   37,   60,   70,   70,   37,   61,   61,  466,   70,

       76,  132,  132,   61,   71,   71,   61,   61,   61,  465,
       71,    7,    7,    8,    8,    8,    8,    8,    8,    8,
      100,    8,   76,    8,    8,    8,    8,    8,  282,   38,
       79,   79,   61,  282,   38,  462,  100,  133,  133,  138,
      138,  460,   79,  455,   38,  139,  139,  450,   38,    8,
        8,    9,    9,    9,    9,    9,    9,    9,  100,    9,
      104,    9,    9,    9,    9,    9,   38,   65,   65,   65,
       38,  141,  141,   98,   65,   86,  104,  447,   92,  105,
       65,  126,   86,   86,   92,  162,  105,    9,    9,   10,
       10,   10,   10,   10,   10,   10,   98,   10,  104,   10,

       10,   10,   10,   10,  126,   86,   86,   92,  162,  105,
       93,   49,   49,   93,  142,  142,   99,  101,   98,   99,
      101,  143,  143,  446,   49,   10,   10,   31,   31,   31,
       31,   31,   31,   31,   49,   31,   93,   31,   31,   31,
       31,   31,   99,  101,   49,  106,  110,  164,  106,  111,
       31,  445,  111,  444,   31,  442,   49,  134,  134,  144,
      144,  434,  110,   31,   31,  432,   49,  146,  146,  134,
      164,  106,   31,   50,   50,  111,   31,   32,   32,   32,
       32,   32,   32,   32,  110,   32,   50,   32,   32,   32,
       32,   32,   35,   36,  107,  112,   50,   35,   36,  115,

       32,  107,  112,  431,   32,  430,   50,   35,   36,  145,
      145,   35,   36,   32,   32,  115,   35,   36,   50,  154,
      120,  145,   32,  429,  107,  112,   32,   39,   50,   35,
       36,  427,   39,   35,   36,   40,   39,  115,   35,   36,
       40,  154,   39,  120,   40,   88,   39,   47,  116,  425,
       40,  116,   47,  117,   40,  169,   88,  203,   88,   39,
      117,  423,   47,  417,   39,  120,   47,   40,   39,   88,
       48,   47,   40,  155,  116,   48,   40,   41,  169,   88,
      203,   88,   41,  117,   47,   48,   41,   41,   47,   48,
      409,   88,   41,   47,   48,  155,   41,  150,  150,  122,

      122,  157,  157,   41,  158,  158,  348,   48,  140,   41,
       41,   48,  122,  157,   41,  163,   48,  166,   41,  140,
      140,  345,  122,  147,  147,   41,   43,  123,  123,  147,
      204,   43,  122,  205,  205,   43,   43,  163,  221,  166,
      123,  167,  140,  140,  122,   43,  296,  168,  153,  153,
      123,  296,   43,  204,  122,  131,  131,  131,   43,   43,
      123,  221,  131,  167,  211,  211,  172,   43,  131,  168,
      333,  171,  123,  170,   43,   44,  129,  129,  153,  170,
       44,  172,  123,  129,   44,   44,  129,  129,  129,  172,
      165,  165,  165,  171,   44,  173,  170,  215,  215,  332,

      153,   44,  170,  172,  178,  182,  183,   44,   44,  216,
      216,  188,  129,  165,  165,  165,   44,  173,  178,  184,
      183,  190,  182,   44,   45,  184,  187,  185,  330,   45,
      188,  189,  187,   45,   45,  193,  190,  206,  329,  207,
      178,  185,  183,   45,  182,  189,  327,  192,  184,  193,
       45,  194,  188,  192,  226,  187,   45,   45,  190,  206,
      197,  207,  196,  185,  198,   45,  194,  189,  196,  200,
      325,  193,   45,   46,  197,  213,  192,  226,   46,  198,
      201,  201,   46,   46,  324,  214,  200,  219,  194,  217,
      217,  196,   46,  201,  218,  218,  197,  213,  222,   46,

      323,  198,  223,  201,  224,   46,   46,  214,  200,  219,
      220,  220,  225,  201,   46,  227,  228,  229,  230,  231,
      222,   46,   87,  232,  223,  201,  224,  233,  234,   87,
      322,   87,  320,  235,  225,  201,  236,  227,  228,  229,
      230,  231,  237,  314,  239,  232,   87,  307,   87,  233,
      234,  239,   87,  240,   87,  235,  241,  294,  236,  242,
      240,  247,  243,  241,  237,  244,  242,  247,   87,  243,
       87,  245,  244,  246,  239,  248,  245,  249,  293,  250,
      246,  251,  248,  240,  249,  250,  241,  252,  251,  242,
      247,  253,  243,  254,  252,  244,  257,  253,  259,  245,

      254,  255,  255,  246,  260,  248,  262,  249,  250,  258,
      258,  251,  263,  256,  256,  261,  261,  252,  257,  264,
      253,  259,  265,  254,  256,  266,  260,  267,  268,  262,
      269,  271,  272,  273,  263,  274,  275,  276,  277,  278,
      279,  291,  264,  290,  265,  288,  287,  286,  266,  267,
      268,  289,  269,  271,  292,  272,  273,  274,  275,  276,
      277,  278,  295,  279,  287,  297,  297,  289,  298,  298,
      292,  298,  299,  300,  300,  301,  297,  302,  295,  303,
      304,  305,  306,  308,  309,  311,  287,  310,  312,  289,
      313,  315,  292,  318,  285,  299,  339,  301,  328,  302,

      295,  303,  304,  305,  306,  308,  321,  309,  311,  310,
      331,  312,  313,  315,  326,  318,  328,  334,  339,  335,
      340,  321,  342,  336,  336,  326,  336,  343,  331,  338,
      338,  344,  284,  347,  335,  334,  335,  349,  328,  350,
      338,  351,  340,  321,  342,  341,  341,  326,  341,  343,
      331,  352,  354,  355,  344,  347,  335,  334,  335,  357,
      349,  350,  357,  362,  351,  364,  367,  370,  375,  376,
      364,  367,  370,  352,  354,  371,  355,  379,  371,  372,
      362,  380,  372,  373,  373,  357,  374,  374,  381,  374,
      375,  376,  377,  377,  373,  377,  382,  391,  384,  379,

      385,  371,  362,  380,  386,  372,  388,  389,  390,  283,
      392,  381,  395,  393,  394,  396,  402,  391,  399,  382,
      384,  392,  390,  385,  393,  394,  395,  386,  401,  388,
      389,  397,  397,  396,  397,  400,  400,  403,  402,  391,
      404,  399,  405,  392,  390,  407,  393,  394,  395,  408,
      410,  401,  412,  411,  413,  396,  414,  410,  412,  403,
      413,  415,  414,  404,  411,  405,  416,  407,  415,  418,
      418,  419,  408,  416,  420,  433,  421,  422,  428,  436,
      410,  412,  437,  413,  438,  414,  411,  435,  435,  439,
      433,  415,  443,  419,  428,  448,  416,  420,  421,  422,

      451,  436,  449,  449,  437,  452,  438,  443,  453,  464,
      281,  439,  433,  238,  212,  448,  428,  202,  179,  177,
      174,  160,  451,  149,  148,  137,  135,  452,  130,  443,
      453,  464,  124,  118,  113,  108,  102,  448,  473,  473,
      473,  473,  473,  474,  474,  474,  474,  474,  475,  475,
      475,  475,  475,  476,  476,  476,  476,  476,  477,  477,
      477,  477,  477,  478,  478,  478,  478,  478,  479,  479,
      479,  479,  479,  480,  480,  480,  480,  480,  481,  481,
      481,  481,  481,  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,  490,   96,
      490,  490,  490,  491,   95,  491,  491,  491,  492,  492,
      493,  493,  493,  493,  493,  494,   90,  494,  494,  494,
      495,   89,  495,  495,  495,  496,  496,   82,  496,  496,
      497,  497,  497,  497,  497,   81,   72,   64,   62,   57,
       54,   53,   52,   51,   30,   29,   28,   27,   26,   25,
       22,   21,   18,   17,   16,   15,   14,   13,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,

      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472,  472,  472,  472,
      472,  472,  472,  472,  472,  472,  472
    } ;

static yy_state_type yy_last_accepting_state;
static char *yy_last_accepting_cpos;

extern int DiamDict_flex_debug;
int DiamDict_flex_debug = 0;

/* The intent behind this definition is that it'll catch
 * any uses of REJECT which flex missed.
 */
#define REJECT reject_used_but_not_detected
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
char *DiamDicttext;
#line 1 "diam_dict.l"
/*
 * 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 from the terminal.
 */
/*
 * The language we're scanning is case-insensitive.
 */
/*
 * We use start condition stacks.
 */
/*
 * Prefix scanner routines with "DiamDict" rather than "yy", so this scanner
 * can coexist with other scanners.
 */
#line 35 "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 "config.h"

#include <glib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
#include "diam_dict.h"
#include "diam_dict_lex.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" )); attr_uint = &(cont); yy_push_state(GET_UINT_ATTR); } while(0)
#define ATTR_STR(cont) do { D(("attr_str " #cont "\t" )); attr_str = &(cont); yy_push_state(GET_ATTR); } while(0)
#define IGNORE() do { D(("ignore: %s\t",DiamDicttext)); yy_push_state(IGNORE_ATTR); } while(0)

#define D(args) ddict_debug args

#define MAX_INCLUDE_DEPTH 10
#define YY_INPUT(buf,result,max_size) { result = current_yyinput(buf,max_size); }
#define ECHO
#define APPEND(txt,len) append_to_buffer(txt,len)

static entity_t ents;
static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
static int include_stack_ptr = 0;
static size_t (*current_yyinput)(char*,size_t);
static const char* sys_dir;
static ddict_t* dict;
static ddict_application_t* appl;
static ddict_avp_t* avp;
static ddict_enum_t* enumitem;
static ddict_gavp_t* gavp;
static ddict_typedefn_t* typedefn;
static ddict_cmd_t* cmd;
static ddict_vendor_t* vnd;
static ddict_xmlpi_t* xmlpi;

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

static char** attr_str;
static unsigned* attr_uint;

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





#line 1018 "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

#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif

static int yy_init_globals (void );

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

int DiamDictlex_destroy (void );

int DiamDictget_debug (void );

void DiamDictset_debug (int debug_flag  );

YY_EXTRA_TYPE DiamDictget_extra (void );

void DiamDictset_extra (YY_EXTRA_TYPE user_defined  );

FILE *DiamDictget_in (void );

void DiamDictset_in  (FILE * in_str  );

FILE *DiamDictget_out (void );

void DiamDictset_out  (FILE * out_str  );

int DiamDictget_leng (void );

char *DiamDictget_text (void );

int DiamDictget_lineno (void );

void DiamDictset_lineno (int line_number  );

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

#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int DiamDictwrap (void );
#else
extern int DiamDictwrap (void );
#endif
#endif

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

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

#ifndef YY_NO_INPUT

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

#endif

        static int yy_start_stack_ptr = 0;
        static int yy_start_stack_depth = 0;
        static int *yy_start_stack = NULL;
    
    static void yy_push_state (int new_state );
    
    static void yy_pop_state (void );
    
    static int yy_top_state (void );
    
/* 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( DiamDicttext, DiamDictleng, 1, DiamDictout )) {} } 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( DiamDictin )) != EOF && c != '\n'; ++n ) \
			buf[n] = (char) c; \
		if ( c == '\n' ) \
			buf[n++] = (char) c; \
		if ( c == EOF && ferror( DiamDictin ) ) \
			YY_FATAL_ERROR( "input in flex scanner failed" ); \
		result = n; \
		} \
	else \
		{ \
		errno=0; \
		while ( (result = fread(buf, 1, max_size, DiamDictin))==0 && ferror(DiamDictin)) \
			{ \
			if( errno != EINTR) \
				{ \
				YY_FATAL_ERROR( "input in flex scanner failed" ); \
				break; \
				} \
			errno=0; \
			clearerr(DiamDictin); \
			} \
		}\
\

#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 )
#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 DiamDictlex (void);

#define YY_DECL int DiamDictlex (void)
#endif /* !YY_DECL */

/* Code executed at the beginning of each rule, after DiamDicttext and DiamDictleng
 * 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 break;
#endif

#define YY_RULE_SETUP \
	YY_USER_ACTION

/** The main scanner function which does all the work.
 */
YY_DECL
{
	register yy_state_type yy_current_state;
	register char *yy_cp, *yy_bp;
	register int yy_act;
    
#line 200 "diam_dict.l"

#line 1242 "diam_dict.c"

	if ( !(yy_init) )
		{
		(yy_init) = 1;

#ifdef YY_USER_INIT
		YY_USER_INIT;
#endif

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

		if ( ! DiamDictin )
			DiamDictin = stdin;

		if ( ! DiamDictout )
			DiamDictout = stdout;

		if ( ! YY_CURRENT_BUFFER ) {
			DiamDictensure_buffer_stack ();
			YY_CURRENT_BUFFER_LVALUE =
				DiamDict_create_buffer(DiamDictin,YY_BUF_SIZE );
		}

		DiamDict_load_buffer_state( );
		}

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

		/* Support of DiamDicttext. */
		*yy_cp = (yy_hold_char);

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

		yy_current_state = (yy_start);
yy_match:
		do
			{
			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
			if ( yy_accept[yy_current_state] )
				{
				(yy_last_accepting_state) = yy_current_state;
				(yy_last_accepting_cpos) = yy_cp;
				}
			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
				{
				yy_current_state = (int) yy_def[yy_current_state];
				if ( yy_current_state >= 473 )
					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 != 472 );
		yy_cp = (yy_last_accepting_cpos);
		yy_current_state = (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 = (yy_hold_char);
			yy_cp = (yy_last_accepting_cpos);
			yy_current_state = (yy_last_accepting_state);
			goto yy_find_action;

case 1:
/* rule 1 can match eol */
YY_RULE_SETUP
#line 201 "diam_dict.l"
;
	YY_BREAK
case 2:
/* rule 2 can match eol */
YY_RULE_SETUP
#line 202 "diam_dict.l"
;
	YY_BREAK
case 3:
/* rule 3 can match eol */
YY_RULE_SETUP
#line 204 "diam_dict.l"
BEGIN LOADING_COMMENT;
	YY_BREAK
case 4:
YY_RULE_SETUP
#line 205 "diam_dict.l"
;
	YY_BREAK
case 5:
/* rule 5 can match eol */
YY_RULE_SETUP
#line 206 "diam_dict.l"
BEGIN LOADING;
	YY_BREAK
case 6:
/* rule 6 can match eol */
YY_RULE_SETUP
#line 208 "diam_dict.l"
BEGIN LOADING_XMLPI;
	YY_BREAK
case 7:
/* rule 7 can match eol */
YY_RULE_SETUP
#line 209 "diam_dict.l"
;
	YY_BREAK
case 8:
YY_RULE_SETUP
#line 210 "diam_dict.l"
{
	xmlpi = g_new(ddict_xmlpi_t,1);
	xmlpi->name = g_strdup(DiamDicttext);
	xmlpi->key = NULL;
	xmlpi->value = NULL;
	xmlpi->next = NULL;

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

	BEGIN XMLPI_ATTRS;
}
	YY_BREAK
case 9:
/* rule 9 can match eol */
YY_RULE_SETUP
#line 223 "diam_dict.l"
BEGIN XMLPI_GETKEY;
	YY_BREAK
case 10:
/* rule 10 can match eol */
YY_RULE_SETUP
#line 224 "diam_dict.l"
{ xmlpi->key = strdup(DiamDicttext); BEGIN XMLPI_ATTRS; }
	YY_BREAK
case 11:
/* rule 11 can match eol */
YY_RULE_SETUP
#line 226 "diam_dict.l"
BEGIN XMLPI_GETVAL;
	YY_BREAK
case 12:
/* rule 12 can match eol */
YY_RULE_SETUP
#line 227 "diam_dict.l"
{ xmlpi->value = strdup(DiamDicttext); BEGIN XMLPI_ATTRS; }
	YY_BREAK
case 13:
YY_RULE_SETUP
#line 229 "diam_dict.l"

	YY_BREAK
case 14:
/* rule 14 can match eol */
YY_RULE_SETUP
#line 230 "diam_dict.l"
BEGIN LOADING;
	YY_BREAK
case 15:
/* rule 15 can match eol */
YY_RULE_SETUP
#line 233 "diam_dict.l"
BEGIN ENTITY;
	YY_BREAK
case 16:
YY_RULE_SETUP
#line 234 "diam_dict.l"
{
	entity_t* e = g_new(entity_t,1);
	e->name = strdup(DiamDicttext);
	e->next = ents.next;
	ents.next = e;
	BEGIN GET_SYSTEM;
	};
	YY_BREAK
case 17:
/* rule 17 can match eol */
YY_RULE_SETUP
#line 241 "diam_dict.l"
BEGIN GET_FILE;
	YY_BREAK
case 18:
/* rule 18 can match eol */
YY_RULE_SETUP
#line 242 "diam_dict.l"
{
		ents.next->file = strdup(DiamDicttext);
		BEGIN END_ENTITY;
	}
	YY_BREAK
case 19:
/* rule 19 can match eol */
YY_RULE_SETUP
#line 246 "diam_dict.l"
BEGIN LOADING;
	YY_BREAK
case 20:
/* rule 20 can match eol */
YY_RULE_SETUP
#line 248 "diam_dict.l"
APPEND("<",1);
	YY_BREAK
case 21:
/* rule 21 can match eol */
YY_RULE_SETUP
#line 250 "diam_dict.l"
APPEND(">",1);
	YY_BREAK
case 22:
/* rule 22 can match eol */
YY_RULE_SETUP
#line 252 "diam_dict.l"
APPEND("/>",2);
	YY_BREAK
case 23:
/* rule 23 can match eol */
YY_RULE_SETUP
#line 254 "diam_dict.l"
APPEND("</",2);
	YY_BREAK
case 24:
/* rule 24 can match eol */
YY_RULE_SETUP
#line 256 "diam_dict.l"
APPEND(" ",1);
	YY_BREAK
case 25:
/* rule 25 can match eol */
YY_RULE_SETUP
#line 258 "diam_dict.l"
APPEND(DiamDicttext, (unsigned) DiamDictleng);
	YY_BREAK
case 26:
/* rule 26 can match eol */
YY_RULE_SETUP
#line 260 "diam_dict.l"
APPEND("=",1);
	YY_BREAK
case 27:
YY_RULE_SETUP
#line 262 "diam_dict.l"
APPEND(DiamDicttext, (unsigned) DiamDictleng);
	YY_BREAK
case 28:
YY_RULE_SETUP
#line 264 "diam_dict.l"
{
	char* p = ++DiamDicttext;
	entity_t* e;

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

	*p = '\0';

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

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

	for (e = ents.next; e; e = e->next) {
		if (strcmp(e->name,DiamDicttext) == 0) {
			DiamDictin = ddict_open(sys_dir,e->file);
			D(("entity: %s filename: %s DiamDictin: %p\n",e->name,e->file,DiamDictin));
			if (!DiamDictin) {
				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 {
				include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER;
				DiamDict_switch_to_buffer(DiamDict_create_buffer(DiamDictin,YY_BUF_SIZE ) );
				BEGIN LOADING;
			}
			break;
		}
	}

	if (!e) {
		fprintf(stderr, "Could not find entity: '%s'\n", DiamDicttext );
		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 305 "diam_dict.l"
{
	if (!DiamDictin) yyterminate();

	fclose(DiamDictin);
	D(("closing: %p %i\n",DiamDictin,include_stack_ptr));

	if ( --include_stack_ptr < 0 ) {
		D(("DONE READING\n"));
		DiamDictin = NULL;
		yyterminate();
	} else {
		DiamDict_delete_buffer(YY_CURRENT_BUFFER );
		DiamDict_switch_to_buffer(include_stack[include_stack_ptr]);
		BEGIN LOADING;
	}
}
	YY_BREAK
case 29:
/* rule 29 can match eol */
YY_RULE_SETUP
#line 323 "diam_dict.l"
{
	*attr_str = strdup(DiamDicttext);
	D(("%s\n",DiamDicttext));
	attr_str = NULL;
	BEGIN END_ATTR;
}
	YY_BREAK
case 30:
YY_RULE_SETUP
#line 330 "diam_dict.l"
{
	*attr_uint = (unsigned) strtoul(DiamDicttext,NULL,10);
	D(("%s\n",DiamDicttext););
	attr_uint = NULL;
	BEGIN END_ATTR;
}
	YY_BREAK
case 31:
YY_RULE_SETUP
#line 337 "diam_dict.l"
{	yy_pop_state(); }
	YY_BREAK
case 32:
YY_RULE_SETUP
#line 339 "diam_dict.l"
{
	/* XXX: should go?*/
	D(("{%s}",DiamDicttext));
}
	YY_BREAK
case 33:
/* rule 33 can match eol */
YY_RULE_SETUP
#line 344 "diam_dict.l"
{
	D(("=>%s<=\n",DiamDicttext));
	yy_pop_state();
}
	YY_BREAK
case 34:
YY_RULE_SETUP
#line 349 "diam_dict.l"
{
	D(("dictionary_start\n"));

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

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

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

	BEGIN APPL_ATTRS;
}
	YY_BREAK
case 37:
YY_RULE_SETUP
#line 374 "diam_dict.l"
{ ATTR_STR(appl->name); }
	YY_BREAK
case 38:
YY_RULE_SETUP
#line 375 "diam_dict.l"
{ ATTR_UINT(appl->code); }
	YY_BREAK
case 39:
YY_RULE_SETUP
#line 377 "diam_dict.l"
BEGIN IN_APPL;
	YY_BREAK
case 40:
YY_RULE_SETUP
#line 378 "diam_dict.l"
BEGIN IN_DICT;
	YY_BREAK
case 41:
YY_RULE_SETUP
#line 380 "diam_dict.l"
;
	YY_BREAK
case 42:
YY_RULE_SETUP
#line 382 "diam_dict.l"
{
	D(("command_start\n"));

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

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

	BEGIN COMMAND_ATTRS;
}
	YY_BREAK
case 43:
YY_RULE_SETUP
#line 397 "diam_dict.l"
{ ATTR_STR(cmd->name); }
	YY_BREAK
case 44:
YY_RULE_SETUP
#line 398 "diam_dict.l"
{ ATTR_STR(cmd->vendor); }
	YY_BREAK
case 45:
YY_RULE_SETUP
#line 399 "diam_dict.l"
{ ATTR_UINT(cmd->code); }
	YY_BREAK
case 46:
#line 401 "diam_dict.l"
case 47:
YY_RULE_SETUP
#line 401 "diam_dict.l"
{ BEGIN IN_APPL; }
	YY_BREAK
case 48:
YY_RULE_SETUP
#line 403 "diam_dict.l"
{
	D(("vendor_start\n"));

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

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

	BEGIN VENDOR_ATTRS;
}
	YY_BREAK
case 49:
YY_RULE_SETUP
#line 417 "diam_dict.l"
{ ATTR_STR(vnd->desc); }
	YY_BREAK
case 50:
YY_RULE_SETUP
#line 418 "diam_dict.l"
{ ATTR_STR(vnd->name); }
	YY_BREAK
case 51:
YY_RULE_SETUP
#line 419 "diam_dict.l"
{ ATTR_UINT(vnd->code); }
	YY_BREAK
case 52:
#line 421 "diam_dict.l"
case 53:
YY_RULE_SETUP
#line 421 "diam_dict.l"
{ BEGIN IN_APPL; }
	YY_BREAK
case 54:
YY_RULE_SETUP
#line 423 "diam_dict.l"
{
	D(("typedefn_start\n"));

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

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

	BEGIN TYPEDEFN_ATTRS;
}
	YY_BREAK
case 55:
YY_RULE_SETUP
#line 437 "diam_dict.l"
{ ATTR_STR(typedefn->name); }
	YY_BREAK
case 56:
YY_RULE_SETUP
#line 438 "diam_dict.l"
{ ATTR_STR(typedefn->parent); }
	YY_BREAK
case 57:
#line 440 "diam_dict.l"
case 58:
YY_RULE_SETUP
#line 440 "diam_dict.l"
{ BEGIN IN_APPL; }
	YY_BREAK
case 59:
YY_RULE_SETUP
#line 443 "diam_dict.l"
{
	D(("avp_start\n"));

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

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

	BEGIN AVP_ATTRS;
}
	YY_BREAK
case 60:
YY_RULE_SETUP
#line 462 "diam_dict.l"
{ ATTR_STR(avp->name); }
	YY_BREAK
case 61:
YY_RULE_SETUP
#line 463 "diam_dict.l"
{ ATTR_STR(avp->description); }
	YY_BREAK
case 62:
YY_RULE_SETUP
#line 464 "diam_dict.l"
{ ATTR_STR(avp->vendor); }
	YY_BREAK
case 63:
YY_RULE_SETUP
#line 465 "diam_dict.l"
{ ATTR_UINT(avp->code); }
	YY_BREAK
case 64:
YY_RULE_SETUP
#line 466 "diam_dict.l"
{ BEGIN IN_AVP;  }
	YY_BREAK
case 65:
YY_RULE_SETUP
#line 467 "diam_dict.l"
{ BEGIN IN_APPL; }
	YY_BREAK
case 66:
YY_RULE_SETUP
#line 470 "diam_dict.l"
{ avp->type = strdup("Grouped"); };
	YY_BREAK
case 67:
YY_RULE_SETUP
#line 471 "diam_dict.l"
;
	YY_BREAK
case 68:
YY_RULE_SETUP
#line 473 "diam_dict.l"
{ BEGIN TYPE_ATTRS; }
	YY_BREAK
case 69:
YY_RULE_SETUP
#line 474 "diam_dict.l"
{ ATTR_STR(avp->type); }
	YY_BREAK
case 70:
YY_RULE_SETUP
#line 476 "diam_dict.l"
{
	D(("gavp_start\n"));

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

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

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

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

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

	BEGIN ENUM_ATTRS;
}
	YY_BREAK
case 73:
YY_RULE_SETUP
#line 509 "diam_dict.l"
{ ATTR_STR(enumitem->name); }
	YY_BREAK
case 74:
YY_RULE_SETUP
#line 510 "diam_dict.l"
{ ATTR_UINT(enumitem->code); }
	YY_BREAK
case 75:
YY_RULE_SETUP
#line 512 "diam_dict.l"
{ BEGIN IN_AVP; }
	YY_BREAK
case 76:
YY_RULE_SETUP
#line 513 "diam_dict.l"
{ BEGIN IN_AVP; }
	YY_BREAK
case 77:
YY_RULE_SETUP
#line 515 "diam_dict.l"
{ D(("avp_end")); BEGIN IN_APPL; }
	YY_BREAK
case 78:
#line 518 "diam_dict.l"
case 79:
YY_RULE_SETUP
#line 518 "diam_dict.l"
{
	BEGIN IN_DICT;
}
	YY_BREAK
case 80:
YY_RULE_SETUP
#line 522 "diam_dict.l"
{
	yyterminate();
}
	YY_BREAK
case 81:
YY_RULE_SETUP
#line 526 "diam_dict.l"
IGNORE();
	YY_BREAK
case 82:
YY_RULE_SETUP
#line 528 "diam_dict.l"
;
	YY_BREAK
case 83:
YY_RULE_SETUP
#line 535 "diam_dict.l"
ECHO;
	YY_BREAK
#line 1971 "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 - (yytext_ptr)) - 1;

		/* Undo the effects of YY_DO_BEFORE_ACTION. */
		*yy_cp = (yy_hold_char);
		YY_RESTORE_YY_MORE_OFFSET

		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
			{
			/* We're scanning a new file or input source.  It's
			 * possible that this happened because the user
			 * just pointed DiamDictin at a new source and called
			 * DiamDictlex().  If so, then we have to assure
			 * consistency between YY_CURRENT_BUFFER and our
			 * globals.  Here is the right place to do so, because
			 * this is the first action (other than possibly a
			 * back-up) that will match for the new input source.
			 */
			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
			YY_CURRENT_BUFFER_LVALUE->yy_input_file = DiamDictin;
			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
			}

		/* Note that here we test for yy_c_buf_p "<=" to the position
		 * of the first EOB in the buffer, since yy_c_buf_p will
		 * already have been incremented past the NUL character
		 * (since all states make transitions on EOB to the
		 * end-of-buffer state).  Contrast this with the test
		 * in input().
		 */
		if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
			{ /* This was really a NUL. */
			yy_state_type yy_next_state;

			(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;

			yy_current_state = yy_get_previous_state(  );

			/* Okay, we're now positioned to make the NUL
			 * transition.  We couldn't have
			 * yy_get_previous_state() go ahead and do it
			 * for us because it doesn't know how to deal
			 * with the possibility of jamming (and we don't
			 * want to build jamming into it because then it
			 * will run more slowly).
			 */

			yy_next_state = yy_try_NUL_trans( yy_current_state );

			yy_bp = (yytext_ptr) + YY_MORE_ADJ;

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

			else
				{
				yy_cp = (yy_last_accepting_cpos);
				yy_current_state = (yy_last_accepting_state);
				goto yy_find_action;
				}
			}

		else switch ( yy_get_next_buffer(  ) )
			{
			case EOB_ACT_END_OF_FILE:
				{
				(yy_did_buffer_switch_on_eof) = 0;

				if ( DiamDictwrap( ) )
					{
					/* Note: because we've taken care in
					 * yy_get_next_buffer() to have set up
					 * DiamDicttext, we can now set up
					 * yy_c_buf_p so that if some total
					 * hoser (like flex itself) wants to
					 * call the scanner after we return the
					 * YY_NULL, it'll still work - another
					 * YY_NULL will get returned.
					 */
					(yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;

					yy_act = YY_STATE_EOF(YY_START);
					goto do_action;
					}

				else
					{
					if ( ! (yy_did_buffer_switch_on_eof) )
						YY_NEW_FILE;
					}
				break;
				}

			case EOB_ACT_CONTINUE_SCAN:
				(yy_c_buf_p) =
					(yytext_ptr) + yy_amount_of_matched_text;

				yy_current_state = yy_get_previous_state(  );

				yy_cp = (yy_c_buf_p);
				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
				goto yy_match;

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

				yy_current_state = yy_get_previous_state(  );

				yy_cp = (yy_c_buf_p);
				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
				goto yy_find_action;
			}
		break;
		}

	default:
		YY_FATAL_ERROR(
			"fatal flex scanner internal error--no action found" );
	} /* end of action switch */
		} /* end of scanning one token */
} /* end of DiamDictlex */

/* 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 (void)
{
    	register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
	register char *source = (yytext_ptr);
	register int number_to_move, i;
	int ret_val;

	if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
		YY_FATAL_ERROR(
		"fatal flex scanner internal error--end of buffer missed" );

	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
		{ /* Don't try to fill the buffer, so this is an EOF. */
		if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
			{
			/* We matched a single character, the EOB, so
			 * treat this as a final EOF.
			 */
			return EOB_ACT_END_OF_FILE;
			}

		else
			{
			/* We matched some text prior to the EOB, first
			 * process it.
			 */
			return EOB_ACT_LAST_MATCH;
			}
		}

	/* Try to read more data. */

	/* First move last chars to start of buffer. */
	number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;

	for ( i = 0; i < number_to_move; ++i )
		*(dest++) = *(source++);

	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
		/* don't do the read, it's not guaranteed to return an EOF,
		 * just force an EOF
		 */
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;

	else
		{
			int num_to_read =
			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;

		while ( num_to_read <= 0 )
			{ /* Not enough room in the buffer - grow it. */

			/* just a shorter name for the current buffer */
			YY_BUFFER_STATE b = YY_CURRENT_BUFFER;

			int yy_c_buf_p_offset =
				(int) ((yy_c_buf_p) - b->yy_ch_buf);

			if ( b->yy_is_our_buffer )
				{
				int new_size = b->yy_buf_size * 2;

				if ( new_size <= 0 )
					b->yy_buf_size += b->yy_buf_size / 8;
				else
					b->yy_buf_size *= 2;

				b->yy_ch_buf = (char *)
					/* Include room in for 2 EOB chars. */
					DiamDictrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
				}
			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" );

			(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];

			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
						number_to_move - 1;

			}

		if ( num_to_read > YY_READ_BUF_SIZE )
			num_to_read = YY_READ_BUF_SIZE;

		/* Read in more data. */
		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
			(yy_n_chars), (size_t) num_to_read );

		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
		}

	if ( (yy_n_chars) == 0 )
		{
		if ( number_to_move == YY_MORE_ADJ )
			{
			ret_val = EOB_ACT_END_OF_FILE;
			DiamDictrestart(DiamDictin  );
			}

		else
			{
			ret_val = EOB_ACT_LAST_MATCH;
			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
				YY_BUFFER_EOF_PENDING;
			}
		}

	else
		ret_val = EOB_ACT_CONTINUE_SCAN;

	if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
		/* Extend the array by 50%, plus the number we really need. */
		yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) DiamDictrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
	}

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

	(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];

	return ret_val;
}

/* yy_get_previous_state - get the state just before the EOB char was reached */

    static yy_state_type yy_get_previous_state (void)
{
	register yy_state_type yy_current_state;
	register char *yy_cp;
    
	yy_current_state = (yy_start);

	for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
		{
		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
		if ( yy_accept[yy_current_state] )
			{
			(yy_last_accepting_state) = yy_current_state;
			(yy_last_accepting_cpos) = yy_cp;
			}
		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
			{
			yy_current_state = (int) yy_def[yy_current_state];
			if ( yy_current_state >= 473 )
				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 )
{
	register int yy_is_jam;
    	register char *yy_cp = (yy_c_buf_p);

	register YY_CHAR yy_c = 1;
	if ( yy_accept[yy_current_state] )
		{
		(yy_last_accepting_state) = yy_current_state;
		(yy_last_accepting_cpos) = yy_cp;
		}
	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
		{
		yy_current_state = (int) yy_def[yy_current_state];
		if ( yy_current_state >= 473 )
			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 == 472);

	return yy_is_jam ? 0 : yy_current_state;
}

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

{
	int c;
    
	*(yy_c_buf_p) = (yy_hold_char);

	if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
		{
		/* yy_c_buf_p now points to the character we want to return.
		 * If this occurs *before* the EOB characters, then it's a
		 * valid NUL; if not, then we've hit the end of the buffer.
		 */
		if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
			/* This was really a NUL. */
			*(yy_c_buf_p) = '\0';

		else
			{ /* need more input */
			int offset = (yy_c_buf_p) - (yytext_ptr);
			++(yy_c_buf_p);

			switch ( yy_get_next_buffer(  ) )
				{
				case EOB_ACT_LAST_MATCH:
					/* This happens because yy_g_n_b()
					 * sees that we've accumulated a
					 * token and flags that we need to
					 * try matching the token before
					 * proceeding.  But for input(),
					 * there's no matching to consider.
					 * So convert the EOB_ACT_LAST_MATCH
					 * to EOB_ACT_END_OF_FILE.
					 */

					/* Reset buffer status. */
					DiamDictrestart(DiamDictin );

					/*FALLTHROUGH*/

				case EOB_ACT_END_OF_FILE:
					{
					if ( DiamDictwrap( ) )
						return EOF;

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

				case EOB_ACT_CONTINUE_SCAN:
					(yy_c_buf_p) = (yytext_ptr) + offset;
					break;
				}
			}
		}

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

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

/** Immediately switch to a different input stream.
 * @param input_file A readable stream.
 * 
 * @note This function does not reset the start condition to @c INITIAL .
 */
    void DiamDictrestart  (FILE * input_file )
{
    
	if ( ! YY_CURRENT_BUFFER ){
        DiamDictensure_buffer_stack ();
		YY_CURRENT_BUFFER_LVALUE =
            DiamDict_create_buffer(DiamDictin,YY_BUF_SIZE );
	}

	DiamDict_init_buffer(YY_CURRENT_BUFFER,input_file );
	DiamDict_load_buffer_state( );
}

/** Switch to a different input buffer.
 * @param new_buffer The new input buffer.
 * 
 */
    void DiamDict_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
{
    
	/* TODO. We should be able to replace this entire function body
	 * with
	 *		DiamDictpop_buffer_state();
	 *		DiamDictpush_buffer_state(new_buffer);
     */
	DiamDictensure_buffer_stack ();
	if ( YY_CURRENT_BUFFER == new_buffer )
		return;

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

	YY_CURRENT_BUFFER_LVALUE = new_buffer;
	DiamDict_load_buffer_state( );

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

static void DiamDict_load_buffer_state  (void)
{
    	(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
	(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
	DiamDictin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
	(yy_hold_char) = *(yy_c_buf_p);
}

/** Allocate and initialize an input buffer state.
 * @param file A readable stream.
 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
 * 
 * @return the allocated buffer state.
 */
    YY_BUFFER_STATE DiamDict_create_buffer  (FILE * file, int  size )
{
	YY_BUFFER_STATE b;
    
	b = (YY_BUFFER_STATE) DiamDictalloc(sizeof( struct yy_buffer_state )  );
	if ( ! b )
		YY_FATAL_ERROR( "out of dynamic memory in DiamDict_create_buffer()" );

	b->yy_buf_size = size;

	/* yy_ch_buf has to be 2 characters longer than the size given because
	 * we need to put in 2 end-of-buffer characters.
	 */
	b->yy_ch_buf = (char *) DiamDictalloc(b->yy_buf_size + 2  );
	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 );

	return b;
}

/** Destroy the buffer.
 * @param b a buffer created with DiamDict_create_buffer()
 * 
 */
    void DiamDict_delete_buffer (YY_BUFFER_STATE  b )
{
    
	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 )
		DiamDictfree((void *) b->yy_ch_buf  );

	DiamDictfree((void *) b  );
}

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

{
	int oerrno = errno;
    
	DiamDict_flush_buffer(b );

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

    /* If b is the current buffer, then DiamDict_init_buffer was _probably_
     * called from DiamDictrestart() 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.
 * 
 */
    void DiamDict_flush_buffer (YY_BUFFER_STATE  b )
{
    	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( );
}

/** 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.
 *  
 */
void DiamDictpush_buffer_state (YY_BUFFER_STATE new_buffer )
{
    	if (new_buffer == NULL)
		return;

	DiamDictensure_buffer_stack();

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

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

	/* copied from DiamDict_switch_to_buffer. */
	DiamDict_load_buffer_state( );
	(yy_did_buffer_switch_on_eof) = 1;
}

/** Removes and deletes the top of the stack, if present.
 *  The next element becomes the new top.
 *  
 */
void DiamDictpop_buffer_state (void)
{
    	if (!YY_CURRENT_BUFFER)
		return;

	DiamDict_delete_buffer(YY_CURRENT_BUFFER );
	YY_CURRENT_BUFFER_LVALUE = NULL;
	if ((yy_buffer_stack_top) > 0)
		--(yy_buffer_stack_top);

	if (YY_CURRENT_BUFFER) {
		DiamDict_load_buffer_state( );
		(yy_did_buffer_switch_on_eof) = 1;
	}
}

/* Allocates the stack if it does not exist.
 *  Guarantees space for at least one push.
 */
static void DiamDictensure_buffer_stack (void)
{
	int num_to_alloc;
    
	if (!(yy_buffer_stack)) {

		/* First allocation is just for 2 elements, since we don't know if this
		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
		 * immediate realloc on the next call.
         */
		num_to_alloc = 1;
		(yy_buffer_stack) = (struct yy_buffer_state**)DiamDictalloc
								(num_to_alloc * sizeof(struct yy_buffer_state*)
								);
		if ( ! (yy_buffer_stack) )
			YY_FATAL_ERROR( "out of dynamic memory in DiamDictensure_buffer_stack()" );
								  
		memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
				
		(yy_buffer_stack_max) = num_to_alloc;
		(yy_buffer_stack_top) = 0;
		return;
	}

	if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){

		/* Increase the buffer to prepare for a possible push. */
		int grow_size = 8 /* arbitrary grow size */;

		num_to_alloc = (yy_buffer_stack_max) + grow_size;
		(yy_buffer_stack) = (struct yy_buffer_state**)DiamDictrealloc
								((yy_buffer_stack),
								num_to_alloc * sizeof(struct yy_buffer_state*)
								);
		if ( ! (yy_buffer_stack) )
			YY_FATAL_ERROR( "out of dynamic memory in DiamDictensure_buffer_stack()" );

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

/** Setup the input buffer state to scan directly from a user-specified character buffer.
 * @param base the character buffer
 * @param size the size in bytes of the character buffer
 * 
 * @return the newly allocated buffer state object. 
 */
YY_BUFFER_STATE DiamDict_scan_buffer  (char * base, yy_size_t  size )
{
	YY_BUFFER_STATE b;
    
	if ( size < 2 ||
	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
	     base[size-1] != YY_END_OF_BUFFER_CHAR )
		/* They forgot to leave room for the EOB's. */
		return 0;

	b = (YY_BUFFER_STATE) DiamDictalloc(sizeof( struct yy_buffer_state )  );
	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  );

	return b;
}

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

/** Setup the input buffer state to scan the given bytes. The next call to DiamDictlex() will
 * scan from a @e copy of @a bytes.
 * @param yybytes the byte buffer to scan
 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
 * 
 * @return the newly allocated buffer state object.
 */
YY_BUFFER_STATE DiamDict_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
{
	YY_BUFFER_STATE b;
	char *buf;
	yy_size_t n;
	int i;
    
	/* Get memory for full buffer, including space for trailing EOB's. */
	n = _yybytes_len + 2;
	buf = (char *) DiamDictalloc(n  );
	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 );
	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 )
{
    	if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) )
		{
		yy_size_t new_size;

		(yy_start_stack_depth) += YY_START_STACK_INCR;
		new_size = (yy_start_stack_depth) * sizeof( int );

		if ( ! (yy_start_stack) )
			(yy_start_stack) = (int *) DiamDictalloc(new_size  );

		else
			(yy_start_stack) = (int *) DiamDictrealloc((void *) (yy_start_stack),new_size  );

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

	(yy_start_stack)[(yy_start_stack_ptr)++] = YY_START;

	BEGIN(new_state);
}

    static void yy_pop_state  (void)
{
    	if ( --(yy_start_stack_ptr) < 0 )
		YY_FATAL_ERROR( "start-condition stack underflow" );

	BEGIN((yy_start_stack)[(yy_start_stack_ptr)]);
}

    static int yy_top_state  (void)
{
    	return (yy_start_stack)[(yy_start_stack_ptr) - 1];
}

#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif

static void yy_fatal_error (yyconst char* msg )
{
    	(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 DiamDicttext. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
		DiamDicttext[DiamDictleng] = (yy_hold_char); \
		(yy_c_buf_p) = DiamDicttext + yyless_macro_arg; \
		(yy_hold_char) = *(yy_c_buf_p); \
		*(yy_c_buf_p) = '\0'; \
		DiamDictleng = yyless_macro_arg; \
		} \
	while ( 0 )

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

/** Get the current line number.
 * 
 */
int DiamDictget_lineno  (void)
{
        
    return DiamDictlineno;
}

/** Get the input stream.
 * 
 */
FILE *DiamDictget_in  (void)
{
        return DiamDictin;
}

/** Get the output stream.
 * 
 */
FILE *DiamDictget_out  (void)
{
        return DiamDictout;
}

/** Get the length of the current token.
 * 
 */
int DiamDictget_leng  (void)
{
        return DiamDictleng;
}

/** Get the current token.
 * 
 */

char *DiamDictget_text  (void)
{
        return DiamDicttext;
}

/** Set the current line number.
 * @param line_number
 * 
 */
void DiamDictset_lineno (int  line_number )
{
    
    DiamDictlineno = line_number;
}

/** Set the input stream. This does not discard the current
 * input buffer.
 * @param in_str A readable stream.
 * 
 * @see DiamDict_switch_to_buffer
 */
void DiamDictset_in (FILE *  in_str )
{
        DiamDictin = in_str ;
}

void DiamDictset_out (FILE *  out_str )
{
        DiamDictout = out_str ;
}

int DiamDictget_debug  (void)
{
        return DiamDict_flex_debug;
}

void DiamDictset_debug (int  bdebug )
{
        DiamDict_flex_debug = bdebug ;
}

static int yy_init_globals (void)
{
        /* Initialization is the same as for the non-reentrant scanner.
     * This function is called from DiamDictlex_destroy(), so don't allocate here.
     */

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

    (yy_start_stack_ptr) = 0;
    (yy_start_stack_depth) = 0;
    (yy_start_stack) =  NULL;

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

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

/* DiamDictlex_destroy is for both reentrant and non-reentrant scanners. */
int DiamDictlex_destroy  (void)
{
    
    /* Pop the buffer stack, destroying each element. */
	while(YY_CURRENT_BUFFER){
		DiamDict_delete_buffer(YY_CURRENT_BUFFER  );
		YY_CURRENT_BUFFER_LVALUE = NULL;
		DiamDictpop_buffer_state();
	}

	/* Destroy the stack itself. */
	DiamDictfree((yy_buffer_stack) );
	(yy_buffer_stack) = NULL;

    /* Destroy the start condition stack. */
        DiamDictfree((yy_start_stack)  );
        (yy_start_stack) = NULL;

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

    return 0;
}

/*
 * Internal utility routines.
 */

#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
{
	register 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 )
{
	register int n;
	for ( n = 0; s[n]; ++n )
		;

	return n;
}
#endif

void *DiamDictalloc (yy_size_t  size )
{
	return (void *) malloc( size );
}

void *DiamDictrealloc  (void * ptr, yy_size_t  size )
{
	/* The cast to (char *) in the following accommodates both
	 * implementations that use char* generic pointers, and those
	 * that use void* generic pointers.  It works with the latter
	 * because both ANSI C and C++ allow castless assignment from
	 * any pointer type to void*, and deal with argument conversions
	 * as though doing an assignment.
	 */
	return (void *) realloc( (char *) ptr, size );
}

void DiamDictfree (void * ptr )
{
	free( (char *) ptr );	/* see DiamDictrealloc() for (char *) cast */
}

#define YYTABLES_NAME "yytables"

#line 535 "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);
}


static char* strbuf = NULL;
static char* write_ptr = NULL;
static char* read_ptr = NULL;

static unsigned size_strbuf = 8192;
static unsigned len_strbuf = 0;

extern void ddict_unused(void);
void ddict_unused(void) {
	yy_top_state();
}

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

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

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

	write_ptr = strbuf + len_strbuf;
	strncpy(write_ptr,txt,len);
	len_strbuf += len;

}

static size_t file_input(char* buf, size_t max) {
	size_t read_cnt;

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

	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) {
	if (read_ptr >= write_ptr ) {
		return YY_NULL;
	} else if ( read_ptr + max > write_ptr ) {
		max = write_ptr - read_ptr;
	}

	memcpy(buf,read_ptr,max);
	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,fh));

	g_free(fname);


	return fh;
}

ddict_t* ddict_scan(const char* system_directory, const char* filename, int dbg) {

	debugging = dbg;

	sys_dir = system_directory;

	DiamDictin = ddict_open(sys_dir,filename);

	if (DiamDictin == NULL) {
		D(("unable to open %s\n", filename));
		return NULL;
	}

	write_ptr = NULL;
	read_ptr = NULL;

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

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

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

	ents.next = NULL;
	current_yyinput = file_input;
	BEGIN LOADING;
	DiamDictlex();

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

	current_yyinput = string_input;

	BEGIN OUTSIDE;
	DiamDictlex();

	g_free(strbuf);
	strbuf = NULL;
	size_strbuf = 8192;

	return 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;

#define FREE_NAMEANDOBJ(n) do { if(n->name) 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;
		if (!v->desc)  g_free(v->desc);
		FREE_NAMEANDOBJ(v);
	}

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

	for (t = d->typedefns; t; t = tn) {
		tn = t->next;
		if (!t->parent)  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);
		}

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

	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);
		}
	}
}

/*
 * We want to stop processing when we get to the end of the input.
 * (%option noyywrap is not used because if used then
 * some flex versions (eg: 2.5.35) generate code which causes
 * warnings by the Windows VC compiler).
 */

int DiamDictwrap(void) {
    return 1;
}

#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

