]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ofed/libsdp/src/config_parser.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ofed / libsdp / src / config_parser.c
1 /* A Bison parser, made by GNU Bison 2.3.  */
2
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
4
5    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6    Free Software Foundation, Inc.
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2, or (at your option)
11    any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor,
21    Boston, MA 02110-1301, USA.  */
22
23 /* As a special exception, you may create a larger work that contains
24    part or all of the Bison parser skeleton and distribute that work
25    under terms of your choice, so long as that work isn't itself a
26    parser generator using the skeleton or a modified version thereof
27    as a parser skeleton.  Alternatively, if you modify or redistribute
28    the parser skeleton itself, you may (at your option) remove this
29    special exception, which will cause the skeleton and the resulting
30    Bison output files to be licensed under the GNU General Public
31    License without this special exception.
32
33    This special exception was added by the Free Software Foundation in
34    version 2.2 of Bison.  */
35
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37    simplifying the original so-called "semantic" parser.  */
38
39 /* All symbols defined below should begin with yy or YY, to avoid
40    infringing on user name space.  This should be done even for local
41    variables, as they might otherwise be expanded by user macros.
42    There are some unavoidable exceptions within include files to
43    define necessary library symbols; they are noted "INFRINGES ON
44    USER NAME SPACE" below.  */
45
46 /* Identify Bison output.  */
47 #define YYBISON 1
48
49 /* Bison version.  */
50 #define YYBISON_VERSION "2.3"
51
52 /* Skeleton name.  */
53 #define YYSKELETON_NAME "yacc.c"
54
55 /* Pure parsers.  */
56 #define YYPURE 0
57
58 /* Using locations.  */
59 #define YYLSP_NEEDED 0
60
61 /* Substitute the variable and function names.  */
62 #define yyparse libsdp_yyparse
63 #define yylex   libsdp_yylex
64 #define yyerror libsdp_yyerror
65 #define yylval  libsdp_yylval
66 #define yychar  libsdp_yychar
67 #define yydebug libsdp_yydebug
68 #define yynerrs libsdp_yynerrs
69
70
71 /* Tokens.  */
72 #ifndef YYTOKENTYPE
73 # define YYTOKENTYPE
74    /* Put the tokens into the symbol table, so that GDB and other debuggers
75       know about them.  */
76    enum yytokentype {
77      USE = 258,
78      CLIENT = 259,
79      SERVER = 260,
80      TCP = 261,
81      SDP = 262,
82      BOTH = 263,
83      INT = 264,
84      LOG = 265,
85      DEST = 266,
86      STDERR = 267,
87      SYSLOG = 268,
88      FILENAME = 269,
89      NAME = 270,
90      LEVEL = 271,
91      LINE = 272
92    };
93 #endif
94 /* Tokens.  */
95 #define USE 258
96 #define CLIENT 259
97 #define SERVER 260
98 #define TCP 261
99 #define SDP 262
100 #define BOTH 263
101 #define INT 264
102 #define LOG 265
103 #define DEST 266
104 #define STDERR 267
105 #define SYSLOG 268
106 #define FILENAME 269
107 #define NAME 270
108 #define LEVEL 271
109 #define LINE 272
110
111
112
113
114 /* Copy the first part of user declarations.  */
115 #line 39 "./config_parser.y"
116
117
118 /* header section */
119 #include <stdlib.h>
120 #include <stdio.h>
121 #include <string.h>
122 #include "libsdp.h"
123 #include <sys/socket.h>
124 #include <netinet/in.h>
125 #include <arpa/inet.h>
126
127 #define YYERROR_VERBOSE 1
128
129 extern int yyerror(char *msg);
130 extern int yylex(void);
131 static int parse_err = 0;
132
133 struct use_family_rule *__sdp_clients_family_rules_head = NULL;
134 struct use_family_rule *__sdp_clients_family_rules_tail = NULL;
135 struct use_family_rule *__sdp_servers_family_rules_head = NULL;
136 struct use_family_rule *__sdp_servers_family_rules_tail = NULL;
137
138 /* some globals to store intermidiate parser state */
139 static struct use_family_rule __sdp_rule;
140 static int current_role = 0;
141
142 int __sdp_config_empty(
143                        void
144                        )
145 {
146   return ( (__sdp_clients_family_rules_head == NULL) &&
147            (__sdp_servers_family_rules_head == NULL) );
148 }
149
150 /* define the address by 4 integers */
151 static void __sdp_set_ipv4_addr(short a0, short a1, short a2, short a3)
152 {
153   char buf[16];
154   sprintf(buf,"%d.%d.%d.%d", a0, a1, a2, a3);
155   if (!inet_aton(buf, &( __sdp_rule.ipv4 )))
156   {
157     parse_err = 1;
158     yyerror("provided address is not legal");
159   }
160 }
161
162 static void __sdp_set_prog_name_expr(char *prog_name_expr)
163 {
164   __sdp_rule.prog_name_expr = strdup(prog_name_expr);
165   if (!__sdp_rule.prog_name_expr) {
166     yyerror("fail to allocate program name expression");    
167   }
168 }
169
170 static char *__sdp_get_role_str(int role)
171 {
172   if (role == 1) return("server");
173   if (role == 2) return("client");
174   return("unknown role");
175 }
176
177 extern int __sdp_min_level;
178
179 /* dump the current state in readable format */
180 static void  __sdp_dump_config_state() {
181   char buf[1024];
182   sprintf(buf, "CONFIG: use %s %s %s", 
183           __sdp_get_family_str(__sdp_rule.target_family), 
184           __sdp_get_role_str( current_role ),
185           __sdp_rule.prog_name_expr);
186   if (__sdp_rule.match_by_addr) {
187     if ( __sdp_rule.prefixlen != 32 )
188       sprintf(buf+strlen(buf), " %s/%d", 
189               inet_ntoa( __sdp_rule.ipv4 ), __sdp_rule.prefixlen);
190     else
191       sprintf(buf+strlen(buf), " %s", inet_ntoa( __sdp_rule.ipv4 ));
192   } else {
193     sprintf(buf+strlen(buf), " *");
194   }
195   if (__sdp_rule.match_by_port) {
196     sprintf(buf+strlen(buf), ":%d",__sdp_rule.sport);
197     if (__sdp_rule.eport > __sdp_rule.sport) 
198       sprintf(buf+strlen(buf), "-%d",__sdp_rule.eport);
199   }
200   else
201     sprintf(buf+strlen(buf), ":*");
202   sprintf(buf+strlen(buf), "\n");
203   __sdp_log(1, buf);
204 }
205
206 /* use the above state for making a new rule */
207 static void __sdp_add_rule() {
208   struct use_family_rule **p_tail, **p_head, *rule;
209
210   if (__sdp_min_level <= 1) __sdp_dump_config_state();
211   if ( current_role == 1 ) {
212     p_tail = &__sdp_servers_family_rules_tail;
213     p_head = &__sdp_servers_family_rules_head;
214   } else if ( current_role == 2 ) {
215     p_tail = &__sdp_clients_family_rules_tail;
216     p_head = &__sdp_clients_family_rules_head;
217   } else {
218     yyerror("ignoring unknown role");
219     parse_err = 1;
220     return;
221   }
222
223   rule = (struct use_family_rule *)malloc(sizeof(*rule));
224   if (!rule) {
225     yyerror("fail to allocate new rule");
226     parse_err = 1;
227     return;
228   }
229
230   memset(rule, 0, sizeof(*rule));
231   *rule = __sdp_rule;
232   rule->prev = *p_tail;
233   if (!(*p_head)) {
234     *p_head = rule;
235   } else {
236     (*p_tail)->next = rule;
237   } /* if */
238   *p_tail = rule;
239 }
240
241
242
243 /* Enabling traces.  */
244 #ifndef YYDEBUG
245 # define YYDEBUG 1
246 #endif
247
248 /* Enabling verbose error messages.  */
249 #ifdef YYERROR_VERBOSE
250 # undef YYERROR_VERBOSE
251 # define YYERROR_VERBOSE 1
252 #else
253 # define YYERROR_VERBOSE 1
254 #endif
255
256 /* Enabling the token table.  */
257 #ifndef YYTOKEN_TABLE
258 # define YYTOKEN_TABLE 0
259 #endif
260
261 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
262 typedef union YYSTYPE
263 #line 167 "./config_parser.y"
264 {
265   int        ival;
266   char      *sval;
267 }
268 /* Line 193 of yacc.c.  */
269 #line 270 "y.tab.c"
270         YYSTYPE;
271 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
272 # define YYSTYPE_IS_DECLARED 1
273 # define YYSTYPE_IS_TRIVIAL 1
274 #endif
275
276
277
278 /* Copy the second part of user declarations.  */
279 #line 192 "./config_parser.y"
280
281   long __sdp_config_line_num;
282
283
284 /* Line 216 of yacc.c.  */
285 #line 286 "y.tab.c"
286
287 #ifdef short
288 # undef short
289 #endif
290
291 #ifdef YYTYPE_UINT8
292 typedef YYTYPE_UINT8 yytype_uint8;
293 #else
294 typedef unsigned char yytype_uint8;
295 #endif
296
297 #ifdef YYTYPE_INT8
298 typedef YYTYPE_INT8 yytype_int8;
299 #elif (defined __STDC__ || defined __C99__FUNC__ \
300      || defined __cplusplus || defined _MSC_VER)
301 typedef signed char yytype_int8;
302 #else
303 typedef short int yytype_int8;
304 #endif
305
306 #ifdef YYTYPE_UINT16
307 typedef YYTYPE_UINT16 yytype_uint16;
308 #else
309 typedef unsigned short int yytype_uint16;
310 #endif
311
312 #ifdef YYTYPE_INT16
313 typedef YYTYPE_INT16 yytype_int16;
314 #else
315 typedef short int yytype_int16;
316 #endif
317
318 #ifndef YYSIZE_T
319 # ifdef __SIZE_TYPE__
320 #  define YYSIZE_T __SIZE_TYPE__
321 # elif defined size_t
322 #  define YYSIZE_T size_t
323 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
324      || defined __cplusplus || defined _MSC_VER)
325 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
326 #  define YYSIZE_T size_t
327 # else
328 #  define YYSIZE_T unsigned int
329 # endif
330 #endif
331
332 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
333
334 #ifndef YY_
335 # if YYENABLE_NLS
336 #  if ENABLE_NLS
337 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
338 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
339 #  endif
340 # endif
341 # ifndef YY_
342 #  define YY_(msgid) msgid
343 # endif
344 #endif
345
346 /* Suppress unused-variable warnings by "using" E.  */
347 #if ! defined lint || defined __GNUC__
348 # define YYUSE(e) ((void) (e))
349 #else
350 # define YYUSE(e) /* empty */
351 #endif
352
353 /* Identity function, used to suppress warnings about constant conditions.  */
354 #ifndef lint
355 # define YYID(n) (n)
356 #else
357 #if (defined __STDC__ || defined __C99__FUNC__ \
358      || defined __cplusplus || defined _MSC_VER)
359 static int
360 YYID (int i)
361 #else
362 static int
363 YYID (i)
364     int i;
365 #endif
366 {
367   return i;
368 }
369 #endif
370
371 #if ! defined yyoverflow || YYERROR_VERBOSE
372
373 /* The parser invokes alloca or malloc; define the necessary symbols.  */
374
375 # ifdef YYSTACK_USE_ALLOCA
376 #  if YYSTACK_USE_ALLOCA
377 #   ifdef __GNUC__
378 #    define YYSTACK_ALLOC __builtin_alloca
379 #   elif defined __BUILTIN_VA_ARG_INCR
380 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
381 #   elif defined _AIX
382 #    define YYSTACK_ALLOC __alloca
383 #   elif defined _MSC_VER
384 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
385 #    define alloca _alloca
386 #   else
387 #    define YYSTACK_ALLOC alloca
388 #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
389      || defined __cplusplus || defined _MSC_VER)
390 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
391 #     ifndef _STDLIB_H
392 #      define _STDLIB_H 1
393 #     endif
394 #    endif
395 #   endif
396 #  endif
397 # endif
398
399 # ifdef YYSTACK_ALLOC
400    /* Pacify GCC's `empty if-body' warning.  */
401 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
402 #  ifndef YYSTACK_ALLOC_MAXIMUM
403     /* The OS might guarantee only one guard page at the bottom of the stack,
404        and a page size can be as small as 4096 bytes.  So we cannot safely
405        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
406        to allow for a few compiler-allocated temporary stack slots.  */
407 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
408 #  endif
409 # else
410 #  define YYSTACK_ALLOC YYMALLOC
411 #  define YYSTACK_FREE YYFREE
412 #  ifndef YYSTACK_ALLOC_MAXIMUM
413 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
414 #  endif
415 #  if (defined __cplusplus && ! defined _STDLIB_H \
416        && ! ((defined YYMALLOC || defined malloc) \
417              && (defined YYFREE || defined free)))
418 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
419 #   ifndef _STDLIB_H
420 #    define _STDLIB_H 1
421 #   endif
422 #  endif
423 #  ifndef YYMALLOC
424 #   define YYMALLOC malloc
425 #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
426      || defined __cplusplus || defined _MSC_VER)
427 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
428 #   endif
429 #  endif
430 #  ifndef YYFREE
431 #   define YYFREE free
432 #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
433      || defined __cplusplus || defined _MSC_VER)
434 void free (void *); /* INFRINGES ON USER NAME SPACE */
435 #   endif
436 #  endif
437 # endif
438 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
439
440
441 #if (! defined yyoverflow \
442      && (! defined __cplusplus \
443          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
444
445 /* A type that is properly aligned for any stack member.  */
446 union yyalloc
447 {
448   yytype_int16 yyss;
449   YYSTYPE yyvs;
450   };
451
452 /* The size of the maximum gap between one aligned stack and the next.  */
453 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
454
455 /* The size of an array large to enough to hold all stacks, each with
456    N elements.  */
457 # define YYSTACK_BYTES(N) \
458      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
459       + YYSTACK_GAP_MAXIMUM)
460
461 /* Copy COUNT objects from FROM to TO.  The source and destination do
462    not overlap.  */
463 # ifndef YYCOPY
464 #  if defined __GNUC__ && 1 < __GNUC__
465 #   define YYCOPY(To, From, Count) \
466       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
467 #  else
468 #   define YYCOPY(To, From, Count)              \
469       do                                        \
470         {                                       \
471           YYSIZE_T yyi;                         \
472           for (yyi = 0; yyi < (Count); yyi++)   \
473             (To)[yyi] = (From)[yyi];            \
474         }                                       \
475       while (YYID (0))
476 #  endif
477 # endif
478
479 /* Relocate STACK from its old location to the new one.  The
480    local variables YYSIZE and YYSTACKSIZE give the old and new number of
481    elements in the stack, and YYPTR gives the new location of the
482    stack.  Advance YYPTR to a properly aligned location for the next
483    stack.  */
484 # define YYSTACK_RELOCATE(Stack)                                        \
485     do                                                                  \
486       {                                                                 \
487         YYSIZE_T yynewbytes;                                            \
488         YYCOPY (&yyptr->Stack, Stack, yysize);                          \
489         Stack = &yyptr->Stack;                                          \
490         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
491         yyptr += yynewbytes / sizeof (*yyptr);                          \
492       }                                                                 \
493     while (YYID (0))
494
495 #endif
496
497 /* YYFINAL -- State number of the termination state.  */
498 #define YYFINAL  7
499 /* YYLAST -- Last index in YYTABLE.  */
500 #define YYLAST   36
501
502 /* YYNTOKENS -- Number of terminals.  */
503 #define YYNTOKENS  23
504 /* YYNNTS -- Number of nonterminals.  */
505 #define YYNNTS  17
506 /* YYNRULES -- Number of rules.  */
507 #define YYNRULES  33
508 /* YYNRULES -- Number of states.  */
509 #define YYNSTATES  53
510
511 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
512 #define YYUNDEFTOK  2
513 #define YYMAXUTOK   272
514
515 #define YYTRANSLATE(YYX)                                                \
516   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
517
518 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
519 static const yytype_uint8 yytranslate[] =
520 {
521        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
522        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
523        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
524        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
525        2,     2,    19,     2,     2,    22,    21,    20,     2,     2,
526        2,     2,     2,     2,     2,     2,     2,     2,    18,     2,
527        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
528        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
529        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
530        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
531        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
532        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
533        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
534        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
535        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
536        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
537        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
538        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
539        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
540        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
541        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
542        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
543        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
544        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
545        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
546        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
547        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
548       15,    16,    17
549 };
550
551 #if YYDEBUG
552 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
553    YYRHS.  */
554 static const yytype_uint8 yyprhs[] =
555 {
556        0,     0,     3,     5,     8,     9,    11,    14,    15,    18,
557       20,    22,    26,    27,    30,    33,    36,    39,    43,    46,
558       55,    57,    59,    61,    63,    65,    67,    69,    71,    75,
559       77,    85,    87,    91
560 };
561
562 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
563 static const yytype_int8 yyrhs[] =
564 {
565       26,     0,    -1,    17,    -1,    24,    17,    -1,    -1,    24,
566       -1,    25,    27,    -1,    -1,    27,    28,    -1,    29,    -1,
567       33,    -1,    10,    30,    24,    -1,    -1,    30,    31,    -1,
568       30,    32,    -1,    11,    12,    -1,    11,    13,    -1,    11,
569       14,    15,    -1,    16,     9,    -1,     3,    34,    35,    36,
570       37,    18,    39,    24,    -1,     6,    -1,     7,    -1,     8,
571       -1,     5,    -1,     4,    -1,    15,    -1,    19,    -1,    38,
572       -1,    38,    20,     9,    -1,    19,    -1,     9,    21,     9,
573       21,     9,    21,     9,    -1,     9,    -1,     9,    22,     9,
574       -1,    19,    -1
575 };
576
577 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
578 static const yytype_uint16 yyrline[] =
579 {
580        0,   198,   198,   199,   201,   202,   205,   208,   209,   213,
581      214,   218,   221,   222,   223,   227,   228,   229,   233,   237,
582      241,   242,   243,   247,   248,   252,   253,   257,   258,   259,
583      263,   267,   268,   269
584 };
585 #endif
586
587 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
588 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
589    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
590 static const char *const yytname[] =
591 {
592   "$end", "error", "$undefined", "\"use\"", "\"client or connect\"",
593   "\"server or listen\"", "\"tcp\"", "\"sdp\"", "\"both\"",
594   "\"integer value\"", "\"log statement\"", "\"destination\"",
595   "\"stderr\"", "\"syslog\"", "\"file\"", "\"a name\"", "\"min-level\"",
596   "\"new line\"", "':'", "'*'", "'/'", "'.'", "'-'", "$accept", "NL",
597   "ONL", "config", "statements", "statement", "log_statement", "log_opts",
598   "log_dest", "verbosity", "socket_statement", "family", "role", "program",
599   "address", "ipv4", "ports", 0
600 };
601 #endif
602
603 # ifdef YYPRINT
604 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
605    token YYLEX-NUM.  */
606 static const yytype_uint16 yytoknum[] =
607 {
608        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
609      265,   266,   267,   268,   269,   270,   271,   272,    58,    42,
610       47,    46,    45
611 };
612 # endif
613
614 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
615 static const yytype_uint8 yyr1[] =
616 {
617        0,    23,    24,    24,    25,    25,    26,    27,    27,    28,
618       28,    29,    30,    30,    30,    31,    31,    31,    32,    33,
619       34,    34,    34,    35,    35,    36,    36,    37,    37,    37,
620       38,    39,    39,    39
621 };
622
623 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
624 static const yytype_uint8 yyr2[] =
625 {
626        0,     2,     1,     2,     0,     1,     2,     0,     2,     1,
627        1,     3,     0,     2,     2,     2,     2,     3,     2,     8,
628        1,     1,     1,     1,     1,     1,     1,     1,     3,     1,
629        7,     1,     3,     1
630 };
631
632 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
633    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
634    means the default is an error.  */
635 static const yytype_uint8 yydefact[] =
636 {
637        4,     2,     5,     7,     0,     3,     6,     1,     0,    12,
638        8,     9,    10,    20,    21,    22,     0,     0,    24,    23,
639        0,     0,     0,    11,    13,    14,    25,    26,     0,    15,
640       16,     0,    18,     0,    29,     0,    27,    17,     0,     0,
641        0,     0,    31,    33,     0,    28,     0,     0,    19,     0,
642       32,     0,    30
643 };
644
645 /* YYDEFGOTO[NTERM-NUM].  */
646 static const yytype_int8 yydefgoto[] =
647 {
648       -1,     2,     3,     4,     6,    10,    11,    17,    24,    25,
649       12,    16,    20,    28,    35,    36,    44
650 };
651
652 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
653    STATE-NUM.  */
654 #define YYPACT_NINF -18
655 static const yytype_int8 yypact[] =
656 {
657      -13,   -18,     4,   -18,    22,   -18,     0,   -18,     9,   -18,
658      -18,   -18,   -18,   -18,   -18,   -18,     2,    -3,   -18,   -18,
659      -10,     6,    14,     4,   -18,   -18,   -18,   -18,    -8,   -18,
660      -18,    10,   -18,     3,   -18,     8,    11,   -18,    19,    -7,
661       20,    12,    13,   -18,   -13,   -18,    21,    23,     4,    15,
662      -18,    25,   -18
663 };
664
665 /* YYPGOTO[NTERM-NUM].  */
666 static const yytype_int8 yypgoto[] =
667 {
668      -18,   -17,   -18,   -18,   -18,   -18,   -18,   -18,   -18,   -18,
669      -18,   -18,   -18,   -18,   -18,   -18,   -18
670 };
671
672 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
673    positive, shift that token.  If negative, reduce the rule which
674    number is the opposite.  If zero, do what YYDEFACT says.
675    If YYTABLE_NINF, syntax error.  */
676 #define YYTABLE_NINF -1
677 static const yytype_uint8 yytable[] =
678 {
679       23,    33,    42,     8,     1,    26,    18,    19,    21,    27,
680        9,    34,    43,    22,     1,    13,    14,    15,    29,    30,
681       31,     5,     7,    32,    38,    37,    39,    48,    41,    45,
682       49,    40,    50,    46,    52,    47,    51
683 };
684
685 static const yytype_uint8 yycheck[] =
686 {
687       17,     9,     9,     3,    17,    15,     4,     5,    11,    19,
688       10,    19,    19,    16,    17,     6,     7,     8,    12,    13,
689       14,    17,     0,     9,    21,    15,    18,    44,     9,     9,
690        9,    20,     9,    21,     9,    22,    21
691 };
692
693 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
694    symbol of state STATE-NUM.  */
695 static const yytype_uint8 yystos[] =
696 {
697        0,    17,    24,    25,    26,    17,    27,     0,     3,    10,
698       28,    29,    33,     6,     7,     8,    34,    30,     4,     5,
699       35,    11,    16,    24,    31,    32,    15,    19,    36,    12,
700       13,    14,     9,     9,    19,    37,    38,    15,    21,    18,
701       20,     9,     9,    19,    39,     9,    21,    22,    24,     9,
702        9,    21,     9
703 };
704
705 #define yyerrok         (yyerrstatus = 0)
706 #define yyclearin       (yychar = YYEMPTY)
707 #define YYEMPTY         (-2)
708 #define YYEOF           0
709
710 #define YYACCEPT        goto yyacceptlab
711 #define YYABORT         goto yyabortlab
712 #define YYERROR         goto yyerrorlab
713
714
715 /* Like YYERROR except do call yyerror.  This remains here temporarily
716    to ease the transition to the new meaning of YYERROR, for GCC.
717    Once GCC version 2 has supplanted version 1, this can go.  */
718
719 #define YYFAIL          goto yyerrlab
720
721 #define YYRECOVERING()  (!!yyerrstatus)
722
723 #define YYBACKUP(Token, Value)                                  \
724 do                                                              \
725   if (yychar == YYEMPTY && yylen == 1)                          \
726     {                                                           \
727       yychar = (Token);                                         \
728       yylval = (Value);                                         \
729       yytoken = YYTRANSLATE (yychar);                           \
730       YYPOPSTACK (1);                                           \
731       goto yybackup;                                            \
732     }                                                           \
733   else                                                          \
734     {                                                           \
735       yyerror (YY_("syntax error: cannot back up")); \
736       YYERROR;                                                  \
737     }                                                           \
738 while (YYID (0))
739
740
741 #define YYTERROR        1
742 #define YYERRCODE       256
743
744
745 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
746    If N is 0, then set CURRENT to the empty location which ends
747    the previous symbol: RHS[0] (always defined).  */
748
749 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
750 #ifndef YYLLOC_DEFAULT
751 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
752     do                                                                  \
753       if (YYID (N))                                                    \
754         {                                                               \
755           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
756           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
757           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
758           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
759         }                                                               \
760       else                                                              \
761         {                                                               \
762           (Current).first_line   = (Current).last_line   =              \
763             YYRHSLOC (Rhs, 0).last_line;                                \
764           (Current).first_column = (Current).last_column =              \
765             YYRHSLOC (Rhs, 0).last_column;                              \
766         }                                                               \
767     while (YYID (0))
768 #endif
769
770
771 /* YY_LOCATION_PRINT -- Print the location on the stream.
772    This macro was not mandated originally: define only if we know
773    we won't break user code: when these are the locations we know.  */
774
775 #ifndef YY_LOCATION_PRINT
776 # if YYLTYPE_IS_TRIVIAL
777 #  define YY_LOCATION_PRINT(File, Loc)                  \
778      fprintf (File, "%d.%d-%d.%d",                      \
779               (Loc).first_line, (Loc).first_column,     \
780               (Loc).last_line,  (Loc).last_column)
781 # else
782 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
783 # endif
784 #endif
785
786
787 /* YYLEX -- calling `yylex' with the right arguments.  */
788
789 #ifdef YYLEX_PARAM
790 # define YYLEX yylex (YYLEX_PARAM)
791 #else
792 # define YYLEX yylex ()
793 #endif
794
795 /* Enable debugging if requested.  */
796 #if YYDEBUG
797
798 # ifndef YYFPRINTF
799 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
800 #  define YYFPRINTF fprintf
801 # endif
802
803 # define YYDPRINTF(Args)                        \
804 do {                                            \
805   if (yydebug)                                  \
806     YYFPRINTF Args;                             \
807 } while (YYID (0))
808
809 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
810 do {                                                                      \
811   if (yydebug)                                                            \
812     {                                                                     \
813       YYFPRINTF (stderr, "%s ", Title);                                   \
814       yy_symbol_print (stderr,                                            \
815                   Type, Value); \
816       YYFPRINTF (stderr, "\n");                                           \
817     }                                                                     \
818 } while (YYID (0))
819
820
821 /*--------------------------------.
822 | Print this symbol on YYOUTPUT.  |
823 `--------------------------------*/
824
825 /*ARGSUSED*/
826 #if (defined __STDC__ || defined __C99__FUNC__ \
827      || defined __cplusplus || defined _MSC_VER)
828 static void
829 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
830 #else
831 static void
832 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
833     FILE *yyoutput;
834     int yytype;
835     YYSTYPE const * const yyvaluep;
836 #endif
837 {
838   if (!yyvaluep)
839     return;
840 # ifdef YYPRINT
841   if (yytype < YYNTOKENS)
842     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
843 # else
844   YYUSE (yyoutput);
845 # endif
846   switch (yytype)
847     {
848       default:
849         break;
850     }
851 }
852
853
854 /*--------------------------------.
855 | Print this symbol on YYOUTPUT.  |
856 `--------------------------------*/
857
858 #if (defined __STDC__ || defined __C99__FUNC__ \
859      || defined __cplusplus || defined _MSC_VER)
860 static void
861 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
862 #else
863 static void
864 yy_symbol_print (yyoutput, yytype, yyvaluep)
865     FILE *yyoutput;
866     int yytype;
867     YYSTYPE const * const yyvaluep;
868 #endif
869 {
870   if (yytype < YYNTOKENS)
871     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
872   else
873     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
874
875   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
876   YYFPRINTF (yyoutput, ")");
877 }
878
879 /*------------------------------------------------------------------.
880 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
881 | TOP (included).                                                   |
882 `------------------------------------------------------------------*/
883
884 #if (defined __STDC__ || defined __C99__FUNC__ \
885      || defined __cplusplus || defined _MSC_VER)
886 static void
887 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
888 #else
889 static void
890 yy_stack_print (bottom, top)
891     yytype_int16 *bottom;
892     yytype_int16 *top;
893 #endif
894 {
895   YYFPRINTF (stderr, "Stack now");
896   for (; bottom <= top; ++bottom)
897     YYFPRINTF (stderr, " %d", *bottom);
898   YYFPRINTF (stderr, "\n");
899 }
900
901 # define YY_STACK_PRINT(Bottom, Top)                            \
902 do {                                                            \
903   if (yydebug)                                                  \
904     yy_stack_print ((Bottom), (Top));                           \
905 } while (YYID (0))
906
907
908 /*------------------------------------------------.
909 | Report that the YYRULE is going to be reduced.  |
910 `------------------------------------------------*/
911
912 #if (defined __STDC__ || defined __C99__FUNC__ \
913      || defined __cplusplus || defined _MSC_VER)
914 static void
915 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
916 #else
917 static void
918 yy_reduce_print (yyvsp, yyrule)
919     YYSTYPE *yyvsp;
920     int yyrule;
921 #endif
922 {
923   int yynrhs = yyr2[yyrule];
924   int yyi;
925   unsigned long int yylno = yyrline[yyrule];
926   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
927              yyrule - 1, yylno);
928   /* The symbols being reduced.  */
929   for (yyi = 0; yyi < yynrhs; yyi++)
930     {
931       fprintf (stderr, "   $%d = ", yyi + 1);
932       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
933                        &(yyvsp[(yyi + 1) - (yynrhs)])
934                                        );
935       fprintf (stderr, "\n");
936     }
937 }
938
939 # define YY_REDUCE_PRINT(Rule)          \
940 do {                                    \
941   if (yydebug)                          \
942     yy_reduce_print (yyvsp, Rule); \
943 } while (YYID (0))
944
945 /* Nonzero means print parse trace.  It is left uninitialized so that
946    multiple parsers can coexist.  */
947 int yydebug;
948 #else /* !YYDEBUG */
949 # define YYDPRINTF(Args)
950 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
951 # define YY_STACK_PRINT(Bottom, Top)
952 # define YY_REDUCE_PRINT(Rule)
953 #endif /* !YYDEBUG */
954
955
956 /* YYINITDEPTH -- initial size of the parser's stacks.  */
957 #ifndef YYINITDEPTH
958 # define YYINITDEPTH 200
959 #endif
960
961 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
962    if the built-in stack extension method is used).
963
964    Do not make this value too large; the results are undefined if
965    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
966    evaluated with infinite-precision integer arithmetic.  */
967
968 #ifndef YYMAXDEPTH
969 # define YYMAXDEPTH 10000
970 #endif
971
972 \f
973
974 #if YYERROR_VERBOSE
975
976 # ifndef yystrlen
977 #  if defined __GLIBC__ && defined _STRING_H
978 #   define yystrlen strlen
979 #  else
980 /* Return the length of YYSTR.  */
981 #if (defined __STDC__ || defined __C99__FUNC__ \
982      || defined __cplusplus || defined _MSC_VER)
983 static YYSIZE_T
984 yystrlen (const char *yystr)
985 #else
986 static YYSIZE_T
987 yystrlen (yystr)
988     const char *yystr;
989 #endif
990 {
991   YYSIZE_T yylen;
992   for (yylen = 0; yystr[yylen]; yylen++)
993     continue;
994   return yylen;
995 }
996 #  endif
997 # endif
998
999 # ifndef yystpcpy
1000 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1001 #   define yystpcpy stpcpy
1002 #  else
1003 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1004    YYDEST.  */
1005 #if (defined __STDC__ || defined __C99__FUNC__ \
1006      || defined __cplusplus || defined _MSC_VER)
1007 static char *
1008 yystpcpy (char *yydest, const char *yysrc)
1009 #else
1010 static char *
1011 yystpcpy (yydest, yysrc)
1012     char *yydest;
1013     const char *yysrc;
1014 #endif
1015 {
1016   char *yyd = yydest;
1017   const char *yys = yysrc;
1018
1019   while ((*yyd++ = *yys++) != '\0')
1020     continue;
1021
1022   return yyd - 1;
1023 }
1024 #  endif
1025 # endif
1026
1027 # ifndef yytnamerr
1028 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1029    quotes and backslashes, so that it's suitable for yyerror.  The
1030    heuristic is that double-quoting is unnecessary unless the string
1031    contains an apostrophe, a comma, or backslash (other than
1032    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1033    null, do not copy; instead, return the length of what the result
1034    would have been.  */
1035 static YYSIZE_T
1036 yytnamerr (char *yyres, const char *yystr)
1037 {
1038   if (*yystr == '"')
1039     {
1040       YYSIZE_T yyn = 0;
1041       char const *yyp = yystr;
1042
1043       for (;;)
1044         switch (*++yyp)
1045           {
1046           case '\'':
1047           case ',':
1048             goto do_not_strip_quotes;
1049
1050           case '\\':
1051             if (*++yyp != '\\')
1052               goto do_not_strip_quotes;
1053             /* Fall through.  */
1054           default:
1055             if (yyres)
1056               yyres[yyn] = *yyp;
1057             yyn++;
1058             break;
1059
1060           case '"':
1061             if (yyres)
1062               yyres[yyn] = '\0';
1063             return yyn;
1064           }
1065     do_not_strip_quotes: ;
1066     }
1067
1068   if (! yyres)
1069     return yystrlen (yystr);
1070
1071   return yystpcpy (yyres, yystr) - yyres;
1072 }
1073 # endif
1074
1075 /* Copy into YYRESULT an error message about the unexpected token
1076    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
1077    including the terminating null byte.  If YYRESULT is null, do not
1078    copy anything; just return the number of bytes that would be
1079    copied.  As a special case, return 0 if an ordinary "syntax error"
1080    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
1081    size calculation.  */
1082 static YYSIZE_T
1083 yysyntax_error (char *yyresult, int yystate, int yychar)
1084 {
1085   int yyn = yypact[yystate];
1086
1087   if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1088     return 0;
1089   else
1090     {
1091       int yytype = YYTRANSLATE (yychar);
1092       YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1093       YYSIZE_T yysize = yysize0;
1094       YYSIZE_T yysize1;
1095       int yysize_overflow = 0;
1096       enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1097       char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1098       int yyx;
1099
1100 # if 0
1101       /* This is so xgettext sees the translatable formats that are
1102          constructed on the fly.  */
1103       YY_("syntax error, unexpected %s");
1104       YY_("syntax error, unexpected %s, expecting %s");
1105       YY_("syntax error, unexpected %s, expecting %s or %s");
1106       YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1107       YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1108 # endif
1109       char *yyfmt;
1110       char const *yyf;
1111       static char const yyunexpected[] = "syntax error, unexpected %s";
1112       static char const yyexpecting[] = ", expecting %s";
1113       static char const yyor[] = " or %s";
1114       char yyformat[sizeof yyunexpected
1115                     + sizeof yyexpecting - 1
1116                     + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1117                        * (sizeof yyor - 1))];
1118       char const *yyprefix = yyexpecting;
1119
1120       /* Start YYX at -YYN if negative to avoid negative indexes in
1121          YYCHECK.  */
1122       int yyxbegin = yyn < 0 ? -yyn : 0;
1123
1124       /* Stay within bounds of both yycheck and yytname.  */
1125       int yychecklim = YYLAST - yyn + 1;
1126       int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1127       int yycount = 1;
1128
1129       yyarg[0] = yytname[yytype];
1130       yyfmt = yystpcpy (yyformat, yyunexpected);
1131
1132       for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1133         if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1134           {
1135             if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1136               {
1137                 yycount = 1;
1138                 yysize = yysize0;
1139                 yyformat[sizeof yyunexpected - 1] = '\0';
1140                 break;
1141               }
1142             yyarg[yycount++] = yytname[yyx];
1143             yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1144             yysize_overflow |= (yysize1 < yysize);
1145             yysize = yysize1;
1146             yyfmt = yystpcpy (yyfmt, yyprefix);
1147             yyprefix = yyor;
1148           }
1149
1150       yyf = YY_(yyformat);
1151       yysize1 = yysize + yystrlen (yyf);
1152       yysize_overflow |= (yysize1 < yysize);
1153       yysize = yysize1;
1154
1155       if (yysize_overflow)
1156         return YYSIZE_MAXIMUM;
1157
1158       if (yyresult)
1159         {
1160           /* Avoid sprintf, as that infringes on the user's name space.
1161              Don't have undefined behavior even if the translation
1162              produced a string with the wrong number of "%s"s.  */
1163           char *yyp = yyresult;
1164           int yyi = 0;
1165           while ((*yyp = *yyf) != '\0')
1166             {
1167               if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1168                 {
1169                   yyp += yytnamerr (yyp, yyarg[yyi++]);
1170                   yyf += 2;
1171                 }
1172               else
1173                 {
1174                   yyp++;
1175                   yyf++;
1176                 }
1177             }
1178         }
1179       return yysize;
1180     }
1181 }
1182 #endif /* YYERROR_VERBOSE */
1183 \f
1184
1185 /*-----------------------------------------------.
1186 | Release the memory associated to this symbol.  |
1187 `-----------------------------------------------*/
1188
1189 /*ARGSUSED*/
1190 #if (defined __STDC__ || defined __C99__FUNC__ \
1191      || defined __cplusplus || defined _MSC_VER)
1192 static void
1193 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1194 #else
1195 static void
1196 yydestruct (yymsg, yytype, yyvaluep)
1197     const char *yymsg;
1198     int yytype;
1199     YYSTYPE *yyvaluep;
1200 #endif
1201 {
1202   YYUSE (yyvaluep);
1203
1204   if (!yymsg)
1205     yymsg = "Deleting";
1206   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1207
1208   switch (yytype)
1209     {
1210
1211       default:
1212         break;
1213     }
1214 }
1215 \f
1216
1217 /* Prevent warnings from -Wmissing-prototypes.  */
1218
1219 #ifdef YYPARSE_PARAM
1220 #if defined __STDC__ || defined __cplusplus
1221 int yyparse (void *YYPARSE_PARAM);
1222 #else
1223 int yyparse ();
1224 #endif
1225 #else /* ! YYPARSE_PARAM */
1226 #if defined __STDC__ || defined __cplusplus
1227 int yyparse (void);
1228 #else
1229 int yyparse ();
1230 #endif
1231 #endif /* ! YYPARSE_PARAM */
1232
1233
1234
1235 /* The look-ahead symbol.  */
1236 int yychar;
1237
1238 /* The semantic value of the look-ahead symbol.  */
1239 YYSTYPE yylval;
1240
1241 /* Number of syntax errors so far.  */
1242 int yynerrs;
1243
1244
1245
1246 /*----------.
1247 | yyparse.  |
1248 `----------*/
1249
1250 #ifdef YYPARSE_PARAM
1251 #if (defined __STDC__ || defined __C99__FUNC__ \
1252      || defined __cplusplus || defined _MSC_VER)
1253 int
1254 yyparse (void *YYPARSE_PARAM)
1255 #else
1256 int
1257 yyparse (YYPARSE_PARAM)
1258     void *YYPARSE_PARAM;
1259 #endif
1260 #else /* ! YYPARSE_PARAM */
1261 #if (defined __STDC__ || defined __C99__FUNC__ \
1262      || defined __cplusplus || defined _MSC_VER)
1263 int
1264 yyparse (void)
1265 #else
1266 int
1267 yyparse ()
1268
1269 #endif
1270 #endif
1271 {
1272   
1273   int yystate;
1274   int yyn;
1275   int yyresult;
1276   /* Number of tokens to shift before error messages enabled.  */
1277   int yyerrstatus;
1278   /* Look-ahead token as an internal (translated) token number.  */
1279   int yytoken = 0;
1280 #if YYERROR_VERBOSE
1281   /* Buffer for error messages, and its allocated size.  */
1282   char yymsgbuf[128];
1283   char *yymsg = yymsgbuf;
1284   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1285 #endif
1286
1287   /* Three stacks and their tools:
1288      `yyss': related to states,
1289      `yyvs': related to semantic values,
1290      `yyls': related to locations.
1291
1292      Refer to the stacks thru separate pointers, to allow yyoverflow
1293      to reallocate them elsewhere.  */
1294
1295   /* The state stack.  */
1296   yytype_int16 yyssa[YYINITDEPTH];
1297   yytype_int16 *yyss = yyssa;
1298   yytype_int16 *yyssp;
1299
1300   /* The semantic value stack.  */
1301   YYSTYPE yyvsa[YYINITDEPTH];
1302   YYSTYPE *yyvs = yyvsa;
1303   YYSTYPE *yyvsp;
1304
1305
1306
1307 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1308
1309   YYSIZE_T yystacksize = YYINITDEPTH;
1310
1311   /* The variables used to return semantic value and location from the
1312      action routines.  */
1313   YYSTYPE yyval;
1314
1315
1316   /* The number of symbols on the RHS of the reduced rule.
1317      Keep to zero when no symbol should be popped.  */
1318   int yylen = 0;
1319
1320   YYDPRINTF ((stderr, "Starting parse\n"));
1321
1322   yystate = 0;
1323   yyerrstatus = 0;
1324   yynerrs = 0;
1325   yychar = YYEMPTY;             /* Cause a token to be read.  */
1326
1327   /* Initialize stack pointers.
1328      Waste one element of value and location stack
1329      so that they stay on the same level as the state stack.
1330      The wasted elements are never initialized.  */
1331
1332   yyssp = yyss;
1333   yyvsp = yyvs;
1334
1335   goto yysetstate;
1336
1337 /*------------------------------------------------------------.
1338 | yynewstate -- Push a new state, which is found in yystate.  |
1339 `------------------------------------------------------------*/
1340  yynewstate:
1341   /* In all cases, when you get here, the value and location stacks
1342      have just been pushed.  So pushing a state here evens the stacks.  */
1343   yyssp++;
1344
1345  yysetstate:
1346   *yyssp = yystate;
1347
1348   if (yyss + yystacksize - 1 <= yyssp)
1349     {
1350       /* Get the current used size of the three stacks, in elements.  */
1351       YYSIZE_T yysize = yyssp - yyss + 1;
1352
1353 #ifdef yyoverflow
1354       {
1355         /* Give user a chance to reallocate the stack.  Use copies of
1356            these so that the &'s don't force the real ones into
1357            memory.  */
1358         YYSTYPE *yyvs1 = yyvs;
1359         yytype_int16 *yyss1 = yyss;
1360
1361
1362         /* Each stack pointer address is followed by the size of the
1363            data in use in that stack, in bytes.  This used to be a
1364            conditional around just the two extra args, but that might
1365            be undefined if yyoverflow is a macro.  */
1366         yyoverflow (YY_("memory exhausted"),
1367                     &yyss1, yysize * sizeof (*yyssp),
1368                     &yyvs1, yysize * sizeof (*yyvsp),
1369
1370                     &yystacksize);
1371
1372         yyss = yyss1;
1373         yyvs = yyvs1;
1374       }
1375 #else /* no yyoverflow */
1376 # ifndef YYSTACK_RELOCATE
1377       goto yyexhaustedlab;
1378 # else
1379       /* Extend the stack our own way.  */
1380       if (YYMAXDEPTH <= yystacksize)
1381         goto yyexhaustedlab;
1382       yystacksize *= 2;
1383       if (YYMAXDEPTH < yystacksize)
1384         yystacksize = YYMAXDEPTH;
1385
1386       {
1387         yytype_int16 *yyss1 = yyss;
1388         union yyalloc *yyptr =
1389           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1390         if (! yyptr)
1391           goto yyexhaustedlab;
1392         YYSTACK_RELOCATE (yyss);
1393         YYSTACK_RELOCATE (yyvs);
1394
1395 #  undef YYSTACK_RELOCATE
1396         if (yyss1 != yyssa)
1397           YYSTACK_FREE (yyss1);
1398       }
1399 # endif
1400 #endif /* no yyoverflow */
1401
1402       yyssp = yyss + yysize - 1;
1403       yyvsp = yyvs + yysize - 1;
1404
1405
1406       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1407                   (unsigned long int) yystacksize));
1408
1409       if (yyss + yystacksize - 1 <= yyssp)
1410         YYABORT;
1411     }
1412
1413   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1414
1415   goto yybackup;
1416
1417 /*-----------.
1418 | yybackup.  |
1419 `-----------*/
1420 yybackup:
1421
1422   /* Do appropriate processing given the current state.  Read a
1423      look-ahead token if we need one and don't already have one.  */
1424
1425   /* First try to decide what to do without reference to look-ahead token.  */
1426   yyn = yypact[yystate];
1427   if (yyn == YYPACT_NINF)
1428     goto yydefault;
1429
1430   /* Not known => get a look-ahead token if don't already have one.  */
1431
1432   /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
1433   if (yychar == YYEMPTY)
1434     {
1435       YYDPRINTF ((stderr, "Reading a token: "));
1436       yychar = YYLEX;
1437     }
1438
1439   if (yychar <= YYEOF)
1440     {
1441       yychar = yytoken = YYEOF;
1442       YYDPRINTF ((stderr, "Now at end of input.\n"));
1443     }
1444   else
1445     {
1446       yytoken = YYTRANSLATE (yychar);
1447       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1448     }
1449
1450   /* If the proper action on seeing token YYTOKEN is to reduce or to
1451      detect an error, take that action.  */
1452   yyn += yytoken;
1453   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1454     goto yydefault;
1455   yyn = yytable[yyn];
1456   if (yyn <= 0)
1457     {
1458       if (yyn == 0 || yyn == YYTABLE_NINF)
1459         goto yyerrlab;
1460       yyn = -yyn;
1461       goto yyreduce;
1462     }
1463
1464   if (yyn == YYFINAL)
1465     YYACCEPT;
1466
1467   /* Count tokens shifted since error; after three, turn off error
1468      status.  */
1469   if (yyerrstatus)
1470     yyerrstatus--;
1471
1472   /* Shift the look-ahead token.  */
1473   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1474
1475   /* Discard the shifted token unless it is eof.  */
1476   if (yychar != YYEOF)
1477     yychar = YYEMPTY;
1478
1479   yystate = yyn;
1480   *++yyvsp = yylval;
1481
1482   goto yynewstate;
1483
1484
1485 /*-----------------------------------------------------------.
1486 | yydefault -- do the default action for the current state.  |
1487 `-----------------------------------------------------------*/
1488 yydefault:
1489   yyn = yydefact[yystate];
1490   if (yyn == 0)
1491     goto yyerrlab;
1492   goto yyreduce;
1493
1494
1495 /*-----------------------------.
1496 | yyreduce -- Do a reduction.  |
1497 `-----------------------------*/
1498 yyreduce:
1499   /* yyn is the number of a rule to reduce with.  */
1500   yylen = yyr2[yyn];
1501
1502   /* If YYLEN is nonzero, implement the default value of the action:
1503      `$$ = $1'.
1504
1505      Otherwise, the following line sets YYVAL to garbage.
1506      This behavior is undocumented and Bison
1507      users should not rely upon it.  Assigning to YYVAL
1508      unconditionally makes the parser a bit smaller, and it avoids a
1509      GCC warning that YYVAL may be used uninitialized.  */
1510   yyval = yyvsp[1-yylen];
1511
1512
1513   YY_REDUCE_PRINT (yyn);
1514   switch (yyn)
1515     {
1516         case 15:
1517 #line 227 "./config_parser.y"
1518     { __sdp_log_set_log_stderr(); }
1519     break;
1520
1521   case 16:
1522 #line 228 "./config_parser.y"
1523     { __sdp_log_set_log_syslog(); }
1524     break;
1525
1526   case 17:
1527 #line 229 "./config_parser.y"
1528     { __sdp_log_set_log_file((yyvsp[(3) - (3)].sval)); }
1529     break;
1530
1531   case 18:
1532 #line 233 "./config_parser.y"
1533     { __sdp_log_set_min_level((yyvsp[(2) - (2)].ival)); }
1534     break;
1535
1536   case 19:
1537 #line 237 "./config_parser.y"
1538     { __sdp_add_rule(); }
1539     break;
1540
1541   case 20:
1542 #line 241 "./config_parser.y"
1543     { __sdp_rule.target_family = USE_TCP; }
1544     break;
1545
1546   case 21:
1547 #line 242 "./config_parser.y"
1548     { __sdp_rule.target_family = USE_SDP; }
1549     break;
1550
1551   case 22:
1552 #line 243 "./config_parser.y"
1553     { __sdp_rule.target_family = USE_BOTH; }
1554     break;
1555
1556   case 23:
1557 #line 247 "./config_parser.y"
1558     { current_role = 1; }
1559     break;
1560
1561   case 24:
1562 #line 248 "./config_parser.y"
1563     { current_role = 2; }
1564     break;
1565
1566   case 25:
1567 #line 252 "./config_parser.y"
1568     { __sdp_set_prog_name_expr((yyvsp[(1) - (1)].sval)); }
1569     break;
1570
1571   case 26:
1572 #line 253 "./config_parser.y"
1573     { __sdp_set_prog_name_expr("*"); }
1574     break;
1575
1576   case 27:
1577 #line 257 "./config_parser.y"
1578     { __sdp_rule.match_by_addr = 1; __sdp_rule.prefixlen = 32; }
1579     break;
1580
1581   case 28:
1582 #line 258 "./config_parser.y"
1583     { __sdp_rule.match_by_addr = 1; __sdp_rule.prefixlen = (yyvsp[(3) - (3)].ival); }
1584     break;
1585
1586   case 29:
1587 #line 259 "./config_parser.y"
1588     { __sdp_rule.match_by_addr = 0; __sdp_rule.prefixlen = 32; }
1589     break;
1590
1591   case 30:
1592 #line 263 "./config_parser.y"
1593     { __sdp_set_ipv4_addr((yyvsp[(1) - (7)].ival),(yyvsp[(3) - (7)].ival),(yyvsp[(5) - (7)].ival),(yyvsp[(7) - (7)].ival)); }
1594     break;
1595
1596   case 31:
1597 #line 267 "./config_parser.y"
1598     { __sdp_rule.match_by_port = 1; __sdp_rule.sport= (yyvsp[(1) - (1)].ival); __sdp_rule.eport= (yyvsp[(1) - (1)].ival); }
1599     break;
1600
1601   case 32:
1602 #line 268 "./config_parser.y"
1603     { __sdp_rule.match_by_port = 1; __sdp_rule.sport= (yyvsp[(1) - (3)].ival); __sdp_rule.eport= (yyvsp[(3) - (3)].ival); }
1604     break;
1605
1606   case 33:
1607 #line 269 "./config_parser.y"
1608     { __sdp_rule.match_by_port = 0; __sdp_rule.sport= 0 ; __sdp_rule.eport= 0; }
1609     break;
1610
1611
1612 /* Line 1267 of yacc.c.  */
1613 #line 1614 "y.tab.c"
1614       default: break;
1615     }
1616   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1617
1618   YYPOPSTACK (yylen);
1619   yylen = 0;
1620   YY_STACK_PRINT (yyss, yyssp);
1621
1622   *++yyvsp = yyval;
1623
1624
1625   /* Now `shift' the result of the reduction.  Determine what state
1626      that goes to, based on the state we popped back to and the rule
1627      number reduced by.  */
1628
1629   yyn = yyr1[yyn];
1630
1631   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1632   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1633     yystate = yytable[yystate];
1634   else
1635     yystate = yydefgoto[yyn - YYNTOKENS];
1636
1637   goto yynewstate;
1638
1639
1640 /*------------------------------------.
1641 | yyerrlab -- here on detecting error |
1642 `------------------------------------*/
1643 yyerrlab:
1644   /* If not already recovering from an error, report this error.  */
1645   if (!yyerrstatus)
1646     {
1647       ++yynerrs;
1648 #if ! YYERROR_VERBOSE
1649       yyerror (YY_("syntax error"));
1650 #else
1651       {
1652         YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1653         if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1654           {
1655             YYSIZE_T yyalloc = 2 * yysize;
1656             if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1657               yyalloc = YYSTACK_ALLOC_MAXIMUM;
1658             if (yymsg != yymsgbuf)
1659               YYSTACK_FREE (yymsg);
1660             yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1661             if (yymsg)
1662               yymsg_alloc = yyalloc;
1663             else
1664               {
1665                 yymsg = yymsgbuf;
1666                 yymsg_alloc = sizeof yymsgbuf;
1667               }
1668           }
1669
1670         if (0 < yysize && yysize <= yymsg_alloc)
1671           {
1672             (void) yysyntax_error (yymsg, yystate, yychar);
1673             yyerror (yymsg);
1674           }
1675         else
1676           {
1677             yyerror (YY_("syntax error"));
1678             if (yysize != 0)
1679               goto yyexhaustedlab;
1680           }
1681       }
1682 #endif
1683     }
1684
1685
1686
1687   if (yyerrstatus == 3)
1688     {
1689       /* If just tried and failed to reuse look-ahead token after an
1690          error, discard it.  */
1691
1692       if (yychar <= YYEOF)
1693         {
1694           /* Return failure if at end of input.  */
1695           if (yychar == YYEOF)
1696             YYABORT;
1697         }
1698       else
1699         {
1700           yydestruct ("Error: discarding",
1701                       yytoken, &yylval);
1702           yychar = YYEMPTY;
1703         }
1704     }
1705
1706   /* Else will try to reuse look-ahead token after shifting the error
1707      token.  */
1708   goto yyerrlab1;
1709
1710
1711 /*---------------------------------------------------.
1712 | yyerrorlab -- error raised explicitly by YYERROR.  |
1713 `---------------------------------------------------*/
1714 yyerrorlab:
1715
1716   /* Pacify compilers like GCC when the user code never invokes
1717      YYERROR and the label yyerrorlab therefore never appears in user
1718      code.  */
1719   if (/*CONSTCOND*/ 0)
1720      goto yyerrorlab;
1721
1722   /* Do not reclaim the symbols of the rule which action triggered
1723      this YYERROR.  */
1724   YYPOPSTACK (yylen);
1725   yylen = 0;
1726   YY_STACK_PRINT (yyss, yyssp);
1727   yystate = *yyssp;
1728   goto yyerrlab1;
1729
1730
1731 /*-------------------------------------------------------------.
1732 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1733 `-------------------------------------------------------------*/
1734 yyerrlab1:
1735   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1736
1737   for (;;)
1738     {
1739       yyn = yypact[yystate];
1740       if (yyn != YYPACT_NINF)
1741         {
1742           yyn += YYTERROR;
1743           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1744             {
1745               yyn = yytable[yyn];
1746               if (0 < yyn)
1747                 break;
1748             }
1749         }
1750
1751       /* Pop the current state because it cannot handle the error token.  */
1752       if (yyssp == yyss)
1753         YYABORT;
1754
1755
1756       yydestruct ("Error: popping",
1757                   yystos[yystate], yyvsp);
1758       YYPOPSTACK (1);
1759       yystate = *yyssp;
1760       YY_STACK_PRINT (yyss, yyssp);
1761     }
1762
1763   if (yyn == YYFINAL)
1764     YYACCEPT;
1765
1766   *++yyvsp = yylval;
1767
1768
1769   /* Shift the error token.  */
1770   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1771
1772   yystate = yyn;
1773   goto yynewstate;
1774
1775
1776 /*-------------------------------------.
1777 | yyacceptlab -- YYACCEPT comes here.  |
1778 `-------------------------------------*/
1779 yyacceptlab:
1780   yyresult = 0;
1781   goto yyreturn;
1782
1783 /*-----------------------------------.
1784 | yyabortlab -- YYABORT comes here.  |
1785 `-----------------------------------*/
1786 yyabortlab:
1787   yyresult = 1;
1788   goto yyreturn;
1789
1790 #ifndef yyoverflow
1791 /*-------------------------------------------------.
1792 | yyexhaustedlab -- memory exhaustion comes here.  |
1793 `-------------------------------------------------*/
1794 yyexhaustedlab:
1795   yyerror (YY_("memory exhausted"));
1796   yyresult = 2;
1797   /* Fall through.  */
1798 #endif
1799
1800 yyreturn:
1801   if (yychar != YYEOF && yychar != YYEMPTY)
1802      yydestruct ("Cleanup: discarding lookahead",
1803                  yytoken, &yylval);
1804   /* Do not reclaim the symbols of the rule which action triggered
1805      this YYABORT or YYACCEPT.  */
1806   YYPOPSTACK (yylen);
1807   YY_STACK_PRINT (yyss, yyssp);
1808   while (yyssp != yyss)
1809     {
1810       yydestruct ("Cleanup: popping",
1811                   yystos[*yyssp], yyvsp);
1812       YYPOPSTACK (1);
1813     }
1814 #ifndef yyoverflow
1815   if (yyss != yyssa)
1816     YYSTACK_FREE (yyss);
1817 #endif
1818 #if YYERROR_VERBOSE
1819   if (yymsg != yymsgbuf)
1820     YYSTACK_FREE (yymsg);
1821 #endif
1822   /* Make sure YYID is used.  */
1823   return YYID (yyresult);
1824 }
1825
1826
1827 #line 272 "./config_parser.y"
1828
1829
1830 int yyerror(char *msg)
1831 {
1832         /* replace the $undefined and $end if exists */
1833         char *orig_msg = (char*)malloc(strlen(msg)+25);
1834         char *final_msg = (char*)malloc(strlen(msg)+25);
1835
1836         strcpy(orig_msg, msg);
1837         
1838         char *word = strtok(orig_msg, " ");
1839         final_msg[0] = '\0';
1840         while (word != NULL) {
1841                 if (!strncmp(word, "$undefined", 10)) {
1842                         strcat(final_msg, "unrecognized-token ");
1843                 } else if (!strncmp(word, "$end",4)) {
1844                         strcat(final_msg, "end-of-file ");
1845                 } else {
1846                         strcat(final_msg, word);
1847                         strcat(final_msg, " ");
1848                 }
1849                 word = strtok(NULL, " ");
1850         }
1851         
1852         __sdp_log(9, "Error (line:%ld) : %s\n", __sdp_config_line_num, final_msg);
1853         parse_err = 1;
1854         
1855         free(orig_msg);
1856         free(final_msg);
1857         return 1;
1858 }
1859
1860 #include <unistd.h>
1861 #include <errno.h>
1862
1863 /* parse apollo route dump file */
1864 int __sdp_parse_config (const char *fileName) {
1865   extern FILE * libsdp_yyin;
1866    
1867   /* open the file */
1868   if (access(fileName, R_OK)) {
1869          printf("libsdp Error: No access to open File:%s %s\n", 
1870            fileName, strerror(errno));
1871          return(1);
1872   }
1873
1874   libsdp_yyin = fopen(fileName,"r");
1875   if (!libsdp_yyin) {
1876          printf("libsdp Error: Fail to open File:%s\n", fileName);
1877          return(1);
1878   }
1879   parse_err = 0;
1880   __sdp_config_line_num = 1;
1881
1882   /* parse it */
1883   yyparse();
1884
1885   fclose(libsdp_yyin);
1886   return(parse_err);
1887 }
1888
1889
1890