OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [binutils/] [nlmheader.c] - Blame information for rev 868

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* A Bison parser, made by GNU Bison 1.875c.  */
2
 
3
/* Skeleton parser for Yacc-like parsing with Bison,
4
   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 2, or (at your option)
9
   any later version.
10
 
11
   This program is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
 
16
   You should have received a copy of the GNU General Public License
17
   along with this program; if not, write to the Free Software
18
   Foundation, Inc., 59 Temple Place - Suite 330,
19
   Boston, MA 02111-1307, USA.  */
20
 
21
/* As a special exception, when this file is copied by Bison into a
22
   Bison output file, you may use that output file without restriction.
23
   This special exception was added by the Free Software Foundation
24
   in version 1.24 of Bison.  */
25
 
26
/* Written by Richard Stallman by simplifying the original so called
27
   ``semantic'' parser.  */
28
 
29
/* All symbols defined below should begin with yy or YY, to avoid
30
   infringing on user name space.  This should be done even for local
31
   variables, as they might otherwise be expanded by user macros.
32
   There are some unavoidable exceptions within include files to
33
   define necessary library symbols; they are noted "INFRINGES ON
34
   USER NAME SPACE" below.  */
35
 
36
/* Identify Bison output.  */
37
#define YYBISON 1
38
 
39
/* Skeleton name.  */
40
#define YYSKELETON_NAME "yacc.c"
41
 
42
/* Pure parsers.  */
43
#define YYPURE 0
44
 
45
/* Using locations.  */
46
#define YYLSP_NEEDED 0
47
 
48
 
49
 
50
/* Tokens.  */
51
#ifndef YYTOKENTYPE
52
# define YYTOKENTYPE
53
   /* Put the tokens into the symbol table, so that GDB and other debuggers
54
      know about them.  */
55
   enum yytokentype {
56
     CHECK = 258,
57
     CODESTART = 259,
58
     COPYRIGHT = 260,
59
     CUSTOM = 261,
60
     DATE = 262,
61
     DEBUG = 263,
62
     DESCRIPTION = 264,
63
     EXIT = 265,
64
     EXPORT = 266,
65
     FLAG_ON = 267,
66
     FLAG_OFF = 268,
67
     FULLMAP = 269,
68
     HELP = 270,
69
     IMPORT = 271,
70
     INPUT = 272,
71
     MAP = 273,
72
     MESSAGES = 274,
73
     MODULE = 275,
74
     MULTIPLE = 276,
75
     OS_DOMAIN = 277,
76
     OUTPUT = 278,
77
     PSEUDOPREEMPTION = 279,
78
     REENTRANT = 280,
79
     SCREENNAME = 281,
80
     SHARELIB = 282,
81
     STACK = 283,
82
     START = 284,
83
     SYNCHRONIZE = 285,
84
     THREADNAME = 286,
85
     TYPE = 287,
86
     VERBOSE = 288,
87
     VERSIONK = 289,
88
     XDCDATA = 290,
89
     STRING = 291,
90
     QUOTED_STRING = 292
91
   };
92
#endif
93
#define CHECK 258
94
#define CODESTART 259
95
#define COPYRIGHT 260
96
#define CUSTOM 261
97
#define DATE 262
98
#define DEBUG 263
99
#define DESCRIPTION 264
100
#define EXIT 265
101
#define EXPORT 266
102
#define FLAG_ON 267
103
#define FLAG_OFF 268
104
#define FULLMAP 269
105
#define HELP 270
106
#define IMPORT 271
107
#define INPUT 272
108
#define MAP 273
109
#define MESSAGES 274
110
#define MODULE 275
111
#define MULTIPLE 276
112
#define OS_DOMAIN 277
113
#define OUTPUT 278
114
#define PSEUDOPREEMPTION 279
115
#define REENTRANT 280
116
#define SCREENNAME 281
117
#define SHARELIB 282
118
#define STACK 283
119
#define START 284
120
#define SYNCHRONIZE 285
121
#define THREADNAME 286
122
#define TYPE 287
123
#define VERBOSE 288
124
#define VERSIONK 289
125
#define XDCDATA 290
126
#define STRING 291
127
#define QUOTED_STRING 292
128
 
129
 
130
 
131
 
132
/* Copy the first part of user declarations.  */
133
#line 1 "nlmheader.y"
134
/* nlmheader.y - parse NLM header specification keywords.
135
     Copyright 1993, 1994, 1995, 1997, 1998, 2001, 2002, 2003, 2007
136
     Free Software Foundation, Inc.
137
 
138
     This file is part of GNU Binutils.
139
 
140
     This program is free software; you can redistribute it and/or modify
141
     it under the terms of the GNU General Public License as published by
142
     the Free Software Foundation; either version 3 of the License, or
143
     (at your option) any later version.
144
 
145
     This program is distributed in the hope that it will be useful,
146
     but WITHOUT ANY WARRANTY; without even the implied warranty of
147
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
148
     GNU General Public License for more details.
149
 
150
     You should have received a copy of the GNU General Public License
151
     along with this program; if not, write to the Free Software
152
     Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
153
     MA 02110-1301, USA.  */
154
 
155
/* Written by Ian Lance Taylor <ian@cygnus.com>.
156
 
157
   This bison file parses the commands recognized by the NetWare NLM
158
   linker, except for lists of object files.  It stores the
159
   information in global variables.
160
 
161
   This implementation is based on the description in the NetWare Tool
162
   Maker Specification manual, edition 1.0.  */
163
 
164
#include "sysdep.h"
165
#include "safe-ctype.h"
166
#include "bfd.h"
167
#include "nlm/common.h"
168
#include "nlm/internal.h"
169
#include "bucomm.h"
170
#include "nlmconv.h"
171
 
172
/* Information is stored in the structures pointed to by these
173
   variables.  */
174
 
175
Nlm_Internal_Fixed_Header *fixed_hdr;
176
Nlm_Internal_Variable_Header *var_hdr;
177
Nlm_Internal_Version_Header *version_hdr;
178
Nlm_Internal_Copyright_Header *copyright_hdr;
179
Nlm_Internal_Extended_Header *extended_hdr;
180
 
181
/* Procedure named by CHECK.  */
182
char *check_procedure;
183
/* File named by CUSTOM.  */
184
char *custom_file;
185
/* Whether to generate debugging information (DEBUG).  */
186
bfd_boolean debug_info;
187
/* Procedure named by EXIT.  */
188
char *exit_procedure;
189
/* Exported symbols (EXPORT).  */
190
struct string_list *export_symbols;
191
/* List of files from INPUT.  */
192
struct string_list *input_files;
193
/* Map file name (MAP, FULLMAP).  */
194
char *map_file;
195
/* Whether a full map has been requested (FULLMAP).  */
196
bfd_boolean full_map;
197
/* File named by HELP.  */
198
char *help_file;
199
/* Imported symbols (IMPORT).  */
200
struct string_list *import_symbols;
201
/* File named by MESSAGES.  */
202
char *message_file;
203
/* Autoload module list (MODULE).  */
204
struct string_list *modules;
205
/* File named by OUTPUT.  */
206
char *output_file;
207
/* File named by SHARELIB.  */
208
char *sharelib_file;
209
/* Start procedure name (START).  */
210
char *start_procedure;
211
/* VERBOSE.  */
212
bfd_boolean verbose;
213
/* RPC description file (XDCDATA).  */
214
char *rpc_file;
215
 
216
/* The number of serious errors that have occurred.  */
217
int parse_errors;
218
 
219
/* The current symbol prefix when reading a list of import or export
220
   symbols.  */
221
static char *symbol_prefix;
222
 
223
/* Parser error message handler.  */
224
#define yyerror(msg) nlmheader_error (msg);
225
 
226
/* Local functions.  */
227
static int yylex (void);
228
static void nlmlex_file_push (const char *);
229
static bfd_boolean nlmlex_file_open (const char *);
230
static int nlmlex_buf_init (void);
231
static char nlmlex_buf_add (int);
232
static long nlmlex_get_number (const char *);
233
static void nlmheader_identify (void);
234
static void nlmheader_warn (const char *, int);
235
static void nlmheader_error (const char *);
236
static struct string_list * string_list_cons (char *, struct string_list *);
237
static struct string_list * string_list_append (struct string_list *,
238
                                                struct string_list *);
239
static struct string_list * string_list_append1 (struct string_list *,
240
                                                 char *);
241
static char *xstrdup (const char *);
242
 
243
 
244
 
245
/* Enabling traces.  */
246
#ifndef YYDEBUG
247
# define YYDEBUG 0
248
#endif
249
 
250
/* Enabling verbose error messages.  */
251
#ifdef YYERROR_VERBOSE
252
# undef YYERROR_VERBOSE
253
# define YYERROR_VERBOSE 1
254
#else
255
# define YYERROR_VERBOSE 0
256
#endif
257
 
258
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
259
#line 113 "nlmheader.y"
260
typedef union YYSTYPE {
261
  char *string;
262
  struct string_list *list;
263
} YYSTYPE;
264
/* Line 191 of yacc.c.  */
265
#line 266 "nlmheader.c"
266
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
267
# define YYSTYPE_IS_DECLARED 1
268
# define YYSTYPE_IS_TRIVIAL 1
269
#endif
270
 
271
 
272
 
273
/* Copy the second part of user declarations.  */
274
 
275
 
276
/* Line 214 of yacc.c.  */
277
#line 278 "nlmheader.c"
278
 
279
#if ! defined (yyoverflow) || YYERROR_VERBOSE
280
 
281
# ifndef YYFREE
282
#  define YYFREE free
283
# endif
284
# ifndef YYMALLOC
285
#  define YYMALLOC malloc
286
# endif
287
 
288
/* The parser invokes alloca or malloc; define the necessary symbols.  */
289
 
290
# ifdef YYSTACK_USE_ALLOCA
291
#  if YYSTACK_USE_ALLOCA
292
#   define YYSTACK_ALLOC alloca
293
#  endif
294
# else
295
#  if defined (alloca) || defined (_ALLOCA_H)
296
#   define YYSTACK_ALLOC alloca
297
#  else
298
#   ifdef __GNUC__
299
#    define YYSTACK_ALLOC __builtin_alloca
300
#   endif
301
#  endif
302
# endif
303
 
304
# ifdef YYSTACK_ALLOC
305
   /* Pacify GCC's `empty if-body' warning. */
306
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
307
# else
308
#  if defined (__STDC__) || defined (__cplusplus)
309
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
310
#   define YYSIZE_T size_t
311
#  endif
312
#  define YYSTACK_ALLOC YYMALLOC
313
#  define YYSTACK_FREE YYFREE
314
# endif
315
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
316
 
317
 
318
#if (! defined (yyoverflow) \
319
     && (! defined (__cplusplus) \
320
         || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
321
 
322
/* A type that is properly aligned for any stack member.  */
323
union yyalloc
324
{
325
  short yyss;
326
  YYSTYPE yyvs;
327
  };
328
 
329
/* The size of the maximum gap between one aligned stack and the next.  */
330
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
331
 
332
/* The size of an array large to enough to hold all stacks, each with
333
   N elements.  */
334
# define YYSTACK_BYTES(N) \
335
     ((N) * (sizeof (short) + sizeof (YYSTYPE))                         \
336
      + YYSTACK_GAP_MAXIMUM)
337
 
338
/* Copy COUNT objects from FROM to TO.  The source and destination do
339
   not overlap.  */
340
# ifndef YYCOPY
341
#  if defined (__GNUC__) && 1 < __GNUC__
342
#   define YYCOPY(To, From, Count) \
343
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
344
#  else
345
#   define YYCOPY(To, From, Count)              \
346
      do                                        \
347
        {                                       \
348
          register YYSIZE_T yyi;                \
349
          for (yyi = 0; yyi < (Count); yyi++)    \
350
            (To)[yyi] = (From)[yyi];            \
351
        }                                       \
352
      while (0)
353
#  endif
354
# endif
355
 
356
/* Relocate STACK from its old location to the new one.  The
357
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
358
   elements in the stack, and YYPTR gives the new location of the
359
   stack.  Advance YYPTR to a properly aligned location for the next
360
   stack.  */
361
# define YYSTACK_RELOCATE(Stack)                                        \
362
    do                                                                  \
363
      {                                                                 \
364
        YYSIZE_T yynewbytes;                                            \
365
        YYCOPY (&yyptr->Stack, Stack, yysize);                          \
366
        Stack = &yyptr->Stack;                                          \
367
        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
368
        yyptr += yynewbytes / sizeof (*yyptr);                          \
369
      }                                                                 \
370
    while (0)
371
 
372
#endif
373
 
374
#if defined (__STDC__) || defined (__cplusplus)
375
   typedef signed char yysigned_char;
376
#else
377
   typedef short yysigned_char;
378
#endif
379
 
380
/* YYFINAL -- State number of the termination state. */
381
#define YYFINAL  64
382
/* YYLAST -- Last index in YYTABLE.  */
383
#define YYLAST   73
384
 
385
/* YYNTOKENS -- Number of terminals. */
386
#define YYNTOKENS  40
387
/* YYNNTS -- Number of nonterminals. */
388
#define YYNNTS  11
389
/* YYNRULES -- Number of rules. */
390
#define YYNRULES  52
391
/* YYNRULES -- Number of states. */
392
#define YYNSTATES  82
393
 
394
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
395
#define YYUNDEFTOK  2
396
#define YYMAXUTOK   292
397
 
398
#define YYTRANSLATE(YYX)                                                \
399
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
400
 
401
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
402
static const unsigned char yytranslate[] =
403
{
404
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
405
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
406
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
407
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
408
      38,    39,     2,     2,     2,     2,     2,     2,     2,     2,
409
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
410
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
411
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
412
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
413
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
414
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
415
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
416
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
417
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
418
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
419
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
420
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
421
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
422
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
423
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
424
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
425
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
426
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
427
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
428
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
429
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
430
       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
431
      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
432
      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
433
      35,    36,    37
434
};
435
 
436
#if YYDEBUG
437
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
438
   YYRHS.  */
439
static const unsigned char yyprhs[] =
440
{
441
       0,     0,     3,     5,     6,     9,    12,    15,    18,    21,
442
      26,    28,    31,    34,    35,    39,    42,    45,    47,    50,
443
      53,    54,    58,    61,    63,    66,    69,    72,    74,    76,
444
      79,    81,    83,    86,    89,    92,    95,    97,   100,   103,
445
     105,   110,   114,   117,   118,   120,   122,   124,   127,   130,
446
     134,   136,   137
447
};
448
 
449
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
450
static const yysigned_char yyrhs[] =
451
{
452
      41,     0,    -1,    42,    -1,    -1,    43,    42,    -1,     3,
453
      36,    -1,     4,    36,    -1,     5,    37,    -1,     6,    36,
454
      -1,     7,    36,    36,    36,    -1,     8,    -1,     9,    37,
455
      -1,    10,    36,    -1,    -1,    11,    44,    46,    -1,    12,
456
      36,    -1,    13,    36,    -1,    14,    -1,    14,    36,    -1,
457
      15,    36,    -1,    -1,    16,    45,    46,    -1,    17,    50,
458
      -1,    18,    -1,    18,    36,    -1,    19,    36,    -1,    20,
459
      50,    -1,    21,    -1,    22,    -1,    23,    36,    -1,    24,
460
      -1,    25,    -1,    26,    37,    -1,    27,    36,    -1,    28,
461
      36,    -1,    29,    36,    -1,    30,    -1,    31,    37,    -1,
462
      32,    36,    -1,    33,    -1,    34,    36,    36,    36,    -1,
463
      34,    36,    36,    -1,    35,    36,    -1,    -1,    47,    -1,
464
      49,    -1,    48,    -1,    47,    49,    -1,    47,    48,    -1,
465
      38,    36,    39,    -1,    36,    -1,    -1,    36,    50,    -1
466
};
467
 
468
/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
469
static const unsigned short yyrline[] =
470
{
471
       0,   144,   144,   149,   151,   157,   161,   166,   183,   187,
472
     205,   209,   225,   230,   229,   237,   242,   247,   252,   257,
473
     262,   261,   269,   273,   277,   281,   285,   289,   293,   297,
474
     304,   308,   312,   328,   332,   337,   341,   345,   361,   366,
475
     370,   394,   410,   420,   423,   434,   438,   442,   446,   455,
476
     466,   483,   486
477
};
478
#endif
479
 
480
#if YYDEBUG || YYERROR_VERBOSE
481
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
482
   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
483
static const char *const yytname[] =
484
{
485
  "$end", "error", "$undefined", "CHECK", "CODESTART", "COPYRIGHT",
486
  "CUSTOM", "DATE", "DEBUG", "DESCRIPTION", "EXIT", "EXPORT", "FLAG_ON",
487
  "FLAG_OFF", "FULLMAP", "HELP", "IMPORT", "INPUT", "MAP", "MESSAGES",
488
  "MODULE", "MULTIPLE", "OS_DOMAIN", "OUTPUT", "PSEUDOPREEMPTION",
489
  "REENTRANT", "SCREENNAME", "SHARELIB", "STACK", "START", "SYNCHRONIZE",
490
  "THREADNAME", "TYPE", "VERBOSE", "VERSIONK", "XDCDATA", "STRING",
491
  "QUOTED_STRING", "'('", "')'", "$accept", "file", "commands", "command",
492
  "@1", "@2", "symbol_list_opt", "symbol_list", "symbol_prefix", "symbol",
493
  "string_list", 0
494
};
495
#endif
496
 
497
# ifdef YYPRINT
498
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
499
   token YYLEX-NUM.  */
500
static const unsigned short yytoknum[] =
501
{
502
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
503
     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
504
     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
505
     285,   286,   287,   288,   289,   290,   291,   292,    40,    41
506
};
507
# endif
508
 
509
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
510
static const unsigned char yyr1[] =
511
{
512
       0,    40,    41,    42,    42,    43,    43,    43,    43,    43,
513
      43,    43,    43,    44,    43,    43,    43,    43,    43,    43,
514
      45,    43,    43,    43,    43,    43,    43,    43,    43,    43,
515
      43,    43,    43,    43,    43,    43,    43,    43,    43,    43,
516
      43,    43,    43,    46,    46,    47,    47,    47,    47,    48,
517
      49,    50,    50
518
};
519
 
520
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
521
static const unsigned char yyr2[] =
522
{
523
       0,     2,     1,     0,     2,     2,     2,     2,     2,     4,
524
       1,     2,     2,     0,     3,     2,     2,     1,     2,     2,
525
       0,     3,     2,     1,     2,     2,     2,     1,     1,     2,
526
       1,     1,     2,     2,     2,     2,     1,     2,     2,     1,
527
       4,     3,     2,     0,     1,     1,     1,     2,     2,     3,
528
       1,     0,     2
529
};
530
 
531
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
532
   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
533
   means the default is an error.  */
534
static const unsigned char yydefact[] =
535
{
536
       3,     0,     0,     0,     0,     0,    10,     0,     0,    13,
537
       0,     0,    17,     0,    20,    51,    23,     0,    51,    27,
538
      28,     0,    30,    31,     0,     0,     0,     0,    36,     0,
539
       0,    39,     0,     0,     0,     2,     3,     5,     6,     7,
540
       8,     0,    11,    12,    43,    15,    16,    18,    19,    43,
541
      51,    22,    24,    25,    26,    29,    32,    33,    34,    35,
542
      37,    38,     0,    42,     1,     4,     0,    50,     0,    14,
543
      44,    46,    45,    21,    52,    41,     9,     0,    48,    47,
544
      40,    49
545
};
546
 
547
/* YYDEFGOTO[NTERM-NUM]. */
548
static const yysigned_char yydefgoto[] =
549
{
550
      -1,    34,    35,    36,    44,    49,    69,    70,    71,    72,
551
      51
552
};
553
 
554
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
555
   STATE-NUM.  */
556
#define YYPACT_NINF -20
557
static const yysigned_char yypact[] =
558
{
559
      -3,    -1,     1,     2,     4,     5,   -20,     6,     8,   -20,
560
       9,    10,    11,    12,   -20,    13,    14,    16,    13,   -20,
561
     -20,    17,   -20,   -20,    18,    20,    21,    22,   -20,    23,
562
      25,   -20,    26,    27,    38,   -20,    -3,   -20,   -20,   -20,
563
     -20,    28,   -20,   -20,    -2,   -20,   -20,   -20,   -20,    -2,
564
      13,   -20,   -20,   -20,   -20,   -20,   -20,   -20,   -20,   -20,
565
     -20,   -20,    30,   -20,   -20,   -20,    31,   -20,    32,   -20,
566
      -2,   -20,   -20,   -20,   -20,    33,   -20,     3,   -20,   -20,
567
     -20,   -20
568
};
569
 
570
/* YYPGOTO[NTERM-NUM].  */
571
static const yysigned_char yypgoto[] =
572
{
573
     -20,   -20,    34,   -20,   -20,   -20,    24,   -20,   -19,   -16,
574
      15
575
};
576
 
577
/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
578
   positive, shift that token.  If negative, reduce the rule which
579
   number is the opposite.  If zero, do what YYDEFACT says.
580
   If YYTABLE_NINF, syntax error.  */
581
#define YYTABLE_NINF -1
582
static const unsigned char yytable[] =
583
{
584
       1,     2,     3,     4,     5,     6,     7,     8,     9,    10,
585
      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
586
      21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
587
      31,    32,    33,    54,    67,    37,    68,    38,    64,    39,
588
      40,    41,    81,    42,    43,    45,    46,    47,    48,    50,
589
      52,    78,    53,    55,    79,    56,    57,    58,    59,     0,
590
      60,    61,    62,    63,    66,    74,    75,    76,    77,    80,
591
      65,     0,     0,    73
592
};
593
 
594
static const yysigned_char yycheck[] =
595
{
596
       3,     4,     5,     6,     7,     8,     9,    10,    11,    12,
597
      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
598
      23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
599
      33,    34,    35,    18,    36,    36,    38,    36,     0,    37,
600
      36,    36,    39,    37,    36,    36,    36,    36,    36,    36,
601
      36,    70,    36,    36,    70,    37,    36,    36,    36,    -1,
602
      37,    36,    36,    36,    36,    50,    36,    36,    36,    36,
603
      36,    -1,    -1,    49
604
};
605
 
606
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
607
   symbol of state STATE-NUM.  */
608
static const unsigned char yystos[] =
609
{
610
       0,     3,     4,     5,     6,     7,     8,     9,    10,    11,
611
      12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
612
      22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
613
      32,    33,    34,    35,    41,    42,    43,    36,    36,    37,
614
      36,    36,    37,    36,    44,    36,    36,    36,    36,    45,
615
      36,    50,    36,    36,    50,    36,    37,    36,    36,    36,
616
      37,    36,    36,    36,     0,    42,    36,    36,    38,    46,
617
      47,    48,    49,    46,    50,    36,    36,    36,    48,    49,
618
      36,    39
619
};
620
 
621
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
622
# define YYSIZE_T __SIZE_TYPE__
623
#endif
624
#if ! defined (YYSIZE_T) && defined (size_t)
625
# define YYSIZE_T size_t
626
#endif
627
#if ! defined (YYSIZE_T)
628
# if defined (__STDC__) || defined (__cplusplus)
629
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
630
#  define YYSIZE_T size_t
631
# endif
632
#endif
633
#if ! defined (YYSIZE_T)
634
# define YYSIZE_T unsigned int
635
#endif
636
 
637
#define yyerrok         (yyerrstatus = 0)
638
#define yyclearin       (yychar = YYEMPTY)
639
#define YYEMPTY         (-2)
640
#define YYEOF           0
641
 
642
#define YYACCEPT        goto yyacceptlab
643
#define YYABORT         goto yyabortlab
644
#define YYERROR         goto yyerrorlab
645
 
646
 
647
/* Like YYERROR except do call yyerror.  This remains here temporarily
648
   to ease the transition to the new meaning of YYERROR, for GCC.
649
   Once GCC version 2 has supplanted version 1, this can go.  */
650
 
651
#define YYFAIL          goto yyerrlab
652
 
653
#define YYRECOVERING()  (!!yyerrstatus)
654
 
655
#define YYBACKUP(Token, Value)                                  \
656
do                                                              \
657
  if (yychar == YYEMPTY && yylen == 1)                          \
658
    {                                                           \
659
      yychar = (Token);                                         \
660
      yylval = (Value);                                         \
661
      yytoken = YYTRANSLATE (yychar);                           \
662
      YYPOPSTACK;                                               \
663
      goto yybackup;                                            \
664
    }                                                           \
665
  else                                                          \
666
    {                                                           \
667
      yyerror ("syntax error: cannot back up");\
668
      YYERROR;                                                  \
669
    }                                                           \
670
while (0)
671
 
672
#define YYTERROR        1
673
#define YYERRCODE       256
674
 
675
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
676
   are run).  */
677
 
678
#ifndef YYLLOC_DEFAULT
679
# define YYLLOC_DEFAULT(Current, Rhs, N)                \
680
   ((Current).first_line   = (Rhs)[1].first_line,       \
681
    (Current).first_column = (Rhs)[1].first_column,     \
682
    (Current).last_line    = (Rhs)[N].last_line,        \
683
    (Current).last_column  = (Rhs)[N].last_column)
684
#endif
685
 
686
/* YYLEX -- calling `yylex' with the right arguments.  */
687
 
688
#ifdef YYLEX_PARAM
689
# define YYLEX yylex (YYLEX_PARAM)
690
#else
691
# define YYLEX yylex ()
692
#endif
693
 
694
/* Enable debugging if requested.  */
695
#if YYDEBUG
696
 
697
# ifndef YYFPRINTF
698
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
699
#  define YYFPRINTF fprintf
700
# endif
701
 
702
# define YYDPRINTF(Args)                        \
703
do {                                            \
704
  if (yydebug)                                  \
705
    YYFPRINTF Args;                             \
706
} while (0)
707
 
708
# define YYDSYMPRINT(Args)                      \
709
do {                                            \
710
  if (yydebug)                                  \
711
    yysymprint Args;                            \
712
} while (0)
713
 
714
# define YYDSYMPRINTF(Title, Token, Value, Location)            \
715
do {                                                            \
716
  if (yydebug)                                                  \
717
    {                                                           \
718
      YYFPRINTF (stderr, "%s ", Title);                         \
719
      yysymprint (stderr,                                       \
720
                  Token, Value);        \
721
      YYFPRINTF (stderr, "\n");                                 \
722
    }                                                           \
723
} while (0)
724
 
725
/*------------------------------------------------------------------.
726
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
727
| TOP (included).                                                   |
728
`------------------------------------------------------------------*/
729
 
730
#if defined (__STDC__) || defined (__cplusplus)
731
static void
732
yy_stack_print (short *bottom, short *top)
733
#else
734
static void
735
yy_stack_print (bottom, top)
736
    short *bottom;
737
    short *top;
738
#endif
739
{
740
  YYFPRINTF (stderr, "Stack now");
741
  for (/* Nothing. */; bottom <= top; ++bottom)
742
    YYFPRINTF (stderr, " %d", *bottom);
743
  YYFPRINTF (stderr, "\n");
744
}
745
 
746
# define YY_STACK_PRINT(Bottom, Top)                            \
747
do {                                                            \
748
  if (yydebug)                                                  \
749
    yy_stack_print ((Bottom), (Top));                           \
750
} while (0)
751
 
752
 
753
/*------------------------------------------------.
754
| Report that the YYRULE is going to be reduced.  |
755
`------------------------------------------------*/
756
 
757
#if defined (__STDC__) || defined (__cplusplus)
758
static void
759
yy_reduce_print (int yyrule)
760
#else
761
static void
762
yy_reduce_print (yyrule)
763
    int yyrule;
764
#endif
765
{
766
  int yyi;
767
  unsigned int yylno = yyrline[yyrule];
768
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
769
             yyrule - 1, yylno);
770
  /* Print the symbols being reduced, and their result.  */
771
  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
772
    YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
773
  YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
774
}
775
 
776
# define YY_REDUCE_PRINT(Rule)          \
777
do {                                    \
778
  if (yydebug)                          \
779
    yy_reduce_print (Rule);             \
780
} while (0)
781
 
782
/* Nonzero means print parse trace.  It is left uninitialized so that
783
   multiple parsers can coexist.  */
784
int yydebug;
785
#else /* !YYDEBUG */
786
# define YYDPRINTF(Args)
787
# define YYDSYMPRINT(Args)
788
# define YYDSYMPRINTF(Title, Token, Value, Location)
789
# define YY_STACK_PRINT(Bottom, Top)
790
# define YY_REDUCE_PRINT(Rule)
791
#endif /* !YYDEBUG */
792
 
793
 
794
/* YYINITDEPTH -- initial size of the parser's stacks.  */
795
#ifndef YYINITDEPTH
796
# define YYINITDEPTH 200
797
#endif
798
 
799
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
800
   if the built-in stack extension method is used).
801
 
802
   Do not make this value too large; the results are undefined if
803
   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
804
   evaluated with infinite-precision integer arithmetic.  */
805
 
806
#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
807
# undef YYMAXDEPTH
808
#endif
809
 
810
#ifndef YYMAXDEPTH
811
# define YYMAXDEPTH 10000
812
#endif
813
 
814
 
815
 
816
#if YYERROR_VERBOSE
817
 
818
# ifndef yystrlen
819
#  if defined (__GLIBC__) && defined (_STRING_H)
820
#   define yystrlen strlen
821
#  else
822
/* Return the length of YYSTR.  */
823
static YYSIZE_T
824
#   if defined (__STDC__) || defined (__cplusplus)
825
yystrlen (const char *yystr)
826
#   else
827
yystrlen (yystr)
828
     const char *yystr;
829
#   endif
830
{
831
  register const char *yys = yystr;
832
 
833
  while (*yys++ != '\0')
834
    continue;
835
 
836
  return yys - yystr - 1;
837
}
838
#  endif
839
# endif
840
 
841
# ifndef yystpcpy
842
#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
843
#   define yystpcpy stpcpy
844
#  else
845
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
846
   YYDEST.  */
847
static char *
848
#   if defined (__STDC__) || defined (__cplusplus)
849
yystpcpy (char *yydest, const char *yysrc)
850
#   else
851
yystpcpy (yydest, yysrc)
852
     char *yydest;
853
     const char *yysrc;
854
#   endif
855
{
856
  register char *yyd = yydest;
857
  register const char *yys = yysrc;
858
 
859
  while ((*yyd++ = *yys++) != '\0')
860
    continue;
861
 
862
  return yyd - 1;
863
}
864
#  endif
865
# endif
866
 
867
#endif /* !YYERROR_VERBOSE */
868
 
869
 
870
 
871
#if YYDEBUG
872
/*--------------------------------.
873
| Print this symbol on YYOUTPUT.  |
874
`--------------------------------*/
875
 
876
#if defined (__STDC__) || defined (__cplusplus)
877
static void
878
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
879
#else
880
static void
881
yysymprint (yyoutput, yytype, yyvaluep)
882
    FILE *yyoutput;
883
    int yytype;
884
    YYSTYPE *yyvaluep;
885
#endif
886
{
887
  /* Pacify ``unused variable'' warnings.  */
888
  (void) yyvaluep;
889
 
890
  if (yytype < YYNTOKENS)
891
    {
892
      YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
893
# ifdef YYPRINT
894
      YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
895
# endif
896
    }
897
  else
898
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
899
 
900
  switch (yytype)
901
    {
902
      default:
903
        break;
904
    }
905
  YYFPRINTF (yyoutput, ")");
906
}
907
 
908
#endif /* ! YYDEBUG */
909
/*-----------------------------------------------.
910
| Release the memory associated to this symbol.  |
911
`-----------------------------------------------*/
912
 
913
#if defined (__STDC__) || defined (__cplusplus)
914
static void
915
yydestruct (int yytype, YYSTYPE *yyvaluep)
916
#else
917
static void
918
yydestruct (yytype, yyvaluep)
919
    int yytype;
920
    YYSTYPE *yyvaluep;
921
#endif
922
{
923
  /* Pacify ``unused variable'' warnings.  */
924
  (void) yyvaluep;
925
 
926
  switch (yytype)
927
    {
928
 
929
      default:
930
        break;
931
    }
932
}
933
 
934
 
935
/* Prevent warnings from -Wmissing-prototypes.  */
936
 
937
#ifdef YYPARSE_PARAM
938
# if defined (__STDC__) || defined (__cplusplus)
939
int yyparse (void *YYPARSE_PARAM);
940
# else
941
int yyparse ();
942
# endif
943
#else /* ! YYPARSE_PARAM */
944
#if defined (__STDC__) || defined (__cplusplus)
945
int yyparse (void);
946
#else
947
int yyparse ();
948
#endif
949
#endif /* ! YYPARSE_PARAM */
950
 
951
 
952
 
953
/* The lookahead symbol.  */
954
int yychar;
955
 
956
/* The semantic value of the lookahead symbol.  */
957
YYSTYPE yylval;
958
 
959
/* Number of syntax errors so far.  */
960
int yynerrs;
961
 
962
 
963
 
964
/*----------.
965
| yyparse.  |
966
`----------*/
967
 
968
#ifdef YYPARSE_PARAM
969
# if defined (__STDC__) || defined (__cplusplus)
970
int yyparse (void *YYPARSE_PARAM)
971
# else
972
int yyparse (YYPARSE_PARAM)
973
  void *YYPARSE_PARAM;
974
# endif
975
#else /* ! YYPARSE_PARAM */
976
#if defined (__STDC__) || defined (__cplusplus)
977
int
978
yyparse (void)
979
#else
980
int
981
yyparse ()
982
 
983
#endif
984
#endif
985
{
986
 
987
  register int yystate;
988
  register int yyn;
989
  int yyresult;
990
  /* Number of tokens to shift before error messages enabled.  */
991
  int yyerrstatus;
992
  /* Lookahead token as an internal (translated) token number.  */
993
  int yytoken = 0;
994
 
995
  /* Three stacks and their tools:
996
     `yyss': related to states,
997
     `yyvs': related to semantic values,
998
     `yyls': related to locations.
999
 
1000
     Refer to the stacks thru separate pointers, to allow yyoverflow
1001
     to reallocate them elsewhere.  */
1002
 
1003
  /* The state stack.  */
1004
  short yyssa[YYINITDEPTH];
1005
  short *yyss = yyssa;
1006
  register short *yyssp;
1007
 
1008
  /* The semantic value stack.  */
1009
  YYSTYPE yyvsa[YYINITDEPTH];
1010
  YYSTYPE *yyvs = yyvsa;
1011
  register YYSTYPE *yyvsp;
1012
 
1013
 
1014
 
1015
#define YYPOPSTACK   (yyvsp--, yyssp--)
1016
 
1017
  YYSIZE_T yystacksize = YYINITDEPTH;
1018
 
1019
  /* The variables used to return semantic value and location from the
1020
     action routines.  */
1021
  YYSTYPE yyval;
1022
 
1023
 
1024
  /* When reducing, the number of symbols on the RHS of the reduced
1025
     rule.  */
1026
  int yylen;
1027
 
1028
  YYDPRINTF ((stderr, "Starting parse\n"));
1029
 
1030
  yystate = 0;
1031
  yyerrstatus = 0;
1032
  yynerrs = 0;
1033
  yychar = YYEMPTY;             /* Cause a token to be read.  */
1034
 
1035
  /* Initialize stack pointers.
1036
     Waste one element of value and location stack
1037
     so that they stay on the same level as the state stack.
1038
     The wasted elements are never initialized.  */
1039
 
1040
  yyssp = yyss;
1041
  yyvsp = yyvs;
1042
 
1043
  goto yysetstate;
1044
 
1045
/*------------------------------------------------------------.
1046
| yynewstate -- Push a new state, which is found in yystate.  |
1047
`------------------------------------------------------------*/
1048
 yynewstate:
1049
  /* In all cases, when you get here, the value and location stacks
1050
     have just been pushed. so pushing a state here evens the stacks.
1051
     */
1052
  yyssp++;
1053
 
1054
 yysetstate:
1055
  *yyssp = yystate;
1056
 
1057
  if (yyss + yystacksize - 1 <= yyssp)
1058
    {
1059
      /* Get the current used size of the three stacks, in elements.  */
1060
      YYSIZE_T yysize = yyssp - yyss + 1;
1061
 
1062
#ifdef yyoverflow
1063
      {
1064
        /* Give user a chance to reallocate the stack. Use copies of
1065
           these so that the &'s don't force the real ones into
1066
           memory.  */
1067
        YYSTYPE *yyvs1 = yyvs;
1068
        short *yyss1 = yyss;
1069
 
1070
 
1071
        /* Each stack pointer address is followed by the size of the
1072
           data in use in that stack, in bytes.  This used to be a
1073
           conditional around just the two extra args, but that might
1074
           be undefined if yyoverflow is a macro.  */
1075
        yyoverflow ("parser stack overflow",
1076
                    &yyss1, yysize * sizeof (*yyssp),
1077
                    &yyvs1, yysize * sizeof (*yyvsp),
1078
 
1079
                    &yystacksize);
1080
 
1081
        yyss = yyss1;
1082
        yyvs = yyvs1;
1083
      }
1084
#else /* no yyoverflow */
1085
# ifndef YYSTACK_RELOCATE
1086
      goto yyoverflowlab;
1087
# else
1088
      /* Extend the stack our own way.  */
1089
      if (YYMAXDEPTH <= yystacksize)
1090
        goto yyoverflowlab;
1091
      yystacksize *= 2;
1092
      if (YYMAXDEPTH < yystacksize)
1093
        yystacksize = YYMAXDEPTH;
1094
 
1095
      {
1096
        short *yyss1 = yyss;
1097
        union yyalloc *yyptr =
1098
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1099
        if (! yyptr)
1100
          goto yyoverflowlab;
1101
        YYSTACK_RELOCATE (yyss);
1102
        YYSTACK_RELOCATE (yyvs);
1103
 
1104
#  undef YYSTACK_RELOCATE
1105
        if (yyss1 != yyssa)
1106
          YYSTACK_FREE (yyss1);
1107
      }
1108
# endif
1109
#endif /* no yyoverflow */
1110
 
1111
      yyssp = yyss + yysize - 1;
1112
      yyvsp = yyvs + yysize - 1;
1113
 
1114
 
1115
      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1116
                  (unsigned long int) yystacksize));
1117
 
1118
      if (yyss + yystacksize - 1 <= yyssp)
1119
        YYABORT;
1120
    }
1121
 
1122
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1123
 
1124
  goto yybackup;
1125
 
1126
/*-----------.
1127
| yybackup.  |
1128
`-----------*/
1129
yybackup:
1130
 
1131
/* Do appropriate processing given the current state.  */
1132
/* Read a lookahead token if we need one and don't already have one.  */
1133
/* yyresume: */
1134
 
1135
  /* First try to decide what to do without reference to lookahead token.  */
1136
 
1137
  yyn = yypact[yystate];
1138
  if (yyn == YYPACT_NINF)
1139
    goto yydefault;
1140
 
1141
  /* Not known => get a lookahead token if don't already have one.  */
1142
 
1143
  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1144
  if (yychar == YYEMPTY)
1145
    {
1146
      YYDPRINTF ((stderr, "Reading a token: "));
1147
      yychar = YYLEX;
1148
    }
1149
 
1150
  if (yychar <= YYEOF)
1151
    {
1152
      yychar = yytoken = YYEOF;
1153
      YYDPRINTF ((stderr, "Now at end of input.\n"));
1154
    }
1155
  else
1156
    {
1157
      yytoken = YYTRANSLATE (yychar);
1158
      YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1159
    }
1160
 
1161
  /* If the proper action on seeing token YYTOKEN is to reduce or to
1162
     detect an error, take that action.  */
1163
  yyn += yytoken;
1164
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1165
    goto yydefault;
1166
  yyn = yytable[yyn];
1167
  if (yyn <= 0)
1168
    {
1169
      if (yyn == 0 || yyn == YYTABLE_NINF)
1170
        goto yyerrlab;
1171
      yyn = -yyn;
1172
      goto yyreduce;
1173
    }
1174
 
1175
  if (yyn == YYFINAL)
1176
    YYACCEPT;
1177
 
1178
  /* Shift the lookahead token.  */
1179
  YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1180
 
1181
  /* Discard the token being shifted unless it is eof.  */
1182
  if (yychar != YYEOF)
1183
    yychar = YYEMPTY;
1184
 
1185
  *++yyvsp = yylval;
1186
 
1187
 
1188
  /* Count tokens shifted since error; after three, turn off error
1189
     status.  */
1190
  if (yyerrstatus)
1191
    yyerrstatus--;
1192
 
1193
  yystate = yyn;
1194
  goto yynewstate;
1195
 
1196
 
1197
/*-----------------------------------------------------------.
1198
| yydefault -- do the default action for the current state.  |
1199
`-----------------------------------------------------------*/
1200
yydefault:
1201
  yyn = yydefact[yystate];
1202
  if (yyn == 0)
1203
    goto yyerrlab;
1204
  goto yyreduce;
1205
 
1206
 
1207
/*-----------------------------.
1208
| yyreduce -- Do a reduction.  |
1209
`-----------------------------*/
1210
yyreduce:
1211
  /* yyn is the number of a rule to reduce with.  */
1212
  yylen = yyr2[yyn];
1213
 
1214
  /* If YYLEN is nonzero, implement the default value of the action:
1215
     `$$ = $1'.
1216
 
1217
     Otherwise, the following line sets YYVAL to garbage.
1218
     This behavior is undocumented and Bison
1219
     users should not rely upon it.  Assigning to YYVAL
1220
     unconditionally makes the parser a bit smaller, and it avoids a
1221
     GCC warning that YYVAL may be used uninitialized.  */
1222
  yyval = yyvsp[1-yylen];
1223
 
1224
 
1225
  YY_REDUCE_PRINT (yyn);
1226
  switch (yyn)
1227
    {
1228
        case 5:
1229
#line 158 "nlmheader.y"
1230
    {
1231
            check_procedure = yyvsp[0].string;
1232
          }
1233
    break;
1234
 
1235
  case 6:
1236
#line 162 "nlmheader.y"
1237
    {
1238
            nlmheader_warn (_("CODESTART is not implemented; sorry"), -1);
1239
            free (yyvsp[0].string);
1240
          }
1241
    break;
1242
 
1243
  case 7:
1244
#line 167 "nlmheader.y"
1245
    {
1246
            int len;
1247
 
1248
            strncpy (copyright_hdr->stamp, "CoPyRiGhT=", 10);
1249
            len = strlen (yyvsp[0].string);
1250
            if (len >= NLM_MAX_COPYRIGHT_MESSAGE_LENGTH)
1251
              {
1252
                nlmheader_warn (_("copyright string is too long"),
1253
                                NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1);
1254
                len = NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1;
1255
              }
1256
            copyright_hdr->copyrightMessageLength = len;
1257
            strncpy (copyright_hdr->copyrightMessage, yyvsp[0].string, len);
1258
            copyright_hdr->copyrightMessage[len] = '\0';
1259
            free (yyvsp[0].string);
1260
          }
1261
    break;
1262
 
1263
  case 8:
1264
#line 184 "nlmheader.y"
1265
    {
1266
            custom_file = yyvsp[0].string;
1267
          }
1268
    break;
1269
 
1270
  case 9:
1271
#line 188 "nlmheader.y"
1272
    {
1273
            /* We don't set the version stamp here, because we use the
1274
               version stamp to detect whether the required VERSION
1275
               keyword was given.  */
1276
            version_hdr->month = nlmlex_get_number (yyvsp[-2].string);
1277
            version_hdr->day = nlmlex_get_number (yyvsp[-1].string);
1278
            version_hdr->year = nlmlex_get_number (yyvsp[0].string);
1279
            free (yyvsp[-2].string);
1280
            free (yyvsp[-1].string);
1281
            free (yyvsp[0].string);
1282
            if (version_hdr->month < 1 || version_hdr->month > 12)
1283
              nlmheader_warn (_("illegal month"), -1);
1284
            if (version_hdr->day < 1 || version_hdr->day > 31)
1285
              nlmheader_warn (_("illegal day"), -1);
1286
            if (version_hdr->year < 1900 || version_hdr->year > 3000)
1287
              nlmheader_warn (_("illegal year"), -1);
1288
          }
1289
    break;
1290
 
1291
  case 10:
1292
#line 206 "nlmheader.y"
1293
    {
1294
            debug_info = TRUE;
1295
          }
1296
    break;
1297
 
1298
  case 11:
1299
#line 210 "nlmheader.y"
1300
    {
1301
            int len;
1302
 
1303
            len = strlen (yyvsp[0].string);
1304
            if (len > NLM_MAX_DESCRIPTION_LENGTH)
1305
              {
1306
                nlmheader_warn (_("description string is too long"),
1307
                                NLM_MAX_DESCRIPTION_LENGTH);
1308
                len = NLM_MAX_DESCRIPTION_LENGTH;
1309
              }
1310
            var_hdr->descriptionLength = len;
1311
            strncpy (var_hdr->descriptionText, yyvsp[0].string, len);
1312
            var_hdr->descriptionText[len] = '\0';
1313
            free (yyvsp[0].string);
1314
          }
1315
    break;
1316
 
1317
  case 12:
1318
#line 226 "nlmheader.y"
1319
    {
1320
            exit_procedure = yyvsp[0].string;
1321
          }
1322
    break;
1323
 
1324
  case 13:
1325
#line 230 "nlmheader.y"
1326
    {
1327
            symbol_prefix = NULL;
1328
          }
1329
    break;
1330
 
1331
  case 14:
1332
#line 234 "nlmheader.y"
1333
    {
1334
            export_symbols = string_list_append (export_symbols, yyvsp[0].list);
1335
          }
1336
    break;
1337
 
1338
  case 15:
1339
#line 238 "nlmheader.y"
1340
    {
1341
            fixed_hdr->flags |= nlmlex_get_number (yyvsp[0].string);
1342
            free (yyvsp[0].string);
1343
          }
1344
    break;
1345
 
1346
  case 16:
1347
#line 243 "nlmheader.y"
1348
    {
1349
            fixed_hdr->flags &=~ nlmlex_get_number (yyvsp[0].string);
1350
            free (yyvsp[0].string);
1351
          }
1352
    break;
1353
 
1354
  case 17:
1355
#line 248 "nlmheader.y"
1356
    {
1357
            map_file = "";
1358
            full_map = TRUE;
1359
          }
1360
    break;
1361
 
1362
  case 18:
1363
#line 253 "nlmheader.y"
1364
    {
1365
            map_file = yyvsp[0].string;
1366
            full_map = TRUE;
1367
          }
1368
    break;
1369
 
1370
  case 19:
1371
#line 258 "nlmheader.y"
1372
    {
1373
            help_file = yyvsp[0].string;
1374
          }
1375
    break;
1376
 
1377
  case 20:
1378
#line 262 "nlmheader.y"
1379
    {
1380
            symbol_prefix = NULL;
1381
          }
1382
    break;
1383
 
1384
  case 21:
1385
#line 266 "nlmheader.y"
1386
    {
1387
            import_symbols = string_list_append (import_symbols, yyvsp[0].list);
1388
          }
1389
    break;
1390
 
1391
  case 22:
1392
#line 270 "nlmheader.y"
1393
    {
1394
            input_files = string_list_append (input_files, yyvsp[0].list);
1395
          }
1396
    break;
1397
 
1398
  case 23:
1399
#line 274 "nlmheader.y"
1400
    {
1401
            map_file = "";
1402
          }
1403
    break;
1404
 
1405
  case 24:
1406
#line 278 "nlmheader.y"
1407
    {
1408
            map_file = yyvsp[0].string;
1409
          }
1410
    break;
1411
 
1412
  case 25:
1413
#line 282 "nlmheader.y"
1414
    {
1415
            message_file = yyvsp[0].string;
1416
          }
1417
    break;
1418
 
1419
  case 26:
1420
#line 286 "nlmheader.y"
1421
    {
1422
            modules = string_list_append (modules, yyvsp[0].list);
1423
          }
1424
    break;
1425
 
1426
  case 27:
1427
#line 290 "nlmheader.y"
1428
    {
1429
            fixed_hdr->flags |= 0x2;
1430
          }
1431
    break;
1432
 
1433
  case 28:
1434
#line 294 "nlmheader.y"
1435
    {
1436
            fixed_hdr->flags |= 0x10;
1437
          }
1438
    break;
1439
 
1440
  case 29:
1441
#line 298 "nlmheader.y"
1442
    {
1443
            if (output_file == NULL)
1444
              output_file = yyvsp[0].string;
1445
            else
1446
              nlmheader_warn (_("ignoring duplicate OUTPUT statement"), -1);
1447
          }
1448
    break;
1449
 
1450
  case 30:
1451
#line 305 "nlmheader.y"
1452
    {
1453
            fixed_hdr->flags |= 0x8;
1454
          }
1455
    break;
1456
 
1457
  case 31:
1458
#line 309 "nlmheader.y"
1459
    {
1460
            fixed_hdr->flags |= 0x1;
1461
          }
1462
    break;
1463
 
1464
  case 32:
1465
#line 313 "nlmheader.y"
1466
    {
1467
            int len;
1468
 
1469
            len = strlen (yyvsp[0].string);
1470
            if (len >= NLM_MAX_SCREEN_NAME_LENGTH)
1471
              {
1472
                nlmheader_warn (_("screen name is too long"),
1473
                                NLM_MAX_SCREEN_NAME_LENGTH);
1474
                len = NLM_MAX_SCREEN_NAME_LENGTH;
1475
              }
1476
            var_hdr->screenNameLength = len;
1477
            strncpy (var_hdr->screenName, yyvsp[0].string, len);
1478
            var_hdr->screenName[NLM_MAX_SCREEN_NAME_LENGTH] = '\0';
1479
            free (yyvsp[0].string);
1480
          }
1481
    break;
1482
 
1483
  case 33:
1484
#line 329 "nlmheader.y"
1485
    {
1486
            sharelib_file = yyvsp[0].string;
1487
          }
1488
    break;
1489
 
1490
  case 34:
1491
#line 333 "nlmheader.y"
1492
    {
1493
            var_hdr->stackSize = nlmlex_get_number (yyvsp[0].string);
1494
            free (yyvsp[0].string);
1495
          }
1496
    break;
1497
 
1498
  case 35:
1499
#line 338 "nlmheader.y"
1500
    {
1501
            start_procedure = yyvsp[0].string;
1502
          }
1503
    break;
1504
 
1505
  case 36:
1506
#line 342 "nlmheader.y"
1507
    {
1508
            fixed_hdr->flags |= 0x4;
1509
          }
1510
    break;
1511
 
1512
  case 37:
1513
#line 346 "nlmheader.y"
1514
    {
1515
            int len;
1516
 
1517
            len = strlen (yyvsp[0].string);
1518
            if (len >= NLM_MAX_THREAD_NAME_LENGTH)
1519
              {
1520
                nlmheader_warn (_("thread name is too long"),
1521
                                NLM_MAX_THREAD_NAME_LENGTH);
1522
                len = NLM_MAX_THREAD_NAME_LENGTH;
1523
              }
1524
            var_hdr->threadNameLength = len;
1525
            strncpy (var_hdr->threadName, yyvsp[0].string, len);
1526
            var_hdr->threadName[len] = '\0';
1527
            free (yyvsp[0].string);
1528
          }
1529
    break;
1530
 
1531
  case 38:
1532
#line 362 "nlmheader.y"
1533
    {
1534
            fixed_hdr->moduleType = nlmlex_get_number (yyvsp[0].string);
1535
            free (yyvsp[0].string);
1536
          }
1537
    break;
1538
 
1539
  case 39:
1540
#line 367 "nlmheader.y"
1541
    {
1542
            verbose = TRUE;
1543
          }
1544
    break;
1545
 
1546
  case 40:
1547
#line 371 "nlmheader.y"
1548
    {
1549
            long val;
1550
 
1551
            strncpy (version_hdr->stamp, "VeRsIoN#", 8);
1552
            version_hdr->majorVersion = nlmlex_get_number (yyvsp[-2].string);
1553
            val = nlmlex_get_number (yyvsp[-1].string);
1554
            if (val < 0 || val > 99)
1555
              nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"),
1556
                              -1);
1557
            else
1558
              version_hdr->minorVersion = val;
1559
            val = nlmlex_get_number (yyvsp[0].string);
1560
            if (val < 0)
1561
              nlmheader_warn (_("illegal revision number (must be between 0 and 26)"),
1562
                              -1);
1563
            else if (val > 26)
1564
              version_hdr->revision = 0;
1565
            else
1566
              version_hdr->revision = val;
1567
            free (yyvsp[-2].string);
1568
            free (yyvsp[-1].string);
1569
            free (yyvsp[0].string);
1570
          }
1571
    break;
1572
 
1573
  case 41:
1574
#line 395 "nlmheader.y"
1575
    {
1576
            long val;
1577
 
1578
            strncpy (version_hdr->stamp, "VeRsIoN#", 8);
1579
            version_hdr->majorVersion = nlmlex_get_number (yyvsp[-1].string);
1580
            val = nlmlex_get_number (yyvsp[0].string);
1581
            if (val < 0 || val > 99)
1582
              nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"),
1583
                              -1);
1584
            else
1585
              version_hdr->minorVersion = val;
1586
            version_hdr->revision = 0;
1587
            free (yyvsp[-1].string);
1588
            free (yyvsp[0].string);
1589
          }
1590
    break;
1591
 
1592
  case 42:
1593
#line 411 "nlmheader.y"
1594
    {
1595
            rpc_file = yyvsp[0].string;
1596
          }
1597
    break;
1598
 
1599
  case 43:
1600
#line 420 "nlmheader.y"
1601
    {
1602
            yyval.list = NULL;
1603
          }
1604
    break;
1605
 
1606
  case 44:
1607
#line 424 "nlmheader.y"
1608
    {
1609
            yyval.list = yyvsp[0].list;
1610
          }
1611
    break;
1612
 
1613
  case 45:
1614
#line 435 "nlmheader.y"
1615
    {
1616
            yyval.list = string_list_cons (yyvsp[0].string, NULL);
1617
          }
1618
    break;
1619
 
1620
  case 46:
1621
#line 439 "nlmheader.y"
1622
    {
1623
            yyval.list = NULL;
1624
          }
1625
    break;
1626
 
1627
  case 47:
1628
#line 443 "nlmheader.y"
1629
    {
1630
            yyval.list = string_list_append1 (yyvsp[-1].list, yyvsp[0].string);
1631
          }
1632
    break;
1633
 
1634
  case 48:
1635
#line 447 "nlmheader.y"
1636
    {
1637
            yyval.list = yyvsp[-1].list;
1638
          }
1639
    break;
1640
 
1641
  case 49:
1642
#line 456 "nlmheader.y"
1643
    {
1644
            if (symbol_prefix != NULL)
1645
              free (symbol_prefix);
1646
            symbol_prefix = yyvsp[-1].string;
1647
          }
1648
    break;
1649
 
1650
  case 50:
1651
#line 467 "nlmheader.y"
1652
    {
1653
            if (symbol_prefix == NULL)
1654
              yyval.string = yyvsp[0].string;
1655
            else
1656
              {
1657
                yyval.string = xmalloc (strlen (symbol_prefix) + strlen (yyvsp[0].string) + 2);
1658
                sprintf (yyval.string, "%s@%s", symbol_prefix, yyvsp[0].string);
1659
                free (yyvsp[0].string);
1660
              }
1661
          }
1662
    break;
1663
 
1664
  case 51:
1665
#line 483 "nlmheader.y"
1666
    {
1667
            yyval.list = NULL;
1668
          }
1669
    break;
1670
 
1671
  case 52:
1672
#line 487 "nlmheader.y"
1673
    {
1674
            yyval.list = string_list_cons (yyvsp[-1].string, yyvsp[0].list);
1675
          }
1676
    break;
1677
 
1678
 
1679
    }
1680
 
1681
/* Line 1000 of yacc.c.  */
1682
#line 1683 "nlmheader.c"
1683
 
1684
  yyvsp -= yylen;
1685
  yyssp -= yylen;
1686
 
1687
 
1688
  YY_STACK_PRINT (yyss, yyssp);
1689
 
1690
  *++yyvsp = yyval;
1691
 
1692
 
1693
  /* Now `shift' the result of the reduction.  Determine what state
1694
     that goes to, based on the state we popped back to and the rule
1695
     number reduced by.  */
1696
 
1697
  yyn = yyr1[yyn];
1698
 
1699
  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1700
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1701
    yystate = yytable[yystate];
1702
  else
1703
    yystate = yydefgoto[yyn - YYNTOKENS];
1704
 
1705
  goto yynewstate;
1706
 
1707
 
1708
/*------------------------------------.
1709
| yyerrlab -- here on detecting error |
1710
`------------------------------------*/
1711
yyerrlab:
1712
  /* If not already recovering from an error, report this error.  */
1713
  if (!yyerrstatus)
1714
    {
1715
      ++yynerrs;
1716
#if YYERROR_VERBOSE
1717
      yyn = yypact[yystate];
1718
 
1719
      if (YYPACT_NINF < yyn && yyn < YYLAST)
1720
        {
1721
          YYSIZE_T yysize = 0;
1722
          int yytype = YYTRANSLATE (yychar);
1723
          const char* yyprefix;
1724
          char *yymsg;
1725
          int yyx;
1726
 
1727
          /* Start YYX at -YYN if negative to avoid negative indexes in
1728
             YYCHECK.  */
1729
          int yyxbegin = yyn < 0 ? -yyn : 0;
1730
 
1731
          /* Stay within bounds of both yycheck and yytname.  */
1732
          int yychecklim = YYLAST - yyn;
1733
          int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1734
          int yycount = 0;
1735
 
1736
          yyprefix = ", expecting ";
1737
          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1738
            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1739
              {
1740
                yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
1741
                yycount += 1;
1742
                if (yycount == 5)
1743
                  {
1744
                    yysize = 0;
1745
                    break;
1746
                  }
1747
              }
1748
          yysize += (sizeof ("syntax error, unexpected ")
1749
                     + yystrlen (yytname[yytype]));
1750
          yymsg = (char *) YYSTACK_ALLOC (yysize);
1751
          if (yymsg != 0)
1752
            {
1753
              char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1754
              yyp = yystpcpy (yyp, yytname[yytype]);
1755
 
1756
              if (yycount < 5)
1757
                {
1758
                  yyprefix = ", expecting ";
1759
                  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1760
                    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1761
                      {
1762
                        yyp = yystpcpy (yyp, yyprefix);
1763
                        yyp = yystpcpy (yyp, yytname[yyx]);
1764
                        yyprefix = " or ";
1765
                      }
1766
                }
1767
              yyerror (yymsg);
1768
              YYSTACK_FREE (yymsg);
1769
            }
1770
          else
1771
            yyerror ("syntax error; also virtual memory exhausted");
1772
        }
1773
      else
1774
#endif /* YYERROR_VERBOSE */
1775
        yyerror ("syntax error");
1776
    }
1777
 
1778
 
1779
 
1780
  if (yyerrstatus == 3)
1781
    {
1782
      /* If just tried and failed to reuse lookahead token after an
1783
         error, discard it.  */
1784
 
1785
      if (yychar <= YYEOF)
1786
        {
1787
          /* If at end of input, pop the error token,
1788
             then the rest of the stack, then return failure.  */
1789
          if (yychar == YYEOF)
1790
             for (;;)
1791
               {
1792
                 YYPOPSTACK;
1793
                 if (yyssp == yyss)
1794
                   YYABORT;
1795
                 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1796
                 yydestruct (yystos[*yyssp], yyvsp);
1797
               }
1798
        }
1799
      else
1800
        {
1801
          YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1802
          yydestruct (yytoken, &yylval);
1803
          yychar = YYEMPTY;
1804
 
1805
        }
1806
    }
1807
 
1808
  /* Else will try to reuse lookahead token after shifting the error
1809
     token.  */
1810
  goto yyerrlab1;
1811
 
1812
 
1813
/*---------------------------------------------------.
1814
| yyerrorlab -- error raised explicitly by YYERROR.  |
1815
`---------------------------------------------------*/
1816
yyerrorlab:
1817
 
1818
#ifdef __GNUC__
1819
  /* Pacify GCC when the user code never invokes YYERROR and the label
1820
     yyerrorlab therefore never appears in user code.  */
1821
  if (0)
1822
     goto yyerrorlab;
1823
#endif
1824
 
1825
  yyvsp -= yylen;
1826
  yyssp -= yylen;
1827
  yystate = *yyssp;
1828
  goto yyerrlab1;
1829
 
1830
 
1831
/*-------------------------------------------------------------.
1832
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
1833
`-------------------------------------------------------------*/
1834
yyerrlab1:
1835
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1836
 
1837
  for (;;)
1838
    {
1839
      yyn = yypact[yystate];
1840
      if (yyn != YYPACT_NINF)
1841
        {
1842
          yyn += YYTERROR;
1843
          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1844
            {
1845
              yyn = yytable[yyn];
1846
              if (0 < yyn)
1847
                break;
1848
            }
1849
        }
1850
 
1851
      /* Pop the current state because it cannot handle the error token.  */
1852
      if (yyssp == yyss)
1853
        YYABORT;
1854
 
1855
      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1856
      yydestruct (yystos[yystate], yyvsp);
1857
      YYPOPSTACK;
1858
      yystate = *yyssp;
1859
      YY_STACK_PRINT (yyss, yyssp);
1860
    }
1861
 
1862
  if (yyn == YYFINAL)
1863
    YYACCEPT;
1864
 
1865
  YYDPRINTF ((stderr, "Shifting error token, "));
1866
 
1867
  *++yyvsp = yylval;
1868
 
1869
 
1870
  yystate = yyn;
1871
  goto yynewstate;
1872
 
1873
 
1874
/*-------------------------------------.
1875
| yyacceptlab -- YYACCEPT comes here.  |
1876
`-------------------------------------*/
1877
yyacceptlab:
1878
  yyresult = 0;
1879
  goto yyreturn;
1880
 
1881
/*-----------------------------------.
1882
| yyabortlab -- YYABORT comes here.  |
1883
`-----------------------------------*/
1884
yyabortlab:
1885
  yyresult = 1;
1886
  goto yyreturn;
1887
 
1888
#ifndef yyoverflow
1889
/*----------------------------------------------.
1890
| yyoverflowlab -- parser overflow comes here.  |
1891
`----------------------------------------------*/
1892
yyoverflowlab:
1893
  yyerror ("parser stack overflow");
1894
  yyresult = 2;
1895
  /* Fall through.  */
1896
#endif
1897
 
1898
yyreturn:
1899
#ifndef yyoverflow
1900
  if (yyss != yyssa)
1901
    YYSTACK_FREE (yyss);
1902
#endif
1903
  return yyresult;
1904
}
1905
 
1906
 
1907
#line 492 "nlmheader.y"
1908
 
1909
 
1910
/* If strerror is just a macro, we want to use the one from libiberty
1911
   since it will handle undefined values.  */
1912
#undef strerror
1913
extern char *strerror PARAMS ((int));
1914
 
1915
/* The lexer is simple, too simple for flex.  Keywords are only
1916
   recognized at the start of lines.  Everything else must be an
1917
   argument.  A comma is treated as whitespace.  */
1918
 
1919
/* The states the lexer can be in.  */
1920
 
1921
enum lex_state
1922
{
1923
  /* At the beginning of a line.  */
1924
  BEGINNING_OF_LINE,
1925
  /* In the middle of a line.  */
1926
  IN_LINE
1927
};
1928
 
1929
/* We need to keep a stack of files to handle file inclusion.  */
1930
 
1931
struct input
1932
{
1933
  /* The file to read from.  */
1934
  FILE *file;
1935
  /* The name of the file.  */
1936
  char *name;
1937
  /* The current line number.  */
1938
  int lineno;
1939
  /* The current state.  */
1940
  enum lex_state state;
1941
  /* The next file on the stack.  */
1942
  struct input *next;
1943
};
1944
 
1945
/* The current input file.  */
1946
 
1947
static struct input current;
1948
 
1949
/* The character which introduces comments.  */
1950
#define COMMENT_CHAR '#'
1951
 
1952
/* Start the lexer going on the main input file.  */
1953
 
1954
bfd_boolean
1955
nlmlex_file (const char *name)
1956
{
1957
  current.next = NULL;
1958
  return nlmlex_file_open (name);
1959
}
1960
 
1961
/* Start the lexer going on a subsidiary input file.  */
1962
 
1963
static void
1964
nlmlex_file_push (const char *name)
1965
{
1966
  struct input *push;
1967
 
1968
  push = (struct input *) xmalloc (sizeof (struct input));
1969
  *push = current;
1970
  if (nlmlex_file_open (name))
1971
    current.next = push;
1972
  else
1973
    {
1974
      current = *push;
1975
      free (push);
1976
    }
1977
}
1978
 
1979
/* Start lexing from a file.  */
1980
 
1981
static bfd_boolean
1982
nlmlex_file_open (const char *name)
1983
{
1984
  current.file = fopen (name, "r");
1985
  if (current.file == NULL)
1986
    {
1987
      fprintf (stderr, "%s:%s: %s\n", program_name, name, strerror (errno));
1988
      ++parse_errors;
1989
      return FALSE;
1990
    }
1991
  current.name = xstrdup (name);
1992
  current.lineno = 1;
1993
  current.state = BEGINNING_OF_LINE;
1994
  return TRUE;
1995
}
1996
 
1997
/* Table used to turn keywords into tokens.  */
1998
 
1999
struct keyword_tokens_struct
2000
{
2001
  const char *keyword;
2002
  int token;
2003
};
2004
 
2005
static struct keyword_tokens_struct keyword_tokens[] =
2006
{
2007
  { "CHECK", CHECK },
2008
  { "CODESTART", CODESTART },
2009
  { "COPYRIGHT", COPYRIGHT },
2010
  { "CUSTOM", CUSTOM },
2011
  { "DATE", DATE },
2012
  { "DEBUG", DEBUG },
2013
  { "DESCRIPTION", DESCRIPTION },
2014
  { "EXIT", EXIT },
2015
  { "EXPORT", EXPORT },
2016
  { "FLAG_ON", FLAG_ON },
2017
  { "FLAG_OFF", FLAG_OFF },
2018
  { "FULLMAP", FULLMAP },
2019
  { "HELP", HELP },
2020
  { "IMPORT", IMPORT },
2021
  { "INPUT", INPUT },
2022
  { "MAP", MAP },
2023
  { "MESSAGES", MESSAGES },
2024
  { "MODULE", MODULE },
2025
  { "MULTIPLE", MULTIPLE },
2026
  { "OS_DOMAIN", OS_DOMAIN },
2027
  { "OUTPUT", OUTPUT },
2028
  { "PSEUDOPREEMPTION", PSEUDOPREEMPTION },
2029
  { "REENTRANT", REENTRANT },
2030
  { "SCREENNAME", SCREENNAME },
2031
  { "SHARELIB", SHARELIB },
2032
  { "STACK", STACK },
2033
  { "STACKSIZE", STACK },
2034
  { "START", START },
2035
  { "SYNCHRONIZE", SYNCHRONIZE },
2036
  { "THREADNAME", THREADNAME },
2037
  { "TYPE", TYPE },
2038
  { "VERBOSE", VERBOSE },
2039
  { "VERSION", VERSIONK },
2040
  { "XDCDATA", XDCDATA }
2041
};
2042
 
2043
#define KEYWORD_COUNT (sizeof (keyword_tokens) / sizeof (keyword_tokens[0]))
2044
 
2045
/* The lexer accumulates strings in these variables.  */
2046
static char *lex_buf;
2047
static int lex_size;
2048
static int lex_pos;
2049
 
2050
/* Start accumulating strings into the buffer.  */
2051
#define BUF_INIT() \
2052
  ((void) (lex_buf != NULL ? lex_pos = 0 : nlmlex_buf_init ()))
2053
 
2054
static int
2055
nlmlex_buf_init (void)
2056
{
2057
  lex_size = 10;
2058
  lex_buf = xmalloc (lex_size + 1);
2059
  lex_pos = 0;
2060
  return 0;
2061
}
2062
 
2063
/* Finish a string in the buffer.  */
2064
#define BUF_FINISH() ((void) (lex_buf[lex_pos] = '\0'))
2065
 
2066
/* Accumulate a character into the buffer.  */
2067
#define BUF_ADD(c) \
2068
  ((void) (lex_pos < lex_size \
2069
           ? lex_buf[lex_pos++] = (c) \
2070
           : nlmlex_buf_add (c)))
2071
 
2072
static char
2073
nlmlex_buf_add (int c)
2074
{
2075
  if (lex_pos >= lex_size)
2076
    {
2077
      lex_size *= 2;
2078
      lex_buf = xrealloc (lex_buf, lex_size + 1);
2079
    }
2080
 
2081
  return lex_buf[lex_pos++] = c;
2082
}
2083
 
2084
/* The lexer proper.  This is called by the bison generated parsing
2085
   code.  */
2086
 
2087
static int
2088
yylex (void)
2089
{
2090
  int c;
2091
 
2092
tail_recurse:
2093
 
2094
  c = getc (current.file);
2095
 
2096
  /* Commas are treated as whitespace characters.  */
2097
  while (ISSPACE (c) || c == ',')
2098
    {
2099
      current.state = IN_LINE;
2100
      if (c == '\n')
2101
        {
2102
          ++current.lineno;
2103
          current.state = BEGINNING_OF_LINE;
2104
        }
2105
      c = getc (current.file);
2106
    }
2107
 
2108
  /* At the end of the file we either pop to the previous file or
2109
     finish up.  */
2110
  if (c == EOF)
2111
    {
2112
      fclose (current.file);
2113
      free (current.name);
2114
      if (current.next == NULL)
2115
        return 0;
2116
      else
2117
        {
2118
          struct input *next;
2119
 
2120
          next = current.next;
2121
          current = *next;
2122
          free (next);
2123
          goto tail_recurse;
2124
        }
2125
    }
2126
 
2127
  /* A comment character always means to drop everything until the
2128
     next newline.  */
2129
  if (c == COMMENT_CHAR)
2130
    {
2131
      do
2132
        {
2133
          c = getc (current.file);
2134
        }
2135
      while (c != '\n');
2136
      ++current.lineno;
2137
      current.state = BEGINNING_OF_LINE;
2138
      goto tail_recurse;
2139
    }
2140
 
2141
  /* An '@' introduces an include file.  */
2142
  if (c == '@')
2143
    {
2144
      do
2145
        {
2146
          c = getc (current.file);
2147
          if (c == '\n')
2148
            ++current.lineno;
2149
        }
2150
      while (ISSPACE (c));
2151
      BUF_INIT ();
2152
      while (! ISSPACE (c) && c != EOF)
2153
        {
2154
          BUF_ADD (c);
2155
          c = getc (current.file);
2156
        }
2157
      BUF_FINISH ();
2158
 
2159
      ungetc (c, current.file);
2160
 
2161
      nlmlex_file_push (lex_buf);
2162
      goto tail_recurse;
2163
    }
2164
 
2165
  /* A non-space character at the start of a line must be the start of
2166
     a keyword.  */
2167
  if (current.state == BEGINNING_OF_LINE)
2168
    {
2169
      BUF_INIT ();
2170
      while (ISALNUM (c) || c == '_')
2171
        {
2172
          BUF_ADD (TOUPPER (c));
2173
          c = getc (current.file);
2174
        }
2175
      BUF_FINISH ();
2176
 
2177
      if (c != EOF && ! ISSPACE (c) && c != ',')
2178
        {
2179
          nlmheader_identify ();
2180
          fprintf (stderr, _("%s:%d: illegal character in keyword: %c\n"),
2181
                   current.name, current.lineno, c);
2182
        }
2183
      else
2184
        {
2185
          unsigned int i;
2186
 
2187
          for (i = 0; i < KEYWORD_COUNT; i++)
2188
            {
2189
              if (lex_buf[0] == keyword_tokens[i].keyword[0]
2190
                  && strcmp (lex_buf, keyword_tokens[i].keyword) == 0)
2191
                {
2192
                  /* Pushing back the final whitespace avoids worrying
2193
                     about \n here.  */
2194
                  ungetc (c, current.file);
2195
                  current.state = IN_LINE;
2196
                  return keyword_tokens[i].token;
2197
                }
2198
            }
2199
 
2200
          nlmheader_identify ();
2201
          fprintf (stderr, _("%s:%d: unrecognized keyword: %s\n"),
2202
                   current.name, current.lineno, lex_buf);
2203
        }
2204
 
2205
      ++parse_errors;
2206
      /* Treat the rest of this line as a comment.  */
2207
      ungetc (COMMENT_CHAR, current.file);
2208
      goto tail_recurse;
2209
    }
2210
 
2211
  /* Parentheses just represent themselves.  */
2212
  if (c == '(' || c == ')')
2213
    return c;
2214
 
2215
  /* Handle quoted strings.  */
2216
  if (c == '"' || c == '\'')
2217
    {
2218
      int quote;
2219
      int start_lineno;
2220
 
2221
      quote = c;
2222
      start_lineno = current.lineno;
2223
 
2224
      c = getc (current.file);
2225
      BUF_INIT ();
2226
      while (c != quote && c != EOF)
2227
        {
2228
          BUF_ADD (c);
2229
          if (c == '\n')
2230
            ++current.lineno;
2231
          c = getc (current.file);
2232
        }
2233
      BUF_FINISH ();
2234
 
2235
      if (c == EOF)
2236
        {
2237
          nlmheader_identify ();
2238
          fprintf (stderr, _("%s:%d: end of file in quoted string\n"),
2239
                   current.name, start_lineno);
2240
          ++parse_errors;
2241
        }
2242
 
2243
      /* FIXME: Possible memory leak.  */
2244
      yylval.string = xstrdup (lex_buf);
2245
      return QUOTED_STRING;
2246
    }
2247
 
2248
  /* Gather a generic argument.  */
2249
  BUF_INIT ();
2250
  while (! ISSPACE (c)
2251
         && c != ','
2252
         && c != COMMENT_CHAR
2253
         && c != '('
2254
         && c != ')')
2255
    {
2256
      BUF_ADD (c);
2257
      c = getc (current.file);
2258
    }
2259
  BUF_FINISH ();
2260
 
2261
  ungetc (c, current.file);
2262
 
2263
  /* FIXME: Possible memory leak.  */
2264
  yylval.string = xstrdup (lex_buf);
2265
  return STRING;
2266
}
2267
 
2268
/* Get a number from a string.  */
2269
 
2270
static long
2271
nlmlex_get_number (const char *s)
2272
{
2273
  long ret;
2274
  char *send;
2275
 
2276
  ret = strtol (s, &send, 10);
2277
  if (*send != '\0')
2278
    nlmheader_warn (_("bad number"), -1);
2279
  return ret;
2280
}
2281
 
2282
/* Prefix the nlmconv warnings with a note as to where they come from.
2283
   We don't use program_name on every warning, because then some
2284
   versions of the emacs next-error function can't recognize the line
2285
   number.  */
2286
 
2287
static void
2288
nlmheader_identify (void)
2289
{
2290
  static int done;
2291
 
2292
  if (! done)
2293
    {
2294
      fprintf (stderr, _("%s: problems in NLM command language input:\n"),
2295
               program_name);
2296
      done = 1;
2297
    }
2298
}
2299
 
2300
/* Issue a warning.  */
2301
 
2302
static void
2303
nlmheader_warn (const char *s, int imax)
2304
{
2305
  nlmheader_identify ();
2306
  fprintf (stderr, "%s:%d: %s", current.name, current.lineno, s);
2307
  if (imax != -1)
2308
    fprintf (stderr, " (max %d)", imax);
2309
  fprintf (stderr, "\n");
2310
}
2311
 
2312
/* Report an error.  */
2313
 
2314
static void
2315
nlmheader_error (const char *s)
2316
{
2317
  nlmheader_warn (s, -1);
2318
  ++parse_errors;
2319
}
2320
 
2321
/* Add a string to a string list.  */
2322
 
2323
static struct string_list *
2324
string_list_cons (char *s, struct string_list *l)
2325
{
2326
  struct string_list *ret;
2327
 
2328
  ret = (struct string_list *) xmalloc (sizeof (struct string_list));
2329
  ret->next = l;
2330
  ret->string = s;
2331
  return ret;
2332
}
2333
 
2334
/* Append a string list to another string list.  */
2335
 
2336
static struct string_list *
2337
string_list_append (struct string_list *l1, struct string_list *l2)
2338
{
2339
  register struct string_list **pp;
2340
 
2341
  for (pp = &l1; *pp != NULL; pp = &(*pp)->next)
2342
    ;
2343
  *pp = l2;
2344
  return l1;
2345
}
2346
 
2347
/* Append a string to a string list.  */
2348
 
2349
static struct string_list *
2350
string_list_append1 (struct string_list *l, char *s)
2351
{
2352
  struct string_list *n;
2353
  register struct string_list **pp;
2354
 
2355
  n = (struct string_list *) xmalloc (sizeof (struct string_list));
2356
  n->next = NULL;
2357
  n->string = s;
2358
  for (pp = &l; *pp != NULL; pp = &(*pp)->next)
2359
    ;
2360
  *pp = n;
2361
  return l;
2362
}
2363
 
2364
/* Duplicate a string in memory.  */
2365
 
2366
static char *
2367
xstrdup (const char *s)
2368
{
2369
  unsigned long len;
2370
  char *ret;
2371
 
2372
  len = strlen (s);
2373
  ret = xmalloc (len + 1);
2374
  strcpy (ret, s);
2375
  return ret;
2376
}
2377
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.