fa73a878d115b92c566411e60920c079502a406a
[iproute2.git] / misc / ssfilter.c
1 /* A Bison parser, made by GNU Bison 1.875c.  */
2
3 /* Skeleton parser for Yacc-like parsing with Bison,
4    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.  */
20
21 /* As a special exception, when this file is copied by Bison into a
22    Bison output file, you may use that output file without restriction.
23    This special exception was added by the Free Software Foundation
24    in version 1.24 of Bison.  */
25
26 /* Written by Richard Stallman by simplifying the original so called
27    ``semantic'' parser.  */
28
29 /* All symbols defined below should begin with yy or YY, to avoid
30    infringing on user name space.  This should be done even for local
31    variables, as they might otherwise be expanded by user macros.
32    There are some unavoidable exceptions within include files to
33    define necessary library symbols; they are noted "INFRINGES ON
34    USER NAME SPACE" below.  */
35
36 /* Identify Bison output.  */
37 #define YYBISON 1
38
39 /* Skeleton name.  */
40 #define YYSKELETON_NAME "yacc.c"
41
42 /* Pure parsers.  */
43 #define YYPURE 0
44
45 /* Using locations.  */
46 #define YYLSP_NEEDED 0
47
48
49
50 /* Tokens.  */
51 #ifndef YYTOKENTYPE
52 # define YYTOKENTYPE
53    /* Put the tokens into the symbol table, so that GDB and other debuggers
54       know about them.  */
55    enum yytokentype {
56      HOSTCOND = 258,
57      DCOND = 259,
58      SCOND = 260,
59      DPORT = 261,
60      SPORT = 262,
61      LEQ = 263,
62      GEQ = 264,
63      NEQ = 265,
64      AUTOBOUND = 266
65    };
66 #endif
67 #define HOSTCOND 258
68 #define DCOND 259
69 #define SCOND 260
70 #define DPORT 261
71 #define SPORT 262
72 #define LEQ 263
73 #define GEQ 264
74 #define NEQ 265
75 #define AUTOBOUND 266
76
77
78
79
80 /* Copy the first part of user declarations.  */
81 #line 1 "ssfilter.y"
82
83
84 #include <stdio.h>
85 #include <stdlib.h>
86 #include <malloc.h>
87 #include <string.h>
88 #include "ssfilter.h"
89
90 typedef struct ssfilter * ssfilter_t;
91
92 #define YYSTYPE ssfilter_t
93
94 static struct ssfilter * alloc_node(int type, void *pred)
95 {
96         struct ssfilter *n = malloc(sizeof(*n));
97         if (n == NULL)
98                 abort();
99         n->type = type;
100         n->pred = pred;
101         n->post = NULL;
102         return n;
103 }
104
105 static char             **yy_argv;
106 static int              yy_argc;
107 static FILE             *yy_fp;
108 static ssfilter_t       *yy_ret;
109
110 static int yylex(void);
111
112 static void yyerror(char *s)
113 {
114         fprintf(stderr, "ss: bison bellows (while parsing filter): \"%s!\"", s);
115 }
116
117
118
119 /* Enabling traces.  */
120 #ifndef YYDEBUG
121 # define YYDEBUG 0
122 #endif
123
124 /* Enabling verbose error messages.  */
125 #ifdef YYERROR_VERBOSE
126 # undef YYERROR_VERBOSE
127 # define YYERROR_VERBOSE 1
128 #else
129 # define YYERROR_VERBOSE 0
130 #endif
131
132 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
133 typedef int YYSTYPE;
134 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
135 # define YYSTYPE_IS_DECLARED 1
136 # define YYSTYPE_IS_TRIVIAL 1
137 #endif
138
139
140
141 /* Copy the second part of user declarations.  */
142
143
144 /* Line 214 of yacc.c.  */
145 #line 146 "ssfilter.c"
146
147 #if ! defined (yyoverflow) || YYERROR_VERBOSE
148
149 # ifndef YYFREE
150 #  define YYFREE free
151 # endif
152 # ifndef YYMALLOC
153 #  define YYMALLOC malloc
154 # endif
155
156 /* The parser invokes alloca or malloc; define the necessary symbols.  */
157
158 # ifdef YYSTACK_USE_ALLOCA
159 #  if YYSTACK_USE_ALLOCA
160 #   define YYSTACK_ALLOC alloca
161 #  endif
162 # else
163 #  if defined (alloca) || defined (_ALLOCA_H)
164 #   define YYSTACK_ALLOC alloca
165 #  else
166 #   ifdef __GNUC__
167 #    define YYSTACK_ALLOC __builtin_alloca
168 #   endif
169 #  endif
170 # endif
171
172 # ifdef YYSTACK_ALLOC
173    /* Pacify GCC's `empty if-body' warning. */
174 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
175 # else
176 #  if defined (__STDC__) || defined (__cplusplus)
177 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
178 #   define YYSIZE_T size_t
179 #  endif
180 #  define YYSTACK_ALLOC YYMALLOC
181 #  define YYSTACK_FREE YYFREE
182 # endif
183 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
184
185
186 #if (! defined (yyoverflow) \
187      && (! defined (__cplusplus) \
188          || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
189
190 /* A type that is properly aligned for any stack member.  */
191 union yyalloc
192 {
193   short yyss;
194   YYSTYPE yyvs;
195   };
196
197 /* The size of the maximum gap between one aligned stack and the next.  */
198 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
199
200 /* The size of an array large to enough to hold all stacks, each with
201    N elements.  */
202 # define YYSTACK_BYTES(N) \
203      ((N) * (sizeof (short) + sizeof (YYSTYPE))                         \
204       + YYSTACK_GAP_MAXIMUM)
205
206 /* Copy COUNT objects from FROM to TO.  The source and destination do
207    not overlap.  */
208 # ifndef YYCOPY
209 #  if defined (__GNUC__) && 1 < __GNUC__
210 #   define YYCOPY(To, From, Count) \
211       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
212 #  else
213 #   define YYCOPY(To, From, Count)              \
214       do                                        \
215         {                                       \
216           register YYSIZE_T yyi;                \
217           for (yyi = 0; yyi < (Count); yyi++)   \
218             (To)[yyi] = (From)[yyi];            \
219         }                                       \
220       while (0)
221 #  endif
222 # endif
223
224 /* Relocate STACK from its old location to the new one.  The
225    local variables YYSIZE and YYSTACKSIZE give the old and new number of
226    elements in the stack, and YYPTR gives the new location of the
227    stack.  Advance YYPTR to a properly aligned location for the next
228    stack.  */
229 # define YYSTACK_RELOCATE(Stack)                                        \
230     do                                                                  \
231       {                                                                 \
232         YYSIZE_T yynewbytes;                                            \
233         YYCOPY (&yyptr->Stack, Stack, yysize);                          \
234         Stack = &yyptr->Stack;                                          \
235         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
236         yyptr += yynewbytes / sizeof (*yyptr);                          \
237       }                                                                 \
238     while (0)
239
240 #endif
241
242 #if defined (__STDC__) || defined (__cplusplus)
243    typedef signed char yysigned_char;
244 #else
245    typedef short yysigned_char;
246 #endif
247
248 /* YYFINAL -- State number of the termination state. */
249 #define YYFINAL  3
250 /* YYLAST -- Last index in YYTABLE.  */
251 #define YYLAST   90
252
253 /* YYNTOKENS -- Number of terminals. */
254 #define YYNTOKENS  20
255 /* YYNNTS -- Number of nonterminals. */
256 #define YYNNTS  4
257 /* YYNRULES -- Number of rules. */
258 #define YYNRULES  24
259 /* YYNRULES -- Number of states. */
260 #define YYNSTATES  46
261
262 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
263 #define YYUNDEFTOK  2
264 #define YYMAXUTOK   266
265
266 #define YYTRANSLATE(YYX)                                                \
267   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
268
269 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
270 static const unsigned char yytranslate[] =
271 {
272        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
273        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
274        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
275        2,     2,     2,    14,     2,     2,     2,     2,    13,     2,
276       18,    19,     2,     2,     2,     2,     2,     2,     2,     2,
277        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
278       16,    17,    15,     2,     2,     2,     2,     2,     2,     2,
279        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
280        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
281        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
282        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
283        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
284        2,     2,     2,     2,    12,     2,     2,     2,     2,     2,
285        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
286        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
287        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
288        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
289        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
290        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
291        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
292        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
293        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
294        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
295        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
296        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
297        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
298        5,     6,     7,     8,     9,    10,    11
299 };
300
301 #if YYDEBUG
302 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
303    YYRHS.  */
304 static const unsigned char yyprhs[] =
305 {
306        0,     0,     3,     6,     8,     9,    12,    15,    19,    23,
307       27,    31,    35,    39,    43,    47,    51,    55,    59,    63,
308       65,    69,    72,    76,    79
309 };
310
311 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
312 static const yysigned_char yyrhs[] =
313 {
314       21,     0,    -1,    22,    23,    -1,    22,    -1,    -1,     4,
315        3,    -1,     5,     3,    -1,     6,     9,     3,    -1,     6,
316        8,     3,    -1,     6,    15,     3,    -1,     6,    16,     3,
317       -1,     6,    17,     3,    -1,     6,    10,     3,    -1,     7,
318        9,     3,    -1,     7,     8,     3,    -1,     7,    15,     3,
319       -1,     7,    16,     3,    -1,     7,    17,     3,    -1,     7,
320       10,     3,    -1,    11,    -1,    23,    12,    23,    -1,    23,
321       23,    -1,    23,    13,    23,    -1,    14,    23,    -1,    18,
322       23,    19,    -1
323 };
324
325 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
326 static const unsigned char yyrline[] =
327 {
328        0,    44,    44,    49,    51,    53,    57,    61,    65,    69,
329       73,    77,    81,    86,    90,    94,    98,   102,   106,   111,
330      115,   120,   125,   131,   135
331 };
332 #endif
333
334 #if YYDEBUG || YYERROR_VERBOSE
335 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
336    First, the terminals, then, starting at YYNTOKENS, nonterminals. */
337 static const char *const yytname[] =
338 {
339   "$end", "error", "$undefined", "HOSTCOND", "DCOND", "SCOND", "DPORT",
340   "SPORT", "LEQ", "GEQ", "NEQ", "AUTOBOUND", "'|'", "'&'", "'!'", "'>'",
341   "'<'", "'='", "'('", "')'", "$accept", "applet", "null", "expr", 0
342 };
343 #endif
344
345 # ifdef YYPRINT
346 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
347    token YYLEX-NUM.  */
348 static const unsigned short yytoknum[] =
349 {
350        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
351      265,   266,   124,    38,    33,    62,    60,    61,    40,    41
352 };
353 # endif
354
355 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
356 static const unsigned char yyr1[] =
357 {
358        0,    20,    21,    21,    22,    23,    23,    23,    23,    23,
359       23,    23,    23,    23,    23,    23,    23,    23,    23,    23,
360       23,    23,    23,    23,    23
361 };
362
363 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
364 static const unsigned char yyr2[] =
365 {
366        0,     2,     2,     1,     0,     2,     2,     3,     3,     3,
367        3,     3,     3,     3,     3,     3,     3,     3,     3,     1,
368        3,     2,     3,     2,     3
369 };
370
371 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
372    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
373    means the default is an error.  */
374 static const unsigned char yydefact[] =
375 {
376        4,     0,     3,     1,     0,     0,     0,     0,    19,     0,
377        0,     2,     5,     6,     0,     0,     0,     0,     0,     0,
378        0,     0,     0,     0,     0,     0,    23,     0,     0,     0,
379       21,     8,     7,    12,     9,    10,    11,    14,    13,    18,
380       15,    16,    17,    24,    20,    22
381 };
382
383 /* YYDEFGOTO[NTERM-NUM]. */
384 static const yysigned_char yydefgoto[] =
385 {
386       -1,     1,     2,    30
387 };
388
389 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
390    STATE-NUM.  */
391 #define YYPACT_NINF -3
392 static const yysigned_char yypact[] =
393 {
394       -3,     1,    47,    -3,     6,    11,    69,    73,    -3,    47,
395       47,    17,    -3,    -3,    12,    13,    16,    22,    29,    30,
396       31,    37,    38,    39,    41,    44,    62,    -1,    47,    47,
397       17,    -3,    -3,    -3,    -3,    -3,    -3,    -3,    -3,    -3,
398       -3,    -3,    -3,    -3,    32,    47
399 };
400
401 /* YYPGOTO[NTERM-NUM].  */
402 static const yysigned_char yypgoto[] =
403 {
404       -3,    -3,    -3,    -2
405 };
406
407 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
408    positive, shift that token.  If negative, reduce the rule which
409    number is the opposite.  If zero, do what YYDEFACT says.
410    If YYTABLE_NINF, syntax error.  */
411 #define YYTABLE_NINF -1
412 static const yysigned_char yytable[] =
413 {
414       11,     3,     0,     4,     5,     6,     7,    26,    27,    12,
415        8,    28,    29,     9,    13,    31,    32,    10,    43,    33,
416        0,     4,     5,     6,     7,    34,    44,    45,     8,    28,
417       29,     9,    35,    36,    37,    10,     4,     5,     6,     7,
418       38,    39,    40,     8,    41,    29,     9,    42,     0,     0,
419       10,     4,     5,     6,     7,     0,     0,     0,     8,     0,
420        0,     9,     0,     0,     0,    10,     4,     5,     6,     7,
421        0,     0,     0,     8,     0,     0,    -1,    14,    15,    16,
422       10,    20,    21,    22,    17,    18,    19,     0,    23,    24,
423       25
424 };
425
426 static const yysigned_char yycheck[] =
427 {
428        2,     0,    -1,     4,     5,     6,     7,     9,    10,     3,
429       11,    12,    13,    14,     3,     3,     3,    18,    19,     3,
430       -1,     4,     5,     6,     7,     3,    28,    29,    11,    12,
431       13,    14,     3,     3,     3,    18,     4,     5,     6,     7,
432        3,     3,     3,    11,     3,    13,    14,     3,    -1,    -1,
433       18,     4,     5,     6,     7,    -1,    -1,    -1,    11,    -1,
434       -1,    14,    -1,    -1,    -1,    18,     4,     5,     6,     7,
435       -1,    -1,    -1,    11,    -1,    -1,    14,     8,     9,    10,
436       18,     8,     9,    10,    15,    16,    17,    -1,    15,    16,
437       17
438 };
439
440 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
441    symbol of state STATE-NUM.  */
442 static const unsigned char yystos[] =
443 {
444        0,    21,    22,     0,     4,     5,     6,     7,    11,    14,
445       18,    23,     3,     3,     8,     9,    10,    15,    16,    17,
446        8,     9,    10,    15,    16,    17,    23,    23,    12,    13,
447       23,     3,     3,     3,     3,     3,     3,     3,     3,     3,
448        3,     3,     3,    19,    23,    23
449 };
450
451 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
452 # define YYSIZE_T __SIZE_TYPE__
453 #endif
454 #if ! defined (YYSIZE_T) && defined (size_t)
455 # define YYSIZE_T size_t
456 #endif
457 #if ! defined (YYSIZE_T)
458 # if defined (__STDC__) || defined (__cplusplus)
459 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
460 #  define YYSIZE_T size_t
461 # endif
462 #endif
463 #if ! defined (YYSIZE_T)
464 # define YYSIZE_T unsigned int
465 #endif
466
467 #define yyerrok         (yyerrstatus = 0)
468 #define yyclearin       (yychar = YYEMPTY)
469 #define YYEMPTY         (-2)
470 #define YYEOF           0
471
472 #define YYACCEPT        goto yyacceptlab
473 #define YYABORT         goto yyabortlab
474 #define YYERROR         goto yyerrorlab
475
476
477 /* Like YYERROR except do call yyerror.  This remains here temporarily
478    to ease the transition to the new meaning of YYERROR, for GCC.
479    Once GCC version 2 has supplanted version 1, this can go.  */
480
481 #define YYFAIL          goto yyerrlab
482
483 #define YYRECOVERING()  (!!yyerrstatus)
484
485 #define YYBACKUP(Token, Value)                                  \
486 do                                                              \
487   if (yychar == YYEMPTY && yylen == 1)                          \
488     {                                                           \
489       yychar = (Token);                                         \
490       yylval = (Value);                                         \
491       yytoken = YYTRANSLATE (yychar);                           \
492       YYPOPSTACK;                                               \
493       goto yybackup;                                            \
494     }                                                           \
495   else                                                          \
496     {                                                           \
497       yyerror ("syntax error: cannot back up");\
498       YYERROR;                                                  \
499     }                                                           \
500 while (0)
501
502 #define YYTERROR        1
503 #define YYERRCODE       256
504
505 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
506    are run).  */
507
508 #ifndef YYLLOC_DEFAULT
509 # define YYLLOC_DEFAULT(Current, Rhs, N)                \
510    ((Current).first_line   = (Rhs)[1].first_line,       \
511     (Current).first_column = (Rhs)[1].first_column,     \
512     (Current).last_line    = (Rhs)[N].last_line,        \
513     (Current).last_column  = (Rhs)[N].last_column)
514 #endif
515
516 /* YYLEX -- calling `yylex' with the right arguments.  */
517
518 #ifdef YYLEX_PARAM
519 # define YYLEX yylex (YYLEX_PARAM)
520 #else
521 # define YYLEX yylex ()
522 #endif
523
524 /* Enable debugging if requested.  */
525 #if YYDEBUG
526
527 # ifndef YYFPRINTF
528 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
529 #  define YYFPRINTF fprintf
530 # endif
531
532 # define YYDPRINTF(Args)                        \
533 do {                                            \
534   if (yydebug)                                  \
535     YYFPRINTF Args;                             \
536 } while (0)
537
538 # define YYDSYMPRINT(Args)                      \
539 do {                                            \
540   if (yydebug)                                  \
541     yysymprint Args;                            \
542 } while (0)
543
544 # define YYDSYMPRINTF(Title, Token, Value, Location)            \
545 do {                                                            \
546   if (yydebug)                                                  \
547     {                                                           \
548       YYFPRINTF (stderr, "%s ", Title);                         \
549       yysymprint (stderr,                                       \
550                   Token, Value);        \
551       YYFPRINTF (stderr, "\n");                                 \
552     }                                                           \
553 } while (0)
554
555 /*------------------------------------------------------------------.
556 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
557 | TOP (included).                                                   |
558 `------------------------------------------------------------------*/
559
560 #if defined (__STDC__) || defined (__cplusplus)
561 static void
562 yy_stack_print (short *bottom, short *top)
563 #else
564 static void
565 yy_stack_print (bottom, top)
566     short *bottom;
567     short *top;
568 #endif
569 {
570   YYFPRINTF (stderr, "Stack now");
571   for (/* Nothing. */; bottom <= top; ++bottom)
572     YYFPRINTF (stderr, " %d", *bottom);
573   YYFPRINTF (stderr, "\n");
574 }
575
576 # define YY_STACK_PRINT(Bottom, Top)                            \
577 do {                                                            \
578   if (yydebug)                                                  \
579     yy_stack_print ((Bottom), (Top));                           \
580 } while (0)
581
582
583 /*------------------------------------------------.
584 | Report that the YYRULE is going to be reduced.  |
585 `------------------------------------------------*/
586
587 #if defined (__STDC__) || defined (__cplusplus)
588 static void
589 yy_reduce_print (int yyrule)
590 #else
591 static void
592 yy_reduce_print (yyrule)
593     int yyrule;
594 #endif
595 {
596   int yyi;
597   unsigned int yylno = yyrline[yyrule];
598   YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
599              yyrule - 1, yylno);
600   /* Print the symbols being reduced, and their result.  */
601   for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
602     YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
603   YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
604 }
605
606 # define YY_REDUCE_PRINT(Rule)          \
607 do {                                    \
608   if (yydebug)                          \
609     yy_reduce_print (Rule);             \
610 } while (0)
611
612 /* Nonzero means print parse trace.  It is left uninitialized so that
613    multiple parsers can coexist.  */
614 int yydebug;
615 #else /* !YYDEBUG */
616 # define YYDPRINTF(Args)
617 # define YYDSYMPRINT(Args)
618 # define YYDSYMPRINTF(Title, Token, Value, Location)
619 # define YY_STACK_PRINT(Bottom, Top)
620 # define YY_REDUCE_PRINT(Rule)
621 #endif /* !YYDEBUG */
622
623
624 /* YYINITDEPTH -- initial size of the parser's stacks.  */
625 #ifndef YYINITDEPTH
626 # define YYINITDEPTH 200
627 #endif
628
629 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
630    if the built-in stack extension method is used).
631
632    Do not make this value too large; the results are undefined if
633    SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
634    evaluated with infinite-precision integer arithmetic.  */
635
636 #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
637 # undef YYMAXDEPTH
638 #endif
639
640 #ifndef YYMAXDEPTH
641 # define YYMAXDEPTH 10000
642 #endif
643
644 \f
645
646 #if YYERROR_VERBOSE
647
648 # ifndef yystrlen
649 #  if defined (__GLIBC__) && defined (_STRING_H)
650 #   define yystrlen strlen
651 #  else
652 /* Return the length of YYSTR.  */
653 static YYSIZE_T
654 #   if defined (__STDC__) || defined (__cplusplus)
655 yystrlen (const char *yystr)
656 #   else
657 yystrlen (yystr)
658      const char *yystr;
659 #   endif
660 {
661   register const char *yys = yystr;
662
663   while (*yys++ != '\0')
664     continue;
665
666   return yys - yystr - 1;
667 }
668 #  endif
669 # endif
670
671 # ifndef yystpcpy
672 #  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
673 #   define yystpcpy stpcpy
674 #  else
675 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
676    YYDEST.  */
677 static char *
678 #   if defined (__STDC__) || defined (__cplusplus)
679 yystpcpy (char *yydest, const char *yysrc)
680 #   else
681 yystpcpy (yydest, yysrc)
682      char *yydest;
683      const char *yysrc;
684 #   endif
685 {
686   register char *yyd = yydest;
687   register const char *yys = yysrc;
688
689   while ((*yyd++ = *yys++) != '\0')
690     continue;
691
692   return yyd - 1;
693 }
694 #  endif
695 # endif
696
697 #endif /* !YYERROR_VERBOSE */
698
699 \f
700
701 #if YYDEBUG
702 /*--------------------------------.
703 | Print this symbol on YYOUTPUT.  |
704 `--------------------------------*/
705
706 #if defined (__STDC__) || defined (__cplusplus)
707 static void
708 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
709 #else
710 static void
711 yysymprint (yyoutput, yytype, yyvaluep)
712     FILE *yyoutput;
713     int yytype;
714     YYSTYPE *yyvaluep;
715 #endif
716 {
717   /* Pacify ``unused variable'' warnings.  */
718   (void) yyvaluep;
719
720   if (yytype < YYNTOKENS)
721     {
722       YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
723 # ifdef YYPRINT
724       YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
725 # endif
726     }
727   else
728     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
729
730   switch (yytype)
731     {
732       default:
733         break;
734     }
735   YYFPRINTF (yyoutput, ")");
736 }
737
738 #endif /* ! YYDEBUG */
739 /*-----------------------------------------------.
740 | Release the memory associated to this symbol.  |
741 `-----------------------------------------------*/
742
743 #if defined (__STDC__) || defined (__cplusplus)
744 static void
745 yydestruct (int yytype, YYSTYPE *yyvaluep)
746 #else
747 static void
748 yydestruct (yytype, yyvaluep)
749     int yytype;
750     YYSTYPE *yyvaluep;
751 #endif
752 {
753   /* Pacify ``unused variable'' warnings.  */
754   (void) yyvaluep;
755
756   switch (yytype)
757     {
758
759       default:
760         break;
761     }
762 }
763 \f
764
765 /* Prevent warnings from -Wmissing-prototypes.  */
766
767 #ifdef YYPARSE_PARAM
768 # if defined (__STDC__) || defined (__cplusplus)
769 int yyparse (void *YYPARSE_PARAM);
770 # else
771 int yyparse ();
772 # endif
773 #else /* ! YYPARSE_PARAM */
774 #if defined (__STDC__) || defined (__cplusplus)
775 int yyparse (void);
776 #else
777 int yyparse ();
778 #endif
779 #endif /* ! YYPARSE_PARAM */
780
781
782
783 /* The lookahead symbol.  */
784 int yychar;
785
786 /* The semantic value of the lookahead symbol.  */
787 YYSTYPE yylval;
788
789 /* Number of syntax errors so far.  */
790 int yynerrs;
791
792
793
794 /*----------.
795 | yyparse.  |
796 `----------*/
797
798 #ifdef YYPARSE_PARAM
799 # if defined (__STDC__) || defined (__cplusplus)
800 int yyparse (void *YYPARSE_PARAM)
801 # else
802 int yyparse (YYPARSE_PARAM)
803   void *YYPARSE_PARAM;
804 # endif
805 #else /* ! YYPARSE_PARAM */
806 #if defined (__STDC__) || defined (__cplusplus)
807 int
808 yyparse (void)
809 #else
810 int
811 yyparse ()
812
813 #endif
814 #endif
815 {
816   
817   register int yystate;
818   register int yyn;
819   int yyresult;
820   /* Number of tokens to shift before error messages enabled.  */
821   int yyerrstatus;
822   /* Lookahead token as an internal (translated) token number.  */
823   int yytoken = 0;
824
825   /* Three stacks and their tools:
826      `yyss': related to states,
827      `yyvs': related to semantic values,
828      `yyls': related to locations.
829
830      Refer to the stacks thru separate pointers, to allow yyoverflow
831      to reallocate them elsewhere.  */
832
833   /* The state stack.  */
834   short yyssa[YYINITDEPTH];
835   short *yyss = yyssa;
836   register short *yyssp;
837
838   /* The semantic value stack.  */
839   YYSTYPE yyvsa[YYINITDEPTH];
840   YYSTYPE *yyvs = yyvsa;
841   register YYSTYPE *yyvsp;
842
843
844
845 #define YYPOPSTACK   (yyvsp--, yyssp--)
846
847   YYSIZE_T yystacksize = YYINITDEPTH;
848
849   /* The variables used to return semantic value and location from the
850      action routines.  */
851   YYSTYPE yyval;
852
853
854   /* When reducing, the number of symbols on the RHS of the reduced
855      rule.  */
856   int yylen;
857
858   YYDPRINTF ((stderr, "Starting parse\n"));
859
860   yystate = 0;
861   yyerrstatus = 0;
862   yynerrs = 0;
863   yychar = YYEMPTY;             /* Cause a token to be read.  */
864
865   /* Initialize stack pointers.
866      Waste one element of value and location stack
867      so that they stay on the same level as the state stack.
868      The wasted elements are never initialized.  */
869
870   yyssp = yyss;
871   yyvsp = yyvs;
872
873   goto yysetstate;
874
875 /*------------------------------------------------------------.
876 | yynewstate -- Push a new state, which is found in yystate.  |
877 `------------------------------------------------------------*/
878  yynewstate:
879   /* In all cases, when you get here, the value and location stacks
880      have just been pushed. so pushing a state here evens the stacks.
881      */
882   yyssp++;
883
884  yysetstate:
885   *yyssp = yystate;
886
887   if (yyss + yystacksize - 1 <= yyssp)
888     {
889       /* Get the current used size of the three stacks, in elements.  */
890       YYSIZE_T yysize = yyssp - yyss + 1;
891
892 #ifdef yyoverflow
893       {
894         /* Give user a chance to reallocate the stack. Use copies of
895            these so that the &'s don't force the real ones into
896            memory.  */
897         YYSTYPE *yyvs1 = yyvs;
898         short *yyss1 = yyss;
899
900
901         /* Each stack pointer address is followed by the size of the
902            data in use in that stack, in bytes.  This used to be a
903            conditional around just the two extra args, but that might
904            be undefined if yyoverflow is a macro.  */
905         yyoverflow ("parser stack overflow",
906                     &yyss1, yysize * sizeof (*yyssp),
907                     &yyvs1, yysize * sizeof (*yyvsp),
908
909                     &yystacksize);
910
911         yyss = yyss1;
912         yyvs = yyvs1;
913       }
914 #else /* no yyoverflow */
915 # ifndef YYSTACK_RELOCATE
916       goto yyoverflowlab;
917 # else
918       /* Extend the stack our own way.  */
919       if (YYMAXDEPTH <= yystacksize)
920         goto yyoverflowlab;
921       yystacksize *= 2;
922       if (YYMAXDEPTH < yystacksize)
923         yystacksize = YYMAXDEPTH;
924
925       {
926         short *yyss1 = yyss;
927         union yyalloc *yyptr =
928           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
929         if (! yyptr)
930           goto yyoverflowlab;
931         YYSTACK_RELOCATE (yyss);
932         YYSTACK_RELOCATE (yyvs);
933
934 #  undef YYSTACK_RELOCATE
935         if (yyss1 != yyssa)
936           YYSTACK_FREE (yyss1);
937       }
938 # endif
939 #endif /* no yyoverflow */
940
941       yyssp = yyss + yysize - 1;
942       yyvsp = yyvs + yysize - 1;
943
944
945       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
946                   (unsigned long int) yystacksize));
947
948       if (yyss + yystacksize - 1 <= yyssp)
949         YYABORT;
950     }
951
952   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
953
954   goto yybackup;
955
956 /*-----------.
957 | yybackup.  |
958 `-----------*/
959 yybackup:
960
961 /* Do appropriate processing given the current state.  */
962 /* Read a lookahead token if we need one and don't already have one.  */
963 /* yyresume: */
964
965   /* First try to decide what to do without reference to lookahead token.  */
966
967   yyn = yypact[yystate];
968   if (yyn == YYPACT_NINF)
969     goto yydefault;
970
971   /* Not known => get a lookahead token if don't already have one.  */
972
973   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
974   if (yychar == YYEMPTY)
975     {
976       YYDPRINTF ((stderr, "Reading a token: "));
977       yychar = YYLEX;
978     }
979
980   if (yychar <= YYEOF)
981     {
982       yychar = yytoken = YYEOF;
983       YYDPRINTF ((stderr, "Now at end of input.\n"));
984     }
985   else
986     {
987       yytoken = YYTRANSLATE (yychar);
988       YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
989     }
990
991   /* If the proper action on seeing token YYTOKEN is to reduce or to
992      detect an error, take that action.  */
993   yyn += yytoken;
994   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
995     goto yydefault;
996   yyn = yytable[yyn];
997   if (yyn <= 0)
998     {
999       if (yyn == 0 || yyn == YYTABLE_NINF)
1000         goto yyerrlab;
1001       yyn = -yyn;
1002       goto yyreduce;
1003     }
1004
1005   if (yyn == YYFINAL)
1006     YYACCEPT;
1007
1008   /* Shift the lookahead token.  */
1009   YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1010
1011   /* Discard the token being shifted unless it is eof.  */
1012   if (yychar != YYEOF)
1013     yychar = YYEMPTY;
1014
1015   *++yyvsp = yylval;
1016
1017
1018   /* Count tokens shifted since error; after three, turn off error
1019      status.  */
1020   if (yyerrstatus)
1021     yyerrstatus--;
1022
1023   yystate = yyn;
1024   goto yynewstate;
1025
1026
1027 /*-----------------------------------------------------------.
1028 | yydefault -- do the default action for the current state.  |
1029 `-----------------------------------------------------------*/
1030 yydefault:
1031   yyn = yydefact[yystate];
1032   if (yyn == 0)
1033     goto yyerrlab;
1034   goto yyreduce;
1035
1036
1037 /*-----------------------------.
1038 | yyreduce -- Do a reduction.  |
1039 `-----------------------------*/
1040 yyreduce:
1041   /* yyn is the number of a rule to reduce with.  */
1042   yylen = yyr2[yyn];
1043
1044   /* If YYLEN is nonzero, implement the default value of the action:
1045      `$$ = $1'.
1046
1047      Otherwise, the following line sets YYVAL to garbage.
1048      This behavior is undocumented and Bison
1049      users should not rely upon it.  Assigning to YYVAL
1050      unconditionally makes the parser a bit smaller, and it avoids a
1051      GCC warning that YYVAL may be used uninitialized.  */
1052   yyval = yyvsp[1-yylen];
1053
1054
1055   YY_REDUCE_PRINT (yyn);
1056   switch (yyn)
1057     {
1058         case 2:
1059 #line 45 "ssfilter.y"
1060     {
1061                 *yy_ret = yyvsp[0];
1062                 yyval = yyvsp[0];
1063         ;}
1064     break;
1065
1066   case 4:
1067 #line 51 "ssfilter.y"
1068     { yyval = NULL; ;}
1069     break;
1070
1071   case 5:
1072 #line 54 "ssfilter.y"
1073     {
1074                 yyval = alloc_node(SSF_DCOND, yyvsp[0]);
1075         ;}
1076     break;
1077
1078   case 6:
1079 #line 58 "ssfilter.y"
1080     { 
1081                 yyval = alloc_node(SSF_SCOND, yyvsp[0]);
1082         ;}
1083     break;
1084
1085   case 7:
1086 #line 62 "ssfilter.y"
1087     {
1088                 yyval = alloc_node(SSF_D_GE, yyvsp[0]);
1089         ;}
1090     break;
1091
1092   case 8:
1093 #line 66 "ssfilter.y"
1094     {
1095                 yyval = alloc_node(SSF_D_LE, yyvsp[0]);
1096         ;}
1097     break;
1098
1099   case 9:
1100 #line 70 "ssfilter.y"
1101     {
1102                 yyval = alloc_node(SSF_NOT, alloc_node(SSF_D_LE, yyvsp[0]));
1103         ;}
1104     break;
1105
1106   case 10:
1107 #line 74 "ssfilter.y"
1108     {
1109                 yyval = alloc_node(SSF_NOT, alloc_node(SSF_D_GE, yyvsp[0]));
1110         ;}
1111     break;
1112
1113   case 11:
1114 #line 78 "ssfilter.y"
1115     {
1116                 yyval = alloc_node(SSF_DCOND, yyvsp[0]);
1117         ;}
1118     break;
1119
1120   case 12:
1121 #line 82 "ssfilter.y"
1122     {
1123                 yyval = alloc_node(SSF_NOT, alloc_node(SSF_DCOND, yyvsp[0]));
1124         ;}
1125     break;
1126
1127   case 13:
1128 #line 87 "ssfilter.y"
1129     {
1130                 yyval = alloc_node(SSF_S_GE, yyvsp[0]);
1131         ;}
1132     break;
1133
1134   case 14:
1135 #line 91 "ssfilter.y"
1136     {
1137                 yyval = alloc_node(SSF_S_LE, yyvsp[0]);
1138         ;}
1139     break;
1140
1141   case 15:
1142 #line 95 "ssfilter.y"
1143     {
1144                 yyval = alloc_node(SSF_NOT, alloc_node(SSF_S_LE, yyvsp[0]));
1145         ;}
1146     break;
1147
1148   case 16:
1149 #line 99 "ssfilter.y"
1150     {
1151                 yyval = alloc_node(SSF_NOT, alloc_node(SSF_S_GE, yyvsp[0]));
1152         ;}
1153     break;
1154
1155   case 17:
1156 #line 103 "ssfilter.y"
1157     {
1158                 yyval = alloc_node(SSF_SCOND, yyvsp[0]);
1159         ;}
1160     break;
1161
1162   case 18:
1163 #line 107 "ssfilter.y"
1164     {
1165                 yyval = alloc_node(SSF_NOT, alloc_node(SSF_SCOND, yyvsp[0]));
1166         ;}
1167     break;
1168
1169   case 19:
1170 #line 112 "ssfilter.y"
1171     {
1172                 yyval = alloc_node(SSF_S_AUTO, NULL);
1173         ;}
1174     break;
1175
1176   case 20:
1177 #line 116 "ssfilter.y"
1178     {
1179                 yyval = alloc_node(SSF_OR, yyvsp[-2]);
1180                 yyval->post = yyvsp[0];
1181         ;}
1182     break;
1183
1184   case 21:
1185 #line 121 "ssfilter.y"
1186     {
1187                 yyval = alloc_node(SSF_AND, yyvsp[-1]);
1188                 yyval->post = yyvsp[0];
1189         ;}
1190     break;
1191
1192   case 22:
1193 #line 127 "ssfilter.y"
1194     {
1195                 yyval = alloc_node(SSF_AND, yyvsp[-2]);
1196                 yyval->post = yyvsp[0];
1197         ;}
1198     break;
1199
1200   case 23:
1201 #line 132 "ssfilter.y"
1202     {
1203                 yyval = alloc_node(SSF_NOT, yyvsp[0]);
1204         ;}
1205     break;
1206
1207   case 24:
1208 #line 136 "ssfilter.y"
1209     {
1210                 yyval = yyvsp[-1];
1211         ;}
1212     break;
1213
1214
1215     }
1216
1217 /* Line 1000 of yacc.c.  */
1218 #line 1219 "ssfilter.c"
1219 \f
1220   yyvsp -= yylen;
1221   yyssp -= yylen;
1222
1223
1224   YY_STACK_PRINT (yyss, yyssp);
1225
1226   *++yyvsp = yyval;
1227
1228
1229   /* Now `shift' the result of the reduction.  Determine what state
1230      that goes to, based on the state we popped back to and the rule
1231      number reduced by.  */
1232
1233   yyn = yyr1[yyn];
1234
1235   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1236   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1237     yystate = yytable[yystate];
1238   else
1239     yystate = yydefgoto[yyn - YYNTOKENS];
1240
1241   goto yynewstate;
1242
1243
1244 /*------------------------------------.
1245 | yyerrlab -- here on detecting error |
1246 `------------------------------------*/
1247 yyerrlab:
1248   /* If not already recovering from an error, report this error.  */
1249   if (!yyerrstatus)
1250     {
1251       ++yynerrs;
1252 #if YYERROR_VERBOSE
1253       yyn = yypact[yystate];
1254
1255       if (YYPACT_NINF < yyn && yyn < YYLAST)
1256         {
1257           YYSIZE_T yysize = 0;
1258           int yytype = YYTRANSLATE (yychar);
1259           const char* yyprefix;
1260           char *yymsg;
1261           int yyx;
1262
1263           /* Start YYX at -YYN if negative to avoid negative indexes in
1264              YYCHECK.  */
1265           int yyxbegin = yyn < 0 ? -yyn : 0;
1266
1267           /* Stay within bounds of both yycheck and yytname.  */
1268           int yychecklim = YYLAST - yyn;
1269           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1270           int yycount = 0;
1271
1272           yyprefix = ", expecting ";
1273           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1274             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1275               {
1276                 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
1277                 yycount += 1;
1278                 if (yycount == 5)
1279                   {
1280                     yysize = 0;
1281                     break;
1282                   }
1283               }
1284           yysize += (sizeof ("syntax error, unexpected ")
1285                      + yystrlen (yytname[yytype]));
1286           yymsg = (char *) YYSTACK_ALLOC (yysize);
1287           if (yymsg != 0)
1288             {
1289               char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1290               yyp = yystpcpy (yyp, yytname[yytype]);
1291
1292               if (yycount < 5)
1293                 {
1294                   yyprefix = ", expecting ";
1295                   for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1296                     if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1297                       {
1298                         yyp = yystpcpy (yyp, yyprefix);
1299                         yyp = yystpcpy (yyp, yytname[yyx]);
1300                         yyprefix = " or ";
1301                       }
1302                 }
1303               yyerror (yymsg);
1304               YYSTACK_FREE (yymsg);
1305             }
1306           else
1307             yyerror ("syntax error; also virtual memory exhausted");
1308         }
1309       else
1310 #endif /* YYERROR_VERBOSE */
1311         yyerror ("syntax error");
1312     }
1313
1314
1315
1316   if (yyerrstatus == 3)
1317     {
1318       /* If just tried and failed to reuse lookahead token after an
1319          error, discard it.  */
1320
1321       if (yychar <= YYEOF)
1322         {
1323           /* If at end of input, pop the error token,
1324              then the rest of the stack, then return failure.  */
1325           if (yychar == YYEOF)
1326              for (;;)
1327                {
1328                  YYPOPSTACK;
1329                  if (yyssp == yyss)
1330                    YYABORT;
1331                  YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1332                  yydestruct (yystos[*yyssp], yyvsp);
1333                }
1334         }
1335       else
1336         {
1337           YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1338           yydestruct (yytoken, &yylval);
1339           yychar = YYEMPTY;
1340
1341         }
1342     }
1343
1344   /* Else will try to reuse lookahead token after shifting the error
1345      token.  */
1346   goto yyerrlab1;
1347
1348
1349 /*---------------------------------------------------.
1350 | yyerrorlab -- error raised explicitly by YYERROR.  |
1351 `---------------------------------------------------*/
1352 yyerrorlab:
1353
1354 #ifdef __GNUC__
1355   /* Pacify GCC when the user code never invokes YYERROR and the label
1356      yyerrorlab therefore never appears in user code.  */
1357   if (0)
1358      goto yyerrorlab;
1359 #endif
1360
1361   yyvsp -= yylen;
1362   yyssp -= yylen;
1363   yystate = *yyssp;
1364   goto yyerrlab1;
1365
1366
1367 /*-------------------------------------------------------------.
1368 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1369 `-------------------------------------------------------------*/
1370 yyerrlab1:
1371   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1372
1373   for (;;)
1374     {
1375       yyn = yypact[yystate];
1376       if (yyn != YYPACT_NINF)
1377         {
1378           yyn += YYTERROR;
1379           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1380             {
1381               yyn = yytable[yyn];
1382               if (0 < yyn)
1383                 break;
1384             }
1385         }
1386
1387       /* Pop the current state because it cannot handle the error token.  */
1388       if (yyssp == yyss)
1389         YYABORT;
1390
1391       YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1392       yydestruct (yystos[yystate], yyvsp);
1393       YYPOPSTACK;
1394       yystate = *yyssp;
1395       YY_STACK_PRINT (yyss, yyssp);
1396     }
1397
1398   if (yyn == YYFINAL)
1399     YYACCEPT;
1400
1401   YYDPRINTF ((stderr, "Shifting error token, "));
1402
1403   *++yyvsp = yylval;
1404
1405
1406   yystate = yyn;
1407   goto yynewstate;
1408
1409
1410 /*-------------------------------------.
1411 | yyacceptlab -- YYACCEPT comes here.  |
1412 `-------------------------------------*/
1413 yyacceptlab:
1414   yyresult = 0;
1415   goto yyreturn;
1416
1417 /*-----------------------------------.
1418 | yyabortlab -- YYABORT comes here.  |
1419 `-----------------------------------*/
1420 yyabortlab:
1421   yyresult = 1;
1422   goto yyreturn;
1423
1424 #ifndef yyoverflow
1425 /*----------------------------------------------.
1426 | yyoverflowlab -- parser overflow comes here.  |
1427 `----------------------------------------------*/
1428 yyoverflowlab:
1429   yyerror ("parser stack overflow");
1430   yyresult = 2;
1431   /* Fall through.  */
1432 #endif
1433
1434 yyreturn:
1435 #ifndef yyoverflow
1436   if (yyss != yyssa)
1437     YYSTACK_FREE (yyss);
1438 #endif
1439   return yyresult;
1440 }
1441
1442
1443 #line 140 "ssfilter.y"
1444
1445
1446 static char *get_token_from_line(char **ptr)
1447 {
1448         char *tok, *cp = *ptr;
1449
1450         while (*cp == ' ' || *cp == '\t') cp++;
1451
1452         if (*cp == 0) {
1453                 *ptr = cp;
1454                 return NULL;
1455         }
1456
1457         tok = cp;
1458
1459         while (*cp != 0 && *cp != ' ' && *cp != '\t') {
1460                 /* Backslash escapes everything. */
1461                 if (*cp == '\\') {
1462                         char *tp;
1463                         for (tp = cp; tp != tok; tp--)
1464                                 *tp = *(tp-1);
1465                         cp++;
1466                         tok++;
1467                         if (*cp == 0)
1468                                 break;
1469                 }
1470                 cp++;
1471         }
1472         if (*cp)
1473                 *cp++ = 0;
1474         *ptr = cp;
1475         return tok;
1476 }
1477
1478 int yylex(void)
1479 {
1480         static char argbuf[1024];
1481         static char *tokptr = argbuf;
1482         static int argc;
1483         char *curtok;
1484
1485         do {
1486                 while (*tokptr == 0) {
1487                         tokptr = NULL;
1488                         if (argc < yy_argc) {
1489                                 tokptr = yy_argv[argc];
1490                                 argc++;
1491                         } else if (yy_fp) {
1492                                 while (tokptr == NULL) {
1493                                         if (fgets(argbuf, sizeof(argbuf)-1, yy_fp) == NULL)
1494                                                 return 0;
1495                                         argbuf[sizeof(argbuf)-1] = 0;
1496                                         if (strlen(argbuf) == sizeof(argbuf) - 1) {
1497                                                 fprintf(stderr, "Too long line in filter");
1498                                                 exit(-1);
1499                                         }
1500                                         if (argbuf[strlen(argbuf)-1] == '\n')
1501                                                 argbuf[strlen(argbuf)-1] = 0;
1502                                         if (argbuf[0] == '#' || argbuf[0] == '0')
1503                                                 continue;
1504                                         tokptr = argbuf;
1505                                 }
1506                         } else {
1507                                 return 0;
1508                         }
1509                 }
1510         } while ((curtok = get_token_from_line(&tokptr)) == NULL);
1511
1512         if (strcmp(curtok, "!") == 0 ||
1513             strcmp(curtok, "not") == 0)
1514                 return '!';
1515         if (strcmp(curtok, "&") == 0 ||
1516             strcmp(curtok, "&&") == 0 ||
1517             strcmp(curtok, "and") == 0)
1518                 return '&';
1519         if (strcmp(curtok, "|") == 0 ||
1520             strcmp(curtok, "||") == 0 ||
1521             strcmp(curtok, "or") == 0)
1522                 return '|';
1523         if (strcmp(curtok, "(") == 0)
1524                 return '(';
1525         if (strcmp(curtok, ")") == 0)
1526                 return ')';
1527         if (strcmp(curtok, "dst") == 0)
1528                 return DCOND;
1529         if (strcmp(curtok, "src") == 0)
1530                 return SCOND;
1531         if (strcmp(curtok, "dport") == 0)
1532                 return DPORT;
1533         if (strcmp(curtok, "sport") == 0)
1534                 return SPORT;
1535         if (strcmp(curtok, ">=") == 0 ||
1536             strcmp(curtok, "ge") == 0 ||
1537             strcmp(curtok, "geq") == 0)
1538                 return GEQ;
1539         if (strcmp(curtok, "<=") == 0 ||
1540             strcmp(curtok, "le") == 0 ||
1541             strcmp(curtok, "leq") == 0)
1542                 return LEQ;
1543         if (strcmp(curtok, "!=") == 0 ||
1544             strcmp(curtok, "ne") == 0 ||
1545             strcmp(curtok, "neq") == 0)
1546                 return NEQ;
1547         if (strcmp(curtok, "=") == 0 ||
1548             strcmp(curtok, "==") == 0 ||
1549             strcmp(curtok, "eq") == 0)
1550                 return '=';
1551         if (strcmp(curtok, ">") == 0 ||
1552             strcmp(curtok, "gt") == 0)
1553                 return '>';
1554         if (strcmp(curtok, "<") == 0 ||
1555             strcmp(curtok, "lt") == 0)
1556                 return '<';
1557         if (strcmp(curtok, "autobound") == 0)
1558                 return AUTOBOUND;
1559         yylval = (void*)parse_hostcond(curtok);
1560         if (yylval == NULL) {
1561                 fprintf(stderr, "Cannot parse dst/src address.\n");
1562                 exit(1);
1563         }
1564         return HOSTCOND;
1565 }
1566
1567 int ssfilter_parse(struct ssfilter **f, int argc, char **argv, FILE *fp)
1568 {
1569         yy_argc = argc;
1570         yy_argv = argv;
1571         yy_fp   = fp;
1572         yy_ret  = f;
1573
1574         if (yyparse()) {
1575                 fprintf(stderr, " Sorry.\n");
1576                 return -1;
1577         }
1578         return 0;
1579 }
1580
1581