1    | 
2    | /*  A Bison parser, made from filter.y
3    |     by GNU Bison version 1.28  */
4    | 
5    | #define YYBISON 1  /* Identify Bison output.  */
6    | 
7    | #define yyparse filterparse
8    | #define yylex filterlex
9    | #define yyerror filtererror
10   | #define yylval filterlval
11   | #define yychar filterchar
12   | #define yydebug filterdebug
13   | #define yynerrs filternerrs
14   | #define	OP_OR	257
15   | #define	OP_AND	258
16   | #define	OP_NOT	259
17   | #define	OP_MS	260
18   | #define	OP_EQUAL	261
19   | #define	OP_APPEND	262
20   | #define	OP_COMPARE	263
21   | #define	KEYW_ANY	264
22   | #define	KEYW_PEERAS	265
23   | #define	KEYW_IGP_COST	266
24   | #define	KEYW_PREPEND	267
25   | #define	KEYW_APPEND	268
26   | #define	KEYW_DELETE	269
27   | #define	KEYW_CONTAINS	270
28   | #define	KEYW_INTERNET	271
29   | #define	KEYW_NO_EXPORT	272
30   | #define	KEYW_NO_ADVERTISE	273
31   | #define	KEYW_SELF	274
32   | #define	ASPATH_POSTFIX	275
33   | #define	TKN_FLTRNAME	276
34   | #define	TKN_ASNO	277
35   | #define	TKN_RSNAME	278
36   | #define	TKN_ASNAME	279
37   | #define	TKN_PRFXV4	280
38   | #define	TKN_PRFXV4RNG	281
39   | #define	TKN_PREF	282
40   | #define	TKN_MED	283
41   | #define	TKN_DPA	284
42   | #define	TKN_ASPATH	285
43   | #define	TKN_COMMUNITY	286
44   | #define	TKN_COMM_NO	287
45   | #define	TKN_NEXT_HOP	288
46   | #define	TKN_IPV4	289
47   | #define	TKN_COST	290
48   | #define	TKN_INT	291
49   | 
50   | #line 1 "filter.y"
51   | 
52   | /*
53   |   filename: filter.y
54   | 
55   |   description:
56   |     Defines the grammar for an RPSL filter attribute.  It was mostly
57   |     stolen from the IRRToolSet, simplified by removing ability to parse
58   |     things defined by a dictionary (we use XML for extensibility rather
59   |     than a dictionary).
60   | 
61   |   notes:
62   |     Defines tokens for the associated lexer, filter.l.
63   | */
64   | 
65   | #line 16 "filter.y"
66   | typedef union {
67   |     char *sval;
68   | } YYSTYPE;
69   | #line 30 "filter.y"
70   | 
71   | #include <stdio.h>
72   | #include <stdarg.h>
73   | #include <stdlib.h>
74   | 
75   | int yyerror(const char *s);
76   | 
77   | /* defines for unit testing */
78   | #ifdef UNIT_TEST
79   | int main();
80   | #endif /* UNIT_TEST */
81   | #include <stdio.h>
82   | 
83   | #ifndef __cplusplus
84   | #ifndef __STDC__
85   | #define const
86   | #endif
87   | #endif
88   | 
89   | 
90   | 
91   | #define	YYFINAL		137
92   | #define	YYFLAG		-32768
93   | #define	YYNTBASE	56
94   | 
95   | #define YYTRANSLATE(x) ((unsigned)(x) <= 291 ? yytranslate[x] : 83)
96   | 
97   | static const char yytranslate[] = {     0,
98   |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
99   |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
100  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
101  |      2,     2,     2,     2,     2,    50,     2,     2,     2,    38,
102  |     39,    46,    48,    44,    54,    51,     2,     2,     2,     2,
103  |      2,     2,     2,     2,     2,     2,     2,     2,    55,    40,
104  |      2,    41,    47,     2,     2,     2,     2,     2,     2,     2,
105  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
106  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
107  |     52,     2,    53,    49,     2,     2,     2,     2,     2,     2,
108  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
109  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
110  |      2,     2,    42,    45,    43,     2,     2,     2,     2,     2,
111  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
112  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
113  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
114  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
115  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
116  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
117  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
118  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
119  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
120  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
121  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
122  |      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
123  |      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
124  |      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
125  |     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
126  |     27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
127  |     37
128  | };
129  | 
130  | #if YYDEBUG != 0
131  | static const short yyprhs[] = {     0,
132  |      0,     4,     7,     9,    13,    15,    18,    22,    24,    26,
133  |     30,    32,    34,    36,    39,    41,    43,    45,    47,    49,
134  |     53,    54,    56,    58,    62,    64,    66,    70,    72,    75,
135  |     77,    80,    83,    86,    89,    91,    93,    95,    99,   101,
136  |    103,   105,   107,   109,   113,   118,   119,   122,   125,   128,
137  |    133,   136,   139,   143,   145,   147,   149,   151,   153,   155,
138  |    157,   161,   165,   169,   173,   180,   182,   186,   190,   194,
139  |    201,   208,   215,   220,   224,   228,   230,   234,   236,   238,
140  |    240,   242,   244,   248,   252
141  | };
142  | 
143  | static const short yyrhs[] = {    56,
144  |      3,    57,     0,    56,    57,     0,    57,     0,    57,     4,
145  |     58,     0,    58,     0,     5,    58,     0,    38,    56,    39,
146  |      0,    59,     0,    10,     0,    40,    65,    41,     0,    71,
147  |      0,    22,     0,    60,     0,    61,     6,     0,    61,     0,
148  |     23,     0,    11,     0,    25,     0,    24,     0,    42,    62,
149  |     43,     0,     0,    63,     0,    64,     0,    63,    44,    64,
150  |      0,    26,     0,    27,     0,    65,    45,    66,     0,    66,
151  |      0,    66,    67,     0,    67,     0,    67,    46,     0,    67,
152  |     47,     0,    67,    48,     0,    67,    21,     0,    68,     0,
153  |     49,     0,    50,     0,    38,    65,    39,     0,    69,     0,
154  |     23,     0,    11,     0,    25,     0,    51,     0,    52,    70,
155  |     53,     0,    52,    49,    70,    53,     0,     0,    70,    23,
156  |      0,    70,    11,     0,    70,    51,     0,    70,    23,    54,
157  |     23,     0,    70,    25,     0,    71,    55,     0,     0,    71,
158  |     55,     0,    72,     0,    73,     0,    74,     0,    75,     0,
159  |     77,     0,    81,     0,    82,     0,    28,     7,    37,     0,
160  |     29,     7,    37,     0,    29,     7,    12,     0,    30,     7,
161  |     37,     0,    31,    51,    13,    38,    76,    39,     0,    23,
162  |      0,    76,    44,    23,     0,    32,     7,    78,     0,    32,
163  |      8,    78,     0,    32,    51,    14,    38,    79,    39,     0,
164  |     32,    51,    15,    38,    79,    39,     0,    32,    51,    16,
165  |     38,    79,    39,     0,    32,    38,    79,    39,     0,    32,
166  |      9,    78,     0,    42,    79,    43,     0,    80,     0,    79,
167  |     44,    80,     0,    17,     0,    18,     0,    19,     0,    37,
168  |      0,    33,     0,    34,     7,    35,     0,    34,     7,    20,
169  |      0,    36,     7,    37,     0
170  | };
171  | 
172  | #endif
173  | 
174  | #if YYDEBUG != 0
175  | static const short yyrline[] = { 0,
176  |     45,    46,    47,    50,    51,    54,    55,    56,    59,    60,
177  |     61,    62,    63,    66,    67,    70,    71,    72,    73,    74,
178  |     77,    78,    81,    82,    85,    86,    89,    90,    93,    94,
179  |     97,    98,    99,   100,   101,   104,   105,   106,   107,   110,
180  |    111,   112,   113,   114,   115,   118,   119,   120,   121,   122,
181  |    123,   126,   127,   130,   131,   132,   133,   134,   135,   136,
182  |    139,   150,   159,   162,   173,   176,   177,   180,   181,   182,
183  |    183,   184,   185,   186,   189,   192,   193,   196,   197,   198,
184  |    199,   209,   212,   213,   216
185  | };
186  | #endif
187  | 
188  | 
189  | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
190  | 
191  | static const char * const yytname[] = {   "$","error","$undefined.","OP_OR",
192  | "OP_AND","OP_NOT","OP_MS","OP_EQUAL","OP_APPEND","OP_COMPARE","KEYW_ANY","KEYW_PEERAS",
193  | "KEYW_IGP_COST","KEYW_PREPEND","KEYW_APPEND","KEYW_DELETE","KEYW_CONTAINS","KEYW_INTERNET",
194  | "KEYW_NO_EXPORT","KEYW_NO_ADVERTISE","KEYW_SELF","ASPATH_POSTFIX","TKN_FLTRNAME",
195  | "TKN_ASNO","TKN_RSNAME","TKN_ASNAME","TKN_PRFXV4","TKN_PRFXV4RNG","TKN_PREF",
196  | "TKN_MED","TKN_DPA","TKN_ASPATH","TKN_COMMUNITY","TKN_COMM_NO","TKN_NEXT_HOP",
197  | "TKN_IPV4","TKN_COST","TKN_INT","'('","')'","'<'","'>'","'{'","'}'","','","'|'",
198  | "'*'","'?'","'+'","'^'","'$'","'.'","'['","']'","'-'","';'","filter","filter_term",
199  | "filter_factor","filter_operand","filter_prefix","filter_prefix_operand","opt_filter_prefix_list",
200  | "filter_prefix_list","filter_prefix_list_prefix","filter_aspath","filter_aspath_term",
201  | "filter_aspath_closure","filter_aspath_factor","filter_aspath_no","filter_aspath_range",
202  | "rp_attribute","pref","med","dpa","aspath","asno_list","community","community_list",
203  | "community_elm_list","community_elm","next_hop","cost", NULL
204  | };
205  | #endif
206  | 
207  | static const short yyr1[] = {     0,
208  |     56,    56,    56,    57,    57,    58,    58,    58,    59,    59,
209  |     59,    59,    59,    60,    60,    61,    61,    61,    61,    61,
210  |     62,    62,    63,    63,    64,    64,    65,    65,    66,    66,
211  |     67,    67,    67,    67,    67,    68,    68,    68,    68,    69,
212  |     69,    69,    69,    69,    69,    70,    70,    70,    70,    70,
213  |     70,    -1,    -1,    71,    71,    71,    71,    71,    71,    71,
214  |     72,    73,    73,    74,    75,    76,    76,    77,    77,    77,
215  |     77,    77,    77,    77,    78,    79,    79,    80,    80,    80,
216  |     80,    80,    81,    81,    82
217  | };
218  | 
219  | static const short yyr2[] = {     0,
220  |      3,     2,     1,     3,     1,     2,     3,     1,     1,     3,
221  |      1,     1,     1,     2,     1,     1,     1,     1,     1,     3,
222  |      0,     1,     1,     3,     1,     1,     3,     1,     2,     1,
223  |      2,     2,     2,     2,     1,     1,     1,     3,     1,     1,
224  |      1,     1,     1,     3,     4,     0,     2,     2,     2,     4,
225  |      2,     2,     3,     1,     1,     1,     1,     1,     1,     1,
226  |      3,     3,     3,     3,     6,     1,     3,     3,     3,     6,
227  |      6,     6,     4,     3,     3,     1,     3,     1,     1,     1,
228  |      1,     1,     3,     3,     3
229  | };
230  | 
231  | static const short yydefact[] = {     0,
232  |      0,     9,    17,    12,    16,    19,    18,     0,     0,     0,
233  |      0,     0,     0,     0,     0,     0,    21,     0,     3,     5,
234  |      8,    13,    15,    11,    54,    55,    56,    57,    58,    59,
235  |     60,     6,     0,     0,     0,     0,     0,     0,     0,     0,
236  |      0,     0,     0,     0,    41,    40,    42,     0,    36,    37,
237  |     43,    46,     0,    28,    30,    35,    39,    25,    26,     0,
238  |     22,    23,     0,     2,     0,    14,    61,    63,    62,    64,
239  |      0,     0,    68,    69,    74,    78,    79,    80,    82,    81,
240  |      0,    76,     0,     0,     0,    84,    83,    85,     7,     0,
241  |     46,     0,    10,     0,    29,    34,    31,    32,    33,    20,
242  |      0,     1,     4,     0,     0,    73,     0,     0,     0,     0,
243  |     38,     0,    48,    47,    51,    49,    44,    27,    24,    66,
244  |      0,    75,    77,     0,     0,     0,    45,     0,    65,     0,
245  |     70,    71,    72,    50,    67,     0,     0
246  | };
247  | 
248  | static const short yydefgoto[] = {    18,
249  |     19,    20,    21,    22,    23,    60,    61,    62,    53,    54,
250  |     55,    56,    57,    92,    24,    25,    26,    27,    28,   121,
251  |     29,    73,    81,    82,    30,    31
252  | };
253  | 
254  | static const short yypact[] = {   114,
255  |    114,-32768,-32768,-32768,-32768,-32768,-32768,     9,    29,    33,
256  |    -13,    -3,    53,    55,   114,    47,    60,    21,    64,-32768,
257  | -32768,-32768,    74,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
258  | -32768,-32768,    57,    -4,    76,    98,    73,    73,    73,    -8,
259  |     63,   -17,    84,    78,-32768,-32768,-32768,    47,-32768,-32768,
260  | -32768,    77,   -11,    47,    45,-32768,-32768,-32768,-32768,    79,
261  |     83,-32768,   114,    64,   114,-32768,-32768,-32768,-32768,-32768,
262  |     85,    -8,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
263  |    -27,-32768,    90,    91,    92,-32768,-32768,-32768,-32768,   -32,
264  | -32768,    16,-32768,    47,    45,-32768,-32768,-32768,-32768,-32768,
265  |     60,    64,-32768,   108,   -21,-32768,    -8,    -8,    -8,    -8,
266  | -32768,    31,-32768,    80,-32768,-32768,-32768,    47,-32768,-32768,
267  |    -25,-32768,-32768,   -24,    32,    51,-32768,   109,-32768,   110,
268  | -32768,-32768,-32768,-32768,-32768,   135,-32768
269  | };
270  | 
271  | static const short yypgoto[] = {   125,
272  |    -16,    -1,-32768,-32768,-32768,-32768,-32768,    40,    99,    59,
273  |    -53,-32768,-32768,    58,-32768,-32768,-32768,-32768,-32768,-32768,
274  | -32768,    66,   -35,    44,-32768,-32768
275  | };
276  | 
277  | 
278  | #define	YYLAST		156
279  | 
280  | 
281  | static const short yytable[] = {    32,
282  |     95,    64,    86,    37,    38,    39,   111,    68,    76,    77,
283  |     78,   106,    94,   129,   131,    33,   107,    87,   130,   107,
284  |    136,   122,   107,    63,    79,     1,   113,    64,    80,    93,
285  |      2,     3,    69,    94,    40,    34,   105,    36,   114,    35,
286  |    115,   113,     4,     5,     6,     7,   102,    41,     8,     9,
287  |     10,    11,    12,   114,    13,   115,    14,    45,    15,    42,
288  |     16,    43,    17,   103,    95,    96,   116,    65,   117,    46,
289  |    132,    47,   124,   125,   126,   107,    83,    84,    85,    66,
290  |     63,   116,     1,   127,    48,    58,    59,     2,     3,   133,
291  |     97,    98,    99,    67,   107,    49,    50,    51,    52,     4,
292  |      5,     6,     7,    74,    75,     8,     9,    10,    11,    12,
293  |     71,    13,    70,    14,    72,    15,    89,    16,     1,    17,
294  |     88,   100,   104,     2,     3,    91,   101,   108,   109,   110,
295  |    120,   134,   135,   128,   137,     4,     5,     6,     7,    44,
296  |    119,     8,     9,    10,    11,    12,    90,    13,   112,    14,
297  |    123,    15,   118,    16,     0,    17
298  | };
299  | 
300  | static const short yycheck[] = {     1,
301  |     54,    18,    20,     7,     8,     9,    39,    12,    17,    18,
302  |     19,    39,    45,    39,    39,     7,    44,    35,    44,    44,
303  |      0,    43,    44,     3,    33,     5,    11,    44,    37,    41,
304  |     10,    11,    37,    45,    38,     7,    72,    51,    23,     7,
305  |     25,    11,    22,    23,    24,    25,    63,    51,    28,    29,
306  |     30,    31,    32,    23,    34,    25,    36,    11,    38,     7,
307  |     40,     7,    42,    65,   118,    21,    51,     4,    53,    23,
308  |     39,    25,   108,   109,   110,    44,    14,    15,    16,     6,
309  |      3,    51,     5,    53,    38,    26,    27,    10,    11,    39,
310  |     46,    47,    48,    37,    44,    49,    50,    51,    52,    22,
311  |     23,    24,    25,    38,    39,    28,    29,    30,    31,    32,
312  |     13,    34,    37,    36,    42,    38,    39,    40,     5,    42,
313  |     37,    43,    38,    10,    11,    49,    44,    38,    38,    38,
314  |     23,    23,    23,    54,     0,    22,    23,    24,    25,    15,
315  |    101,    28,    29,    30,    31,    32,    48,    34,    91,    36,
316  |    107,    38,    94,    40,    -1,    42
317  | };
318  | /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
319  | #line 3 "/usr/local/share/bison.simple"
320  | /* This file comes from bison-1.28.  */
321  | 
322  | /* Skeleton output parser for bison,
323  |    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
324  | 
325  |    This program is free software; you can redistribute it and/or modify
326  |    it under the terms of the GNU General Public License as published by
327  |    the Free Software Foundation; either version 2, or (at your option)
328  |    any later version.
329  | 
330  |    This program is distributed in the hope that it will be useful,
331  |    but WITHOUT ANY WARRANTY; without even the implied warranty of
332  |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
333  |    GNU General Public License for more details.
334  | 
335  |    You should have received a copy of the GNU General Public License
336  |    along with this program; if not, write to the Free Software
337  |    Foundation, Inc., 59 Temple Place - Suite 330,
338  |    Boston, MA 02111-1307, USA.  */
339  | 
340  | /* As a special exception, when this file is copied by Bison into a
341  |    Bison output file, you may use that output file without restriction.
342  |    This special exception was added by the Free Software Foundation
343  |    in version 1.24 of Bison.  */
344  | 
345  | /* This is the parser code that is written into each bison parser
346  |   when the %semantic_parser declaration is not specified in the grammar.
347  |   It was written by Richard Stallman by simplifying the hairy parser
348  |   used when %semantic_parser is specified.  */
349  | 
350  | #ifndef YYSTACK_USE_ALLOCA
351  | #ifdef alloca
352  | #define YYSTACK_USE_ALLOCA
353  | #else /* alloca not defined */
354  | #ifdef __GNUC__
355  | #define YYSTACK_USE_ALLOCA
356  | #define alloca __builtin_alloca
357  | #else /* not GNU C.  */
358  | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
359  | #define YYSTACK_USE_ALLOCA
360  | #include <alloca.h>
361  | #else /* not sparc */
362  | /* We think this test detects Watcom and Microsoft C.  */
363  | /* This used to test MSDOS, but that is a bad idea
364  |    since that symbol is in the user namespace.  */
365  | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
366  | #if 0 /* No need for malloc.h, which pollutes the namespace;
367  | 	 instead, just don't use alloca.  */
368  | #include <malloc.h>
369  | #endif
370  | #else /* not MSDOS, or __TURBOC__ */
371  | #if defined(_AIX)
372  | /* I don't know what this was needed for, but it pollutes the namespace.
373  |    So I turned it off.   rms, 2 May 1997.  */
374  | /* #include <malloc.h>  */
375  |  #pragma alloca
376  | #define YYSTACK_USE_ALLOCA
377  | #else /* not MSDOS, or __TURBOC__, or _AIX */
378  | #if 0
379  | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
380  | 		 and on HPUX 10.  Eventually we can turn this on.  */
381  | #define YYSTACK_USE_ALLOCA
382  | #define alloca __builtin_alloca
383  | #endif /* __hpux */
384  | #endif
385  | #endif /* not _AIX */
386  | #endif /* not MSDOS, or __TURBOC__ */
387  | #endif /* not sparc */
388  | #endif /* not GNU C */
389  | #endif /* alloca not defined */
390  | #endif /* YYSTACK_USE_ALLOCA not defined */
391  | 
392  | #ifdef YYSTACK_USE_ALLOCA
393  | #define YYSTACK_ALLOC alloca
394  | #else
395  | #define YYSTACK_ALLOC malloc
396  | #endif
397  | 
398  | /* Note: there must be only one dollar sign in this file.
399  |    It is replaced by the list of actions, each action
400  |    as one case of the switch.  */
401  | 
402  | #define yyerrok		(yyerrstatus = 0)
403  | #define yyclearin	(yychar = YYEMPTY)
404  | #define YYEMPTY		-2
405  | #define YYEOF		0
406  | #define YYACCEPT	goto yyacceptlab
407  | #define YYABORT 	goto yyabortlab
408  | #define YYERROR		goto yyerrlab1
409  | /* Like YYERROR except do call yyerror.
410  |    This remains here temporarily to ease the
411  |    transition to the new meaning of YYERROR, for GCC.
412  |    Once GCC version 2 has supplanted version 1, this can go.  */
413  | #define YYFAIL		goto yyerrlab
414  | #define YYRECOVERING()  (!!yyerrstatus)
415  | #define YYBACKUP(token, value) \
416  | do								\
417  |   if (yychar == YYEMPTY && yylen == 1)				\
418  |     { yychar = (token), yylval = (value);			\
419  |       yychar1 = YYTRANSLATE (yychar);				\
420  |       YYPOPSTACK;						\
421  |       goto yybackup;						\
422  |     }								\
423  |   else								\
424  |     { yyerror ("syntax error: cannot back up"); YYERROR; }	\
425  | while (0)
426  | 
427  | #define YYTERROR	1
428  | #define YYERRCODE	256
429  | 
430  | #ifndef YYPURE
431  | #define YYLEX		yylex()
432  | #endif
433  | 
434  | #ifdef YYPURE
435  | #ifdef YYLSP_NEEDED
436  | #ifdef YYLEX_PARAM
437  | #define YYLEX		yylex(&yylval, &yylloc, YYLEX_PARAM)
438  | #else
439  | #define YYLEX		yylex(&yylval, &yylloc)
440  | #endif
441  | #else /* not YYLSP_NEEDED */
442  | #ifdef YYLEX_PARAM
443  | #define YYLEX		yylex(&yylval, YYLEX_PARAM)
444  | #else
445  | #define YYLEX		yylex(&yylval)
446  | #endif
447  | #endif /* not YYLSP_NEEDED */
448  | #endif
449  | 
450  | /* If nonreentrant, generate the variables here */
451  | 
452  | #ifndef YYPURE
453  | 
454  | int	yychar;			/*  the lookahead symbol		*/
455  | YYSTYPE	yylval;			/*  the semantic value of the		*/
456  | 				/*  lookahead symbol			*/
457  | 
458  | #ifdef YYLSP_NEEDED
459  | YYLTYPE yylloc;			/*  location data for the lookahead	*/
460  | 				/*  symbol				*/
461  | #endif
462  | 
463  | int yynerrs;			/*  number of parse errors so far       */
464  | #endif  /* not YYPURE */
465  | 
466  | #if YYDEBUG != 0
467  | int yydebug;			/*  nonzero means print parse trace	*/
468  | /* Since this is uninitialized, it does not stop multiple parsers
469  |    from coexisting.  */
470  | #endif
471  | 
472  | /*  YYINITDEPTH indicates the initial size of the parser's stacks	*/
473  | 
474  | #ifndef	YYINITDEPTH
475  | #define YYINITDEPTH 200
476  | #endif
477  | 
478  | /*  YYMAXDEPTH is the maximum size the stacks can grow to
479  |     (effective only if the built-in stack extension method is used).  */
480  | 
481  | #if YYMAXDEPTH == 0
482  | #undef YYMAXDEPTH
483  | #endif
484  | 
485  | #ifndef YYMAXDEPTH
486  | #define YYMAXDEPTH 10000
487  | #endif
488  | 
489  | /* Define __yy_memcpy.  Note that the size argument
490  |    should be passed with type unsigned int, because that is what the non-GCC
491  |    definitions require.  With GCC, __builtin_memcpy takes an arg
492  |    of type size_t, but it can handle unsigned int.  */
493  | 
494  | #if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
495  | #define __yy_memcpy(TO,FROM,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
496  | #else				/* not GNU C or C++ */
497  | #ifndef __cplusplus
498  | 
499  | /* This is the most reliable way to avoid incompatibilities
500  |    in available built-in functions on various systems.  */
501  | static void
502  | __yy_memcpy (to, from, count)
503  |      char *to;
504  |      char *from;
505  |      unsigned int count;
506  | {
507  |   register char *f = from;
508  |   register char *t = to;
509  |   register int i = count;
510  | 
511  |   while (i-- > 0)
512  |     *t++ = *f++;
513  | }
514  | 
515  | #else /* __cplusplus */
516  | 
517  | /* This is the most reliable way to avoid incompatibilities
518  |    in available built-in functions on various systems.  */
519  | static void
520  | __yy_memcpy (char *to, char *from, unsigned int count)
521  | {
522  |   register char *t = to;
523  |   register char *f = from;
524  |   register int i = count;
525  | 
526  |   while (i-- > 0)
527  |     *t++ = *f++;
528  | }
529  | 
530  | #endif
531  | #endif
532  | 
533  | #line 217 "/usr/local/share/bison.simple"
534  | 
535  | /* The user can define YYPARSE_PARAM as the name of an argument to be passed
536  |    into yyparse.  The argument should have type void *.
537  |    It should actually point to an object.
538  |    Grammar actions can access the variable by casting it
539  |    to the proper pointer type.  */
540  | 
541  | #ifdef YYPARSE_PARAM
542  | #ifdef __cplusplus
543  | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
544  | #define YYPARSE_PARAM_DECL
545  | #else /* not __cplusplus */
546  | #define YYPARSE_PARAM_ARG YYPARSE_PARAM
547  | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
548  | #endif /* not __cplusplus */
549  | #else /* not YYPARSE_PARAM */
550  | #define YYPARSE_PARAM_ARG
551  | #define YYPARSE_PARAM_DECL
552  | #endif /* not YYPARSE_PARAM */
553  | 
554  | /* Prevent warning if -Wstrict-prototypes.  */
555  | #ifdef __GNUC__
556  | #ifdef YYPARSE_PARAM
557  | int yyparse (void *);
558  | #else
559  | int yyparse (void);
560  | #endif
561  | #endif
562  | 
563  | int
564  | yyparse(YYPARSE_PARAM_ARG)
565  |      YYPARSE_PARAM_DECL
566  | {
567  |   register int yystate;
568  |   register int yyn;
569  |   register short *yyssp;
570  |   register YYSTYPE *yyvsp;
571  |   int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
572  |   int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */
573  | 
574  |   short	yyssa[YYINITDEPTH];	/*  the state stack			*/
575  |   YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/
576  | 
577  |   short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
578  |   YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */
579  | 
580  | #ifdef YYLSP_NEEDED
581  |   YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
582  |   YYLTYPE *yyls = yylsa;
583  |   YYLTYPE *yylsp;
584  | 
585  | #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
586  | #else
587  | #define YYPOPSTACK   (yyvsp--, yyssp--)
588  | #endif
589  | 
590  |   int yystacksize = YYINITDEPTH;
591  |   int yyfree_stacks = 0;
592  | 
593  | #ifdef YYPURE
594  |   int yychar;
595  |   YYSTYPE yylval;
596  |   int yynerrs;
597  | #ifdef YYLSP_NEEDED
598  |   YYLTYPE yylloc;
599  | #endif
600  | #endif
601  | 
602  |   YYSTYPE yyval;		/*  the variable used to return		*/
603  | 				/*  semantic values from the action	*/
604  | 				/*  routines				*/
605  | 
606  |   int yylen;
607  | 
608  | #if YYDEBUG != 0
609  |   if (yydebug)
610  |     fprintf(stderr, "Starting parse\n");
611  | #endif
612  | 
613  |   yystate = 0;
614  |   yyerrstatus = 0;
615  |   yynerrs = 0;
616  |   yychar = YYEMPTY;		/* Cause a token to be read.  */
617  | 
618  |   /* Initialize stack pointers.
619  |      Waste one element of value and location stack
620  |      so that they stay on the same level as the state stack.
621  |      The wasted elements are never initialized.  */
622  | 
623  |   yyssp = yyss - 1;
624  |   yyvsp = yyvs;
625  | #ifdef YYLSP_NEEDED
626  |   yylsp = yyls;
627  | #endif
628  | 
629  | /* Push a new state, which is found in  yystate  .  */
630  | /* In all cases, when you get here, the value and location stacks
631  |    have just been pushed. so pushing a state here evens the stacks.  */
632  | yynewstate:
633  | 
634  |   *++yyssp = yystate;
635  | 
636  |   if (yyssp >= yyss + yystacksize - 1)
637  |     {
638  |       /* Give user a chance to reallocate the stack */
639  |       /* Use copies of these so that the &'s don't force the real ones into memory. */
640  |       YYSTYPE *yyvs1 = yyvs;
641  |       short *yyss1 = yyss;
642  | #ifdef YYLSP_NEEDED
643  |       YYLTYPE *yyls1 = yyls;
644  | #endif
645  | 
646  |       /* Get the current used size of the three stacks, in elements.  */
647  |       int size = yyssp - yyss + 1;
648  | 
649  | #ifdef yyoverflow
650  |       /* Each stack pointer address is followed by the size of
651  | 	 the data in use in that stack, in bytes.  */
652  | #ifdef YYLSP_NEEDED
653  |       /* This used to be a conditional around just the two extra args,
654  | 	 but that might be undefined if yyoverflow is a macro.  */
655  |       yyoverflow("parser stack overflow",
656  | 		 &yyss1, size * sizeof (*yyssp),
657  | 		 &yyvs1, size * sizeof (*yyvsp),
658  | 		 &yyls1, size * sizeof (*yylsp),
659  | 		 &yystacksize);
660  | #else
661  |       yyoverflow("parser stack overflow",
662  | 		 &yyss1, size * sizeof (*yyssp),
663  | 		 &yyvs1, size * sizeof (*yyvsp),
664  | 		 &yystacksize);
665  | #endif
666  | 
667  |       yyss = yyss1; yyvs = yyvs1;
668  | #ifdef YYLSP_NEEDED
669  |       yyls = yyls1;
670  | #endif
671  | #else /* no yyoverflow */
672  |       /* Extend the stack our own way.  */
673  |       if (yystacksize >= YYMAXDEPTH)
674  | 	{
675  | 	  yyerror("parser stack overflow");
676  | 	  if (yyfree_stacks)
677  | 	    {
678  | 	      free (yyss);
679  | 	      free (yyvs);
680  | #ifdef YYLSP_NEEDED
681  | 	      free (yyls);
682  | #endif
683  | 	    }
684  | 	  return 2;
685  | 	}
686  |       yystacksize *= 2;
687  |       if (yystacksize > YYMAXDEPTH)
688  | 	yystacksize = YYMAXDEPTH;
689  | #ifndef YYSTACK_USE_ALLOCA
690  |       yyfree_stacks = 1;
691  | #endif
692  |       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
693  |       __yy_memcpy ((char *)yyss, (char *)yyss1,
694  | 		   size * (unsigned int) sizeof (*yyssp));
695  |       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
696  |       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
697  | 		   size * (unsigned int) sizeof (*yyvsp));
698  | #ifdef YYLSP_NEEDED
699  |       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
700  |       __yy_memcpy ((char *)yyls, (char *)yyls1,
701  | 		   size * (unsigned int) sizeof (*yylsp));
702  | #endif
703  | #endif /* no yyoverflow */
704  | 
705  |       yyssp = yyss + size - 1;
706  |       yyvsp = yyvs + size - 1;
707  | #ifdef YYLSP_NEEDED
708  |       yylsp = yyls + size - 1;
709  | #endif
710  | 
711  | #if YYDEBUG != 0
712  |       if (yydebug)
713  | 	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
714  | #endif
715  | 
716  |       if (yyssp >= yyss + yystacksize - 1)
717  | 	YYABORT;
718  |     }
719  | 
720  | #if YYDEBUG != 0
721  |   if (yydebug)
722  |     fprintf(stderr, "Entering state %d\n", yystate);
723  | #endif
724  | 
725  |   goto yybackup;
726  |  yybackup:
727  | 
728  | /* Do appropriate processing given the current state.  */
729  | /* Read a lookahead token if we need one and don't already have one.  */
730  | /* yyresume: */
731  | 
732  |   /* First try to decide what to do without reference to lookahead token.  */
733  | 
734  |   yyn = yypact[yystate];
735  |   if (yyn == YYFLAG)
736  |     goto yydefault;
737  | 
738  |   /* Not known => get a lookahead token if don't already have one.  */
739  | 
740  |   /* yychar is either YYEMPTY or YYEOF
741  |      or a valid token in external form.  */
742  | 
743  |   if (yychar == YYEMPTY)
744  |     {
745  | #if YYDEBUG != 0
746  |       if (yydebug)
747  | 	fprintf(stderr, "Reading a token: ");
748  | #endif
749  |       yychar = YYLEX;
750  |     }
751  | 
752  |   /* Convert token to internal form (in yychar1) for indexing tables with */
753  | 
754  |   if (yychar <= 0)		/* This means end of input. */
755  |     {
756  |       yychar1 = 0;
757  |       yychar = YYEOF;		/* Don't call YYLEX any more */
758  | 
759  | #if YYDEBUG != 0
760  |       if (yydebug)
761  | 	fprintf(stderr, "Now at end of input.\n");
762  | #endif
763  |     }
764  |   else
765  |     {
766  |       yychar1 = YYTRANSLATE(yychar);
767  | 
768  | #if YYDEBUG != 0
769  |       if (yydebug)
770  | 	{
771  | 	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
772  | 	  /* Give the individual parser a way to print the precise meaning
773  | 	     of a token, for further debugging info.  */
774  | #ifdef YYPRINT
775  | 	  YYPRINT (stderr, yychar, yylval);
776  | #endif
777  | 	  fprintf (stderr, ")\n");
778  | 	}
779  | #endif
780  |     }
781  | 
782  |   yyn += yychar1;
783  |   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
784  |     goto yydefault;
785  | 
786  |   yyn = yytable[yyn];
787  | 
788  |   /* yyn is what to do for this token type in this state.
789  |      Negative => reduce, -yyn is rule number.
790  |      Positive => shift, yyn is new state.
791  |        New state is final state => don't bother to shift,
792  |        just return success.
793  |      0, or most negative number => error.  */
794  | 
795  |   if (yyn < 0)
796  |     {
797  |       if (yyn == YYFLAG)
798  | 	goto yyerrlab;
799  |       yyn = -yyn;
800  |       goto yyreduce;
801  |     }
802  |   else if (yyn == 0)
803  |     goto yyerrlab;
804  | 
805  |   if (yyn == YYFINAL)
806  |     YYACCEPT;
807  | 
808  |   /* Shift the lookahead token.  */
809  | 
810  | #if YYDEBUG != 0
811  |   if (yydebug)
812  |     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
813  | #endif
814  | 
815  |   /* Discard the token being shifted unless it is eof.  */
816  |   if (yychar != YYEOF)
817  |     yychar = YYEMPTY;
818  | 
819  |   *++yyvsp = yylval;
820  | #ifdef YYLSP_NEEDED
821  |   *++yylsp = yylloc;
822  | #endif
823  | 
824  |   /* count tokens shifted since error; after three, turn off error status.  */
825  |   if (yyerrstatus) yyerrstatus--;
826  | 
827  |   yystate = yyn;
828  |   goto yynewstate;
829  | 
830  | /* Do the default action for the current state.  */
831  | yydefault:
832  | 
833  |   yyn = yydefact[yystate];
834  |   if (yyn == 0)
835  |     goto yyerrlab;
836  | 
837  | /* Do a reduction.  yyn is the number of a rule to reduce with.  */
838  | yyreduce:
839  |   yylen = yyr2[yyn];
840  |   if (yylen > 0)
841  |     yyval = yyvsp[1-yylen]; /* implement default value of the action */
842  | 
843  | #if YYDEBUG != 0
844  |   if (yydebug)
845  |     {
846  |       int i;
847  | 
848  |       fprintf (stderr, "Reducing via rule %d (line %d), ",
849  | 	       yyn, yyrline[yyn]);
850  | 
851  |       /* Print the symbols being reduced, and their result.  */
852  |       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
853  | 	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
854  |       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
855  |     }
856  | #endif
857  | 
858  | 
859  |   switch (yyn) {
860  | 
861  | case 61:
862  | #line 139 "filter.y"
863  | {
864  |       long int val;
865  |       char *s, *p;
866  |       p = yyvsp[0].sval;
867  |       val = strtol(p, &s, 10);
868  |       if ((val < 0) || (val > 65535)) {
869  |           syntax_error("pref value \"%s\" is not between 0 and 65535", p);
870  |       }
871  | ;
872  |     break;}
873  | case 62:
874  | #line 150 "filter.y"
875  | {
876  |       long int val;
877  |       char *s, *p;
878  |       p = yyvsp[0].sval;
879  |       val = strtol(p, &s, 10);
880  |       if ((val < 0) || (val > 65535)) {
881  |           syntax_error("med value \"%s\" is not between 0 and 65535", p);
882  |       }
883  | ;
884  |     break;}
885  | case 64:
886  | #line 162 "filter.y"
887  | {
888  |       long int val;
889  |       char *s, *p;
890  |       p = yyvsp[0].sval;
891  |       val = strtol(p, &s, 10);
892  |       if ((val < 0) || (val > 65535)) {
893  |           syntax_error("dpa value \"%s\" is not between 0 and 65535", p);
894  |       }
895  | ;
896  |     break;}
897  | case 81:
898  | #line 199 "filter.y"
899  | {
900  |       unsigned long int val;
901  |       char *s, *p;
902  |       p = yyvsp[0].sval;
903  |       val = strtoul(p, &s, 10);
904  |       if ((val < 1) || (val > 4294967295UL) || (*s != '\0')) {
905  |           syntax_error("community element \"%s\" is not between 1 and 4294967295",
906  |                        p);
907  |       }
908  | ;
909  |     break;}
910  | case 85:
911  | #line 216 "filter.y"
912  | {
913  |       long int val;
914  |       char *s, *p;
915  |       p = yyvsp[0].sval;
916  |       val = strtol(p, &s, 10);
917  |       if ((val < 0) || (val > 65535)) {
918  |           syntax_error("cost value \"%s\" is not between 0 and 65535", p);
919  |       }
920  | ;
921  |     break;}
922  | }
923  |    /* the action file gets copied in in place of this dollarsign */
924  | #line 543 "/usr/local/share/bison.simple"
925  | 
926  |   yyvsp -= yylen;
927  |   yyssp -= yylen;
928  | #ifdef YYLSP_NEEDED
929  |   yylsp -= yylen;
930  | #endif
931  | 
932  | #if YYDEBUG != 0
933  |   if (yydebug)
934  |     {
935  |       short *ssp1 = yyss - 1;
936  |       fprintf (stderr, "state stack now");
937  |       while (ssp1 != yyssp)
938  | 	fprintf (stderr, " %d", *++ssp1);
939  |       fprintf (stderr, "\n");
940  |     }
941  | #endif
942  | 
943  |   *++yyvsp = yyval;
944  | 
945  | #ifdef YYLSP_NEEDED
946  |   yylsp++;
947  |   if (yylen == 0)
948  |     {
949  |       yylsp->first_line = yylloc.first_line;
950  |       yylsp->first_column = yylloc.first_column;
951  |       yylsp->last_line = (yylsp-1)->last_line;
952  |       yylsp->last_column = (yylsp-1)->last_column;
953  |       yylsp->text = 0;
954  |     }
955  |   else
956  |     {
957  |       yylsp->last_line = (yylsp+yylen-1)->last_line;
958  |       yylsp->last_column = (yylsp+yylen-1)->last_column;
959  |     }
960  | #endif
961  | 
962  |   /* Now "shift" the result of the reduction.
963  |      Determine what state that goes to,
964  |      based on the state we popped back to
965  |      and the rule number reduced by.  */
966  | 
967  |   yyn = yyr1[yyn];
968  | 
969  |   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
970  |   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
971  |     yystate = yytable[yystate];
972  |   else
973  |     yystate = yydefgoto[yyn - YYNTBASE];
974  | 
975  |   goto yynewstate;
976  | 
977  | yyerrlab:   /* here on detecting error */
978  | 
979  |   if (! yyerrstatus)
980  |     /* If not already recovering from an error, report this error.  */
981  |     {
982  |       ++yynerrs;
983  | 
984  | #ifdef YYERROR_VERBOSE
985  |       yyn = yypact[yystate];
986  | 
987  |       if (yyn > YYFLAG && yyn < YYLAST)
988  | 	{
989  | 	  int size = 0;
990  | 	  char *msg;
991  | 	  int x, count;
992  | 
993  | 	  count = 0;
994  | 	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
995  | 	  for (x = (yyn < 0 ? -yyn : 0);
996  | 	       x < (sizeof(yytname) / sizeof(char *)); x++)
997  | 	    if (yycheck[x + yyn] == x)
998  | 	      size += strlen(yytname[x]) + 15, count++;
999  | 	  msg = (char *) malloc(size + 15);
1000 | 	  if (msg != 0)
1001 | 	    {
1002 | 	      strcpy(msg, "parse error");
1003 | 
1004 | 	      if (count < 5)
1005 | 		{
1006 | 		  count = 0;
1007 | 		  for (x = (yyn < 0 ? -yyn : 0);
1008 | 		       x < (sizeof(yytname) / sizeof(char *)); x++)
1009 | 		    if (yycheck[x + yyn] == x)
1010 | 		      {
1011 | 			strcat(msg, count == 0 ? ", expecting `" : " or `");
1012 | 			strcat(msg, yytname[x]);
1013 | 			strcat(msg, "'");
1014 | 			count++;
1015 | 		      }
1016 | 		}
1017 | 	      yyerror(msg);
1018 | 	      free(msg);
1019 | 	    }
1020 | 	  else
1021 | 	    yyerror ("parse error; also virtual memory exceeded");
1022 | 	}
1023 |       else
1024 | #endif /* YYERROR_VERBOSE */
1025 | 	yyerror("parse error");
1026 |     }
1027 | 
1028 |   goto yyerrlab1;
1029 | yyerrlab1:   /* here on error raised explicitly by an action */
1030 | 
1031 |   if (yyerrstatus == 3)
1032 |     {
1033 |       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
1034 | 
1035 |       /* return failure if at end of input */
1036 |       if (yychar == YYEOF)
1037 | 	YYABORT;
1038 | 
1039 | #if YYDEBUG != 0
1040 |       if (yydebug)
1041 | 	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1042 | #endif
1043 | 
1044 |       yychar = YYEMPTY;
1045 |     }
1046 | 
1047 |   /* Else will try to reuse lookahead token
1048 |      after shifting the error token.  */
1049 | 
1050 |   yyerrstatus = 3;		/* Each real token shifted decrements this */
1051 | 
1052 |   goto yyerrhandle;
1053 | 
1054 | yyerrdefault:  /* current state does not do anything special for the error token. */
1055 | 
1056 | #if 0
1057 |   /* This is wrong; only states that explicitly want error tokens
1058 |      should shift them.  */
1059 |   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
1060 |   if (yyn) goto yydefault;
1061 | #endif
1062 | 
1063 | yyerrpop:   /* pop the current state because it cannot handle the error token */
1064 | 
1065 |   if (yyssp == yyss) YYABORT;
1066 |   yyvsp--;
1067 |   yystate = *--yyssp;
1068 | #ifdef YYLSP_NEEDED
1069 |   yylsp--;
1070 | #endif
1071 | 
1072 | #if YYDEBUG != 0
1073 |   if (yydebug)
1074 |     {
1075 |       short *ssp1 = yyss - 1;
1076 |       fprintf (stderr, "Error: state stack now");
1077 |       while (ssp1 != yyssp)
1078 | 	fprintf (stderr, " %d", *++ssp1);
1079 |       fprintf (stderr, "\n");
1080 |     }
1081 | #endif
1082 | 
1083 | yyerrhandle:
1084 | 
1085 |   yyn = yypact[yystate];
1086 |   if (yyn == YYFLAG)
1087 |     goto yyerrdefault;
1088 | 
1089 |   yyn += YYTERROR;
1090 |   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1091 |     goto yyerrdefault;
1092 | 
1093 |   yyn = yytable[yyn];
1094 |   if (yyn < 0)
1095 |     {
1096 |       if (yyn == YYFLAG)
1097 | 	goto yyerrpop;
1098 |       yyn = -yyn;
1099 |       goto yyreduce;
1100 |     }
1101 |   else if (yyn == 0)
1102 |     goto yyerrpop;
1103 | 
1104 |   if (yyn == YYFINAL)
1105 |     YYACCEPT;
1106 | 
1107 | #if YYDEBUG != 0
1108 |   if (yydebug)
1109 |     fprintf(stderr, "Shifting error token, ");
1110 | #endif
1111 | 
1112 |   *++yyvsp = yylval;
1113 | #ifdef YYLSP_NEEDED
1114 |   *++yylsp = yylloc;
1115 | #endif
1116 | 
1117 |   yystate = yyn;
1118 |   goto yynewstate;
1119 | 
1120 |  yyacceptlab:
1121 |   /* YYACCEPT comes here.  */
1122 |   if (yyfree_stacks)
1123 |     {
1124 |       free (yyss);
1125 |       free (yyvs);
1126 | #ifdef YYLSP_NEEDED
1127 |       free (yyls);
1128 | #endif
1129 |     }
1130 |   return 0;
1131 | 
1132 |  yyabortlab:
1133 |   /* YYABORT comes here.  */
1134 |   if (yyfree_stacks)
1135 |     {
1136 |       free (yyss);
1137 |       free (yyvs);
1138 | #ifdef YYLSP_NEEDED
1139 |       free (yyls);
1140 | #endif
1141 |     }
1142 |   return 1;
1143 | }
1144 | #line 228 "filter.y"
1145 | 
1146 | 
1147 | /* define a unit test that simply returns "yes" or "no" for filter input */
1148 | #ifndef UNIT_TEST
1149 | 
1150 | #undef filtererror
1151 | #undef yyerror
1152 | 
1153 | int
1154 | filtererror (const char *s)
1155 | {
1156 |     yyerror(s);
1157 |     return 0;
1158 | }
1159 | #else /* UNIT_TEST */
1160 | 
1161 | int parse_error_count;
1162 | 
1163 | /* parse error */
1164 | void 
1165 | yyerror(const char *s)
1166 | {
1167 |     fputs(s, stderr);
1168 |     putc('\n', stderr);
1169 |     parse_error_count++;
1170 | }
1171 | 
1172 | /* syntax error */
1173 | void 
1174 | syntax_error(const char *fmt, ...)
1175 | {
1176 |     va_list args;
1177 |     char buf[1024];
1178 | 
1179 |     va_start(args, fmt);
1180 |     vsnprintf(buf, sizeof(buf), fmt, args);
1181 |     va_end(args);
1182 |     yyerror(buf);
1183 | }
1184 | 
1185 | int
1186 | yywrap()
1187 | {
1188 |     return 1;
1189 | }
1190 | 
1191 | /* taken from _lex & yacc_ p.157, by Levine, Mason, & Brown (corrected) */
1192 | char *myinputptr;
1193 | char *myinputlim;
1194 | 
1195 | #undef min
1196 | #define min(a, b)  (((a) < (b)) ? (a) : (b))
1197 | 
1198 | void
1199 | yy_input(char *buf, int *result, int max_size)
1200 | {
1201 |     int n = min(max_size, myinputlim - myinputptr);
1202 | 
1203 |     if (n > 0) {
1204 |         memcpy(buf, myinputptr, n);
1205 |         myinputptr += n;
1206 |     }
1207 |     *result = n;
1208 | }
1209 | 
1210 | /* program entry point */
1211 | int 
1212 | main()
1213 | {
1214 |     char buf[4096];
1215 | 
1216 |     setbuf(stdout, NULL);
1217 |     for (;;) {
1218 |         printf("filter> ");
1219 |         if (gets(buf) == NULL) {
1220 |             printf("\n");
1221 |             return(0);
1222 |         }
1223 |         parse_error_count = 0;
1224 |         myinputptr = buf;
1225 |         myinputlim = buf + strlen(buf);
1226 |         filterparse();
1227 |         printf("%d parse errors\n", parse_error_count);
1228 |     }
1229 | }
1230 | #endif /* UNIT_TEST */