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