/* A Bison parser, made by GNU Bison 2.5.  */

/* Bison implementation for Yacc-like parsers in C
   
      Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
   
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

/* As a special exception, you may create a larger work that contains
   part or all of the Bison parser skeleton and distribute that work
   under terms of your choice, so long as that work isn't itself a
   parser generator using the skeleton or a modified version thereof
   as a parser skeleton.  Alternatively, if you modify or redistribute
   the parser skeleton itself, you may (at your option) remove this
   special exception, which will cause the skeleton and the resulting
   Bison output files to be licensed under the GNU General Public
   License without this special exception.
   
   This special exception was added by the Free Software Foundation in
   version 2.2 of Bison.  */

/* C LALR(1) parser skeleton written by Richard Stallman, by
   simplifying the original so-called "semantic" parser.  */

/* All symbols defined below should begin with yy or YY, to avoid
   infringing on user name space.  This should be done even for local
   variables, as they might otherwise be expanded by user macros.
   There are some unavoidable exceptions within include files to
   define necessary library symbols; they are noted "INFRINGES ON
   USER NAME SPACE" below.  */

/* Identify Bison output.  */
#define YYBISON 1

/* Bison version.  */
#define YYBISON_VERSION "2.5"

/* Skeleton name.  */
#define YYSKELETON_NAME "yacc.c"

/* Pure parsers.  */
#define YYPURE 0

/* Push parsers.  */
#define YYPUSH 0

/* Pull parsers.  */
#define YYPULL 1

/* Using locations.  */
#define YYLSP_NEEDED 0



/* Copy the first part of user declarations.  */

/* Line 268 of yacc.c  */
#line 1 "parser.y"

/*
 * Copyright (c) 2004-2005 Endace Technology Ltd, Hamilton, New Zealand.
 * All rights reserved.
 *
 * This source code is proprietary to Endace Technology Limited and no part
 * of it may be redistributed, published or disclosed except as outlined in
 * the written contract supplied with this product.
 *
 * $Id: parser.y 12693 2010-04-01 02:33:09Z wilson.zhu $
 */
#define YYSTYPE long

/* Tcpdump parser headers. */
#include "parser.h"
#include "parse_tree_node.h"

/* C Standard Library headers. */
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define VERBOSE 1


static PtNodePtr uRootNode = NULL; /* Contains root of the "standard" tree. */
static PtNodePtr uProtocolNode = NULL; /* Contains root of the "excluded protocol" tree. */

/* Declarations for routines generated by the flex scanner. */
extern void yy_scan_string(const char *str);
extern int yylex(void);

void yyerror(const char* error_msg);
//int yyparse(void);

void note_construction(const char* comment);
void note_progress(const char* comment);
void note_ip_address(const char* address);
void note_number(int number);
const char* get_token_string(void);
int get_token_number(void);

static qualifiers_t get_qualifiers(int value);
static void apply_qualifiers(PtNodePtr node, qualifiers_t quals);



/* Line 268 of yacc.c  */
#line 121 "parser.c"

/* Enabling traces.  */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif

/* Enabling verbose error messages.  */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif

/* Enabling the token table.  */
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE 0
#endif


/* Tokens.  */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
   /* Put the tokens into the symbol table, so that GDB and other debuggers
      know about them.  */
   enum yytokentype {
     TOK_ICMP = 258,
     TOK_IGRP = 259,
     TOK_IP = 260,
     TOK_TCP = 261,
     TOK_UDP = 262,
     TOK_AND = 263,
     TOK_COMMENT = 264,
     TOK_DST = 265,
     TOK_ERROR = 266,
     TOK_HOST = 267,
     TOK_NET = 268,
     TOK_NOT = 269,
     TOK_OR = 270,
     TOK_PORT = 271,
     TOK_SRC = 272,
     TOK_LEFT_PAREN = 273,
     TOK_RIGHT_PAREN = 274,
     TOK_LEFT_SQUARE = 275,
     TOK_RIGHT_SQUARE = 276,
     TOK_HOSTNAME = 277,
     TOK_NETNAME2 = 278,
     TOK_NETNAME3 = 279,
     TOK_NETLEN = 280,
     TOK_NUMBER = 281,
     TOK_TCP_FLAGS = 282,
     TOK_AMPERSAND = 283,
     TOK_EQUALS = 284,
     TOK_NOT_EQUALS = 285
   };
#endif
/* Tokens.  */
#define TOK_ICMP 258
#define TOK_IGRP 259
#define TOK_IP 260
#define TOK_TCP 261
#define TOK_UDP 262
#define TOK_AND 263
#define TOK_COMMENT 264
#define TOK_DST 265
#define TOK_ERROR 266
#define TOK_HOST 267
#define TOK_NET 268
#define TOK_NOT 269
#define TOK_OR 270
#define TOK_PORT 271
#define TOK_SRC 272
#define TOK_LEFT_PAREN 273
#define TOK_RIGHT_PAREN 274
#define TOK_LEFT_SQUARE 275
#define TOK_RIGHT_SQUARE 276
#define TOK_HOSTNAME 277
#define TOK_NETNAME2 278
#define TOK_NETNAME3 279
#define TOK_NETLEN 280
#define TOK_NUMBER 281
#define TOK_TCP_FLAGS 282
#define TOK_AMPERSAND 283
#define TOK_EQUALS 284
#define TOK_NOT_EQUALS 285




#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif


/* Copy the second part of user declarations.  */


/* Line 343 of yacc.c  */
#line 223 "parser.c"

#ifdef short
# undef short
#endif

#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif

#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#elif (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
typedef signed char yytype_int8;
#else
typedef short int yytype_int8;
#endif

#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
#endif

#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
#endif

#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
#  define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
#  define YYSIZE_T size_t
# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
#  define YYSIZE_T size_t
# else
#  define YYSIZE_T unsigned int
# endif
#endif

#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)

#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
#  if ENABLE_NLS
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
#   define YY_(msgid) dgettext ("bison-runtime", msgid)
#  endif
# endif
# ifndef YY_
#  define YY_(msgid) msgid
# endif
#endif

/* Suppress unused-variable warnings by "using" E.  */
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
#else
# define YYUSE(e) /* empty */
#endif

/* Identity function, used to suppress warnings about constant conditions.  */
#ifndef lint
# define YYID(n) (n)
#else
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static int
YYID (int yyi)
#else
static int
YYID (yyi)
    int yyi;
#endif
{
  return yyi;
}
#endif

#if ! defined yyoverflow || YYERROR_VERBOSE

/* The parser invokes alloca or malloc; define the necessary symbols.  */

# ifdef YYSTACK_USE_ALLOCA
#  if YYSTACK_USE_ALLOCA
#   ifdef __GNUC__
#    define YYSTACK_ALLOC __builtin_alloca
#   elif defined __BUILTIN_VA_ARG_INCR
#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
#   elif defined _AIX
#    define YYSTACK_ALLOC __alloca
#   elif defined _MSC_VER
#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
#    define alloca _alloca
#   else
#    define YYSTACK_ALLOC alloca
#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
#     ifndef EXIT_SUCCESS
#      define EXIT_SUCCESS 0
#     endif
#    endif
#   endif
#  endif
# endif

# ifdef YYSTACK_ALLOC
   /* Pacify GCC's `empty if-body' warning.  */
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
#  ifndef YYSTACK_ALLOC_MAXIMUM
    /* The OS might guarantee only one guard page at the bottom of the stack,
       and a page size can be as small as 4096 bytes.  So we cannot safely
       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
       to allow for a few compiler-allocated temporary stack slots.  */
#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
#  endif
# else
#  define YYSTACK_ALLOC YYMALLOC
#  define YYSTACK_FREE YYFREE
#  ifndef YYSTACK_ALLOC_MAXIMUM
#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
#  endif
#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
       && ! ((defined YYMALLOC || defined malloc) \
	     && (defined YYFREE || defined free)))
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
#   ifndef EXIT_SUCCESS
#    define EXIT_SUCCESS 0
#   endif
#  endif
#  ifndef YYMALLOC
#   define YYMALLOC malloc
#   if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
#   endif
#  endif
#  ifndef YYFREE
#   define YYFREE free
#   if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
void free (void *); /* INFRINGES ON USER NAME SPACE */
#   endif
#  endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */


#if (! defined yyoverflow \
     && (! defined __cplusplus \
	 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))

/* A type that is properly aligned for any stack member.  */
union yyalloc
{
  yytype_int16 yyss_alloc;
  YYSTYPE yyvs_alloc;
};

/* The size of the maximum gap between one aligned stack and the next.  */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)

/* The size of an array large to enough to hold all stacks, each with
   N elements.  */
# define YYSTACK_BYTES(N) \
     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
      + YYSTACK_GAP_MAXIMUM)

# define YYCOPY_NEEDED 1

/* Relocate STACK from its old location to the new one.  The
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
   elements in the stack, and YYPTR gives the new location of the
   stack.  Advance YYPTR to a properly aligned location for the next
   stack.  */
# define YYSTACK_RELOCATE(Stack_alloc, Stack)				\
    do									\
      {									\
	YYSIZE_T yynewbytes;						\
	YYCOPY (&yyptr->Stack_alloc, Stack, yysize);			\
	Stack = &yyptr->Stack_alloc;					\
	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
	yyptr += yynewbytes / sizeof (*yyptr);				\
      }									\
    while (YYID (0))

#endif

#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from FROM to TO.  The source and destination do
   not overlap.  */
# ifndef YYCOPY
#  if defined __GNUC__ && 1 < __GNUC__
#   define YYCOPY(To, From, Count) \
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
#  else
#   define YYCOPY(To, From, Count)		\
      do					\
	{					\
	  YYSIZE_T yyi;				\
	  for (yyi = 0; yyi < (Count); yyi++)	\
	    (To)[yyi] = (From)[yyi];		\
	}					\
      while (YYID (0))
#  endif
# endif
#endif /* !YYCOPY_NEEDED */

/* YYFINAL -- State number of the termination state.  */
#define YYFINAL  10
/* YYLAST -- Last index in YYTABLE.  */
#define YYLAST   301

/* YYNTOKENS -- Number of terminals.  */
#define YYNTOKENS  31
/* YYNNTS -- Number of nonterminals.  */
#define YYNNTS  31
/* YYNRULES -- Number of rules.  */
#define YYNRULES  94
/* YYNRULES -- Number of states.  */
#define YYNSTATES  197

/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
#define YYUNDEFTOK  2
#define YYMAXUTOK   285

#define YYTRANSLATE(YYX)						\
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)

/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
static const yytype_uint8 yytranslate[] =
{
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
      25,    26,    27,    28,    29,    30
};

#if YYDEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
   YYRHS.  */
static const yytype_uint16 yyprhs[] =
{
       0,     0,     3,     4,     6,     8,    10,    12,    16,    20,
      24,    28,    30,    34,    38,    41,    44,    47,    51,    53,
      57,    61,    64,    67,    70,    74,    78,    79,    82,    86,
      87,    90,    92,    95,    99,   101,   106,   108,   112,   114,
     118,   122,   124,   126,   127,   130,   132,   135,   139,   141,
     146,   148,   152,   154,   158,   162,   164,   168,   174,   177,
     179,   183,   189,   192,   194,   196,   198,   199,   201,   203,
     207,   215,   225,   226,   228,   230,   232,   236,   240,   242,
     244,   246,   248,   252,   256,   264,   268,   270,   274,   278,
     280,   284,   290,   294,   296
};

/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
static const yytype_int8 yyrhs[] =
{
      32,     0,    -1,    -1,    11,    -1,    33,    -1,    34,    -1,
       9,    -1,     5,     8,    37,    -1,     5,     8,    35,    -1,
      34,    15,    34,    -1,    18,    34,    19,    -1,    36,    -1,
      36,     8,    35,    -1,    18,    35,    19,    -1,    14,     7,
      -1,    14,     6,    -1,    14,     4,    -1,    18,    36,    19,
      -1,    38,    -1,    38,    15,    37,    -1,    18,    37,    19,
      -1,     6,    45,    -1,     7,    40,    -1,     3,    39,    -1,
       5,     8,    35,    -1,    18,    38,    19,    -1,    -1,     8,
      39,    -1,    18,    39,    19,    -1,    -1,    14,    41,    -1,
      42,    -1,     8,    40,    -1,    18,    40,    19,    -1,    43,
      -1,    43,     8,    14,    41,    -1,    43,    -1,    43,    15,
      42,    -1,    44,    -1,    43,     8,    43,    -1,    18,    43,
      19,    -1,    53,    -1,    57,    -1,    -1,    14,    46,    -1,
      47,    -1,     8,    45,    -1,    18,    45,    19,    -1,    48,
      -1,    48,     8,    14,    46,    -1,    48,    -1,    48,    15,
      47,    -1,    51,    -1,    18,    49,    19,    -1,    18,    50,
      19,    -1,    48,    -1,    49,     8,    49,    -1,    18,    50,
      15,    50,    19,    -1,    14,    51,    -1,    48,    -1,    50,
      15,    50,    -1,    18,    49,     8,    49,    19,    -1,    14,
      51,    -1,    53,    -1,    57,    -1,    60,    -1,    -1,    17,
      -1,    10,    -1,    52,    54,    55,    -1,    52,    54,    18,
      55,     8,    55,    19,    -1,    18,    52,    54,    55,     8,
      52,    54,    55,    19,    -1,    -1,    12,    -1,    13,    -1,
      56,    -1,    56,    15,    55,    -1,    18,    55,    19,    -1,
      22,    -1,    23,    -1,    24,    -1,    25,    -1,    18,    56,
      19,    -1,    52,    16,    58,    -1,    52,    16,    18,    58,
       8,    58,    19,    -1,    18,    57,    19,    -1,    59,    -1,
      59,    15,    58,    -1,    18,    58,    19,    -1,    26,    -1,
      18,    59,    19,    -1,    27,    28,    59,    61,    59,    -1,
      18,    60,    19,    -1,    29,    -1,    30,    -1
};

/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
static const yytype_uint16 yyrline[] =
{
       0,    87,    87,    88,    93,    94,   101,   113,   124,   134,
     162,   170,   176,   185,   193,   204,   216,   229,   238,   245,
     273,   282,   293,   310,   321,   331,   341,   347,   355,   365,
     371,   382,   393,   401,   410,   417,   427,   434,   444,   451,
     463,   472,   479,   489,   494,   504,   515,   522,   530,   536,
     546,   553,   563,   570,   578,   587,   594,   607,   620,   632,
     640,   653,   666,   678,   685,   693,   703,   709,   717,   726,
     737,   755,   776,   782,   790,   799,   806,   819,   828,   843,
     864,   885,   910,   919,   933,   955,   964,   979,  1015,  1024,
    1034,  1043,  1054,  1063,  1070
};
#endif

#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
static const char *const yytname[] =
{
  "$end", "error", "$undefined", "TOK_ICMP", "TOK_IGRP", "TOK_IP",
  "TOK_TCP", "TOK_UDP", "TOK_AND", "TOK_COMMENT", "TOK_DST", "TOK_ERROR",
  "TOK_HOST", "TOK_NET", "TOK_NOT", "TOK_OR", "TOK_PORT", "TOK_SRC",
  "TOK_LEFT_PAREN", "TOK_RIGHT_PAREN", "TOK_LEFT_SQUARE",
  "TOK_RIGHT_SQUARE", "TOK_HOSTNAME", "TOK_NETNAME2", "TOK_NETNAME3",
  "TOK_NETLEN", "TOK_NUMBER", "TOK_TCP_FLAGS", "TOK_AMPERSAND",
  "TOK_EQUALS", "TOK_NOT_EQUALS", "$accept", "line", "comment_line",
  "tcpdump_rule", "protocol_reject_list", "single_protocol_reject",
  "protocol_list", "protocol_tree", "icmp_tree", "udp_tree",
  "udp_reject_tree", "udp_accept_tree", "udp_expression", "udp_clause",
  "tcp_tree", "tcp_reject_tree", "tcp_accept_tree", "tcp_expression",
  "tcp_and_expression", "tcp_or_expression", "tcp_clause", "qualifiers",
  "host_primitive", "host_keyword", "host_list", "single_host",
  "port_primitive", "port_list", "number", "tcp_flags_primitive",
  "tcp_flags_relop", 0
};
#endif

# ifdef YYPRINT
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
   token YYLEX-NUM.  */
static const yytype_uint16 yytoknum[] =
{
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
     285
};
# endif

/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
static const yytype_uint8 yyr1[] =
{
       0,    31,    32,    32,    32,    32,    33,    34,    34,    34,
      34,    35,    35,    35,    36,    36,    36,    36,    37,    37,
      37,    38,    38,    38,    38,    38,    39,    39,    39,    40,
      40,    40,    40,    40,    41,    41,    42,    42,    43,    43,
      43,    44,    44,    45,    45,    45,    45,    45,    46,    46,
      47,    47,    48,    48,    48,    49,    49,    49,    49,    50,
      50,    50,    50,    51,    51,    51,    52,    52,    52,    53,
      53,    53,    54,    54,    54,    55,    55,    55,    56,    56,
      56,    56,    56,    57,    57,    57,    58,    58,    58,    59,
      59,    60,    60,    61,    61
};

/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
static const yytype_uint8 yyr2[] =
{
       0,     2,     0,     1,     1,     1,     1,     3,     3,     3,
       3,     1,     3,     3,     2,     2,     2,     3,     1,     3,
       3,     2,     2,     2,     3,     3,     0,     2,     3,     0,
       2,     1,     2,     3,     1,     4,     1,     3,     1,     3,
       3,     1,     1,     0,     2,     1,     2,     3,     1,     4,
       1,     3,     1,     3,     3,     1,     3,     5,     2,     1,
       3,     5,     2,     1,     1,     1,     0,     1,     1,     3,
       7,     9,     0,     1,     1,     1,     3,     3,     1,     1,
       1,     1,     3,     3,     7,     3,     1,     3,     3,     1,
       3,     5,     3,     1,     1
};

/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
   Performed when YYTABLE doesn't specify something else to do.  Zero
   means the default is an error.  */
static const yytype_uint8 yydefact[] =
{
       2,     0,     6,     3,     0,     0,     4,     5,     0,     0,
       1,     0,    26,     0,    66,    66,     0,     0,     8,    11,
       7,    18,    10,     9,    26,    26,    23,     0,    66,    68,
      66,    67,    66,     0,    21,    45,    50,    52,    72,    63,
      64,    65,    66,    66,    66,    22,    31,    36,    38,    41,
      42,    16,    15,    14,     0,     0,     0,     0,     0,     0,
      27,     0,     0,    24,    46,    66,    44,    48,    66,    66,
       0,    50,     0,     0,    72,    64,    65,     0,    66,    73,
      74,     0,     0,    32,    66,    30,    34,     0,     0,    42,
      66,    66,    13,    17,    20,    25,    12,     0,    19,    28,
      66,    66,    55,     0,    52,     0,     0,    47,    66,    53,
      66,    54,     0,    85,    92,     0,    89,     0,    51,     0,
      83,    86,     0,    78,    79,    80,    81,    69,    75,     0,
      66,    33,    40,    39,    37,    66,    58,    66,    66,    66,
      66,    66,    55,    56,    66,    66,    59,    60,    69,     0,
      93,    94,     0,     0,     0,    86,     0,     0,     0,    75,
       0,    66,    66,    72,     0,     0,    49,     0,     0,    58,
      62,    66,    90,    91,     0,     0,    88,    87,     0,     0,
      77,    82,    76,    35,     0,     0,    61,    57,    72,     0,
       0,     0,     0,    84,    70,     0,    71
};

/* YYDEFGOTO[NTERM-NUM].  */
static const yytype_int16 yydefgoto[] =
{
      -1,     5,     6,     7,    54,    19,    56,    21,    26,    45,
      85,    46,    47,    48,    70,    66,    35,   102,    72,    73,
      37,    38,    39,    82,   127,   128,    40,   120,   121,    41,
     152
};

/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
   STATE-NUM.  */
#define YYPACT_NINF -116
static const yytype_int16 yypact[] =
{
     177,     4,  -116,  -116,    18,    15,  -116,    67,   223,    24,
    -116,    18,   120,    13,   145,   161,   144,   223,  -116,   111,
    -116,   106,  -116,    67,   120,   120,  -116,    50,   145,  -116,
     115,  -116,   173,   137,  -116,  -116,   239,  -116,    32,  -116,
    -116,  -116,   161,   167,   230,  -116,  -116,   217,  -116,  -116,
    -116,  -116,  -116,  -116,   180,    77,   220,    87,    50,   228,
    -116,   242,    50,  -116,  -116,   179,  -116,   267,   115,   173,
     243,   237,    90,   204,    32,   257,   258,   118,   115,  -116,
    -116,   190,   233,  -116,   167,  -116,   270,   260,     3,   257,
     167,   167,  -116,  -116,  -116,  -116,  -116,   228,  -116,  -116,
     197,   179,   265,   268,   266,    93,   252,  -116,   184,  -116,
     195,  -116,   233,  -116,  -116,   118,  -116,   138,  -116,   224,
    -116,   269,   241,  -116,  -116,  -116,  -116,  -116,   271,   103,
     156,  -116,  -116,   275,  -116,   200,   266,   115,   184,   195,
     197,   179,  -116,   277,   197,   179,  -116,   272,   280,   273,
    -116,  -116,   118,   224,   116,   253,   224,   241,   133,   254,
     241,   167,   200,    32,   257,   258,  -116,   135,   255,  -116,
    -116,   226,  -116,  -116,   274,   224,  -116,  -116,   276,   241,
    -116,  -116,  -116,  -116,   278,   241,  -116,  -116,   191,   279,
     281,   280,   241,  -116,  -116,   282,  -116
};

/* YYPGOTO[NTERM-NUM].  */
static const yytype_int16 yypgoto[] =
{
    -116,  -116,  -116,   249,     8,     9,     6,    -8,   196,    61,
     128,   199,   -38,  -116,    46,   154,   218,    19,   -45,    -2,
     -60,   -31,   -12,   -72,  -102,  -115,   -15,   -94,   -58,   -28,
    -116
};

/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
   positive, shift that token.  If negative, reduce the rule which
   number is the opposite.  If YYTABLE_NINF, syntax error.  */
#define YYTABLE_NINF -63
static const yytype_int16 yytable[] =
{
      50,    74,   112,    49,    76,    86,    88,   159,   104,    57,
     148,    90,     8,    74,    20,    10,    18,    75,    91,   117,
     158,    27,   132,     1,   105,   154,    55,    50,    50,    89,
      49,    49,    49,    36,    74,    63,     4,    76,    74,    11,
     136,    76,   159,    22,    79,    80,   129,    36,    81,    67,
      75,    71,   133,    74,    75,   178,   105,   149,   182,   174,
      34,   155,   177,   143,    16,    98,    96,   106,    62,    89,
      74,    55,    49,    76,    64,    50,    50,   190,    49,    49,
     169,   189,    11,   191,   170,    58,    75,    67,    71,    57,
     195,   185,   133,   167,   173,   155,    93,    36,   108,   106,
     105,   138,    59,    83,   163,    87,    95,   165,   147,   109,
      74,    90,   109,    76,    74,    50,   192,    76,    49,    58,
     164,    59,   132,    86,   175,    29,    75,   142,    24,   146,
      75,   184,    31,    65,   165,   176,   115,   168,    25,   106,
     188,   179,    33,   108,   116,   -43,    50,   164,    51,    49,
      52,    53,   180,    28,   186,    29,    67,   142,   146,    30,
     -43,   -29,    31,    32,   -43,    77,    29,   150,   151,    42,
     161,    29,    33,    31,    84,    43,   -29,    29,    31,    44,
     -29,    28,     1,    29,    31,    84,     2,    68,     3,    29,
      31,    69,   -43,   100,    29,     4,    31,   101,   140,    92,
      33,    31,   141,    79,    80,    29,    33,    29,   119,   144,
      29,    33,    31,   145,    31,   135,   116,    31,   162,   110,
      60,    61,    33,   111,    33,    90,    12,    33,    13,    14,
      15,    12,    91,    13,    14,    15,    29,    16,    42,    94,
      29,    17,   153,    31,    43,   -55,    97,    31,    44,   -29,
     116,   122,    78,     9,    78,   123,   124,   125,   126,   157,
      23,    99,   107,   123,   124,   125,   126,   139,   156,   160,
     110,   111,   172,   181,   187,   103,   113,   114,   130,   131,
     -59,   -62,   137,    90,   156,   108,   160,   110,   171,   183,
     134,   166,   172,   176,    81,   180,   118,     0,   193,     0,
     194,   196
};

#define yypact_value_is_default(yystate) \
  ((yystate) == (-116))

#define yytable_value_is_error(yytable_value) \
  YYID (0)

static const yytype_int16 yycheck[] =
{
      15,    32,    74,    15,    32,    43,    44,   122,    68,    17,
     112,     8,     8,    44,     8,     0,     8,    32,    15,    77,
     122,     8,    19,     5,    69,   119,    17,    42,    43,    44,
      42,    43,    44,    14,    65,    27,    18,    65,    69,    15,
     100,    69,   157,    19,    12,    13,    84,    28,    16,    30,
      65,    32,    90,    84,    69,   157,   101,   115,   160,   153,
      14,   119,   156,   108,    14,    59,    58,    69,    18,    84,
     101,    62,    84,   101,    28,    90,    91,   179,    90,    91,
     140,   175,    15,   185,   144,     8,   101,    68,    69,    97,
     192,   163,   130,   138,   152,   153,    19,    78,     8,   101,
     145,     8,    15,    42,   135,    44,    19,   135,   110,    19,
     141,     8,    19,   141,   145,   130,   188,   145,   130,     8,
     135,    15,    19,   161,     8,    10,   141,   108,     8,   110,
     145,   162,    17,    18,   162,    19,    18,   139,    18,   141,
     171,     8,    27,     8,    26,     0,   161,   162,     4,   161,
       6,     7,    19,     8,    19,    10,   137,   138,   139,    14,
      15,     0,    17,    18,    19,    28,    10,    29,    30,     8,
      14,    10,    27,    17,    18,    14,    15,    10,    17,    18,
      19,     8,     5,    10,    17,    18,     9,    14,    11,    10,
      17,    18,    19,    14,    10,    18,    17,    18,    14,    19,
      27,    17,    18,    12,    13,    10,    27,    10,    18,    14,
      10,    27,    17,    18,    17,    18,    26,    17,    18,    15,
      24,    25,    27,    19,    27,     8,     3,    27,     5,     6,
       7,     3,    15,     5,     6,     7,    10,    14,     8,    19,
      10,    18,    18,    17,    14,     8,    18,    17,    18,    19,
      26,    18,    15,     4,    15,    22,    23,    24,    25,    18,
      11,    19,    19,    22,    23,    24,    25,    15,    15,    15,
      15,    19,    19,    19,    19,     8,    19,    19,     8,    19,
      15,    15,    14,     8,    15,     8,    15,    15,     8,   161,
      91,   137,    19,    19,    16,    19,    78,    -1,    19,    -1,
      19,    19
};

/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
   symbol of state STATE-NUM.  */
static const yytype_uint8 yystos[] =
{
       0,     5,     9,    11,    18,    32,    33,    34,     8,    34,
       0,    15,     3,     5,     6,     7,    14,    18,    35,    36,
      37,    38,    19,    34,     8,    18,    39,     8,     8,    10,
      14,    17,    18,    27,    45,    47,    48,    51,    52,    53,
      57,    60,     8,    14,    18,    40,    42,    43,    44,    53,
      57,     4,     6,     7,    35,    36,    37,    38,     8,    15,
      39,    39,    18,    35,    45,    18,    46,    48,    14,    18,
      45,    48,    49,    50,    52,    57,    60,    28,    15,    12,
      13,    16,    54,    40,    18,    41,    43,    40,    43,    57,
       8,    15,    19,    19,    19,    19,    35,    18,    37,    19,
      14,    18,    48,     8,    51,    49,    50,    19,     8,    19,
      15,    19,    54,    19,    19,    18,    26,    59,    47,    18,
      58,    59,    18,    22,    23,    24,    25,    55,    56,    43,
       8,    19,    19,    43,    42,    18,    51,    14,     8,    15,
      14,    18,    48,    49,    14,    18,    48,    50,    55,    59,
      29,    30,    61,    18,    58,    59,    15,    18,    55,    56,
      15,    14,    18,    52,    57,    60,    46,    49,    50,    51,
      51,     8,    19,    59,    58,     8,    19,    58,    55,     8,
      19,    19,    55,    41,    52,    54,    19,    19,    52,    58,
      55,    55,    54,    19,    19,    55,    19
};

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		(-2)
#define YYEOF		0

#define YYACCEPT	goto yyacceptlab
#define YYABORT		goto yyabortlab
#define YYERROR		goto yyerrorlab


/* Like YYERROR except do call yyerror.  This remains here temporarily
   to ease the transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  However,
   YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
   in Bison 2.4.2's NEWS entry, where a plan to phase it out is
   discussed.  */

#define YYFAIL		goto yyerrlab
#if defined YYFAIL
  /* This is here to suppress warnings from the GCC cpp's
     -Wunused-macros.  Normally we don't worry about that warning, but
     some users do, and we want to make it easy for users to remove
     YYFAIL uses, which will produce warnings from Bison 2.5.  */
#endif

#define YYRECOVERING()  (!!yyerrstatus)

#define YYBACKUP(Token, Value)					\
do								\
  if (yychar == YYEMPTY && yylen == 1)				\
    {								\
      yychar = (Token);						\
      yylval = (Value);						\
      YYPOPSTACK (1);						\
      goto yybackup;						\
    }								\
  else								\
    {								\
      yyerror (YY_("syntax error: cannot back up")); \
      YYERROR;							\
    }								\
while (YYID (0))


#define YYTERROR	1
#define YYERRCODE	256


/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
   If N is 0, then set CURRENT to the empty location which ends
   the previous symbol: RHS[0] (always defined).  */

#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N)				\
    do									\
      if (YYID (N))                                                    \
	{								\
	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;	\
	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;	\
	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;		\
	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;	\
	}								\
      else								\
	{								\
	  (Current).first_line   = (Current).last_line   =		\
	    YYRHSLOC (Rhs, 0).last_line;				\
	  (Current).first_column = (Current).last_column =		\
	    YYRHSLOC (Rhs, 0).last_column;				\
	}								\
    while (YYID (0))
#endif


/* This macro is provided for backward compatibility. */

#ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif


/* YYLEX -- calling `yylex' with the right arguments.  */

#ifdef YYLEX_PARAM
# define YYLEX yylex (YYLEX_PARAM)
#else
# define YYLEX yylex ()
#endif

/* Enable debugging if requested.  */
#if YYDEBUG

# ifndef YYFPRINTF
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
#  define YYFPRINTF fprintf
# endif

# define YYDPRINTF(Args)			\
do {						\
  if (yydebug)					\
    YYFPRINTF Args;				\
} while (YYID (0))

# define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
do {									  \
  if (yydebug)								  \
    {									  \
      YYFPRINTF (stderr, "%s ", Title);					  \
      yy_symbol_print (stderr,						  \
		  Type, Value); \
      YYFPRINTF (stderr, "\n");						  \
    }									  \
} while (YYID (0))


/*--------------------------------.
| Print this symbol on YYOUTPUT.  |
`--------------------------------*/

/*ARGSUSED*/
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
#else
static void
yy_symbol_value_print (yyoutput, yytype, yyvaluep)
    FILE *yyoutput;
    int yytype;
    YYSTYPE const * const yyvaluep;
#endif
{
  if (!yyvaluep)
    return;
# ifdef YYPRINT
  if (yytype < YYNTOKENS)
    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# else
  YYUSE (yyoutput);
# endif
  switch (yytype)
    {
      default:
	break;
    }
}


/*--------------------------------.
| Print this symbol on YYOUTPUT.  |
`--------------------------------*/

#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
#else
static void
yy_symbol_print (yyoutput, yytype, yyvaluep)
    FILE *yyoutput;
    int yytype;
    YYSTYPE const * const yyvaluep;
#endif
{
  if (yytype < YYNTOKENS)
    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
  else
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);

  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
  YYFPRINTF (yyoutput, ")");
}

/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included).                                                   |
`------------------------------------------------------------------*/

#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
#else
static void
yy_stack_print (yybottom, yytop)
    yytype_int16 *yybottom;
    yytype_int16 *yytop;
#endif
{
  YYFPRINTF (stderr, "Stack now");
  for (; yybottom <= yytop; yybottom++)
    {
      int yybot = *yybottom;
      YYFPRINTF (stderr, " %d", yybot);
    }
  YYFPRINTF (stderr, "\n");
}

# define YY_STACK_PRINT(Bottom, Top)				\
do {								\
  if (yydebug)							\
    yy_stack_print ((Bottom), (Top));				\
} while (YYID (0))


/*------------------------------------------------.
| Report that the YYRULE is going to be reduced.  |
`------------------------------------------------*/

#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static void
yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
#else
static void
yy_reduce_print (yyvsp, yyrule)
    YYSTYPE *yyvsp;
    int yyrule;
#endif
{
  int yynrhs = yyr2[yyrule];
  int yyi;
  unsigned long int yylno = yyrline[yyrule];
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
	     yyrule - 1, yylno);
  /* The symbols being reduced.  */
  for (yyi = 0; yyi < yynrhs; yyi++)
    {
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
		       &(yyvsp[(yyi + 1) - (yynrhs)])
		       		       );
      YYFPRINTF (stderr, "\n");
    }
}

# define YY_REDUCE_PRINT(Rule)		\
do {					\
  if (yydebug)				\
    yy_reduce_print (yyvsp, Rule); \
} while (YYID (0))

/* Nonzero means print parse trace.  It is left uninitialized so that
   multiple parsers can coexist.  */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */


/* YYINITDEPTH -- initial size of the parser's stacks.  */
#ifndef	YYINITDEPTH
# define YYINITDEPTH 200
#endif

/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
   if the built-in stack extension method is used).

   Do not make this value too large; the results are undefined if
   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
   evaluated with infinite-precision integer arithmetic.  */

#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif


#if YYERROR_VERBOSE

# ifndef yystrlen
#  if defined __GLIBC__ && defined _STRING_H
#   define yystrlen strlen
#  else
/* Return the length of YYSTR.  */
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static YYSIZE_T
yystrlen (const char *yystr)
#else
static YYSIZE_T
yystrlen (yystr)
    const char *yystr;
#endif
{
  YYSIZE_T yylen;
  for (yylen = 0; yystr[yylen]; yylen++)
    continue;
  return yylen;
}
#  endif
# endif

# ifndef yystpcpy
#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
#   define yystpcpy stpcpy
#  else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
   YYDEST.  */
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static char *
yystpcpy (char *yydest, const char *yysrc)
#else
static char *
yystpcpy (yydest, yysrc)
    char *yydest;
    const char *yysrc;
#endif
{
  char *yyd = yydest;
  const char *yys = yysrc;

  while ((*yyd++ = *yys++) != '\0')
    continue;

  return yyd - 1;
}
#  endif
# endif

# ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
   quotes and backslashes, so that it's suitable for yyerror.  The
   heuristic is that double-quoting is unnecessary unless the string
   contains an apostrophe, a comma, or backslash (other than
   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
   null, do not copy; instead, return the length of what the result
   would have been.  */
static YYSIZE_T
yytnamerr (char *yyres, const char *yystr)
{
  if (*yystr == '"')
    {
      YYSIZE_T yyn = 0;
      char const *yyp = yystr;

      for (;;)
	switch (*++yyp)
	  {
	  case '\'':
	  case ',':
	    goto do_not_strip_quotes;

	  case '\\':
	    if (*++yyp != '\\')
	      goto do_not_strip_quotes;
	    /* Fall through.  */
	  default:
	    if (yyres)
	      yyres[yyn] = *yyp;
	    yyn++;
	    break;

	  case '"':
	    if (yyres)
	      yyres[yyn] = '\0';
	    return yyn;
	  }
    do_not_strip_quotes: ;
    }

  if (! yyres)
    return yystrlen (yystr);

  return yystpcpy (yyres, yystr) - yyres;
}
# endif

/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
   about the unexpected token YYTOKEN for the state stack whose top is
   YYSSP.

   Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
   not large enough to hold the message.  In that case, also set
   *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
   required number of bytes is too large to store.  */
static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
                yytype_int16 *yyssp, int yytoken)
{
  YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
  YYSIZE_T yysize = yysize0;
  YYSIZE_T yysize1;
  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  /* Internationalized format string. */
  const char *yyformat = 0;
  /* Arguments of yyformat. */
  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
  /* Number of reported tokens (one for the "unexpected", one per
     "expected"). */
  int yycount = 0;

  /* There are many possibilities here to consider:
     - Assume YYFAIL is not used.  It's too flawed to consider.  See
       <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
       for details.  YYERROR is fine as it does not invoke this
       function.
     - If this state is a consistent state with a default action, then
       the only way this function was invoked is if the default action
       is an error action.  In that case, don't check for expected
       tokens because there are none.
     - The only way there can be no lookahead present (in yychar) is if
       this state is a consistent state with a default action.  Thus,
       detecting the absence of a lookahead is sufficient to determine
       that there is no unexpected or expected token to report.  In that
       case, just report a simple "syntax error".
     - Don't assume there isn't a lookahead just because this state is a
       consistent state with a default action.  There might have been a
       previous inconsistent state, consistent state with a non-default
       action, or user semantic action that manipulated yychar.
     - Of course, the expected token list depends on states to have
       correct lookahead information, and it depends on the parser not
       to perform extra reductions after fetching a lookahead from the
       scanner and before detecting a syntax error.  Thus, state merging
       (from LALR or IELR) and default reductions corrupt the expected
       token list.  However, the list is correct for canonical LR with
       one exception: it will still contain any token that will not be
       accepted due to an error action in a later state.
  */
  if (yytoken != YYEMPTY)
    {
      int yyn = yypact[*yyssp];
      yyarg[yycount++] = yytname[yytoken];
      if (!yypact_value_is_default (yyn))
        {
          /* Start YYX at -YYN if negative to avoid negative indexes in
             YYCHECK.  In other words, skip the first -YYN actions for
             this state because they are default actions.  */
          int yyxbegin = yyn < 0 ? -yyn : 0;
          /* Stay within bounds of both yycheck and yytname.  */
          int yychecklim = YYLAST - yyn + 1;
          int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
          int yyx;

          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
                && !yytable_value_is_error (yytable[yyx + yyn]))
              {
                if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
                  {
                    yycount = 1;
                    yysize = yysize0;
                    break;
                  }
                yyarg[yycount++] = yytname[yyx];
                yysize1 = yysize + yytnamerr (0, yytname[yyx]);
                if (! (yysize <= yysize1
                       && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
                  return 2;
                yysize = yysize1;
              }
        }
    }

  switch (yycount)
    {
# define YYCASE_(N, S)                      \
      case N:                               \
        yyformat = S;                       \
      break
      YYCASE_(0, YY_("syntax error"));
      YYCASE_(1, YY_("syntax error, unexpected %s"));
      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
      YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
      YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
# undef YYCASE_
    }

  yysize1 = yysize + yystrlen (yyformat);
  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
    return 2;
  yysize = yysize1;

  if (*yymsg_alloc < yysize)
    {
      *yymsg_alloc = 2 * yysize;
      if (! (yysize <= *yymsg_alloc
             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
      return 1;
    }

  /* Avoid sprintf, as that infringes on the user's name space.
     Don't have undefined behavior even if the translation
     produced a string with the wrong number of "%s"s.  */
  {
    char *yyp = *yymsg;
    int yyi = 0;
    while ((*yyp = *yyformat) != '\0')
      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
        {
          yyp += yytnamerr (yyp, yyarg[yyi++]);
          yyformat += 2;
        }
      else
        {
          yyp++;
          yyformat++;
        }
  }
  return 0;
}
#endif /* YYERROR_VERBOSE */

/*-----------------------------------------------.
| Release the memory associated to this symbol.  |
`-----------------------------------------------*/

/*ARGSUSED*/
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
#else
static void
yydestruct (yymsg, yytype, yyvaluep)
    const char *yymsg;
    int yytype;
    YYSTYPE *yyvaluep;
#endif
{
  YYUSE (yyvaluep);

  if (!yymsg)
    yymsg = "Deleting";
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);

  switch (yytype)
    {

      default:
	break;
    }
}


/* Prevent warnings from -Wmissing-prototypes.  */
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */


/* The lookahead symbol.  */
int yychar;

/* The semantic value of the lookahead symbol.  */
YYSTYPE yylval;

/* Number of syntax errors so far.  */
int yynerrs;


/*----------.
| yyparse.  |
`----------*/

#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
int
yyparse (void *YYPARSE_PARAM)
#else
int
yyparse (YYPARSE_PARAM)
    void *YYPARSE_PARAM;
#endif
#else /* ! YYPARSE_PARAM */
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
int
yyparse (void)
#else
int
yyparse ()

#endif
#endif
{
    int yystate;
    /* Number of tokens to shift before error messages enabled.  */
    int yyerrstatus;

    /* The stacks and their tools:
       `yyss': related to states.
       `yyvs': related to semantic values.

       Refer to the stacks thru separate pointers, to allow yyoverflow
       to reallocate them elsewhere.  */

    /* The state stack.  */
    yytype_int16 yyssa[YYINITDEPTH];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;

    /* The semantic value stack.  */
    YYSTYPE yyvsa[YYINITDEPTH];
    YYSTYPE *yyvs;
    YYSTYPE *yyvsp;

    YYSIZE_T yystacksize;

  int yyn;
  int yyresult;
  /* Lookahead token as an internal (translated) token number.  */
  int yytoken;
  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;

#if YYERROR_VERBOSE
  /* Buffer for error messages, and its allocated size.  */
  char yymsgbuf[128];
  char *yymsg = yymsgbuf;
  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif

#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))

  /* The number of symbols on the RHS of the reduced rule.
     Keep to zero when no symbol should be popped.  */
  int yylen = 0;

  yytoken = 0;
  yyss = yyssa;
  yyvs = yyvsa;
  yystacksize = YYINITDEPTH;

  YYDPRINTF ((stderr, "Starting parse\n"));

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY; /* Cause a token to be read.  */

  /* Initialize stack pointers.
     Waste one element of value and location stack
     so that they stay on the same level as the state stack.
     The wasted elements are never initialized.  */
  yyssp = yyss;
  yyvsp = yyvs;

  goto yysetstate;

/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate.  |
`------------------------------------------------------------*/
 yynewstate:
  /* In all cases, when you get here, the value and location stacks
     have just been pushed.  So pushing a state here evens the stacks.  */
  yyssp++;

 yysetstate:
  *yyssp = yystate;

  if (yyss + yystacksize - 1 <= yyssp)
    {
      /* Get the current used size of the three stacks, in elements.  */
      YYSIZE_T yysize = yyssp - yyss + 1;

#ifdef yyoverflow
      {
	/* Give user a chance to reallocate the stack.  Use copies of
	   these so that the &'s don't force the real ones into
	   memory.  */
	YYSTYPE *yyvs1 = yyvs;
	yytype_int16 *yyss1 = yyss;

	/* Each stack pointer address is followed by the size of the
	   data in use in that stack, in bytes.  This used to be a
	   conditional around just the two extra args, but that might
	   be undefined if yyoverflow is a macro.  */
	yyoverflow (YY_("memory exhausted"),
		    &yyss1, yysize * sizeof (*yyssp),
		    &yyvs1, yysize * sizeof (*yyvsp),
		    &yystacksize);

	yyss = yyss1;
	yyvs = yyvs1;
      }
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
      goto yyexhaustedlab;
# else
      /* Extend the stack our own way.  */
      if (YYMAXDEPTH <= yystacksize)
	goto yyexhaustedlab;
      yystacksize *= 2;
      if (YYMAXDEPTH < yystacksize)
	yystacksize = YYMAXDEPTH;

      {
	yytype_int16 *yyss1 = yyss;
	union yyalloc *yyptr =
	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
	if (! yyptr)
	  goto yyexhaustedlab;
	YYSTACK_RELOCATE (yyss_alloc, yyss);
	YYSTACK_RELOCATE (yyvs_alloc, yyvs);
#  undef YYSTACK_RELOCATE
	if (yyss1 != yyssa)
	  YYSTACK_FREE (yyss1);
      }
# endif
#endif /* no yyoverflow */

      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;

      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
		  (unsigned long int) yystacksize));

      if (yyss + yystacksize - 1 <= yyssp)
	YYABORT;
    }

  YYDPRINTF ((stderr, "Entering state %d\n", yystate));

  if (yystate == YYFINAL)
    YYACCEPT;

  goto yybackup;

/*-----------.
| yybackup.  |
`-----------*/
yybackup:

  /* Do appropriate processing given the current state.  Read a
     lookahead token if we need one and don't already have one.  */

  /* First try to decide what to do without reference to lookahead token.  */
  yyn = yypact[yystate];
  if (yypact_value_is_default (yyn))
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
  if (yychar == YYEMPTY)
    {
      YYDPRINTF ((stderr, "Reading a token: "));
      yychar = YYLEX;
    }

  if (yychar <= YYEOF)
    {
      yychar = yytoken = YYEOF;
      YYDPRINTF ((stderr, "Now at end of input.\n"));
    }
  else
    {
      yytoken = YYTRANSLATE (yychar);
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
    }

  /* If the proper action on seeing token YYTOKEN is to reduce or to
     detect an error, take that action.  */
  yyn += yytoken;
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (yytable_value_is_error (yyn))
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }

  /* Count tokens shifted since error; after three, turn off error
     status.  */
  if (yyerrstatus)
    yyerrstatus--;

  /* Shift the lookahead token.  */
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);

  /* Discard the shifted token.  */
  yychar = YYEMPTY;

  yystate = yyn;
  *++yyvsp = yylval;

  goto yynewstate;


/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state.  |
`-----------------------------------------------------------*/
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;


/*-----------------------------.
| yyreduce -- Do a reduction.  |
`-----------------------------*/
yyreduce:
  /* yyn is the number of a rule to reduce with.  */
  yylen = yyr2[yyn];

  /* If YYLEN is nonzero, implement the default value of the action:
     `$$ = $1'.

     Otherwise, the following line sets YYVAL to garbage.
     This behavior is undocumented and Bison
     users should not rely upon it.  Assigning to YYVAL
     unconditionally makes the parser a bit smaller, and it avoids a
     GCC warning that YYVAL may be used uninitialized.  */
  yyval = yyvsp[1-yylen];


  YY_REDUCE_PRINT (yyn);
  switch (yyn)
    {
        case 3:

/* Line 1806 of yacc.c  */
#line 89 "parser.y"
    {
			fprintf(stderr, "%s\n", get_token_string());
			exit(EXIT_FAILURE);
		}
    break;

  case 5:

/* Line 1806 of yacc.c  */
#line 95 "parser.y"
    {
			uRootNode = (PtNodePtr) (yyval);
			note_construction("Parsing completed successfully.");
		}
    break;

  case 6:

/* Line 1806 of yacc.c  */
#line 102 "parser.y"
    {
			const char* comment = get_token_string();

			note_construction("comment_line: TOK_COMMENT\n");
			note_progress(comment);
			note_progress("\n");

			free((char*) comment);
		}
    break;

  case 7:

/* Line 1806 of yacc.c  */
#line 114 "parser.y"
    { 
			PtNodePtr root_node = ptn_init(PTN_IP);

			note_construction("tcpdump_rule: TOK_IP TOK_AND protocol_list");

			ptn_add_child(root_node, (PtNodePtr) (yyvsp[(3) - (3)]));

			(yyval) = (YYSTYPE) root_node;
		}
    break;

  case 8:

/* Line 1806 of yacc.c  */
#line 126 "parser.y"
    {
			note_construction("tcpdump_rule: TOK_IP TOK_AND protocol_reject_list");

			assert(uProtocolNode == NULL);
			uProtocolNode = (PtNodePtr) (yyvsp[(3) - (3)]);
			(yyval) = (YYSTYPE) NULL;
		}
    break;

  case 9:

/* Line 1806 of yacc.c  */
#line 136 "parser.y"
    {
			PtNodePtr lhs = (PtNodePtr) (yyvsp[(1) - (3)]);
			PtNodePtr rhs = (PtNodePtr) (yyvsp[(3) - (3)]);

			note_construction("tcpdump_rule: tcpdump_rule TOK_OR tcpdump_rule");
			
			if (lhs && rhs)
			{
				ptn_add_sibling(rhs, lhs);
				(yyval) = (YYSTYPE) rhs;
			}
			else if (lhs)
			{
				(yyval) =(YYSTYPE) lhs;
			}
			else if (rhs)
			{
				(yyval) = (YYSTYPE) rhs;
			} 
			else
			{
				assert(0); /* FIXME: this might be a legitimate case - but it isn't covered by the test cases so far. */
				(yyval) = (YYSTYPE) NULL;
			}
		}
    break;

  case 10:

/* Line 1806 of yacc.c  */
#line 164 "parser.y"
    {
			note_construction("tcpdump_rule: TOK_LEFT_PAREN tcpdump_rule TOK_RIGHT_PAREN");
			(yyval) = (yyvsp[(2) - (3)]);
		}
    break;

  case 11:

/* Line 1806 of yacc.c  */
#line 171 "parser.y"
    {
			note_construction("protocol_reject_list: single_protocol_reject");
			(yyval) = (yyvsp[(1) - (1)]);
        }
    break;

  case 12:

/* Line 1806 of yacc.c  */
#line 178 "parser.y"
    {
			note_construction("protocol_reject_list: single_protocol_reject TOK_AND protocol_reject_list");
			
			ptn_add_sibling((PtNodePtr) (yyvsp[(3) - (3)]), (PtNodePtr) (yyvsp[(1) - (3)]));
			(yyval) = (yyvsp[(3) - (3)]);
		}
    break;

  case 13:

/* Line 1806 of yacc.c  */
#line 187 "parser.y"
    {
			note_construction("protocol_reject_list: TOK_LEFT_PAREN protocol_reject_list TOK_RIGHT_PAREN");
			(yyval) = (yyvsp[(2) - (3)]);
		}
    break;

  case 14:

/* Line 1806 of yacc.c  */
#line 194 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_PROTOCOL);
			
			note_construction("single_protocol_reject: TOK_NOT TOK_UDP");

			ptn_set_protocol(node, IPPROTO_UDP);

			(yyval) = (YYSTYPE) node;
		}
    break;

  case 15:

/* Line 1806 of yacc.c  */
#line 206 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_PROTOCOL);
			
			note_construction("single_protocol_reject: TOK_NOT TOK_TCP");

			ptn_set_protocol(node, IPPROTO_TCP);

			(yyval) = (YYSTYPE) node;
		}
    break;

  case 16:

/* Line 1806 of yacc.c  */
#line 218 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_PROTOCOL);
			
			note_construction("single_protocol_reject: TOK_NOT TOK_IGRP");

			/* IGRP uses IP datagrams with IP protocol 9 (IGP) [http://www.cisco.com/warp/public/103/5.html]. */
			ptn_set_protocol(node, IPPROTO_IGRP); 

			(yyval) = (YYSTYPE) node;
		}
    break;

  case 17:

/* Line 1806 of yacc.c  */
#line 231 "parser.y"
    {
			note_construction("single_protocol_reject: TOK_LEFT_PAREN single_protocol_reject TOK_RIGHT_PAREN");
			
			(yyval) = (yyvsp[(2) - (3)]);
		}
    break;

  case 18:

/* Line 1806 of yacc.c  */
#line 239 "parser.y"
    {
			note_construction("protocol_list: protocol_tree");

			(yyval) = (yyvsp[(1) - (1)]);
		}
    break;

  case 19:

/* Line 1806 of yacc.c  */
#line 247 "parser.y"
    {
			PtNodePtr lhs = (PtNodePtr) (yyvsp[(1) - (3)]);
			PtNodePtr rhs = (PtNodePtr) (yyvsp[(3) - (3)]);

			note_construction("protocol_list: protocol_tree TOK_OR protocol_list");

			if (lhs && rhs)
			{
				ptn_add_sibling(rhs, lhs);
				(yyval) = (YYSTYPE) rhs;
			}
			else if (lhs)
			{
				(yyval) = (YYSTYPE) lhs;
			}
			else if (rhs)
			{
				(yyval) = (YYSTYPE) rhs;
			}
			else
			{
				assert(0);
				(yyval) = (YYSTYPE) NULL;
			}
		}
    break;

  case 20:

/* Line 1806 of yacc.c  */
#line 275 "parser.y"
    {
			note_construction("protocol_list: TOK_LEFT_PAREN protocol_list TOK_RIGHT_PAREN");
			
			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 21:

/* Line 1806 of yacc.c  */
#line 283 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_PROTOCOL);
			
			note_construction("protocol_tree: TOK_TCP tcp_tree");

			ptn_set_protocol(node, IPPROTO_TCP);
			ptn_add_child(node, (PtNodePtr) (yyvsp[(2) - (2)]));
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 22:

/* Line 1806 of yacc.c  */
#line 295 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_PROTOCOL);
			
			note_construction("protocol_tree: TOK_UDP udp_tree");

			ptn_set_protocol(node, IPPROTO_UDP);

			if (NULL != (void*) (yyvsp[(2) - (2)]))
			{
				ptn_add_child(node, (PtNodePtr) (yyvsp[(2) - (2)]));
			}

			(yyval) = (YYSTYPE) node;
		}
    break;

  case 23:

/* Line 1806 of yacc.c  */
#line 312 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_PROTOCOL);
			
			note_construction("protocol_tree: TOK_ICMP icmp_tree");

			ptn_set_protocol(node, IPPROTO_ICMP);
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 24:

/* Line 1806 of yacc.c  */
#line 323 "parser.y"
    {
			note_construction("protocol_tree: TOK_IP TOK_AND protocol_reject_list");

			assert(uProtocolNode == NULL);
			uProtocolNode = (PtNodePtr) (yyvsp[(3) - (3)]);
			(yyval) = (YYSTYPE) NULL;
		}
    break;

  case 25:

/* Line 1806 of yacc.c  */
#line 333 "parser.y"
    {
			note_construction("protocol_tree: TOK_LEFT_PAREN protocol_tree TOK_RIGHT_PAREN");

			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 26:

/* Line 1806 of yacc.c  */
#line 341 "parser.y"
    {
			note_construction("icmp_tree:");

			(yyval) = (YYSTYPE) NULL;
		}
    break;

  case 27:

/* Line 1806 of yacc.c  */
#line 349 "parser.y"
    {
			note_construction("icmp_tree: TOK_AND icmp_tree");

			(yyval) = (YYSTYPE) NULL;
		}
    break;

  case 28:

/* Line 1806 of yacc.c  */
#line 357 "parser.y"
    {
			note_construction("icmp_tree: TOK_LEFT_PAREN icmp_tree TOK_RIGHT_PAREN");

			(yyval) = (YYSTYPE) NULL;
		}
    break;

  case 29:

/* Line 1806 of yacc.c  */
#line 365 "parser.y"
    {
			note_construction("udp_tree:");

			(yyval) = (YYSTYPE) NULL;
		}
    break;

  case 30:

/* Line 1806 of yacc.c  */
#line 373 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_ANDNOT);

			note_construction("udp_tree: TOK_NOT udp_reject_tree");

			ptn_add_child(node, (PtNodePtr) (yyvsp[(2) - (2)]));
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 31:

/* Line 1806 of yacc.c  */
#line 384 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_OR);

			note_construction("udp_tree: udp_accept_tree");

			ptn_add_child(node, (PtNodePtr) (yyvsp[(1) - (1)]));
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 32:

/* Line 1806 of yacc.c  */
#line 395 "parser.y"
    {
			note_construction("udp_tree: TOK_AND udp_tree");

			(yyval) = (YYSTYPE) (yyvsp[(2) - (2)]);
		}
    break;

  case 33:

/* Line 1806 of yacc.c  */
#line 403 "parser.y"
    {
			note_construction("udp_tree: TOK_LEFT_PAREN udp_tree TOK_RIGHT_PAREN");

			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 34:

/* Line 1806 of yacc.c  */
#line 411 "parser.y"
    {
			note_construction("udp_reject_tree: udp_expression");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 35:

/* Line 1806 of yacc.c  */
#line 419 "parser.y"
    {
			note_construction("udp_reject_tree: udp_expression TOK_AND TOK_NOT udp_reject_tree");

			ptn_add_sibling((PtNodePtr) (yyvsp[(4) - (4)]), (PtNodePtr) (yyvsp[(1) - (4)]));
			(yyval) = (YYSTYPE) (yyvsp[(4) - (4)]);
		}
    break;

  case 36:

/* Line 1806 of yacc.c  */
#line 428 "parser.y"
    {
			note_construction("udp_accept_tree: udp_expression");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 37:

/* Line 1806 of yacc.c  */
#line 436 "parser.y"
    {
			note_construction("udp_accept_tree: udp_expression TOK_OR udp_accept_tree");

			ptn_add_sibling((PtNodePtr) (yyvsp[(3) - (3)]), (PtNodePtr) (yyvsp[(1) - (3)]));
			(yyval) = (YYSTYPE) (yyvsp[(3) - (3)]);
		}
    break;

  case 38:

/* Line 1806 of yacc.c  */
#line 445 "parser.y"
    {
			note_construction("udp_expression: udp_clause");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 39:

/* Line 1806 of yacc.c  */
#line 453 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_AND);

			note_construction("udp_expression: udp_expression TOK_AND udp_expression");

			ptn_add_child(node, (PtNodePtr) (yyvsp[(1) - (3)]));
			ptn_add_child(node, (PtNodePtr) (yyvsp[(2) - (3)]));
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 40:

/* Line 1806 of yacc.c  */
#line 465 "parser.y"
    {
			note_construction("udp_expression: TOK_LEFT_PAREN udp_expression TOK_RIGHT_PAREN");

			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 41:

/* Line 1806 of yacc.c  */
#line 473 "parser.y"
    {
			note_construction("udp_clause: host_primitive");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 42:

/* Line 1806 of yacc.c  */
#line 481 "parser.y"
    {
			note_construction("udp_clause: port_primitive");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 43:

/* Line 1806 of yacc.c  */
#line 489 "parser.y"
    {
			note_construction("tcp_tree:");
			(yyval) = (YYSTYPE) NULL;
        }
    break;

  case 44:

/* Line 1806 of yacc.c  */
#line 495 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_ANDNOT);

			note_construction("tcp_tree: TOK_NOT tcp_reject_tree");

			ptn_add_child(node, (PtNodePtr) (yyvsp[(2) - (2)]));
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 45:

/* Line 1806 of yacc.c  */
#line 506 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_OR);

			note_construction("tcp_tree: tcp_accept_tree");

			ptn_add_child(node, (PtNodePtr) (yyvsp[(1) - (1)]));
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 46:

/* Line 1806 of yacc.c  */
#line 517 "parser.y"
    {
			note_construction("tcp_tree: TOK_AND tcp_tree");
			(yyval) = (YYSTYPE) (yyvsp[(2) - (2)]);
		}
    break;

  case 47:

/* Line 1806 of yacc.c  */
#line 524 "parser.y"
    {
			note_construction("tcp_tree: TOK_LEFT_PAREN tcp_tree TOK_RIGHT_PAREN");
			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 48:

/* Line 1806 of yacc.c  */
#line 531 "parser.y"
    {
			note_construction("tcp_reject_tree: tcp_expression");
			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 49:

/* Line 1806 of yacc.c  */
#line 538 "parser.y"
    {
			note_construction("tcp_reject_tree: tcp_expression TOK_AND TOK_NOT tcp_reject_tree");

			ptn_add_sibling((PtNodePtr) (yyvsp[(4) - (4)]), (PtNodePtr) (yyvsp[(1) - (4)]));
			(yyval) = (YYSTYPE) (yyvsp[(4) - (4)]);
		}
    break;

  case 50:

/* Line 1806 of yacc.c  */
#line 547 "parser.y"
    {
			note_construction("tcp_accept_tree: tcp_expression");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 51:

/* Line 1806 of yacc.c  */
#line 555 "parser.y"
    {
			note_construction("tcp_accept_tree: tcp_expression TOK_OR tcp_accept_tree");

			ptn_add_sibling((PtNodePtr) (yyvsp[(3) - (3)]), (PtNodePtr) (yyvsp[(1) - (3)]));
			(yyval) = (YYSTYPE) (yyvsp[(3) - (3)]);
		}
    break;

  case 52:

/* Line 1806 of yacc.c  */
#line 564 "parser.y"
    {
			note_construction("tcp_expression: tcp_clause");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 53:

/* Line 1806 of yacc.c  */
#line 572 "parser.y"
    {
			note_construction("tcp_expression: TOK_LEFT_PAREN tcp_and_expression TOK_RIGHT_PAREN");

			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 54:

/* Line 1806 of yacc.c  */
#line 580 "parser.y"
    {
			note_construction("tcp_expression: TOK_LEFT_PAREN tcp_or_expression TOK_RIGHT_PAREN");

			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 55:

/* Line 1806 of yacc.c  */
#line 588 "parser.y"
    {
			note_construction("tcp_and_expression: tcp_clause");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 56:

/* Line 1806 of yacc.c  */
#line 596 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_AND);
			
			note_construction("tcp_and_expression: tcp_and_expression TOK_AND tcp_and_expression");
			
			ptn_add_child(node, (PtNodePtr) (yyvsp[(1) - (3)]));
			ptn_add_child(node, (PtNodePtr) (yyvsp[(3) - (3)]));
			
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 57:

/* Line 1806 of yacc.c  */
#line 609 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_OR);
			
			note_construction("tcp_and_expression: TOK_LEFT_PAREN tcp_or_expression TOK_OR tcp_or_expression TOK_RIGHT_PAREN");
			
			ptn_add_child(node, (PtNodePtr) (yyvsp[(2) - (5)]));
			ptn_add_child(node, (PtNodePtr) (yyvsp[(4) - (5)]));
			
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 58:

/* Line 1806 of yacc.c  */
#line 622 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_NOT);
			
			note_construction("tcp_and_expression: TOK_NOT tcp_clause");
			
			ptn_add_child(node, (PtNodePtr) (yyvsp[(2) - (2)]));
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 59:

/* Line 1806 of yacc.c  */
#line 634 "parser.y"
    {
			note_construction("tcp_or_expression: tcp_clause");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 60:

/* Line 1806 of yacc.c  */
#line 642 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_OR);
			
			note_construction("tcp_or_expression: tcp_or_expression TOK_OR tcp_or_expression");
			
			ptn_add_child(node, (PtNodePtr) (yyvsp[(1) - (3)]));
			ptn_add_child(node, (PtNodePtr) (yyvsp[(3) - (3)]));
			
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 61:

/* Line 1806 of yacc.c  */
#line 655 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_AND);
			
			note_construction("tcp_or_expression: TOK_LEFT_PAREN tcp_and_expression TOK_AND tcp_and_expression TOK_RIGHT_PAREN");
			
			ptn_add_child(node, (PtNodePtr) (yyvsp[(2) - (5)]));
			ptn_add_child(node, (PtNodePtr) (yyvsp[(4) - (5)]));
			
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 62:

/* Line 1806 of yacc.c  */
#line 668 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_NOT);
			
			note_construction("tcp_or_expression: TOK_NOT tcp_clause");
			
			ptn_add_child(node, (PtNodePtr) (yyvsp[(2) - (2)]));
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 63:

/* Line 1806 of yacc.c  */
#line 679 "parser.y"
    {
			note_construction("tcp_clause: host_primitive");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 64:

/* Line 1806 of yacc.c  */
#line 687 "parser.y"
    {
			note_construction("tcp_clause: port_primitive");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 65:

/* Line 1806 of yacc.c  */
#line 695 "parser.y"
    {
			note_construction("tcp_clause: tcp_flags_primitive");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 66:

/* Line 1806 of yacc.c  */
#line 703 "parser.y"
    {
			note_construction("qualifiers:");

			(yyval) = (YYSTYPE) (void*) 0;
		}
    break;

  case 67:

/* Line 1806 of yacc.c  */
#line 711 "parser.y"
    {
			note_construction("qualifiers: TOK_SRC");

			(yyval) = (YYSTYPE) (void*) TOK_SRC;
		}
    break;

  case 68:

/* Line 1806 of yacc.c  */
#line 719 "parser.y"
    {
			note_construction("qualifiers: TOK_DST");

			(yyval) = (YYSTYPE) (void*) TOK_DST;
		}
    break;

  case 69:

/* Line 1806 of yacc.c  */
#line 727 "parser.y"
    {
			qualifiers_t quals = get_qualifiers((int) (yyvsp[(1) - (3)]));
			
			note_construction("host_primitive: qualifiers host_keyword host_list");
			
			apply_qualifiers((PtNodePtr) (yyvsp[(3) - (3)]), quals);
			
			(yyval) = (YYSTYPE) (yyvsp[(3) - (3)]);
		}
    break;

  case 70:

/* Line 1806 of yacc.c  */
#line 739 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_AND);
			PtNodePtr lhs = (PtNodePtr) (yyvsp[(4) - (7)]);
			PtNodePtr rhs = (PtNodePtr) (yyvsp[(6) - (7)]);
			qualifiers_t quals = get_qualifiers((int) (yyvsp[(1) - (7)]));
			
			note_construction("host_primitive: qualifiers host_keyword TOK_LEFT_PAREN host_list TOK_AND host_list TOK_RIGHT_PAREN");
			
			apply_qualifiers(lhs, quals);
			apply_qualifiers(rhs, quals);
			ptn_add_child(node, lhs);
			ptn_add_child(node, rhs);
			
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 71:

/* Line 1806 of yacc.c  */
#line 757 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_AND);
			qualifiers_t lhs_quals = get_qualifiers((int) (yyvsp[(2) - (9)]));
			PtNodePtr lhs = (PtNodePtr) (yyvsp[(4) - (9)]);
			qualifiers_t rhs_quals = get_qualifiers((int) (yyvsp[(6) - (9)]));
			PtNodePtr rhs = (PtNodePtr) (yyvsp[(8) - (9)]);
			
			note_construction("host_primitive: TOK_LEFT_PAREN qualifiers host_keyword host_list TOK_AND qualifiers host_keyword host_list TOK_RIGHT_PAREN");

			apply_qualifiers(lhs, lhs_quals);
			apply_qualifiers(rhs, rhs_quals);
			ptn_add_child(node, lhs);
			ptn_add_child(node, rhs);
			
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 72:

/* Line 1806 of yacc.c  */
#line 776 "parser.y"
    {
			note_construction("host_keyword:");
			
			(yyval) = (YYSTYPE) (void*) 0;
		}
    break;

  case 73:

/* Line 1806 of yacc.c  */
#line 784 "parser.y"
    {
			note_construction("host_keyword: TOK_HOST");
			
			(yyval) = (YYSTYPE) (void*) TOK_HOST;
		}
    break;

  case 74:

/* Line 1806 of yacc.c  */
#line 792 "parser.y"
    {
			note_construction("host_keyword: TOK_NET");
			
			(yyval) = (YYSTYPE) (void*) TOK_NET;
		}
    break;

  case 75:

/* Line 1806 of yacc.c  */
#line 800 "parser.y"
    {
			note_construction("host_list: single_host");

			(yyval) = (YYSTYPE) (yyvsp[(1) - (1)]);
		}
    break;

  case 76:

/* Line 1806 of yacc.c  */
#line 808 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_OR);
			
			note_construction("host_list: single_host TOK_OR host_list");
			
			ptn_add_child(node, (PtNodePtr) (yyvsp[(1) - (3)]));
			ptn_add_child(node, (PtNodePtr) (yyvsp[(3) - (3)]));
			
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 77:

/* Line 1806 of yacc.c  */
#line 821 "parser.y"
    {
			note_construction("host_list: TOK_LEFT_PAREN host_list TOK_RIGHT_PAREN");

			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 78:

/* Line 1806 of yacc.c  */
#line 829 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_HOST);
			const char* address = (const char*) get_token_string();
			
			note_construction("single_host: TOK_HOSTNAME");
			note_ip_address(address);
			
			ptn_set_host(node, inet_addr(address), htonl(0xffffffff));
			
			free((char*) address);
			
			(yyval) = (YYSTYPE) node;
		}
    break;

  case 79:

/* Line 1806 of yacc.c  */
#line 845 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_HOST);
			const char* address = (const char*) get_token_string();
			char buffer[64];

			note_construction("single_host: TOK_NETNAME2");
			note_ip_address(address);
			strncpy(buffer, address, 32);
			free((char*) address);
			
			/* Add trailing bytes to make the netname look like a hostname. */
			strncat(buffer, ".0.0", 32);
			note_ip_address(buffer);
			
			ptn_set_host(node, inet_addr(buffer), htonl(0xffff0000));

			(yyval) = (YYSTYPE) node;
		}
    break;

  case 80:

/* Line 1806 of yacc.c  */
#line 866 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_HOST);
			const char* address = (const char*) get_token_string();
			char buffer[64];

			note_construction("single_host: TOK_NETNAME3");
			note_ip_address(address);
			strncpy(buffer, address, 32);
			free((char*) address);
			
			/* Add trailing byte to make the netname look like a hostname. */
			strncat(buffer, ".0", 64);
			note_ip_address(buffer);
			
			ptn_set_host(node, inet_addr(buffer), htonl(0xffffff00));

			(yyval) = (YYSTYPE) node;
		}
    break;

  case 81:

/* Line 1806 of yacc.c  */
#line 887 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_HOST);
			const char* address = (const char*) get_token_string();
			char buffer[64];
            char *saveptr = NULL;
	    char *net, *len;

			note_construction("single_host: TOK_NETLEN");
			note_ip_address(address);
			strncpy(buffer, address, 32);
			free((char*) address);
			
			/* separate the network and the mask length*/
            net = strtok_r(buffer, "/", &saveptr);
            len = strtok_r(NULL, "/", &saveptr);
			note_ip_address(net);
			note_number(atoi(len));

			ptn_set_host(node, inet_addr(net), htonl(0xffffffff << atoi(len)));

			(yyval) = (YYSTYPE) node;
		}
    break;

  case 82:

/* Line 1806 of yacc.c  */
#line 912 "parser.y"
    {
			note_construction("host_list: TOK_LEFT_PAREN single_host TOK_RIGHT_PAREN");

			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 83:

/* Line 1806 of yacc.c  */
#line 920 "parser.y"
    {
			PtNodePtr node = (PtNodePtr) (yyvsp[(3) - (3)]);
			qualifiers_t quals = get_qualifiers((int) (yyvsp[(1) - (3)]));

			note_construction("port_primitive: qualifiers TOK_PORT port_list");

			/* Apply qualifiers to all ports in the port list. */
			assert(quals != QUAL_INVALID);
			apply_qualifiers(node, quals);

			(yyval) = (YYSTYPE) (yyvsp[(3) - (3)]);
		}
    break;

  case 84:

/* Line 1806 of yacc.c  */
#line 935 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_AND);
			PtNodePtr lhs = (PtNodePtr) (yyvsp[(4) - (7)]);
			PtNodePtr rhs = (PtNodePtr) (yyvsp[(6) - (7)]);
			qualifiers_t quals = get_qualifiers((int) (yyvsp[(1) - (7)]));

			note_construction("port_primitive: qualifiers TOK_PORT TOK_LEFT_PAREN port_list TOK_AND port_list TOK_RIGHT_PAREN");

			/* Apply qualifiers to all ports in each port list. */
			assert(quals != QUAL_INVALID);
			apply_qualifiers(lhs, quals);
			apply_qualifiers(rhs, quals);

			/* Combine the port lists. */
			ptn_add_child(node, lhs);
			ptn_add_child(node, rhs);

			(yyval) = (YYSTYPE) node;
		}
    break;

  case 85:

/* Line 1806 of yacc.c  */
#line 957 "parser.y"
    {
			note_construction("port_primitive: TOK_LEFT_PAREN port_primitive TOK_RIGHT_PAREN");

			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 86:

/* Line 1806 of yacc.c  */
#line 965 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_PORT);
			uint16_t value = (uint16_t) (yyvsp[(1) - (1)]);

			note_construction("port_list: number");

			assert(0 <= (int) (yyvsp[(1) - (1)]));
			assert((int) (yyvsp[(1) - (1)]) <= UINT16_MAX);

			ptn_set_port(node, value);

			(yyval) = (YYSTYPE) node;
		}
    break;

  case 87:

/* Line 1806 of yacc.c  */
#line 981 "parser.y"
    {
			PtNodePtr lhs = ptn_init(PTN_PORT);
			PtNodePtr rhs = (PtNodePtr) (yyvsp[(3) - (3)]);
			uint16_t value = (uint16_t) (yyvsp[(1) - (3)]);

			note_construction("port_list: number TOK_OR port_list");

			assert(0 <= (int) (yyvsp[(1) - (3)]));
			assert((int) (yyvsp[(1) - (3)]) <= UINT16_MAX);
			ptn_set_port(lhs, value);

			if (ptn_get_type(rhs) == PTN_PORT)
			{
				/* Create OR node to tie them together. */
				PtNodePtr node = ptn_init(PTN_OR);
				
				ptn_add_child(node, lhs);
				ptn_add_child(node, rhs);
				
				(yyval) = (YYSTYPE) node;
			}
			else if (ptn_get_type(rhs) == PTN_OR)
			{
				/* Add new number to existing list. */
				ptn_add_child(rhs, lhs);
				
				(yyval) = (YYSTYPE) rhs;
			}
			else
			{
				assert(0);
			}
		}
    break;

  case 88:

/* Line 1806 of yacc.c  */
#line 1017 "parser.y"
    {
			note_construction("port_list: TOK_LEFT_PAREN port_list TOK_RIGHT_PAREN");

			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 89:

/* Line 1806 of yacc.c  */
#line 1025 "parser.y"
    {
			int port = get_token_number();
			
			note_construction("number: TOK_NUMBER");
			note_number(port);

			(yyval) = (YYSTYPE) port;
		}
    break;

  case 90:

/* Line 1806 of yacc.c  */
#line 1036 "parser.y"
    {
			note_construction("number: TOK_LEFT_PAREN number TOK_RIGHT_PAREN");

			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 91:

/* Line 1806 of yacc.c  */
#line 1044 "parser.y"
    {
			PtNodePtr node = ptn_init(PTN_TCP_FLAGS);

			note_construction("tcp_flags_primitive: TOK_TCP_FLAGS TOK_AMPERSAND number tcp_flags_relop number");

			ptn_set_tcp_flags(node, (uint8_t) (yyvsp[(3) - (5)]), (tcp_flag_op_t) (yyvsp[(4) - (5)]), (uint8_t) (yyvsp[(5) - (5)]));

			(yyval) = (YYSTYPE) node;
		}
    break;

  case 92:

/* Line 1806 of yacc.c  */
#line 1056 "parser.y"
    {
			note_construction("tcp_flags_primitive: TOK_LEFT_PAREN tcp_flags_primitive TOK_RIGHT_PAREN");

			(yyval) = (YYSTYPE) (yyvsp[(2) - (3)]);
		}
    break;

  case 93:

/* Line 1806 of yacc.c  */
#line 1064 "parser.y"
    {
			note_construction("tcp_flags_relop: TOK_EQUALS");

			(yyval) = (YYSTYPE) (void*) TCP_FLAG_OP_EQUALS;
		}
    break;

  case 94:

/* Line 1806 of yacc.c  */
#line 1072 "parser.y"
    {
			note_construction("tcp_flags_relop: TOK_NOT_EQUALS");

			(yyval) = (YYSTYPE) (void*) TCP_FLAG_OP_NOT_EQUALS;
		}
    break;



/* Line 1806 of yacc.c  */
#line 2904 "parser.c"
      default: break;
    }
  /* User semantic actions sometimes alter yychar, and that requires
     that yytoken be updated with the new translation.  We take the
     approach of translating immediately before every use of yytoken.
     One alternative is translating here after every semantic action,
     but that translation would be missed if the semantic action invokes
     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
     incorrect destructor might then be invoked immediately.  In the
     case of YYERROR or YYBACKUP, subsequent parser actions might lead
     to an incorrect destructor call or verbose syntax error message
     before the lookahead is translated.  */
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);

  YYPOPSTACK (yylen);
  yylen = 0;
  YY_STACK_PRINT (yyss, yyssp);

  *++yyvsp = yyval;

  /* Now `shift' the result of the reduction.  Determine what state
     that goes to, based on the state we popped back to and the rule
     number reduced by.  */

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTOKENS];

  goto yynewstate;


/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
  /* Make sure we have latest lookahead translation.  See comments at
     user semantic actions for why this is necessary.  */
  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);

  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;
#if ! YYERROR_VERBOSE
      yyerror (YY_("syntax error"));
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
                                        yyssp, yytoken)
      {
        char const *yymsgp = YY_("syntax error");
        int yysyntax_error_status;
        yysyntax_error_status = YYSYNTAX_ERROR;
        if (yysyntax_error_status == 0)
          yymsgp = yymsg;
        else if (yysyntax_error_status == 1)
          {
            if (yymsg != yymsgbuf)
              YYSTACK_FREE (yymsg);
            yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
            if (!yymsg)
              {
                yymsg = yymsgbuf;
                yymsg_alloc = sizeof yymsgbuf;
                yysyntax_error_status = 2;
              }
            else
              {
                yysyntax_error_status = YYSYNTAX_ERROR;
                yymsgp = yymsg;
              }
          }
        yyerror (yymsgp);
        if (yysyntax_error_status == 2)
          goto yyexhaustedlab;
      }
# undef YYSYNTAX_ERROR
#endif
    }



  if (yyerrstatus == 3)
    {
      /* If just tried and failed to reuse lookahead token after an
	 error, discard it.  */

      if (yychar <= YYEOF)
	{
	  /* Return failure if at end of input.  */
	  if (yychar == YYEOF)
	    YYABORT;
	}
      else
	{
	  yydestruct ("Error: discarding",
		      yytoken, &yylval);
	  yychar = YYEMPTY;
	}
    }

  /* Else will try to reuse lookahead token after shifting the error
     token.  */
  goto yyerrlab1;


/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR.  |
`---------------------------------------------------*/
yyerrorlab:

  /* Pacify compilers like GCC when the user code never invokes
     YYERROR and the label yyerrorlab therefore never appears in user
     code.  */
  if (/*CONSTCOND*/ 0)
     goto yyerrorlab;

  /* Do not reclaim the symbols of the rule which action triggered
     this YYERROR.  */
  YYPOPSTACK (yylen);
  yylen = 0;
  YY_STACK_PRINT (yyss, yyssp);
  yystate = *yyssp;
  goto yyerrlab1;


/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
`-------------------------------------------------------------*/
yyerrlab1:
  yyerrstatus = 3;	/* Each real token shifted decrements this.  */

  for (;;)
    {
      yyn = yypact[yystate];
      if (!yypact_value_is_default (yyn))
	{
	  yyn += YYTERROR;
	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
	    {
	      yyn = yytable[yyn];
	      if (0 < yyn)
		break;
	    }
	}

      /* Pop the current state because it cannot handle the error token.  */
      if (yyssp == yyss)
	YYABORT;


      yydestruct ("Error: popping",
		  yystos[yystate], yyvsp);
      YYPOPSTACK (1);
      yystate = *yyssp;
      YY_STACK_PRINT (yyss, yyssp);
    }

  *++yyvsp = yylval;


  /* Shift the error token.  */
  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);

  yystate = yyn;
  goto yynewstate;


/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  yyresult = 0;
  goto yyreturn;

/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  yyresult = 1;
  goto yyreturn;

#if !defined(yyoverflow) || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here.  |
`-------------------------------------------------*/
yyexhaustedlab:
  yyerror (YY_("memory exhausted"));
  yyresult = 2;
  /* Fall through.  */
#endif

yyreturn:
  if (yychar != YYEMPTY)
    {
      /* Make sure we have latest lookahead translation.  See comments at
         user semantic actions for why this is necessary.  */
      yytoken = YYTRANSLATE (yychar);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  /* Do not reclaim the symbols of the rule which action triggered
     this YYABORT or YYACCEPT.  */
  YYPOPSTACK (yylen);
  YY_STACK_PRINT (yyss, yyssp);
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
		  yystos[*yyssp], yyvsp);
      YYPOPSTACK (1);
    }
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
  if (yymsg != yymsgbuf)
    YYSTACK_FREE (yymsg);
#endif
  /* Make sure YYID is used.  */
  return YYID (yyresult);
}



/* Line 2067 of yacc.c  */
#line 1079 "parser.y"


void
yyerror(const char* error_msg)
{
	fprintf(stderr, "yyerror(): %s\n", error_msg);
}


void
note_construction(const char* comment)
{
#if VERBOSE
	fprintf(stderr, "%s\n", comment);
#endif /* VERBOSE */
}


void
note_progress(const char* comment)
{
#if VERBOSE
	fprintf(stderr, "%s\n", comment);
#endif /* VERBOSE */
}


void
note_ip_address(const char* address)
{
#if VERBOSE
	fprintf(stderr, "%s\n", address);
#endif /* VERBOSE */
}


void
note_number(int number)
{
#if VERBOSE
	fprintf(stderr, "%d\n", number);
#endif /* VERBOSE */
}


static qualifiers_t
get_qualifiers(int value)
{
	/* Determine which qualifiers were applied to the ports. */
	if (0 == value)
	{
		/* Both src and dst. */
		return QUAL_BOTH;
	}
	else if (TOK_SRC == value)
	{
		return QUAL_SRC;
	}
	else if (TOK_DST == value)
	{
		return QUAL_DST;
	}

	return QUAL_INVALID;
}


static void
apply_qualifiers(PtNodePtr node, qualifiers_t quals)
{
	node_t node_type = ptn_get_type(node);

	if ((PTN_PORT == node_type) || (PTN_HOST == node_type))
	{
		ptn_set_qualifiers(node, quals);
	}
	else
	{
		PtNodePtr child = ptn_get_next_child(node, NULL);

		while (child)
		{
			apply_qualifiers(child, quals);
			
			child = ptn_get_sibling(child);
		}
	}
}


void
tcpdump_rule_parse(const char* line, PtNodePtr* root_node, PtNodePtr* protocol_node)
{
	assert(uRootNode == NULL);
	assert(uProtocolNode == NULL);

	*root_node = NULL;
	*protocol_node = NULL;

	yy_scan_string(line);
	yyparse();

	*root_node = uRootNode;
	uRootNode = NULL;

	*protocol_node = uProtocolNode;
	uProtocolNode = NULL;
}

#if 0
int main ()
{
    yyscan_t scanner;
    int tok;
     
    yylex_init(&scanner);
     
    while ((tok=yylex()) > 0)
        printf("tok=%d  yytext=%s\n", tok, yyget_text(scanner));
     
    yylex_destroy(scanner);
    return 0;
}
#endif

