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