2001-03-22 Philip Blundell <philb@gnu.org>
[binutils.git] / binutils / nlmheader.c
blob830e6b70a0e941350e07eeeaaf5585cb9b0f4b2c
2 /* A Bison parser, made from nlmheader.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define CHECK 257
8 #define CODESTART 258
9 #define COPYRIGHT 259
10 #define CUSTOM 260
11 #define DATE 261
12 #define DEBUG 262
13 #define DESCRIPTION 263
14 #define EXIT 264
15 #define EXPORT 265
16 #define FLAG_ON 266
17 #define FLAG_OFF 267
18 #define FULLMAP 268
19 #define HELP 269
20 #define IMPORT 270
21 #define INPUT 271
22 #define MAP 272
23 #define MESSAGES 273
24 #define MODULE 274
25 #define MULTIPLE 275
26 #define OS_DOMAIN 276
27 #define OUTPUT 277
28 #define PSEUDOPREEMPTION 278
29 #define REENTRANT 279
30 #define SCREENNAME 280
31 #define SHARELIB 281
32 #define STACK 282
33 #define START 283
34 #define SYNCHRONIZE 284
35 #define THREADNAME 285
36 #define TYPE 286
37 #define VERBOSE 287
38 #define VERSIONK 288
39 #define XDCDATA 289
40 #define STRING 290
41 #define QUOTED_STRING 291
43 #line 1 "nlmheader.y"
44 /* nlmheader.y - parse NLM header specification keywords.
45 Copyright (C) 1993, 94, 95, 97, 1998 Free Software Foundation, Inc.
47 This file is part of GNU Binutils.
49 This program is free software; you can redistribute it and/or modify
50 it under the terms of the GNU General Public License as published by
51 the Free Software Foundation; either version 2 of the License, or
52 (at your option) any later version.
54 This program is distributed in the hope that it will be useful,
55 but WITHOUT ANY WARRANTY; without even the implied warranty of
56 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 GNU General Public License for more details.
59 You should have received a copy of the GNU General Public License
60 along with this program; if not, write to the Free Software
61 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
63 /* Written by Ian Lance Taylor <ian@cygnus.com>.
65 This bison file parses the commands recognized by the NetWare NLM
66 linker, except for lists of object files. It stores the
67 information in global variables.
69 This implementation is based on the description in the NetWare Tool
70 Maker Specification manual, edition 1.0. */
72 #include <ansidecl.h>
73 #include <stdio.h>
74 #include <ctype.h>
75 #include "bfd.h"
76 #include "bucomm.h"
77 #include "nlm/common.h"
78 #include "nlm/internal.h"
79 #include "nlmconv.h"
81 /* Information is stored in the structures pointed to by these
82 variables. */
84 Nlm_Internal_Fixed_Header *fixed_hdr;
85 Nlm_Internal_Variable_Header *var_hdr;
86 Nlm_Internal_Version_Header *version_hdr;
87 Nlm_Internal_Copyright_Header *copyright_hdr;
88 Nlm_Internal_Extended_Header *extended_hdr;
90 /* Procedure named by CHECK. */
91 char *check_procedure;
92 /* File named by CUSTOM. */
93 char *custom_file;
94 /* Whether to generate debugging information (DEBUG). */
95 boolean debug_info;
96 /* Procedure named by EXIT. */
97 char *exit_procedure;
98 /* Exported symbols (EXPORT). */
99 struct string_list *export_symbols;
100 /* List of files from INPUT. */
101 struct string_list *input_files;
102 /* Map file name (MAP, FULLMAP). */
103 char *map_file;
104 /* Whether a full map has been requested (FULLMAP). */
105 boolean full_map;
106 /* File named by HELP. */
107 char *help_file;
108 /* Imported symbols (IMPORT). */
109 struct string_list *import_symbols;
110 /* File named by MESSAGES. */
111 char *message_file;
112 /* Autoload module list (MODULE). */
113 struct string_list *modules;
114 /* File named by OUTPUT. */
115 char *output_file;
116 /* File named by SHARELIB. */
117 char *sharelib_file;
118 /* Start procedure name (START). */
119 char *start_procedure;
120 /* VERBOSE. */
121 boolean verbose;
122 /* RPC description file (XDCDATA). */
123 char *rpc_file;
125 /* The number of serious errors that have occurred. */
126 int parse_errors;
128 /* The current symbol prefix when reading a list of import or export
129 symbols. */
130 static char *symbol_prefix;
132 /* Parser error message handler. */
133 #define yyerror(msg) nlmheader_error (msg);
135 /* Local functions. */
136 static int yylex PARAMS ((void));
137 static void nlmlex_file_push PARAMS ((const char *));
138 static boolean nlmlex_file_open PARAMS ((const char *));
139 static int nlmlex_buf_init PARAMS ((void));
140 static char nlmlex_buf_add PARAMS ((int));
141 static long nlmlex_get_number PARAMS ((const char *));
142 static void nlmheader_identify PARAMS ((void));
143 static void nlmheader_warn PARAMS ((const char *, int));
144 static void nlmheader_error PARAMS ((const char *));
145 static struct string_list * string_list_cons PARAMS ((char *,
146 struct string_list *));
147 static struct string_list * string_list_append PARAMS ((struct string_list *,
148 struct string_list *));
149 static struct string_list * string_list_append1 PARAMS ((struct string_list *,
150 char *));
151 static char *xstrdup PARAMS ((const char *));
154 #line 112 "nlmheader.y"
155 typedef union
157 char *string;
158 struct string_list *list;
159 } YYSTYPE;
160 #include <stdio.h>
162 #ifndef __cplusplus
163 #ifndef __STDC__
164 #define const
165 #endif
166 #endif
170 #define YYFINAL 82
171 #define YYFLAG -32768
172 #define YYNTBASE 40
174 #define YYTRANSLATE(x) ((unsigned)(x) <= 291 ? yytranslate[x] : 50)
176 static const char yytranslate[] = { 0,
177 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
178 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
179 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
180 2, 2, 2, 2, 2, 2, 2, 2, 2, 38,
181 39, 2, 2, 2, 2, 2, 2, 2, 2, 2,
182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
183 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
184 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
190 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
192 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
193 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
195 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
196 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
197 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
198 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
199 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
200 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
201 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
202 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
203 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
204 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
205 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
209 #if YYDEBUG != 0
210 static const short yyprhs[] = { 0,
211 0, 2, 3, 6, 9, 12, 15, 18, 23, 25,
212 28, 31, 32, 36, 39, 42, 44, 47, 50, 51,
213 55, 58, 60, 63, 66, 69, 71, 73, 76, 78,
214 80, 83, 86, 89, 92, 94, 97, 100, 102, 107,
215 111, 114, 115, 117, 119, 121, 124, 127, 131, 133,
219 static const short yyrhs[] = { 41,
220 0, 0, 42, 41, 0, 3, 36, 0, 4, 36,
221 0, 5, 37, 0, 6, 36, 0, 7, 36, 36,
222 36, 0, 8, 0, 9, 37, 0, 10, 36, 0,
223 0, 11, 43, 45, 0, 12, 36, 0, 13, 36,
224 0, 14, 0, 14, 36, 0, 15, 36, 0, 0,
225 16, 44, 45, 0, 17, 49, 0, 18, 0, 18,
226 36, 0, 19, 36, 0, 20, 49, 0, 21, 0,
227 22, 0, 23, 36, 0, 24, 0, 25, 0, 26,
228 37, 0, 27, 36, 0, 28, 36, 0, 29, 36,
229 0, 30, 0, 31, 37, 0, 32, 36, 0, 33,
230 0, 34, 36, 36, 36, 0, 34, 36, 36, 0,
231 35, 36, 0, 0, 46, 0, 48, 0, 47, 0,
232 46, 48, 0, 46, 47, 0, 38, 36, 39, 0,
233 36, 0, 0, 36, 49, 0
236 #endif
238 #if YYDEBUG != 0
239 static const short yyrline[] = { 0,
240 143, 149, 151, 156, 161, 166, 183, 187, 205, 209,
241 225, 229, 234, 237, 242, 247, 252, 257, 261, 266,
242 269, 273, 277, 281, 285, 289, 293, 297, 304, 308,
243 312, 328, 332, 337, 341, 345, 361, 366, 370, 394,
244 410, 418, 423, 433, 438, 442, 446, 454, 465, 481,
247 #endif
250 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
252 static const char * const yytname[] = { "$","error","$undefined.","CHECK",
253 "CODESTART","COPYRIGHT","CUSTOM","DATE","DEBUG","DESCRIPTION","EXIT","EXPORT",
254 "FLAG_ON","FLAG_OFF","FULLMAP","HELP","IMPORT","INPUT","MAP","MESSAGES","MODULE",
255 "MULTIPLE","OS_DOMAIN","OUTPUT","PSEUDOPREEMPTION","REENTRANT","SCREENNAME",
256 "SHARELIB","STACK","START","SYNCHRONIZE","THREADNAME","TYPE","VERBOSE","VERSIONK",
257 "XDCDATA","STRING","QUOTED_STRING","'('","')'","file","commands","command","@1",
258 "@2","symbol_list_opt","symbol_list","symbol_prefix","symbol","string_list", NULL
260 #endif
262 static const short yyr1[] = { 0,
263 40, 41, 41, 42, 42, 42, 42, 42, 42, 42,
264 42, 43, 42, 42, 42, 42, 42, 42, 44, 42,
265 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
266 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
267 42, 45, 45, 46, 46, 46, 46, 47, 48, 49,
271 static const short yyr2[] = { 0,
272 1, 0, 2, 2, 2, 2, 2, 4, 1, 2,
273 2, 0, 3, 2, 2, 1, 2, 2, 0, 3,
274 2, 1, 2, 2, 2, 1, 1, 2, 1, 1,
275 2, 2, 2, 2, 1, 2, 2, 1, 4, 3,
276 2, 0, 1, 1, 1, 2, 2, 3, 1, 0,
280 static const short yydefact[] = { 2,
281 0, 0, 0, 0, 0, 9, 0, 0, 12, 0,
282 0, 16, 0, 19, 50, 22, 0, 50, 26, 27,
283 0, 29, 30, 0, 0, 0, 0, 35, 0, 0,
284 38, 0, 0, 1, 2, 4, 5, 6, 7, 0,
285 10, 11, 42, 14, 15, 17, 18, 42, 50, 21,
286 23, 24, 25, 28, 31, 32, 33, 34, 36, 37,
287 0, 41, 3, 0, 49, 0, 13, 43, 45, 44,
288 20, 51, 40, 8, 0, 47, 46, 39, 48, 0,
289 0, 0
292 static const short yydefgoto[] = { 80,
293 34, 35, 43, 48, 67, 68, 69, 70, 50
296 static const short yypact[] = { -3,
297 -1, 1, 2, 4, 5,-32768, 6, 8,-32768, 9,
298 10, 11, 12,-32768, 13, 14, 16, 13,-32768,-32768,
299 17,-32768,-32768, 18, 20, 21, 22,-32768, 23, 25,
300 -32768, 26, 27,-32768, -3,-32768,-32768,-32768,-32768, 29,
301 -32768,-32768, -2,-32768,-32768,-32768,-32768, -2, 13,-32768,
302 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
303 30,-32768,-32768, 31,-32768, 32,-32768, -2,-32768,-32768,
304 -32768,-32768, 33,-32768, 3,-32768,-32768,-32768,-32768, 38,
305 51,-32768
308 static const short yypgoto[] = {-32768,
309 19,-32768,-32768,-32768, 24,-32768, -9, 7, 15
313 #define YYLAST 75
316 static const short yytable[] = { 1,
317 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
318 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
319 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
320 32, 33, 53, 65, 36, 66, 37, 81, 38, 39,
321 40, 79, 41, 42, 44, 45, 46, 47, 49, 51,
322 82, 52, 54, 63, 55, 56, 57, 58, 76, 59,
323 60, 61, 62, 72, 64, 73, 74, 75, 78, 0,
324 0, 71, 0, 0, 77
327 static const short yycheck[] = { 3,
328 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
329 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
330 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
331 34, 35, 18, 36, 36, 38, 36, 0, 37, 36,
332 36, 39, 37, 36, 36, 36, 36, 36, 36, 36,
333 0, 36, 36, 35, 37, 36, 36, 36, 68, 37,
334 36, 36, 36, 49, 36, 36, 36, 36, 36, -1,
335 -1, 48, -1, -1, 68
337 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
338 #line 3 "/usr/share/misc/bison.simple"
339 /* This file comes from bison-1.28. */
341 /* Skeleton output parser for bison,
342 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
344 This program is free software; you can redistribute it and/or modify
345 it under the terms of the GNU General Public License as published by
346 the Free Software Foundation; either version 2, or (at your option)
347 any later version.
349 This program is distributed in the hope that it will be useful,
350 but WITHOUT ANY WARRANTY; without even the implied warranty of
351 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
352 GNU General Public License for more details.
354 You should have received a copy of the GNU General Public License
355 along with this program; if not, write to the Free Software
356 Foundation, Inc., 59 Temple Place - Suite 330,
357 Boston, MA 02111-1307, USA. */
359 /* As a special exception, when this file is copied by Bison into a
360 Bison output file, you may use that output file without restriction.
361 This special exception was added by the Free Software Foundation
362 in version 1.24 of Bison. */
364 /* This is the parser code that is written into each bison parser
365 when the %semantic_parser declaration is not specified in the grammar.
366 It was written by Richard Stallman by simplifying the hairy parser
367 used when %semantic_parser is specified. */
369 #ifndef YYSTACK_USE_ALLOCA
370 #ifdef alloca
371 #define YYSTACK_USE_ALLOCA
372 #else /* alloca not defined */
373 #ifdef __GNUC__
374 #define YYSTACK_USE_ALLOCA
375 #define alloca __builtin_alloca
376 #else /* not GNU C. */
377 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
378 #define YYSTACK_USE_ALLOCA
379 #include <alloca.h>
380 #else /* not sparc */
381 /* We think this test detects Watcom and Microsoft C. */
382 /* This used to test MSDOS, but that is a bad idea
383 since that symbol is in the user namespace. */
384 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
385 #if 0 /* No need for malloc.h, which pollutes the namespace;
386 instead, just don't use alloca. */
387 #include <malloc.h>
388 #endif
389 #else /* not MSDOS, or __TURBOC__ */
390 #if defined(_AIX)
391 /* I don't know what this was needed for, but it pollutes the namespace.
392 So I turned it off. rms, 2 May 1997. */
393 /* #include <malloc.h> */
394 #pragma alloca
395 #define YYSTACK_USE_ALLOCA
396 #else /* not MSDOS, or __TURBOC__, or _AIX */
397 #if 0
398 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
399 and on HPUX 10. Eventually we can turn this on. */
400 #define YYSTACK_USE_ALLOCA
401 #define alloca __builtin_alloca
402 #endif /* __hpux */
403 #endif
404 #endif /* not _AIX */
405 #endif /* not MSDOS, or __TURBOC__ */
406 #endif /* not sparc */
407 #endif /* not GNU C */
408 #endif /* alloca not defined */
409 #endif /* YYSTACK_USE_ALLOCA not defined */
411 #ifdef YYSTACK_USE_ALLOCA
412 #define YYSTACK_ALLOC alloca
413 #else
414 #define YYSTACK_ALLOC malloc
415 #endif
417 /* Note: there must be only one dollar sign in this file.
418 It is replaced by the list of actions, each action
419 as one case of the switch. */
421 #define yyerrok (yyerrstatus = 0)
422 #define yyclearin (yychar = YYEMPTY)
423 #define YYEMPTY -2
424 #define YYEOF 0
425 #define YYACCEPT goto yyacceptlab
426 #define YYABORT goto yyabortlab
427 #define YYERROR goto yyerrlab1
428 /* Like YYERROR except do call yyerror.
429 This remains here temporarily to ease the
430 transition to the new meaning of YYERROR, for GCC.
431 Once GCC version 2 has supplanted version 1, this can go. */
432 #define YYFAIL goto yyerrlab
433 #define YYRECOVERING() (!!yyerrstatus)
434 #define YYBACKUP(token, value) \
435 do \
436 if (yychar == YYEMPTY && yylen == 1) \
437 { yychar = (token), yylval = (value); \
438 yychar1 = YYTRANSLATE (yychar); \
439 YYPOPSTACK; \
440 goto yybackup; \
442 else \
443 { yyerror ("syntax error: cannot back up"); YYERROR; } \
444 while (0)
446 #define YYTERROR 1
447 #define YYERRCODE 256
449 #ifndef YYPURE
450 #define YYLEX yylex()
451 #endif
453 #ifdef YYPURE
454 #ifdef YYLSP_NEEDED
455 #ifdef YYLEX_PARAM
456 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
457 #else
458 #define YYLEX yylex(&yylval, &yylloc)
459 #endif
460 #else /* not YYLSP_NEEDED */
461 #ifdef YYLEX_PARAM
462 #define YYLEX yylex(&yylval, YYLEX_PARAM)
463 #else
464 #define YYLEX yylex(&yylval)
465 #endif
466 #endif /* not YYLSP_NEEDED */
467 #endif
469 /* If nonreentrant, generate the variables here */
471 #ifndef YYPURE
473 int yychar; /* the lookahead symbol */
474 YYSTYPE yylval; /* the semantic value of the */
475 /* lookahead symbol */
477 #ifdef YYLSP_NEEDED
478 YYLTYPE yylloc; /* location data for the lookahead */
479 /* symbol */
480 #endif
482 int yynerrs; /* number of parse errors so far */
483 #endif /* not YYPURE */
485 #if YYDEBUG != 0
486 int yydebug; /* nonzero means print parse trace */
487 /* Since this is uninitialized, it does not stop multiple parsers
488 from coexisting. */
489 #endif
491 /* YYINITDEPTH indicates the initial size of the parser's stacks */
493 #ifndef YYINITDEPTH
494 #define YYINITDEPTH 200
495 #endif
497 /* YYMAXDEPTH is the maximum size the stacks can grow to
498 (effective only if the built-in stack extension method is used). */
500 #if YYMAXDEPTH == 0
501 #undef YYMAXDEPTH
502 #endif
504 #ifndef YYMAXDEPTH
505 #define YYMAXDEPTH 10000
506 #endif
508 /* Define __yy_memcpy. Note that the size argument
509 should be passed with type unsigned int, because that is what the non-GCC
510 definitions require. With GCC, __builtin_memcpy takes an arg
511 of type size_t, but it can handle unsigned int. */
513 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
514 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
515 #else /* not GNU C or C++ */
516 #ifndef __cplusplus
518 /* This is the most reliable way to avoid incompatibilities
519 in available built-in functions on various systems. */
520 static void
521 __yy_memcpy (to, from, count)
522 char *to;
523 char *from;
524 unsigned int count;
526 register char *f = from;
527 register char *t = to;
528 register int i = count;
530 while (i-- > 0)
531 *t++ = *f++;
534 #else /* __cplusplus */
536 /* This is the most reliable way to avoid incompatibilities
537 in available built-in functions on various systems. */
538 static void
539 __yy_memcpy (char *to, char *from, unsigned int count)
541 register char *t = to;
542 register char *f = from;
543 register int i = count;
545 while (i-- > 0)
546 *t++ = *f++;
549 #endif
550 #endif
552 #line 217 "/usr/share/misc/bison.simple"
554 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
555 into yyparse. The argument should have type void *.
556 It should actually point to an object.
557 Grammar actions can access the variable by casting it
558 to the proper pointer type. */
560 #ifdef YYPARSE_PARAM
561 #ifdef __cplusplus
562 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
563 #define YYPARSE_PARAM_DECL
564 #else /* not __cplusplus */
565 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
566 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
567 #endif /* not __cplusplus */
568 #else /* not YYPARSE_PARAM */
569 #define YYPARSE_PARAM_ARG
570 #define YYPARSE_PARAM_DECL
571 #endif /* not YYPARSE_PARAM */
573 /* Prevent warning if -Wstrict-prototypes. */
574 #ifdef __GNUC__
575 #ifdef YYPARSE_PARAM
576 int yyparse (void *);
577 #else
578 int yyparse (void);
579 #endif
580 #endif
583 yyparse(YYPARSE_PARAM_ARG)
584 YYPARSE_PARAM_DECL
586 register int yystate;
587 register int yyn;
588 register short *yyssp;
589 register YYSTYPE *yyvsp;
590 int yyerrstatus; /* number of tokens to shift before error messages enabled */
591 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
593 short yyssa[YYINITDEPTH]; /* the state stack */
594 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
596 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
597 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
599 #ifdef YYLSP_NEEDED
600 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
601 YYLTYPE *yyls = yylsa;
602 YYLTYPE *yylsp;
604 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
605 #else
606 #define YYPOPSTACK (yyvsp--, yyssp--)
607 #endif
609 int yystacksize = YYINITDEPTH;
610 int yyfree_stacks = 0;
612 #ifdef YYPURE
613 int yychar;
614 YYSTYPE yylval;
615 int yynerrs;
616 #ifdef YYLSP_NEEDED
617 YYLTYPE yylloc;
618 #endif
619 #endif
621 YYSTYPE yyval; /* the variable used to return */
622 /* semantic values from the action */
623 /* routines */
625 int yylen;
627 #if YYDEBUG != 0
628 if (yydebug)
629 fprintf(stderr, "Starting parse\n");
630 #endif
632 yystate = 0;
633 yyerrstatus = 0;
634 yynerrs = 0;
635 yychar = YYEMPTY; /* Cause a token to be read. */
637 /* Initialize stack pointers.
638 Waste one element of value and location stack
639 so that they stay on the same level as the state stack.
640 The wasted elements are never initialized. */
642 yyssp = yyss - 1;
643 yyvsp = yyvs;
644 #ifdef YYLSP_NEEDED
645 yylsp = yyls;
646 #endif
648 /* Push a new state, which is found in yystate . */
649 /* In all cases, when you get here, the value and location stacks
650 have just been pushed. so pushing a state here evens the stacks. */
651 yynewstate:
653 *++yyssp = yystate;
655 if (yyssp >= yyss + yystacksize - 1)
657 /* Give user a chance to reallocate the stack */
658 /* Use copies of these so that the &'s don't force the real ones into memory. */
659 YYSTYPE *yyvs1 = yyvs;
660 short *yyss1 = yyss;
661 #ifdef YYLSP_NEEDED
662 YYLTYPE *yyls1 = yyls;
663 #endif
665 /* Get the current used size of the three stacks, in elements. */
666 int size = yyssp - yyss + 1;
668 #ifdef yyoverflow
669 /* Each stack pointer address is followed by the size of
670 the data in use in that stack, in bytes. */
671 #ifdef YYLSP_NEEDED
672 /* This used to be a conditional around just the two extra args,
673 but that might be undefined if yyoverflow is a macro. */
674 yyoverflow("parser stack overflow",
675 &yyss1, size * sizeof (*yyssp),
676 &yyvs1, size * sizeof (*yyvsp),
677 &yyls1, size * sizeof (*yylsp),
678 &yystacksize);
679 #else
680 yyoverflow("parser stack overflow",
681 &yyss1, size * sizeof (*yyssp),
682 &yyvs1, size * sizeof (*yyvsp),
683 &yystacksize);
684 #endif
686 yyss = yyss1; yyvs = yyvs1;
687 #ifdef YYLSP_NEEDED
688 yyls = yyls1;
689 #endif
690 #else /* no yyoverflow */
691 /* Extend the stack our own way. */
692 if (yystacksize >= YYMAXDEPTH)
694 yyerror("parser stack overflow");
695 if (yyfree_stacks)
697 free (yyss);
698 free (yyvs);
699 #ifdef YYLSP_NEEDED
700 free (yyls);
701 #endif
703 return 2;
705 yystacksize *= 2;
706 if (yystacksize > YYMAXDEPTH)
707 yystacksize = YYMAXDEPTH;
708 #ifndef YYSTACK_USE_ALLOCA
709 yyfree_stacks = 1;
710 #endif
711 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
712 __yy_memcpy ((char *)yyss, (char *)yyss1,
713 size * (unsigned int) sizeof (*yyssp));
714 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
715 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
716 size * (unsigned int) sizeof (*yyvsp));
717 #ifdef YYLSP_NEEDED
718 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
719 __yy_memcpy ((char *)yyls, (char *)yyls1,
720 size * (unsigned int) sizeof (*yylsp));
721 #endif
722 #endif /* no yyoverflow */
724 yyssp = yyss + size - 1;
725 yyvsp = yyvs + size - 1;
726 #ifdef YYLSP_NEEDED
727 yylsp = yyls + size - 1;
728 #endif
730 #if YYDEBUG != 0
731 if (yydebug)
732 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
733 #endif
735 if (yyssp >= yyss + yystacksize - 1)
736 YYABORT;
739 #if YYDEBUG != 0
740 if (yydebug)
741 fprintf(stderr, "Entering state %d\n", yystate);
742 #endif
744 goto yybackup;
745 yybackup:
747 /* Do appropriate processing given the current state. */
748 /* Read a lookahead token if we need one and don't already have one. */
749 /* yyresume: */
751 /* First try to decide what to do without reference to lookahead token. */
753 yyn = yypact[yystate];
754 if (yyn == YYFLAG)
755 goto yydefault;
757 /* Not known => get a lookahead token if don't already have one. */
759 /* yychar is either YYEMPTY or YYEOF
760 or a valid token in external form. */
762 if (yychar == YYEMPTY)
764 #if YYDEBUG != 0
765 if (yydebug)
766 fprintf(stderr, "Reading a token: ");
767 #endif
768 yychar = YYLEX;
771 /* Convert token to internal form (in yychar1) for indexing tables with */
773 if (yychar <= 0) /* This means end of input. */
775 yychar1 = 0;
776 yychar = YYEOF; /* Don't call YYLEX any more */
778 #if YYDEBUG != 0
779 if (yydebug)
780 fprintf(stderr, "Now at end of input.\n");
781 #endif
783 else
785 yychar1 = YYTRANSLATE(yychar);
787 #if YYDEBUG != 0
788 if (yydebug)
790 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
791 /* Give the individual parser a way to print the precise meaning
792 of a token, for further debugging info. */
793 #ifdef YYPRINT
794 YYPRINT (stderr, yychar, yylval);
795 #endif
796 fprintf (stderr, ")\n");
798 #endif
801 yyn += yychar1;
802 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
803 goto yydefault;
805 yyn = yytable[yyn];
807 /* yyn is what to do for this token type in this state.
808 Negative => reduce, -yyn is rule number.
809 Positive => shift, yyn is new state.
810 New state is final state => don't bother to shift,
811 just return success.
812 0, or most negative number => error. */
814 if (yyn < 0)
816 if (yyn == YYFLAG)
817 goto yyerrlab;
818 yyn = -yyn;
819 goto yyreduce;
821 else if (yyn == 0)
822 goto yyerrlab;
824 if (yyn == YYFINAL)
825 YYACCEPT;
827 /* Shift the lookahead token. */
829 #if YYDEBUG != 0
830 if (yydebug)
831 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
832 #endif
834 /* Discard the token being shifted unless it is eof. */
835 if (yychar != YYEOF)
836 yychar = YYEMPTY;
838 *++yyvsp = yylval;
839 #ifdef YYLSP_NEEDED
840 *++yylsp = yylloc;
841 #endif
843 /* count tokens shifted since error; after three, turn off error status. */
844 if (yyerrstatus) yyerrstatus--;
846 yystate = yyn;
847 goto yynewstate;
849 /* Do the default action for the current state. */
850 yydefault:
852 yyn = yydefact[yystate];
853 if (yyn == 0)
854 goto yyerrlab;
856 /* Do a reduction. yyn is the number of a rule to reduce with. */
857 yyreduce:
858 yylen = yyr2[yyn];
859 if (yylen > 0)
860 yyval = yyvsp[1-yylen]; /* implement default value of the action */
862 #if YYDEBUG != 0
863 if (yydebug)
865 int i;
867 fprintf (stderr, "Reducing via rule %d (line %d), ",
868 yyn, yyrline[yyn]);
870 /* Print the symbols being reduced, and their result. */
871 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
872 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
873 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
875 #endif
878 switch (yyn) {
880 case 4:
881 #line 158 "nlmheader.y"
883 check_procedure = yyvsp[0].string;
885 break;}
886 case 5:
887 #line 162 "nlmheader.y"
889 nlmheader_warn (_("CODESTART is not implemented; sorry"), -1);
890 free (yyvsp[0].string);
892 break;}
893 case 6:
894 #line 167 "nlmheader.y"
896 int len;
898 strncpy (copyright_hdr->stamp, "CoPyRiGhT=", 10);
899 len = strlen (yyvsp[0].string);
900 if (len >= NLM_MAX_COPYRIGHT_MESSAGE_LENGTH)
902 nlmheader_warn (_("copyright string is too long"),
903 NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1);
904 len = NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1;
906 copyright_hdr->copyrightMessageLength = len;
907 strncpy (copyright_hdr->copyrightMessage, yyvsp[0].string, len);
908 copyright_hdr->copyrightMessage[len] = '\0';
909 free (yyvsp[0].string);
911 break;}
912 case 7:
913 #line 184 "nlmheader.y"
915 custom_file = yyvsp[0].string;
917 break;}
918 case 8:
919 #line 188 "nlmheader.y"
921 /* We don't set the version stamp here, because we use the
922 version stamp to detect whether the required VERSION
923 keyword was given. */
924 version_hdr->month = nlmlex_get_number (yyvsp[-2].string);
925 version_hdr->day = nlmlex_get_number (yyvsp[-1].string);
926 version_hdr->year = nlmlex_get_number (yyvsp[0].string);
927 free (yyvsp[-2].string);
928 free (yyvsp[-1].string);
929 free (yyvsp[0].string);
930 if (version_hdr->month < 1 || version_hdr->month > 12)
931 nlmheader_warn (_("illegal month"), -1);
932 if (version_hdr->day < 1 || version_hdr->day > 31)
933 nlmheader_warn (_("illegal day"), -1);
934 if (version_hdr->year < 1900 || version_hdr->year > 3000)
935 nlmheader_warn (_("illegal year"), -1);
937 break;}
938 case 9:
939 #line 206 "nlmheader.y"
941 debug_info = true;
943 break;}
944 case 10:
945 #line 210 "nlmheader.y"
947 int len;
949 len = strlen (yyvsp[0].string);
950 if (len > NLM_MAX_DESCRIPTION_LENGTH)
952 nlmheader_warn (_("description string is too long"),
953 NLM_MAX_DESCRIPTION_LENGTH);
954 len = NLM_MAX_DESCRIPTION_LENGTH;
956 var_hdr->descriptionLength = len;
957 strncpy (var_hdr->descriptionText, yyvsp[0].string, len);
958 var_hdr->descriptionText[len] = '\0';
959 free (yyvsp[0].string);
961 break;}
962 case 11:
963 #line 226 "nlmheader.y"
965 exit_procedure = yyvsp[0].string;
967 break;}
968 case 12:
969 #line 230 "nlmheader.y"
971 symbol_prefix = NULL;
973 break;}
974 case 13:
975 #line 234 "nlmheader.y"
977 export_symbols = string_list_append (export_symbols, yyvsp[0].list);
979 break;}
980 case 14:
981 #line 238 "nlmheader.y"
983 fixed_hdr->flags |= nlmlex_get_number (yyvsp[0].string);
984 free (yyvsp[0].string);
986 break;}
987 case 15:
988 #line 243 "nlmheader.y"
990 fixed_hdr->flags &=~ nlmlex_get_number (yyvsp[0].string);
991 free (yyvsp[0].string);
993 break;}
994 case 16:
995 #line 248 "nlmheader.y"
997 map_file = "";
998 full_map = true;
1000 break;}
1001 case 17:
1002 #line 253 "nlmheader.y"
1004 map_file = yyvsp[0].string;
1005 full_map = true;
1007 break;}
1008 case 18:
1009 #line 258 "nlmheader.y"
1011 help_file = yyvsp[0].string;
1013 break;}
1014 case 19:
1015 #line 262 "nlmheader.y"
1017 symbol_prefix = NULL;
1019 break;}
1020 case 20:
1021 #line 266 "nlmheader.y"
1023 import_symbols = string_list_append (import_symbols, yyvsp[0].list);
1025 break;}
1026 case 21:
1027 #line 270 "nlmheader.y"
1029 input_files = string_list_append (input_files, yyvsp[0].list);
1031 break;}
1032 case 22:
1033 #line 274 "nlmheader.y"
1035 map_file = "";
1037 break;}
1038 case 23:
1039 #line 278 "nlmheader.y"
1041 map_file = yyvsp[0].string;
1043 break;}
1044 case 24:
1045 #line 282 "nlmheader.y"
1047 message_file = yyvsp[0].string;
1049 break;}
1050 case 25:
1051 #line 286 "nlmheader.y"
1053 modules = string_list_append (modules, yyvsp[0].list);
1055 break;}
1056 case 26:
1057 #line 290 "nlmheader.y"
1059 fixed_hdr->flags |= 0x2;
1061 break;}
1062 case 27:
1063 #line 294 "nlmheader.y"
1065 fixed_hdr->flags |= 0x10;
1067 break;}
1068 case 28:
1069 #line 298 "nlmheader.y"
1071 if (output_file == NULL)
1072 output_file = yyvsp[0].string;
1073 else
1074 nlmheader_warn (_("ignoring duplicate OUTPUT statement"), -1);
1076 break;}
1077 case 29:
1078 #line 305 "nlmheader.y"
1080 fixed_hdr->flags |= 0x8;
1082 break;}
1083 case 30:
1084 #line 309 "nlmheader.y"
1086 fixed_hdr->flags |= 0x1;
1088 break;}
1089 case 31:
1090 #line 313 "nlmheader.y"
1092 int len;
1094 len = strlen (yyvsp[0].string);
1095 if (len >= NLM_MAX_SCREEN_NAME_LENGTH)
1097 nlmheader_warn (_("screen name is too long"),
1098 NLM_MAX_SCREEN_NAME_LENGTH);
1099 len = NLM_MAX_SCREEN_NAME_LENGTH;
1101 var_hdr->screenNameLength = len;
1102 strncpy (var_hdr->screenName, yyvsp[0].string, len);
1103 var_hdr->screenName[NLM_MAX_SCREEN_NAME_LENGTH] = '\0';
1104 free (yyvsp[0].string);
1106 break;}
1107 case 32:
1108 #line 329 "nlmheader.y"
1110 sharelib_file = yyvsp[0].string;
1112 break;}
1113 case 33:
1114 #line 333 "nlmheader.y"
1116 var_hdr->stackSize = nlmlex_get_number (yyvsp[0].string);
1117 free (yyvsp[0].string);
1119 break;}
1120 case 34:
1121 #line 338 "nlmheader.y"
1123 start_procedure = yyvsp[0].string;
1125 break;}
1126 case 35:
1127 #line 342 "nlmheader.y"
1129 fixed_hdr->flags |= 0x4;
1131 break;}
1132 case 36:
1133 #line 346 "nlmheader.y"
1135 int len;
1137 len = strlen (yyvsp[0].string);
1138 if (len >= NLM_MAX_THREAD_NAME_LENGTH)
1140 nlmheader_warn (_("thread name is too long"),
1141 NLM_MAX_THREAD_NAME_LENGTH);
1142 len = NLM_MAX_THREAD_NAME_LENGTH;
1144 var_hdr->threadNameLength = len;
1145 strncpy (var_hdr->threadName, yyvsp[0].string, len);
1146 var_hdr->threadName[len] = '\0';
1147 free (yyvsp[0].string);
1149 break;}
1150 case 37:
1151 #line 362 "nlmheader.y"
1153 fixed_hdr->moduleType = nlmlex_get_number (yyvsp[0].string);
1154 free (yyvsp[0].string);
1156 break;}
1157 case 38:
1158 #line 367 "nlmheader.y"
1160 verbose = true;
1162 break;}
1163 case 39:
1164 #line 371 "nlmheader.y"
1166 long val;
1168 strncpy (version_hdr->stamp, "VeRsIoN#", 8);
1169 version_hdr->majorVersion = nlmlex_get_number (yyvsp[-2].string);
1170 val = nlmlex_get_number (yyvsp[-1].string);
1171 if (val < 0 || val > 99)
1172 nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"),
1173 -1);
1174 else
1175 version_hdr->minorVersion = val;
1176 val = nlmlex_get_number (yyvsp[0].string);
1177 if (val < 0)
1178 nlmheader_warn (_("illegal revision number (must be between 0 and 26)"),
1179 -1);
1180 else if (val > 26)
1181 version_hdr->revision = 0;
1182 else
1183 version_hdr->revision = val;
1184 free (yyvsp[-2].string);
1185 free (yyvsp[-1].string);
1186 free (yyvsp[0].string);
1188 break;}
1189 case 40:
1190 #line 395 "nlmheader.y"
1192 long val;
1194 strncpy (version_hdr->stamp, "VeRsIoN#", 8);
1195 version_hdr->majorVersion = nlmlex_get_number (yyvsp[-1].string);
1196 val = nlmlex_get_number (yyvsp[0].string);
1197 if (val < 0 || val > 99)
1198 nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"),
1199 -1);
1200 else
1201 version_hdr->minorVersion = val;
1202 version_hdr->revision = 0;
1203 free (yyvsp[-1].string);
1204 free (yyvsp[0].string);
1206 break;}
1207 case 41:
1208 #line 411 "nlmheader.y"
1210 rpc_file = yyvsp[0].string;
1212 break;}
1213 case 42:
1214 #line 420 "nlmheader.y"
1216 yyval.list = NULL;
1218 break;}
1219 case 43:
1220 #line 424 "nlmheader.y"
1222 yyval.list = yyvsp[0].list;
1224 break;}
1225 case 44:
1226 #line 435 "nlmheader.y"
1228 yyval.list = string_list_cons (yyvsp[0].string, NULL);
1230 break;}
1231 case 45:
1232 #line 439 "nlmheader.y"
1234 yyval.list = NULL;
1236 break;}
1237 case 46:
1238 #line 443 "nlmheader.y"
1240 yyval.list = string_list_append1 (yyvsp[-1].list, yyvsp[0].string);
1242 break;}
1243 case 47:
1244 #line 447 "nlmheader.y"
1246 yyval.list = yyvsp[-1].list;
1248 break;}
1249 case 48:
1250 #line 456 "nlmheader.y"
1252 if (symbol_prefix != NULL)
1253 free (symbol_prefix);
1254 symbol_prefix = yyvsp[-1].string;
1256 break;}
1257 case 49:
1258 #line 467 "nlmheader.y"
1260 if (symbol_prefix == NULL)
1261 yyval.string = yyvsp[0].string;
1262 else
1264 yyval.string = xmalloc (strlen (symbol_prefix) + strlen (yyvsp[0].string) + 2);
1265 sprintf (yyval.string, "%s@%s", symbol_prefix, yyvsp[0].string);
1266 free (yyvsp[0].string);
1269 break;}
1270 case 50:
1271 #line 483 "nlmheader.y"
1273 yyval.list = NULL;
1275 break;}
1276 case 51:
1277 #line 487 "nlmheader.y"
1279 yyval.list = string_list_cons (yyvsp[-1].string, yyvsp[0].list);
1281 break;}
1283 /* the action file gets copied in in place of this dollarsign */
1284 #line 543 "/usr/share/misc/bison.simple"
1286 yyvsp -= yylen;
1287 yyssp -= yylen;
1288 #ifdef YYLSP_NEEDED
1289 yylsp -= yylen;
1290 #endif
1292 #if YYDEBUG != 0
1293 if (yydebug)
1295 short *ssp1 = yyss - 1;
1296 fprintf (stderr, "state stack now");
1297 while (ssp1 != yyssp)
1298 fprintf (stderr, " %d", *++ssp1);
1299 fprintf (stderr, "\n");
1301 #endif
1303 *++yyvsp = yyval;
1305 #ifdef YYLSP_NEEDED
1306 yylsp++;
1307 if (yylen == 0)
1309 yylsp->first_line = yylloc.first_line;
1310 yylsp->first_column = yylloc.first_column;
1311 yylsp->last_line = (yylsp-1)->last_line;
1312 yylsp->last_column = (yylsp-1)->last_column;
1313 yylsp->text = 0;
1315 else
1317 yylsp->last_line = (yylsp+yylen-1)->last_line;
1318 yylsp->last_column = (yylsp+yylen-1)->last_column;
1320 #endif
1322 /* Now "shift" the result of the reduction.
1323 Determine what state that goes to,
1324 based on the state we popped back to
1325 and the rule number reduced by. */
1327 yyn = yyr1[yyn];
1329 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1330 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1331 yystate = yytable[yystate];
1332 else
1333 yystate = yydefgoto[yyn - YYNTBASE];
1335 goto yynewstate;
1337 yyerrlab: /* here on detecting error */
1339 if (! yyerrstatus)
1340 /* If not already recovering from an error, report this error. */
1342 ++yynerrs;
1344 #ifdef YYERROR_VERBOSE
1345 yyn = yypact[yystate];
1347 if (yyn > YYFLAG && yyn < YYLAST)
1349 int size = 0;
1350 char *msg;
1351 int x, count;
1353 count = 0;
1354 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1355 for (x = (yyn < 0 ? -yyn : 0);
1356 x < (sizeof(yytname) / sizeof(char *)); x++)
1357 if (yycheck[x + yyn] == x)
1358 size += strlen(yytname[x]) + 15, count++;
1359 msg = (char *) malloc(size + 15);
1360 if (msg != 0)
1362 strcpy(msg, "parse error");
1364 if (count < 5)
1366 count = 0;
1367 for (x = (yyn < 0 ? -yyn : 0);
1368 x < (sizeof(yytname) / sizeof(char *)); x++)
1369 if (yycheck[x + yyn] == x)
1371 strcat(msg, count == 0 ? ", expecting `" : " or `");
1372 strcat(msg, yytname[x]);
1373 strcat(msg, "'");
1374 count++;
1377 yyerror(msg);
1378 free(msg);
1380 else
1381 yyerror ("parse error; also virtual memory exceeded");
1383 else
1384 #endif /* YYERROR_VERBOSE */
1385 yyerror("parse error");
1388 goto yyerrlab1;
1389 yyerrlab1: /* here on error raised explicitly by an action */
1391 if (yyerrstatus == 3)
1393 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1395 /* return failure if at end of input */
1396 if (yychar == YYEOF)
1397 YYABORT;
1399 #if YYDEBUG != 0
1400 if (yydebug)
1401 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1402 #endif
1404 yychar = YYEMPTY;
1407 /* Else will try to reuse lookahead token
1408 after shifting the error token. */
1410 yyerrstatus = 3; /* Each real token shifted decrements this */
1412 goto yyerrhandle;
1414 yyerrdefault: /* current state does not do anything special for the error token. */
1416 #if 0
1417 /* This is wrong; only states that explicitly want error tokens
1418 should shift them. */
1419 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1420 if (yyn) goto yydefault;
1421 #endif
1423 yyerrpop: /* pop the current state because it cannot handle the error token */
1425 if (yyssp == yyss) YYABORT;
1426 yyvsp--;
1427 yystate = *--yyssp;
1428 #ifdef YYLSP_NEEDED
1429 yylsp--;
1430 #endif
1432 #if YYDEBUG != 0
1433 if (yydebug)
1435 short *ssp1 = yyss - 1;
1436 fprintf (stderr, "Error: state stack now");
1437 while (ssp1 != yyssp)
1438 fprintf (stderr, " %d", *++ssp1);
1439 fprintf (stderr, "\n");
1441 #endif
1443 yyerrhandle:
1445 yyn = yypact[yystate];
1446 if (yyn == YYFLAG)
1447 goto yyerrdefault;
1449 yyn += YYTERROR;
1450 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1451 goto yyerrdefault;
1453 yyn = yytable[yyn];
1454 if (yyn < 0)
1456 if (yyn == YYFLAG)
1457 goto yyerrpop;
1458 yyn = -yyn;
1459 goto yyreduce;
1461 else if (yyn == 0)
1462 goto yyerrpop;
1464 if (yyn == YYFINAL)
1465 YYACCEPT;
1467 #if YYDEBUG != 0
1468 if (yydebug)
1469 fprintf(stderr, "Shifting error token, ");
1470 #endif
1472 *++yyvsp = yylval;
1473 #ifdef YYLSP_NEEDED
1474 *++yylsp = yylloc;
1475 #endif
1477 yystate = yyn;
1478 goto yynewstate;
1480 yyacceptlab:
1481 /* YYACCEPT comes here. */
1482 if (yyfree_stacks)
1484 free (yyss);
1485 free (yyvs);
1486 #ifdef YYLSP_NEEDED
1487 free (yyls);
1488 #endif
1490 return 0;
1492 yyabortlab:
1493 /* YYABORT comes here. */
1494 if (yyfree_stacks)
1496 free (yyss);
1497 free (yyvs);
1498 #ifdef YYLSP_NEEDED
1499 free (yyls);
1500 #endif
1502 return 1;
1504 #line 492 "nlmheader.y"
1507 /* If strerror is just a macro, we want to use the one from libiberty
1508 since it will handle undefined values. */
1509 #undef strerror
1510 extern char *strerror ();
1512 /* The lexer is simple, too simple for flex. Keywords are only
1513 recognized at the start of lines. Everything else must be an
1514 argument. A comma is treated as whitespace. */
1516 /* The states the lexer can be in. */
1518 enum lex_state
1520 /* At the beginning of a line. */
1521 BEGINNING_OF_LINE,
1522 /* In the middle of a line. */
1523 IN_LINE
1526 /* We need to keep a stack of files to handle file inclusion. */
1528 struct input
1530 /* The file to read from. */
1531 FILE *file;
1532 /* The name of the file. */
1533 char *name;
1534 /* The current line number. */
1535 int lineno;
1536 /* The current state. */
1537 enum lex_state state;
1538 /* The next file on the stack. */
1539 struct input *next;
1542 /* The current input file. */
1544 static struct input current;
1546 /* The character which introduces comments. */
1547 #define COMMENT_CHAR '#'
1549 /* Start the lexer going on the main input file. */
1551 boolean
1552 nlmlex_file (name)
1553 const char *name;
1555 current.next = NULL;
1556 return nlmlex_file_open (name);
1559 /* Start the lexer going on a subsidiary input file. */
1561 static void
1562 nlmlex_file_push (name)
1563 const char *name;
1565 struct input *push;
1567 push = (struct input *) xmalloc (sizeof (struct input));
1568 *push = current;
1569 if (nlmlex_file_open (name))
1570 current.next = push;
1571 else
1573 current = *push;
1574 free (push);
1578 /* Start lexing from a file. */
1580 static boolean
1581 nlmlex_file_open (name)
1582 const char *name;
1584 current.file = fopen (name, "r");
1585 if (current.file == NULL)
1587 fprintf (stderr, "%s:%s: %s\n", program_name, name, strerror (errno));
1588 ++parse_errors;
1589 return false;
1591 current.name = xstrdup (name);
1592 current.lineno = 1;
1593 current.state = BEGINNING_OF_LINE;
1594 return true;
1597 /* Table used to turn keywords into tokens. */
1599 struct keyword_tokens_struct
1601 const char *keyword;
1602 int token;
1605 struct keyword_tokens_struct keyword_tokens[] =
1607 { "CHECK", CHECK },
1608 { "CODESTART", CODESTART },
1609 { "COPYRIGHT", COPYRIGHT },
1610 { "CUSTOM", CUSTOM },
1611 { "DATE", DATE },
1612 { "DEBUG", DEBUG },
1613 { "DESCRIPTION", DESCRIPTION },
1614 { "EXIT", EXIT },
1615 { "EXPORT", EXPORT },
1616 { "FLAG_ON", FLAG_ON },
1617 { "FLAG_OFF", FLAG_OFF },
1618 { "FULLMAP", FULLMAP },
1619 { "HELP", HELP },
1620 { "IMPORT", IMPORT },
1621 { "INPUT", INPUT },
1622 { "MAP", MAP },
1623 { "MESSAGES", MESSAGES },
1624 { "MODULE", MODULE },
1625 { "MULTIPLE", MULTIPLE },
1626 { "OS_DOMAIN", OS_DOMAIN },
1627 { "OUTPUT", OUTPUT },
1628 { "PSEUDOPREEMPTION", PSEUDOPREEMPTION },
1629 { "REENTRANT", REENTRANT },
1630 { "SCREENNAME", SCREENNAME },
1631 { "SHARELIB", SHARELIB },
1632 { "STACK", STACK },
1633 { "STACKSIZE", STACK },
1634 { "START", START },
1635 { "SYNCHRONIZE", SYNCHRONIZE },
1636 { "THREADNAME", THREADNAME },
1637 { "TYPE", TYPE },
1638 { "VERBOSE", VERBOSE },
1639 { "VERSION", VERSIONK },
1640 { "XDCDATA", XDCDATA }
1643 #define KEYWORD_COUNT (sizeof (keyword_tokens) / sizeof (keyword_tokens[0]))
1645 /* The lexer accumulates strings in these variables. */
1646 static char *lex_buf;
1647 static int lex_size;
1648 static int lex_pos;
1650 /* Start accumulating strings into the buffer. */
1651 #define BUF_INIT() \
1652 ((void) (lex_buf != NULL ? lex_pos = 0 : nlmlex_buf_init ()))
1654 static int
1655 nlmlex_buf_init ()
1657 lex_size = 10;
1658 lex_buf = xmalloc (lex_size + 1);
1659 lex_pos = 0;
1660 return 0;
1663 /* Finish a string in the buffer. */
1664 #define BUF_FINISH() ((void) (lex_buf[lex_pos] = '\0'))
1666 /* Accumulate a character into the buffer. */
1667 #define BUF_ADD(c) \
1668 ((void) (lex_pos < lex_size \
1669 ? lex_buf[lex_pos++] = (c) \
1670 : nlmlex_buf_add (c)))
1672 static char
1673 nlmlex_buf_add (c)
1674 int c;
1676 if (lex_pos >= lex_size)
1678 lex_size *= 2;
1679 lex_buf = xrealloc (lex_buf, lex_size + 1);
1682 return lex_buf[lex_pos++] = c;
1685 /* The lexer proper. This is called by the bison generated parsing
1686 code. */
1688 static int
1689 yylex ()
1691 int c;
1693 tail_recurse:
1695 c = getc (current.file);
1697 /* Commas are treated as whitespace characters. */
1698 while (isspace ((unsigned char) c) || c == ',')
1700 current.state = IN_LINE;
1701 if (c == '\n')
1703 ++current.lineno;
1704 current.state = BEGINNING_OF_LINE;
1706 c = getc (current.file);
1709 /* At the end of the file we either pop to the previous file or
1710 finish up. */
1711 if (c == EOF)
1713 fclose (current.file);
1714 free (current.name);
1715 if (current.next == NULL)
1716 return 0;
1717 else
1719 struct input *next;
1721 next = current.next;
1722 current = *next;
1723 free (next);
1724 goto tail_recurse;
1728 /* A comment character always means to drop everything until the
1729 next newline. */
1730 if (c == COMMENT_CHAR)
1734 c = getc (current.file);
1736 while (c != '\n');
1737 ++current.lineno;
1738 current.state = BEGINNING_OF_LINE;
1739 goto tail_recurse;
1742 /* An '@' introduces an include file. */
1743 if (c == '@')
1747 c = getc (current.file);
1748 if (c == '\n')
1749 ++current.lineno;
1751 while (isspace ((unsigned char) c));
1752 BUF_INIT ();
1753 while (! isspace ((unsigned char) c) && c != EOF)
1755 BUF_ADD (c);
1756 c = getc (current.file);
1758 BUF_FINISH ();
1760 ungetc (c, current.file);
1762 nlmlex_file_push (lex_buf);
1763 goto tail_recurse;
1766 /* A non-space character at the start of a line must be the start of
1767 a keyword. */
1768 if (current.state == BEGINNING_OF_LINE)
1770 BUF_INIT ();
1771 while (isalnum ((unsigned char) c) || c == '_')
1773 if (islower ((unsigned char) c))
1774 BUF_ADD (toupper ((unsigned char) c));
1775 else
1776 BUF_ADD (c);
1777 c = getc (current.file);
1779 BUF_FINISH ();
1781 if (c != EOF && ! isspace ((unsigned char) c) && c != ',')
1783 nlmheader_identify ();
1784 fprintf (stderr, _("%s:%d: illegal character in keyword: %c\n"),
1785 current.name, current.lineno, c);
1787 else
1789 unsigned int i;
1791 for (i = 0; i < KEYWORD_COUNT; i++)
1793 if (lex_buf[0] == keyword_tokens[i].keyword[0]
1794 && strcmp (lex_buf, keyword_tokens[i].keyword) == 0)
1796 /* Pushing back the final whitespace avoids worrying
1797 about \n here. */
1798 ungetc (c, current.file);
1799 current.state = IN_LINE;
1800 return keyword_tokens[i].token;
1804 nlmheader_identify ();
1805 fprintf (stderr, _("%s:%d: unrecognized keyword: %s\n"),
1806 current.name, current.lineno, lex_buf);
1809 ++parse_errors;
1810 /* Treat the rest of this line as a comment. */
1811 ungetc (COMMENT_CHAR, current.file);
1812 goto tail_recurse;
1815 /* Parentheses just represent themselves. */
1816 if (c == '(' || c == ')')
1817 return c;
1819 /* Handle quoted strings. */
1820 if (c == '"' || c == '\'')
1822 int quote;
1823 int start_lineno;
1825 quote = c;
1826 start_lineno = current.lineno;
1828 c = getc (current.file);
1829 BUF_INIT ();
1830 while (c != quote && c != EOF)
1832 BUF_ADD (c);
1833 if (c == '\n')
1834 ++current.lineno;
1835 c = getc (current.file);
1837 BUF_FINISH ();
1839 if (c == EOF)
1841 nlmheader_identify ();
1842 fprintf (stderr, _("%s:%d: end of file in quoted string\n"),
1843 current.name, start_lineno);
1844 ++parse_errors;
1847 /* FIXME: Possible memory leak. */
1848 yylval.string = xstrdup (lex_buf);
1849 return QUOTED_STRING;
1852 /* Gather a generic argument. */
1853 BUF_INIT ();
1854 while (! isspace (c)
1855 && c != ','
1856 && c != COMMENT_CHAR
1857 && c != '('
1858 && c != ')')
1860 BUF_ADD (c);
1861 c = getc (current.file);
1863 BUF_FINISH ();
1865 ungetc (c, current.file);
1867 /* FIXME: Possible memory leak. */
1868 yylval.string = xstrdup (lex_buf);
1869 return STRING;
1872 /* Get a number from a string. */
1874 static long
1875 nlmlex_get_number (s)
1876 const char *s;
1878 long ret;
1879 char *send;
1881 ret = strtol (s, &send, 10);
1882 if (*send != '\0')
1883 nlmheader_warn (_("bad number"), -1);
1884 return ret;
1887 /* Prefix the nlmconv warnings with a note as to where they come from.
1888 We don't use program_name on every warning, because then some
1889 versions of the emacs next-error function can't recognize the line
1890 number. */
1892 static void
1893 nlmheader_identify ()
1895 static int done;
1897 if (! done)
1899 fprintf (stderr, _("%s: problems in NLM command language input:\n"),
1900 program_name);
1901 done = 1;
1905 /* Issue a warning. */
1907 static void
1908 nlmheader_warn (s, imax)
1909 const char *s;
1910 int imax;
1912 nlmheader_identify ();
1913 fprintf (stderr, "%s:%d: %s", current.name, current.lineno, s);
1914 if (imax != -1)
1915 fprintf (stderr, " (max %d)", imax);
1916 fprintf (stderr, "\n");
1919 /* Report an error. */
1921 static void
1922 nlmheader_error (s)
1923 const char *s;
1925 nlmheader_warn (s, -1);
1926 ++parse_errors;
1929 /* Add a string to a string list. */
1931 static struct string_list *
1932 string_list_cons (s, l)
1933 char *s;
1934 struct string_list *l;
1936 struct string_list *ret;
1938 ret = (struct string_list *) xmalloc (sizeof (struct string_list));
1939 ret->next = l;
1940 ret->string = s;
1941 return ret;
1944 /* Append a string list to another string list. */
1946 static struct string_list *
1947 string_list_append (l1, l2)
1948 struct string_list *l1;
1949 struct string_list *l2;
1951 register struct string_list **pp;
1953 for (pp = &l1; *pp != NULL; pp = &(*pp)->next)
1955 *pp = l2;
1956 return l1;
1959 /* Append a string to a string list. */
1961 static struct string_list *
1962 string_list_append1 (l, s)
1963 struct string_list *l;
1964 char *s;
1966 struct string_list *n;
1967 register struct string_list **pp;
1969 n = (struct string_list *) xmalloc (sizeof (struct string_list));
1970 n->next = NULL;
1971 n->string = s;
1972 for (pp = &l; *pp != NULL; pp = &(*pp)->next)
1974 *pp = n;
1975 return l;
1978 /* Duplicate a string in memory. */
1980 static char *
1981 xstrdup (s)
1982 const char *s;
1984 unsigned long len;
1985 char *ret;
1987 len = strlen (s);
1988 ret = xmalloc (len + 1);
1989 strcpy (ret, s);
1990 return ret;