XINU
y.tab.c
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 3.3.2. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
6  Inc.
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 
21 /* As a special exception, you may create a larger work that contains
22  part or all of the Bison parser skeleton and distribute that work
23  under terms of your choice, so long as that work isn't itself a
24  parser generator using the skeleton or a modified version thereof
25  as a parser skeleton. Alternatively, if you modify or redistribute
26  the parser skeleton itself, you may (at your option) remove this
27  special exception, which will cause the skeleton and the resulting
28  Bison output files to be licensed under the GNU General Public
29  License without this special exception.
30 
31  This special exception was added by the Free Software Foundation in
32  version 2.2 of Bison. */
33 
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35  simplifying the original so-called "semantic" parser. */
36 
37 /* All symbols defined below should begin with yy or YY, to avoid
38  infringing on user name space. This should be done even for local
39  variables, as they might otherwise be expanded by user macros.
40  There are some unavoidable exceptions within include files to
41  define necessary library symbols; they are noted "INFRINGES ON
42  USER NAME SPACE" below. */
43 
44 /* Undocumented macros, especially those whose name start with YY_,
45  are private implementation details. Do not rely on them. */
46 
47 /* Identify Bison output. */
48 #define YYBISON 1
49 
50 /* Bison version. */
51 #define YYBISON_VERSION "3.3.2"
52 
53 /* Skeleton name. */
54 #define YYSKELETON_NAME "yacc.c"
55 
56 /* Pure parsers. */
57 #define YYPURE 0
58 
59 /* Push parsers. */
60 #define YYPUSH 0
61 
62 /* Pull parsers. */
63 #define YYPULL 1
64 
65 
66 
67 
68 /* First part of user prologue. */
69 #line 15 "config.y" /* yacc.c:337 */
70 
71 #include <stdlib.h>
72 #include <stdio.h>
73 #include <string.h>
74 #include <ctype.h>
75 
76 /* Avoid warnings for undeclared items */
77 
78 extern char *yytext;
79 extern int yyleng;
80 extern int yylex(void);
81 
82 
83 /********************************************************************************/
84 /* */
85 /* Start of Definitions */
86 /* */
87 /********************************************************************************/
88 
89 #define NIL (struct dev_ent *)0x00
90 
91 #define CONFC "conf.c" /* Name of .c output */
92 #define CONFH "conf.h" /* Name of .h output */
93 #define CONFHREF "<conf.h>" /* How conf.h referenced */
94 #define INFILE "Configuration" /* Name of input file */
95 #define MAXNAME 16 /* Max length of names */
96 
97 #define NDEVS 250 /* Max devices */
98 #define NTYPES 250 /* Max device types */
99 
100 int linectr = 1;
101 
102 FILE *confc;
103 FILE *confh;
104 
105 int brkcount = 0; /* Count of %% separators till now in */
106  /* the input file */
107 char *doing = "device type declarations";
108 
109 struct dev_ent { /* Entry for a device or device type */
110  char name[MAXNAME]; /* device name (unused in a type) */
111  char tname[MAXNAME]; /* Type name */
112  char ison[MAXNAME]; /* Name is "on" XXX */
113  int tindex; /* Index in dtypes (unused in a type) */
114  int csr; /* Control Status Register addr */
115  int irq; /* interrupt request */
116  char intr[MAXNAME]; /* interrupt function name */
117  char init[MAXNAME]; /* init function name */
118  char open[MAXNAME]; /* open function name */
119  char close[MAXNAME]; /* close function name */
120  char read[MAXNAME]; /* read function name */
121  char write[MAXNAME]; /* write function name */
122  char control[MAXNAME]; /* control function name */
123  char seek[MAXNAME]; /* seek function name */
124  char getc[MAXNAME]; /* getc function name */
125  char putc[MAXNAME]; /* putc function name */
126  int minor; /* In a device, the minor device */
127  /* assigned to the device 0,1,... */
128  /* in a type, the next minor number */
129  /* to assign */
130 };
131 struct dev_ent dtypes[NTYPES];/* Table of all device types */
132 int ntypes = 0; /* Number of device types found */
133 
134 struct dev_ent devs[NDEVS]; /* Table of all devices */
135 int ndevs = 0; /* Number of devices found */
136 
137 char *devstab[] = {
138  "/* Device table entry */",
139  "struct\tdentry\t{",
140  "\tint32 dvnum;",
141  "\tint32 dvminor;",
142  "\tchar *dvname;",
143  "\tdevcall (*dvinit) (struct dentry *);",
144  "\tdevcall (*dvopen) (struct dentry *, char *, char *);",
145  "\tdevcall (*dvclose)(struct dentry *);",
146  "\tdevcall (*dvread) (struct dentry *, void *, uint32);",
147  "\tdevcall (*dvwrite)(struct dentry *, void *, uint32);",
148  "\tdevcall (*dvseek) (struct dentry *, int32);",
149  "\tdevcall (*dvgetc) (struct dentry *);",
150  "\tdevcall (*dvputc) (struct dentry *, char);",
151  "\tdevcall (*dvcntl) (struct dentry *, int32, int32, int32);",
152  "\tvoid *dvcsr;",
153  "\tvoid (*dvintr)(void);",
154  "\tbyte dvirq;",
155  "};\n",
156  "extern struct dentry devtab[]; /* one entry per device */",
157  NULL
158 };
159 
160 char saveattrid[MAXNAME]; /* Holds the IDENT from an attribute */
161 
162 /********************************************************************************/
163 /* */
164 /* Function prototypes */
165 /* */
166 /********************************************************************************/
167 
168 void addattr(int, int);
169 int addton(char *);
170 int config_atoi(char *, int);
171 void devisid(char *);
172 void devonid(char *);
173 void getattrid(char *);
174 void newdev(char *);
175 int newtype(char *);
176 void yyerror(char *);
177 
178 
179 
180 #line 181 "y.tab.c" /* yacc.c:337 */
181 # ifndef YY_NULLPTR
182 # if defined __cplusplus
183 # if 201103L <= __cplusplus
184 # define YY_NULLPTR nullptr
185 # else
186 # define YY_NULLPTR 0
187 # endif
188 # else
189 # define YY_NULLPTR ((void*)0)
190 # endif
191 # endif
192 
193 /* Enabling verbose error messages. */
194 #ifdef YYERROR_VERBOSE
195 # undef YYERROR_VERBOSE
196 # define YYERROR_VERBOSE 1
197 #else
198 # define YYERROR_VERBOSE 0
199 #endif
200 
201 
202 /* Debug traces. */
203 #ifndef YYDEBUG
204 # define YYDEBUG 0
205 #endif
206 #if YYDEBUG
207 extern int yydebug;
208 #endif
209 
210 /* Token type. */
211 #ifndef YYTOKENTYPE
212 # define YYTOKENTYPE
214  {
215  DEFBRK = 258,
216  IFBRK = 259,
217  COLON = 260,
218  OCTAL = 261,
219  INTEGER = 262,
220  IDENT = 263,
221  CSR = 264,
222  IRQ = 265,
223  INTR = 266,
224  INIT = 267,
225  OPEN = 268,
226  CLOSE = 269,
227  READ = 270,
228  WRITE = 271,
229  SEEK = 272,
230  CONTROL = 273,
231  IS = 274,
232  ON = 275,
233  GETC = 276,
234  PUTC = 277
235  };
236 #endif
237 /* Tokens. */
238 #define DEFBRK 258
239 #define IFBRK 259
240 #define COLON 260
241 #define OCTAL 261
242 #define INTEGER 262
243 #define IDENT 263
244 #define CSR 264
245 #define IRQ 265
246 #define INTR 266
247 #define INIT 267
248 #define OPEN 268
249 #define CLOSE 269
250 #define READ 270
251 #define WRITE 271
252 #define SEEK 272
253 #define CONTROL 273
254 #define IS 274
255 #define ON 275
256 #define GETC 276
257 #define PUTC 277
258 
259 /* Value type. */
260 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
261 typedef int YYSTYPE;
262 # define YYSTYPE_IS_TRIVIAL 1
263 # define YYSTYPE_IS_DECLARED 1
264 #endif
265 
266 
267 extern YYSTYPE yylval;
268 
269 int yyparse (void);
270 
271 
272 
273 
274 
275 #ifdef short
276 # undef short
277 #endif
278 
279 #ifdef YYTYPE_UINT8
280 typedef YYTYPE_UINT8 yytype_uint8;
281 #else
282 typedef unsigned char yytype_uint8;
283 #endif
284 
285 #ifdef YYTYPE_INT8
286 typedef YYTYPE_INT8 yytype_int8;
287 #else
288 typedef signed char yytype_int8;
289 #endif
290 
291 #ifdef YYTYPE_UINT16
292 typedef YYTYPE_UINT16 yytype_uint16;
293 #else
294 typedef unsigned short yytype_uint16;
295 #endif
296 
297 #ifdef YYTYPE_INT16
298 typedef YYTYPE_INT16 yytype_int16;
299 #else
300 typedef short yytype_int16;
301 #endif
302 
303 #ifndef YYSIZE_T
304 # ifdef __SIZE_TYPE__
305 # define YYSIZE_T __SIZE_TYPE__
306 # elif defined size_t
307 # define YYSIZE_T size_t
308 # elif ! defined YYSIZE_T
309 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
310 # define YYSIZE_T size_t
311 # else
312 # define YYSIZE_T unsigned
313 # endif
314 #endif
315 
316 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
317 
318 #ifndef YY_
319 # if defined YYENABLE_NLS && YYENABLE_NLS
320 # if ENABLE_NLS
321 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
322 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
323 # endif
324 # endif
325 # ifndef YY_
326 # define YY_(Msgid) Msgid
327 # endif
328 #endif
329 
330 #ifndef YY_ATTRIBUTE
331 # if (defined __GNUC__ \
332  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
333  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
334 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
335 # else
336 # define YY_ATTRIBUTE(Spec) /* empty */
337 # endif
338 #endif
339 
340 #ifndef YY_ATTRIBUTE_PURE
341 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
342 #endif
343 
344 #ifndef YY_ATTRIBUTE_UNUSED
345 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
346 #endif
347 
348 /* Suppress unused-variable warnings by "using" E. */
349 #if ! defined lint || defined __GNUC__
350 # define YYUSE(E) ((void) (E))
351 #else
352 # define YYUSE(E) /* empty */
353 #endif
354 
355 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
356 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
357 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
358  _Pragma ("GCC diagnostic push") \
359  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
360  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
361 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
362  _Pragma ("GCC diagnostic pop")
363 #else
364 # define YY_INITIAL_VALUE(Value) Value
365 #endif
366 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
367 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
368 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
369 #endif
370 #ifndef YY_INITIAL_VALUE
371 # define YY_INITIAL_VALUE(Value) /* Nothing. */
372 #endif
373 
374 
375 #if ! defined yyoverflow || YYERROR_VERBOSE
376 
377 /* The parser invokes alloca or malloc; define the necessary symbols. */
378 
379 # ifdef YYSTACK_USE_ALLOCA
380 # if YYSTACK_USE_ALLOCA
381 # ifdef __GNUC__
382 # define YYSTACK_ALLOC __builtin_alloca
383 # elif defined __BUILTIN_VA_ARG_INCR
384 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
385 # elif defined _AIX
386 # define YYSTACK_ALLOC __alloca
387 # elif defined _MSC_VER
388 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
389 # define alloca _alloca
390 # else
391 # define YYSTACK_ALLOC alloca
392 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
393 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
394  /* Use EXIT_SUCCESS as a witness for stdlib.h. */
395 # ifndef EXIT_SUCCESS
396 # define EXIT_SUCCESS 0
397 # endif
398 # endif
399 # endif
400 # endif
401 # endif
402 
403 # ifdef YYSTACK_ALLOC
404  /* Pacify GCC's 'empty if-body' warning. */
405 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
406 # ifndef YYSTACK_ALLOC_MAXIMUM
407  /* The OS might guarantee only one guard page at the bottom of the stack,
408  and a page size can be as small as 4096 bytes. So we cannot safely
409  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
410  to allow for a few compiler-allocated temporary stack slots. */
411 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
412 # endif
413 # else
414 # define YYSTACK_ALLOC YYMALLOC
415 # define YYSTACK_FREE YYFREE
416 # ifndef YYSTACK_ALLOC_MAXIMUM
417 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
418 # endif
419 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
420  && ! ((defined YYMALLOC || defined malloc) \
421  && (defined YYFREE || defined free)))
422 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
423 # ifndef EXIT_SUCCESS
424 # define EXIT_SUCCESS 0
425 # endif
426 # endif
427 # ifndef YYMALLOC
428 # define YYMALLOC malloc
429 # if ! defined malloc && ! defined EXIT_SUCCESS
430 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
431 # endif
432 # endif
433 # ifndef YYFREE
434 # define YYFREE free
435 # if ! defined free && ! defined EXIT_SUCCESS
436 void free (void *); /* INFRINGES ON USER NAME SPACE */
437 # endif
438 # endif
439 # endif
440 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
441 
442 
443 #if (! defined yyoverflow \
444  && (! defined __cplusplus \
445  || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
446 
447 /* A type that is properly aligned for any stack member. */
448 union yyalloc
449 {
452 };
453 
454 /* The size of the maximum gap between one aligned stack and the next. */
455 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
456 
457 /* The size of an array large to enough to hold all stacks, each with
458  N elements. */
459 # define YYSTACK_BYTES(N) \
460  ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
461  + YYSTACK_GAP_MAXIMUM)
462 
463 # define YYCOPY_NEEDED 1
464 
465 /* Relocate STACK from its old location to the new one. The
466  local variables YYSIZE and YYSTACKSIZE give the old and new number of
467  elements in the stack, and YYPTR gives the new location of the
468  stack. Advance YYPTR to a properly aligned location for the next
469  stack. */
470 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
471  do \
472  { \
473  YYSIZE_T yynewbytes; \
474  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
475  Stack = &yyptr->Stack_alloc; \
476  yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
477  yyptr += yynewbytes / sizeof (*yyptr); \
478  } \
479  while (0)
480 
481 #endif
482 
483 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
484 /* Copy COUNT objects from SRC to DST. The source and destination do
485  not overlap. */
486 # ifndef YYCOPY
487 # if defined __GNUC__ && 1 < __GNUC__
488 # define YYCOPY(Dst, Src, Count) \
489  __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
490 # else
491 # define YYCOPY(Dst, Src, Count) \
492  do \
493  { \
494  YYSIZE_T yyi; \
495  for (yyi = 0; yyi < (Count); yyi++) \
496  (Dst)[yyi] = (Src)[yyi]; \
497  } \
498  while (0)
499 # endif
500 # endif
501 #endif /* !YYCOPY_NEEDED */
502 
503 /* YYFINAL -- State number of the termination state. */
504 #define YYFINAL 3
505 /* YYLAST -- Last index in YYTABLE. */
506 #define YYLAST 39
507 
508 /* YYNTOKENS -- Number of terminals. */
509 #define YYNTOKENS 23
510 /* YYNNTS -- Number of nonterminals. */
511 #define YYNNTS 20
512 /* YYNRULES -- Number of rules. */
513 #define YYNRULES 35
514 /* YYNSTATES -- Number of states. */
515 #define YYNSTATES 58
516 
517 #define YYUNDEFTOK 2
518 #define YYMAXUTOK 277
519 
520 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
521  as returned by yylex, with out-of-bounds checking. */
522 #define YYTRANSLATE(YYX) \
523  ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
524 
525 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
526  as returned by yylex. */
527 static const yytype_uint8 yytranslate[] =
528 {
529  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
530  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
531  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
533  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
555  5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
556  15, 16, 17, 18, 19, 20, 21, 22
557 };
558 
559 #if YYDEBUG
560  /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
561 static const yytype_uint8 yyrline[] =
562 {
563  0, 133, 133, 142, 143, 146, 149, 152, 153, 156,
564  159, 162, 163, 166, 167, 168, 169, 170, 171, 172,
565  173, 174, 175, 176, 177, 180, 183, 193, 194, 197,
566  200, 203, 206, 209, 212, 215
567 };
568 #endif
569 
570 #if YYDEBUG || YYERROR_VERBOSE || 0
571 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
572  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
573 static const char *const yytname[] =
574 {
575  "$end", "error", "$undefined", "DEFBRK", "IFBRK", "COLON", "OCTAL",
576  "INTEGER", "IDENT", "CSR", "IRQ", "INTR", "INIT", "OPEN", "CLOSE",
577  "READ", "WRITE", "SEEK", "CONTROL", "IS", "ON", "GETC", "PUTC",
578  "$accept", "configuration", "devtypes", "devtype", "tname", "dev_tlist",
579  "theader", "tonid", "attr_list", "attr", "id", "number", "devices",
580  "device", "dheader", "dname", "devis", "devisid", "devon", "devonid", YY_NULLPTR
581 };
582 #endif
583 
584 # ifdef YYPRINT
585 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
586  (internal) symbol number NUM (which must be that of a token). */
587 static const yytype_uint16 yytoknum[] =
588 {
589  0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
590  265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
591  275, 276, 277
592 };
593 # endif
594 
595 #define YYPACT_NINF -14
596 
597 #define yypact_value_is_default(Yystate) \
598  (!!((Yystate) == (-14)))
599 
600 #define YYTABLE_NINF -1
601 
602 #define yytable_value_is_error(Yytable_value) \
603  0
604 
605  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
606  STATE-NUM. */
607 static const yytype_int8 yypact[] =
608 {
609  -14, 10, 22, -14, -14, -14, -14, 6, 16, 8,
610  -14, -14, -14, 12, 18, 8, -14, -9, 19, 13,
611  -14, -14, -14, -9, 25, 25, 26, 26, 26, 26,
612  26, 26, 26, 26, 26, 26, -14, -14, -14, 27,
613  -14, -9, -14, -14, -14, -14, -14, -14, -14, -14,
614  -14, -14, -14, -14, -14, -14, -14, -14
615 };
616 
617  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
618  Performed when YYTABLE does not specify something else to do. Zero
619  means the default is an error. */
620 static const yytype_uint8 yydefact[] =
621 {
622  3, 0, 0, 1, 27, 6, 4, 0, 2, 0,
623  31, 28, 11, 0, 0, 5, 11, 29, 0, 0,
624  10, 9, 11, 7, 0, 0, 0, 0, 0, 0,
625  0, 0, 0, 0, 0, 0, 12, 33, 32, 0,
626  30, 8, 26, 13, 14, 25, 15, 18, 16, 17,
627  21, 22, 23, 24, 19, 20, 35, 34
628 };
629 
630  /* YYPGOTO[NTERM-NUM]. */
631 static const yytype_int8 yypgoto[] =
632 {
633  -14, -14, -14, -14, -14, -14, 21, -14, 7, -14,
634  -13, 14, -14, -14, -14, -14, -14, -14, -14, -14
635 };
636 
637  /* YYDEFGOTO[NTERM-NUM]. */
638 static const yytype_int8 yydefgoto[] =
639 {
640  -1, 1, 2, 6, 7, 15, 16, 21, 17, 36,
641  46, 43, 8, 11, 12, 13, 19, 38, 40, 57
642 };
643 
644  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
645  positive, shift that token. If negative, reduce the rule whose
646  number is the opposite. If YYTABLE_NINF, syntax error. */
647 static const yytype_uint8 yytable[] =
648 {
649  24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
650  3, 9, 34, 35, 47, 48, 49, 50, 51, 52,
651  53, 54, 55, 23, 10, 4, 20, 37, 14, 41,
652  5, 18, 42, 39, 45, 56, 22, 0, 0, 44
653 };
654 
655 static const yytype_int8 yycheck[] =
656 {
657  9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
658  0, 5, 21, 22, 27, 28, 29, 30, 31, 32,
659  33, 34, 35, 16, 8, 3, 8, 8, 20, 22,
660  8, 19, 7, 20, 8, 8, 15, -1, -1, 25
661 };
662 
663  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
664  symbol of state STATE-NUM. */
665 static const yytype_uint8 yystos[] =
666 {
667  0, 24, 25, 0, 3, 8, 26, 27, 35, 5,
668  8, 36, 37, 38, 20, 28, 29, 31, 19, 39,
669  8, 30, 29, 31, 9, 10, 11, 12, 13, 14,
670  15, 16, 17, 18, 21, 22, 32, 8, 40, 20,
671  41, 31, 7, 34, 34, 8, 33, 33, 33, 33,
672  33, 33, 33, 33, 33, 33, 8, 42
673 };
674 
675  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
676 static const yytype_uint8 yyr1[] =
677 {
678  0, 23, 24, 25, 25, 26, 27, 28, 28, 29,
679  30, 31, 31, 32, 32, 32, 32, 32, 32, 32,
680  32, 32, 32, 32, 32, 33, 34, 35, 35, 36,
681  37, 38, 39, 40, 41, 42
682 };
683 
684  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
685 static const yytype_uint8 yyr2[] =
686 {
687  0, 2, 3, 0, 2, 3, 1, 2, 3, 2,
688  1, 0, 2, 2, 2, 2, 2, 2, 2, 2,
689  2, 2, 2, 2, 2, 1, 1, 0, 2, 2,
690  3, 1, 2, 1, 2, 1
691 };
692 
693 
694 #define yyerrok (yyerrstatus = 0)
695 #define yyclearin (yychar = YYEMPTY)
696 #define YYEMPTY (-2)
697 #define YYEOF 0
698 
699 #define YYACCEPT goto yyacceptlab
700 #define YYABORT goto yyabortlab
701 #define YYERROR goto yyerrorlab
702 
703 
704 #define YYRECOVERING() (!!yyerrstatus)
705 
706 #define YYBACKUP(Token, Value) \
707  do \
708  if (yychar == YYEMPTY) \
709  { \
710  yychar = (Token); \
711  yylval = (Value); \
712  YYPOPSTACK (yylen); \
713  yystate = *yyssp; \
714  goto yybackup; \
715  } \
716  else \
717  { \
718  yyerror (YY_("syntax error: cannot back up")); \
719  YYERROR; \
720  } \
721  while (0)
722 
723 /* Error token number */
724 #define YYTERROR 1
725 #define YYERRCODE 256
726 
727 
728 
729 /* Enable debugging if requested. */
730 #if YYDEBUG
731 
732 # ifndef YYFPRINTF
733 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
734 # define YYFPRINTF fprintf
735 # endif
736 
737 # define YYDPRINTF(Args) \
738 do { \
739  if (yydebug) \
740  YYFPRINTF Args; \
741 } while (0)
742 
743 /* This macro is provided for backward compatibility. */
744 #ifndef YY_LOCATION_PRINT
745 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
746 #endif
747 
748 
749 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
750 do { \
751  if (yydebug) \
752  { \
753  YYFPRINTF (stderr, "%s ", Title); \
754  yy_symbol_print (stderr, \
755  Type, Value); \
756  YYFPRINTF (stderr, "\n"); \
757  } \
758 } while (0)
759 
760 
761 /*-----------------------------------.
762 | Print this symbol's value on YYO. |
763 `-----------------------------------*/
764 
765 static void
766 yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep)
767 {
768  FILE *yyoutput = yyo;
769  YYUSE (yyoutput);
770  if (!yyvaluep)
771  return;
772 # ifdef YYPRINT
773  if (yytype < YYNTOKENS)
774  YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
775 # endif
776  YYUSE (yytype);
777 }
778 
779 
780 /*---------------------------.
781 | Print this symbol on YYO. |
782 `---------------------------*/
783 
784 static void
785 yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep)
786 {
787  YYFPRINTF (yyo, "%s %s (",
788  yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
789 
790  yy_symbol_value_print (yyo, yytype, yyvaluep);
791  YYFPRINTF (yyo, ")");
792 }
793 
794 /*------------------------------------------------------------------.
795 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
796 | TOP (included). |
797 `------------------------------------------------------------------*/
798 
799 static void
800 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
801 {
802  YYFPRINTF (stderr, "Stack now");
803  for (; yybottom <= yytop; yybottom++)
804  {
805  int yybot = *yybottom;
806  YYFPRINTF (stderr, " %d", yybot);
807  }
808  YYFPRINTF (stderr, "\n");
809 }
810 
811 # define YY_STACK_PRINT(Bottom, Top) \
812 do { \
813  if (yydebug) \
814  yy_stack_print ((Bottom), (Top)); \
815 } while (0)
816 
817 
818 /*------------------------------------------------.
819 | Report that the YYRULE is going to be reduced. |
820 `------------------------------------------------*/
821 
822 static void
823 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
824 {
825  unsigned long yylno = yyrline[yyrule];
826  int yynrhs = yyr2[yyrule];
827  int yyi;
828  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
829  yyrule - 1, yylno);
830  /* The symbols being reduced. */
831  for (yyi = 0; yyi < yynrhs; yyi++)
832  {
833  YYFPRINTF (stderr, " $%d = ", yyi + 1);
834  yy_symbol_print (stderr,
835  yystos[yyssp[yyi + 1 - yynrhs]],
836  &yyvsp[(yyi + 1) - (yynrhs)]
837  );
838  YYFPRINTF (stderr, "\n");
839  }
840 }
841 
842 # define YY_REDUCE_PRINT(Rule) \
843 do { \
844  if (yydebug) \
845  yy_reduce_print (yyssp, yyvsp, Rule); \
846 } while (0)
847 
848 /* Nonzero means print parse trace. It is left uninitialized so that
849  multiple parsers can coexist. */
850 int yydebug;
851 #else /* !YYDEBUG */
852 # define YYDPRINTF(Args)
853 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
854 # define YY_STACK_PRINT(Bottom, Top)
855 # define YY_REDUCE_PRINT(Rule)
856 #endif /* !YYDEBUG */
857 
858 
859 /* YYINITDEPTH -- initial size of the parser's stacks. */
860 #ifndef YYINITDEPTH
861 # define YYINITDEPTH 200
862 #endif
863 
864 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
865  if the built-in stack extension method is used).
866 
867  Do not make this value too large; the results are undefined if
868  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
869  evaluated with infinite-precision integer arithmetic. */
870 
871 #ifndef YYMAXDEPTH
872 # define YYMAXDEPTH 10000
873 #endif
874 
875 
876 #if YYERROR_VERBOSE
877 
878 # ifndef yystrlen
879 # if defined __GLIBC__ && defined _STRING_H
880 # define yystrlen strlen
881 # else
882 /* Return the length of YYSTR. */
883 static YYSIZE_T
884 yystrlen (const char *yystr)
885 {
886  YYSIZE_T yylen;
887  for (yylen = 0; yystr[yylen]; yylen++)
888  continue;
889  return yylen;
890 }
891 # endif
892 # endif
893 
894 # ifndef yystpcpy
895 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
896 # define yystpcpy stpcpy
897 # else
898 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
899  YYDEST. */
900 static char *
901 yystpcpy (char *yydest, const char *yysrc)
902 {
903  char *yyd = yydest;
904  const char *yys = yysrc;
905 
906  while ((*yyd++ = *yys++) != '\0')
907  continue;
908 
909  return yyd - 1;
910 }
911 # endif
912 # endif
913 
914 # ifndef yytnamerr
915 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
916  quotes and backslashes, so that it's suitable for yyerror. The
917  heuristic is that double-quoting is unnecessary unless the string
918  contains an apostrophe, a comma, or backslash (other than
919  backslash-backslash). YYSTR is taken from yytname. If YYRES is
920  null, do not copy; instead, return the length of what the result
921  would have been. */
922 static YYSIZE_T
923 yytnamerr (char *yyres, const char *yystr)
924 {
925  if (*yystr == '"')
926  {
927  YYSIZE_T yyn = 0;
928  char const *yyp = yystr;
929 
930  for (;;)
931  switch (*++yyp)
932  {
933  case '\'':
934  case ',':
935  goto do_not_strip_quotes;
936 
937  case '\\':
938  if (*++yyp != '\\')
939  goto do_not_strip_quotes;
940  else
941  goto append;
942 
943  append:
944  default:
945  if (yyres)
946  yyres[yyn] = *yyp;
947  yyn++;
948  break;
949 
950  case '"':
951  if (yyres)
952  yyres[yyn] = '\0';
953  return yyn;
954  }
955  do_not_strip_quotes: ;
956  }
957 
958  if (! yyres)
959  return yystrlen (yystr);
960 
961  return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
962 }
963 # endif
964 
965 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
966  about the unexpected token YYTOKEN for the state stack whose top is
967  YYSSP.
968 
969  Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
970  not large enough to hold the message. In that case, also set
971  *YYMSG_ALLOC to the required number of bytes. Return 2 if the
972  required number of bytes is too large to store. */
973 static int
974 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
975  yytype_int16 *yyssp, int yytoken)
976 {
977  YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
978  YYSIZE_T yysize = yysize0;
979  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
980  /* Internationalized format string. */
981  const char *yyformat = YY_NULLPTR;
982  /* Arguments of yyformat. */
983  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
984  /* Number of reported tokens (one for the "unexpected", one per
985  "expected"). */
986  int yycount = 0;
987 
988  /* There are many possibilities here to consider:
989  - If this state is a consistent state with a default action, then
990  the only way this function was invoked is if the default action
991  is an error action. In that case, don't check for expected
992  tokens because there are none.
993  - The only way there can be no lookahead present (in yychar) is if
994  this state is a consistent state with a default action. Thus,
995  detecting the absence of a lookahead is sufficient to determine
996  that there is no unexpected or expected token to report. In that
997  case, just report a simple "syntax error".
998  - Don't assume there isn't a lookahead just because this state is a
999  consistent state with a default action. There might have been a
1000  previous inconsistent state, consistent state with a non-default
1001  action, or user semantic action that manipulated yychar.
1002  - Of course, the expected token list depends on states to have
1003  correct lookahead information, and it depends on the parser not
1004  to perform extra reductions after fetching a lookahead from the
1005  scanner and before detecting a syntax error. Thus, state merging
1006  (from LALR or IELR) and default reductions corrupt the expected
1007  token list. However, the list is correct for canonical LR with
1008  one exception: it will still contain any token that will not be
1009  accepted due to an error action in a later state.
1010  */
1011  if (yytoken != YYEMPTY)
1012  {
1013  int yyn = yypact[*yyssp];
1014  yyarg[yycount++] = yytname[yytoken];
1015  if (!yypact_value_is_default (yyn))
1016  {
1017  /* Start YYX at -YYN if negative to avoid negative indexes in
1018  YYCHECK. In other words, skip the first -YYN actions for
1019  this state because they are default actions. */
1020  int yyxbegin = yyn < 0 ? -yyn : 0;
1021  /* Stay within bounds of both yycheck and yytname. */
1022  int yychecklim = YYLAST - yyn + 1;
1023  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1024  int yyx;
1025 
1026  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1027  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1028  && !yytable_value_is_error (yytable[yyx + yyn]))
1029  {
1030  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1031  {
1032  yycount = 1;
1033  yysize = yysize0;
1034  break;
1035  }
1036  yyarg[yycount++] = yytname[yyx];
1037  {
1038  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1039  if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1040  yysize = yysize1;
1041  else
1042  return 2;
1043  }
1044  }
1045  }
1046  }
1047 
1048  switch (yycount)
1049  {
1050 # define YYCASE_(N, S) \
1051  case N: \
1052  yyformat = S; \
1053  break
1054  default: /* Avoid compiler warnings. */
1055  YYCASE_(0, YY_("syntax error"));
1056  YYCASE_(1, YY_("syntax error, unexpected %s"));
1057  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1058  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1059  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1060  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1061 # undef YYCASE_
1062  }
1063 
1064  {
1065  YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1066  if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1067  yysize = yysize1;
1068  else
1069  return 2;
1070  }
1071 
1072  if (*yymsg_alloc < yysize)
1073  {
1074  *yymsg_alloc = 2 * yysize;
1075  if (! (yysize <= *yymsg_alloc
1076  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1077  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1078  return 1;
1079  }
1080 
1081  /* Avoid sprintf, as that infringes on the user's name space.
1082  Don't have undefined behavior even if the translation
1083  produced a string with the wrong number of "%s"s. */
1084  {
1085  char *yyp = *yymsg;
1086  int yyi = 0;
1087  while ((*yyp = *yyformat) != '\0')
1088  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1089  {
1090  yyp += yytnamerr (yyp, yyarg[yyi++]);
1091  yyformat += 2;
1092  }
1093  else
1094  {
1095  yyp++;
1096  yyformat++;
1097  }
1098  }
1099  return 0;
1100 }
1101 #endif /* YYERROR_VERBOSE */
1102 
1103 /*-----------------------------------------------.
1104 | Release the memory associated to this symbol. |
1105 `-----------------------------------------------*/
1106 
1107 static void
1108 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1109 {
1110  YYUSE (yyvaluep);
1111  if (!yymsg)
1112  yymsg = "Deleting";
1113  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1114 
1116  YYUSE (yytype);
1118 }
1119 
1120 
1121 
1122 
1123 /* The lookahead symbol. */
1125 
1126 /* The semantic value of the lookahead symbol. */
1128 /* Number of syntax errors so far. */
1130 
1131 
1132 /*----------.
1133 | yyparse. |
1134 `----------*/
1135 
1136 int
1137 yyparse (void)
1138 {
1139  int yystate;
1140  /* Number of tokens to shift before error messages enabled. */
1141  int yyerrstatus;
1142 
1143  /* The stacks and their tools:
1144  'yyss': related to states.
1145  'yyvs': related to semantic values.
1146 
1147  Refer to the stacks through separate pointers, to allow yyoverflow
1148  to reallocate them elsewhere. */
1149 
1150  /* The state stack. */
1151  yytype_int16 yyssa[YYINITDEPTH];
1152  yytype_int16 *yyss;
1153  yytype_int16 *yyssp;
1154 
1155  /* The semantic value stack. */
1156  YYSTYPE yyvsa[YYINITDEPTH];
1157  YYSTYPE *yyvs;
1158  YYSTYPE *yyvsp;
1159 
1160  YYSIZE_T yystacksize;
1161 
1162  int yyn;
1163  int yyresult;
1164  /* Lookahead token as an internal (translated) token number. */
1165  int yytoken = 0;
1166  /* The variables used to return semantic value and location from the
1167  action routines. */
1168  YYSTYPE yyval;
1169 
1170 #if YYERROR_VERBOSE
1171  /* Buffer for error messages, and its allocated size. */
1172  char yymsgbuf[128];
1173  char *yymsg = yymsgbuf;
1174  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1175 #endif
1176 
1177 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1178 
1179  /* The number of symbols on the RHS of the reduced rule.
1180  Keep to zero when no symbol should be popped. */
1181  int yylen = 0;
1182 
1183  yyssp = yyss = yyssa;
1184  yyvsp = yyvs = yyvsa;
1185  yystacksize = YYINITDEPTH;
1186 
1187  YYDPRINTF ((stderr, "Starting parse\n"));
1188 
1189  yystate = 0;
1190  yyerrstatus = 0;
1191  yynerrs = 0;
1192  yychar = YYEMPTY; /* Cause a token to be read. */
1193  goto yysetstate;
1194 
1195 
1196 /*------------------------------------------------------------.
1197 | yynewstate -- push a new state, which is found in yystate. |
1198 `------------------------------------------------------------*/
1199 yynewstate:
1200  /* In all cases, when you get here, the value and location stacks
1201  have just been pushed. So pushing a state here evens the stacks. */
1202  yyssp++;
1203 
1204 
1205 /*--------------------------------------------------------------------.
1206 | yynewstate -- set current state (the top of the stack) to yystate. |
1207 `--------------------------------------------------------------------*/
1208 yysetstate:
1209  *yyssp = (yytype_int16) yystate;
1210 
1211  if (yyss + yystacksize - 1 <= yyssp)
1212 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1213  goto yyexhaustedlab;
1214 #else
1215  {
1216  /* Get the current used size of the three stacks, in elements. */
1217  YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
1218 
1219 # if defined yyoverflow
1220  {
1221  /* Give user a chance to reallocate the stack. Use copies of
1222  these so that the &'s don't force the real ones into
1223  memory. */
1224  YYSTYPE *yyvs1 = yyvs;
1225  yytype_int16 *yyss1 = yyss;
1226 
1227  /* Each stack pointer address is followed by the size of the
1228  data in use in that stack, in bytes. This used to be a
1229  conditional around just the two extra args, but that might
1230  be undefined if yyoverflow is a macro. */
1231  yyoverflow (YY_("memory exhausted"),
1232  &yyss1, yysize * sizeof (*yyssp),
1233  &yyvs1, yysize * sizeof (*yyvsp),
1234  &yystacksize);
1235  yyss = yyss1;
1236  yyvs = yyvs1;
1237  }
1238 # else /* defined YYSTACK_RELOCATE */
1239  /* Extend the stack our own way. */
1240  if (YYMAXDEPTH <= yystacksize)
1241  goto yyexhaustedlab;
1242  yystacksize *= 2;
1243  if (YYMAXDEPTH < yystacksize)
1244  yystacksize = YYMAXDEPTH;
1245 
1246  {
1247  yytype_int16 *yyss1 = yyss;
1248  union yyalloc *yyptr =
1249  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1250  if (! yyptr)
1251  goto yyexhaustedlab;
1252  YYSTACK_RELOCATE (yyss_alloc, yyss);
1253  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1254 # undef YYSTACK_RELOCATE
1255  if (yyss1 != yyssa)
1256  YYSTACK_FREE (yyss1);
1257  }
1258 # endif
1259 
1260  yyssp = yyss + yysize - 1;
1261  yyvsp = yyvs + yysize - 1;
1262 
1263  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1264  (unsigned long) yystacksize));
1265 
1266  if (yyss + yystacksize - 1 <= yyssp)
1267  YYABORT;
1268  }
1269 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1270 
1271  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1272 
1273  if (yystate == YYFINAL)
1274  YYACCEPT;
1275 
1276  goto yybackup;
1277 
1278 
1279 /*-----------.
1280 | yybackup. |
1281 `-----------*/
1282 yybackup:
1283  /* Do appropriate processing given the current state. Read a
1284  lookahead token if we need one and don't already have one. */
1285 
1286  /* First try to decide what to do without reference to lookahead token. */
1287  yyn = yypact[yystate];
1288  if (yypact_value_is_default (yyn))
1289  goto yydefault;
1290 
1291  /* Not known => get a lookahead token if don't already have one. */
1292 
1293  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1294  if (yychar == YYEMPTY)
1295  {
1296  YYDPRINTF ((stderr, "Reading a token: "));
1297  yychar = yylex ();
1298  }
1299 
1300  if (yychar <= YYEOF)
1301  {
1302  yychar = yytoken = YYEOF;
1303  YYDPRINTF ((stderr, "Now at end of input.\n"));
1304  }
1305  else
1306  {
1307  yytoken = YYTRANSLATE (yychar);
1308  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1309  }
1310 
1311  /* If the proper action on seeing token YYTOKEN is to reduce or to
1312  detect an error, take that action. */
1313  yyn += yytoken;
1314  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1315  goto yydefault;
1316  yyn = yytable[yyn];
1317  if (yyn <= 0)
1318  {
1319  if (yytable_value_is_error (yyn))
1320  goto yyerrlab;
1321  yyn = -yyn;
1322  goto yyreduce;
1323  }
1324 
1325  /* Count tokens shifted since error; after three, turn off error
1326  status. */
1327  if (yyerrstatus)
1328  yyerrstatus--;
1329 
1330  /* Shift the lookahead token. */
1331  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1332 
1333  /* Discard the shifted token. */
1334  yychar = YYEMPTY;
1335 
1336  yystate = yyn;
1338  *++yyvsp = yylval;
1340 
1341  goto yynewstate;
1342 
1343 
1344 /*-----------------------------------------------------------.
1345 | yydefault -- do the default action for the current state. |
1346 `-----------------------------------------------------------*/
1347 yydefault:
1348  yyn = yydefact[yystate];
1349  if (yyn == 0)
1350  goto yyerrlab;
1351  goto yyreduce;
1352 
1353 
1354 /*-----------------------------.
1355 | yyreduce -- do a reduction. |
1356 `-----------------------------*/
1357 yyreduce:
1358  /* yyn is the number of a rule to reduce with. */
1359  yylen = yyr2[yyn];
1360 
1361  /* If YYLEN is nonzero, implement the default value of the action:
1362  '$$ = $1'.
1363 
1364  Otherwise, the following line sets YYVAL to garbage.
1365  This behavior is undocumented and Bison
1366  users should not rely upon it. Assigning to YYVAL
1367  unconditionally makes the parser a bit smaller, and it avoids a
1368  GCC warning that YYVAL may be used uninitialized. */
1369  yyval = yyvsp[1-yylen];
1370 
1371 
1372  YY_REDUCE_PRINT (yyn);
1373  switch (yyn)
1374  {
1375  case 3:
1376 #line 142 "config.y" /* yacc.c:1652 */
1377  { doing = "device definitions"; }
1378 #line 1379 "y.tab.c" /* yacc.c:1652 */
1379  break;
1380 
1381  case 6:
1382 #line 149 "config.y" /* yacc.c:1652 */
1383  { yyval = newtype(yytext); }
1384 #line 1385 "y.tab.c" /* yacc.c:1652 */
1385  break;
1386 
1387  case 9:
1388 #line 156 "config.y" /* yacc.c:1652 */
1389  { yyval = yyvsp[0]; }
1390 #line 1391 "y.tab.c" /* yacc.c:1652 */
1391  break;
1392 
1393  case 10:
1394 #line 159 "config.y" /* yacc.c:1652 */
1395  { yyval = addton(yytext); }
1396 #line 1397 "y.tab.c" /* yacc.c:1652 */
1397  break;
1398 
1399  case 13:
1400 #line 166 "config.y" /* yacc.c:1652 */
1401  { addattr(CSR, yyvsp[0]); }
1402 #line 1403 "y.tab.c" /* yacc.c:1652 */
1403  break;
1404 
1405  case 14:
1406 #line 167 "config.y" /* yacc.c:1652 */
1407  { addattr(IRQ, yyvsp[0]); }
1408 #line 1409 "y.tab.c" /* yacc.c:1652 */
1409  break;
1410 
1411  case 15:
1412 #line 168 "config.y" /* yacc.c:1652 */
1413  { addattr(INTR, 0); }
1414 #line 1415 "y.tab.c" /* yacc.c:1652 */
1415  break;
1416 
1417  case 16:
1418 #line 169 "config.y" /* yacc.c:1652 */
1419  { addattr(OPEN, 0); }
1420 #line 1421 "y.tab.c" /* yacc.c:1652 */
1421  break;
1422 
1423  case 17:
1424 #line 170 "config.y" /* yacc.c:1652 */
1425  { addattr(CLOSE, 0); }
1426 #line 1427 "y.tab.c" /* yacc.c:1652 */
1427  break;
1428 
1429  case 18:
1430 #line 171 "config.y" /* yacc.c:1652 */
1431  { addattr(INIT, 0); }
1432 #line 1433 "y.tab.c" /* yacc.c:1652 */
1433  break;
1434 
1435  case 19:
1436 #line 172 "config.y" /* yacc.c:1652 */
1437  { addattr(GETC, 0); }
1438 #line 1439 "y.tab.c" /* yacc.c:1652 */
1439  break;
1440 
1441  case 20:
1442 #line 173 "config.y" /* yacc.c:1652 */
1443  { addattr(PUTC, 0); }
1444 #line 1445 "y.tab.c" /* yacc.c:1652 */
1445  break;
1446 
1447  case 21:
1448 #line 174 "config.y" /* yacc.c:1652 */
1449  { addattr(READ, 0); }
1450 #line 1451 "y.tab.c" /* yacc.c:1652 */
1451  break;
1452 
1453  case 22:
1454 #line 175 "config.y" /* yacc.c:1652 */
1455  { addattr(WRITE, 0); }
1456 #line 1457 "y.tab.c" /* yacc.c:1652 */
1457  break;
1458 
1459  case 23:
1460 #line 176 "config.y" /* yacc.c:1652 */
1461  { addattr(SEEK, 0); }
1462 #line 1463 "y.tab.c" /* yacc.c:1652 */
1463  break;
1464 
1465  case 24:
1466 #line 177 "config.y" /* yacc.c:1652 */
1467  { addattr(CONTROL, 0); }
1468 #line 1469 "y.tab.c" /* yacc.c:1652 */
1469  break;
1470 
1471  case 25:
1472 #line 180 "config.y" /* yacc.c:1652 */
1473  { yyval = 0; getattrid(yytext); }
1474 #line 1475 "y.tab.c" /* yacc.c:1652 */
1475  break;
1476 
1477  case 26:
1478 #line 183 "config.y" /* yacc.c:1652 */
1479  { yyval = config_atoi(yytext, yyleng); }
1480 #line 1481 "y.tab.c" /* yacc.c:1652 */
1481  break;
1482 
1483  case 27:
1484 #line 193 "config.y" /* yacc.c:1652 */
1485  { doing = "interface types"; }
1486 #line 1487 "y.tab.c" /* yacc.c:1652 */
1487  break;
1488 
1489  case 31:
1490 #line 203 "config.y" /* yacc.c:1652 */
1491  { newdev(yytext); }
1492 #line 1493 "y.tab.c" /* yacc.c:1652 */
1493  break;
1494 
1495  case 33:
1496 #line 209 "config.y" /* yacc.c:1652 */
1497  { devisid(yytext); }
1498 #line 1499 "y.tab.c" /* yacc.c:1652 */
1499  break;
1500 
1501  case 35:
1502 #line 215 "config.y" /* yacc.c:1652 */
1503  { devonid(yytext); }
1504 #line 1505 "y.tab.c" /* yacc.c:1652 */
1505  break;
1506 
1507 
1508 #line 1509 "y.tab.c" /* yacc.c:1652 */
1509  default: break;
1510  }
1511  /* User semantic actions sometimes alter yychar, and that requires
1512  that yytoken be updated with the new translation. We take the
1513  approach of translating immediately before every use of yytoken.
1514  One alternative is translating here after every semantic action,
1515  but that translation would be missed if the semantic action invokes
1516  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1517  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1518  incorrect destructor might then be invoked immediately. In the
1519  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1520  to an incorrect destructor call or verbose syntax error message
1521  before the lookahead is translated. */
1522  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1523 
1524  YYPOPSTACK (yylen);
1525  yylen = 0;
1526  YY_STACK_PRINT (yyss, yyssp);
1527 
1528  *++yyvsp = yyval;
1529 
1530  /* Now 'shift' the result of the reduction. Determine what state
1531  that goes to, based on the state we popped back to and the rule
1532  number reduced by. */
1533  {
1534  const int yylhs = yyr1[yyn] - YYNTOKENS;
1535  const int yyi = yypgoto[yylhs] + *yyssp;
1536  yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1537  ? yytable[yyi]
1538  : yydefgoto[yylhs]);
1539  }
1540 
1541  goto yynewstate;
1542 
1543 
1544 /*--------------------------------------.
1545 | yyerrlab -- here on detecting error. |
1546 `--------------------------------------*/
1547 yyerrlab:
1548  /* Make sure we have latest lookahead translation. See comments at
1549  user semantic actions for why this is necessary. */
1550  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1551 
1552  /* If not already recovering from an error, report this error. */
1553  if (!yyerrstatus)
1554  {
1555  ++yynerrs;
1556 #if ! YYERROR_VERBOSE
1557  yyerror (YY_("syntax error"));
1558 #else
1559 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1560  yyssp, yytoken)
1561  {
1562  char const *yymsgp = YY_("syntax error");
1563  int yysyntax_error_status;
1564  yysyntax_error_status = YYSYNTAX_ERROR;
1565  if (yysyntax_error_status == 0)
1566  yymsgp = yymsg;
1567  else if (yysyntax_error_status == 1)
1568  {
1569  if (yymsg != yymsgbuf)
1570  YYSTACK_FREE (yymsg);
1571  yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1572  if (!yymsg)
1573  {
1574  yymsg = yymsgbuf;
1575  yymsg_alloc = sizeof yymsgbuf;
1576  yysyntax_error_status = 2;
1577  }
1578  else
1579  {
1580  yysyntax_error_status = YYSYNTAX_ERROR;
1581  yymsgp = yymsg;
1582  }
1583  }
1584  yyerror (yymsgp);
1585  if (yysyntax_error_status == 2)
1586  goto yyexhaustedlab;
1587  }
1588 # undef YYSYNTAX_ERROR
1589 #endif
1590  }
1591 
1592 
1593 
1594  if (yyerrstatus == 3)
1595  {
1596  /* If just tried and failed to reuse lookahead token after an
1597  error, discard it. */
1598 
1599  if (yychar <= YYEOF)
1600  {
1601  /* Return failure if at end of input. */
1602  if (yychar == YYEOF)
1603  YYABORT;
1604  }
1605  else
1606  {
1607  yydestruct ("Error: discarding",
1608  yytoken, &yylval);
1609  yychar = YYEMPTY;
1610  }
1611  }
1612 
1613  /* Else will try to reuse lookahead token after shifting the error
1614  token. */
1615  goto yyerrlab1;
1616 
1617 
1618 /*---------------------------------------------------.
1619 | yyerrorlab -- error raised explicitly by YYERROR. |
1620 `---------------------------------------------------*/
1621 yyerrorlab:
1622  /* Pacify compilers when the user code never invokes YYERROR and the
1623  label yyerrorlab therefore never appears in user code. */
1624  if (0)
1625  YYERROR;
1626 
1627  /* Do not reclaim the symbols of the rule whose action triggered
1628  this YYERROR. */
1629  YYPOPSTACK (yylen);
1630  yylen = 0;
1631  YY_STACK_PRINT (yyss, yyssp);
1632  yystate = *yyssp;
1633  goto yyerrlab1;
1634 
1635 
1636 /*-------------------------------------------------------------.
1637 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1638 `-------------------------------------------------------------*/
1639 yyerrlab1:
1640  yyerrstatus = 3; /* Each real token shifted decrements this. */
1641 
1642  for (;;)
1643  {
1644  yyn = yypact[yystate];
1645  if (!yypact_value_is_default (yyn))
1646  {
1647  yyn += YYTERROR;
1648  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1649  {
1650  yyn = yytable[yyn];
1651  if (0 < yyn)
1652  break;
1653  }
1654  }
1655 
1656  /* Pop the current state because it cannot handle the error token. */
1657  if (yyssp == yyss)
1658  YYABORT;
1659 
1660 
1661  yydestruct ("Error: popping",
1662  yystos[yystate], yyvsp);
1663  YYPOPSTACK (1);
1664  yystate = *yyssp;
1665  YY_STACK_PRINT (yyss, yyssp);
1666  }
1667 
1669  *++yyvsp = yylval;
1671 
1672 
1673  /* Shift the error token. */
1674  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1675 
1676  yystate = yyn;
1677  goto yynewstate;
1678 
1679 
1680 /*-------------------------------------.
1681 | yyacceptlab -- YYACCEPT comes here. |
1682 `-------------------------------------*/
1683 yyacceptlab:
1684  yyresult = 0;
1685  goto yyreturn;
1686 
1687 
1688 /*-----------------------------------.
1689 | yyabortlab -- YYABORT comes here. |
1690 `-----------------------------------*/
1691 yyabortlab:
1692  yyresult = 1;
1693  goto yyreturn;
1694 
1695 
1696 #if !defined yyoverflow || YYERROR_VERBOSE
1697 /*-------------------------------------------------.
1698 | yyexhaustedlab -- memory exhaustion comes here. |
1699 `-------------------------------------------------*/
1700 yyexhaustedlab:
1701  yyerror (YY_("memory exhausted"));
1702  yyresult = 2;
1703  /* Fall through. */
1704 #endif
1705 
1706 
1707 /*-----------------------------------------------------.
1708 | yyreturn -- parsing is finished, return the result. |
1709 `-----------------------------------------------------*/
1710 yyreturn:
1711  if (yychar != YYEMPTY)
1712  {
1713  /* Make sure we have latest lookahead translation. See comments at
1714  user semantic actions for why this is necessary. */
1715  yytoken = YYTRANSLATE (yychar);
1716  yydestruct ("Cleanup: discarding lookahead",
1717  yytoken, &yylval);
1718  }
1719  /* Do not reclaim the symbols of the rule whose action triggered
1720  this YYABORT or YYACCEPT. */
1721  YYPOPSTACK (yylen);
1722  YY_STACK_PRINT (yyss, yyssp);
1723  while (yyssp != yyss)
1724  {
1725  yydestruct ("Cleanup: popping",
1726  yystos[*yyssp], yyvsp);
1727  YYPOPSTACK (1);
1728  }
1729 #ifndef yyoverflow
1730  if (yyss != yyssa)
1731  YYSTACK_FREE (yyss);
1732 #endif
1733 #if YYERROR_VERBOSE
1734  if (yymsg != yymsgbuf)
1735  YYSTACK_FREE (yymsg);
1736 #endif
1737  return yyresult;
1738 }
1739 #line 218 "config.y" /* yacc.c:1918 */
1740 
1741 
1742 #include "lex.yy.c"
1743 
1744 
1745 /************************************************************************/
1746 /* */
1747 /* main - main program: parse arguments, invoke the parser, and */
1748 /* write the conf.h and conf.c files */
1749 /* */
1750 /************************************************************************/
1751 
1752 
1753 int main(int argc, char **argv) {
1754  int n, i, j, l, fcount;
1755  struct dev_ent *s;
1756  int verbose = 0;
1757  char *p;
1758  int c;
1759 
1760  if ( argc > 1 && (strncmp("-v", argv[1], 2) == 0) ) {
1761  argc--;
1762  argv++;
1763  verbose++;
1764  }
1765 
1766  if ( argc > 4 ) {
1767  fprintf(stderr, "use: config [-v] [input_file] [conf.c] [conf.h]\n");
1768  exit(1);
1769  }
1770 
1771  if (verbose) { printf("Opening input file...\n"); }
1772 
1773  if (argc >= 2) {
1774  if (freopen(argv[1], "r", stdin) == NULL) {
1775  fprintf(stderr, "Can't open %s\n", argv[1]);
1776  exit(1);
1777  }
1778  }
1779  else { /* try to open Configuration file */
1780  if (freopen(INFILE, "r", stdin) == NULL) {
1781  fprintf(stderr, "Can't open %s\n", INFILE);
1782  exit(1);
1783  }
1784  }
1785 
1786  /****************************************************************/
1787  /* */
1788  /* Parse the Configuration file */
1789  /* */
1790  /****************************************************************/
1791 
1792 
1793  if (verbose) { printf("Parsing configuration specs...\n"); }
1794 
1795  if ( (n = yyparse()) != 0 ) { exit(n); }
1796 
1797  /* Open conf.h and conf.c for writing */
1798 
1799  if (verbose) { printf("Opening output files...\n"); }
1800 
1801  if (argc >= 3) {
1802  if ( (confc = fopen(argv[2],"w") ) == NULL) {
1803  fprintf(stderr, "Can't write on %s\n", argv[2]);
1804  exit(1);
1805  }
1806  }
1807  else { /* try to open conf.c file */
1808  if ( (confc = fopen(CONFC,"w") ) == NULL) {
1809  fprintf(stderr, "Can't write on %s\n", CONFC);
1810  exit(1);
1811  }
1812  }
1813 
1814  if (argc >= 4) {
1815  if ( (confh = fopen(argv[3],"w") ) == NULL) {
1816  fprintf(stderr, "Can't write on %s\n", argv[3]);
1817  exit(1);
1818  }
1819  }
1820  else { /* try to open conf.h file */
1821  if ( (confh = fopen(CONFH,"w") ) == NULL) {
1822  fprintf(stderr, "Can't write on %s\n", CONFH);
1823  exit(1);
1824  }
1825  }
1826 
1827  /****************************************************************/
1828  /* */
1829  /* produce conf.h */
1830  /* */
1831  /****************************************************************/
1832 
1833 
1834  fprintf(confh, "/* conf.h (GENERATED FILE; DO NOT EDIT) */\n\n");
1835 
1836  if (verbose) { printf("Writing output...\n"); }
1837 
1838  fprintf(confh, "/* Device switch table declarations */\n\n");
1839 
1840  for (i = 0; (p = devstab[i]) != NULL; i++) {
1841  fprintf(confh, "%s\n", p);
1842  }
1843 
1844  fprintf(confh, "\n");
1845 
1846  /* write device declarations and definitions */
1847 
1848  fprintf(confh, "/* Device name definitions */\n\n");
1849  for (i = 0; i<ndevs; i++) {
1850  s = &devs[i];
1851  fprintf(confh, "#define %-20s%2d\t/* type %-8s */\n",
1852  s->name, i, s->tname);
1853  }
1854  fprintf(confh, "\n");
1855 
1856  /* write count of device types */
1857 
1858  fprintf(confh, "/* Control block sizes */\n\n");
1859  for (i = 0; i < ntypes; i++) {
1860  s = &dtypes[i];
1861  if (s->minor > 0) {
1862  fprintf(confh, "#define\tN%s\t%d\n",
1863  s->tname, s->minor);
1864  }
1865  }
1866 
1867  fprintf(confh, "\n");
1868 
1869  if (ndevs > 0) { fprintf(confh, "#define NDEVS %d\n", ndevs); }
1870 
1871  /* Copy definitions to output */
1872 
1873  if (brkcount >= 4 && verbose) {
1874  printf("Copying definitions to %s...\n", CONFH);
1875  }
1876 
1877  if (brkcount >= 2) {
1878  while ( (c = input()) > 0) { /* lex input function */
1879  putc(c, confh);
1880  }
1881  }
1882  fclose(confh);
1883 
1884 
1885  /****************************************************************/
1886  /* */
1887  /* produce conf.c */
1888  /* */
1889  /****************************************************************/
1890 
1891 
1892  fprintf(confc, "/* conf.c (GENERATED FILE; DO NOT EDIT) */\n\n");
1893  fprintf(confc, "#include <xinu.h>\n\n");
1894  fprintf(confc, "\n");
1895 
1896  fprintf(confc, "extern\tdevcall\tioerr(void);\n");
1897  fprintf(confc, "extern\tdevcall\tionull(void);\n\n");
1898 
1899  /* produce devtab (giant I/O switch table) */
1900  fprintf(confc, "/* Device independent I/O switch */\n\n");
1901  if (ndevs > 0)
1902  {
1903  fprintf(confc, "struct dentry devtab[NDEVS] =\n{\n");
1904  fprintf(confc, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n\n",
1905  "/**",
1906  " * Format of entries is:",
1907  " * dev-number, minor-number, dev-name,",
1908  " * init, open, close,",
1909  " * read, write, seek,",
1910  " * getc, putc, control,",
1911  " * dev-csr-address, intr-handler, irq",
1912  " */");
1913  }
1914 
1915  for (i=0; i<ndevs; i++) {
1916  s = &devs[i];
1917  fprintf(confc, "/* %s is %s */\n", s->name, s->tname);
1918  fprintf(confc, "\t{ %d, %d, \"%s\",\n", i, s->minor, s->name);
1919  fprintf(confc, "\t (void *)%s, (void *)%s, (void *)%s,\n",
1920  s->init, s->open, s->close);
1921  fprintf(confc, "\t (void *)%s, (void *)%s, (void *)%s,\n",
1922  s->read, s->write, s->seek);
1923  fprintf(confc, "\t (void *)%s, (void *)%s, (void *)%s,\n",
1924  s->getc, s->putc, s->control);
1925  fprintf(confc, "\t (void *)0x%x, (void *)%s, %d }",
1926  s->csr, s->intr, s->irq);
1927  if (i< ndevs-1) {
1928  fprintf(confc, ",\n\n");
1929  } else {
1930  fprintf(confc, "\n};");
1931  }
1932  }
1933 
1934  /* we must guarantee conf.c written later than conf.h for make */
1935  fprintf(confc, "\n");
1936  fclose(confc);
1937 
1938  /* finish up and write report for user if requested */
1939  if (verbose) {
1940  printf("Configuration complete. Number of devs=%d:\n", ndevs);
1941  for (i=0; i<ndevs; i++) {
1942  s = &devs[i];
1943  printf("Device %s (on %s)\n", s->name, s->ison);
1944  printf(" csr=0x%04x, irq=0x%04x, minor=%d\n",
1945  s->csr, s->irq, s->minor);
1946  }
1947  }
1948 }
1949 
1950 /************************************************************************/
1951 /* */
1952 /* addattr - add a new attribute spec to current type/device description*/
1953 /* tok: token type (attribute type) */
1954 /* val: symbol number of value */
1955 /* */
1956 /************************************************************************/
1957 
1958 void addattr(int tok, int val) {
1959  struct dev_ent *s;
1960  char *c;
1961 
1962  if (brkcount == 0) {
1963  /* Doing types */
1964  s = &dtypes[ntypes-1];
1965  } else {
1966  /* Doing devices */
1967  s = &devs[ndevs-1];
1968  }
1969 
1970  switch (tok) {
1971  case CSR: s->csr = val; break;
1972  case IRQ: s->irq = val; break;
1973  case INTR: strcpy(s->intr, saveattrid); break;
1974  case READ: strcpy(s->read, saveattrid); break;
1975  case WRITE: strcpy(s->write,saveattrid); break;
1976  case GETC: strcpy(s->getc, saveattrid); break;
1977  case PUTC: strcpy(s->putc, saveattrid); break;
1978  case OPEN: strcpy(s->open, saveattrid); break;
1979  case CLOSE: strcpy(s->close,saveattrid); break;
1980  case INIT: strcpy(s->init, saveattrid); break;
1981  case SEEK: strcpy(s->seek, saveattrid); break;
1982  case CONTROL: strcpy(s->control,saveattrid); break;
1983  default: fprintf(stderr, "Internal error 1\n");
1984  }
1985 }
1986 
1987 
1988 /************************************************************************/
1989 /* */
1990 /* addton -- add an "on XXX" to the current type */
1991 /* */
1992 /************************************************************************/
1993 
1994 int addton(char *tonid) {
1995  int currtype; /* The current type */
1996 
1997  if (strlen(tonid) >= MAXNAME) {
1998  fprintf(stderr,"string %s is too long on line %d\n",
1999  tonid, linectr);
2000  exit(1);
2001  }
2002  currtype = ntypes - 1;
2003  strcpy(dtypes[currtype].ison, tonid);
2004 
2005  return currtype;
2006 }
2007 
2008 
2009 /************************************************************************/
2010 /* */
2011 /* config_atoi - convert an ascii string of text to an integer, */
2012 /* honoring octal, decimal, and hex */
2013 /* */
2014 /************************************************************************/
2015 
2016 int config_atoi(char *p, int len) {
2017  int base, rv;
2018 
2019  if (*p == '0')
2020  {
2021  ++p;
2022  --len;
2023  if (*p == 'x' || *p == 'X')
2024  {
2025  ++p; --len; /* skip 'x' */
2026  base = 16;
2027  }
2028  else
2029  {
2030  base = 8;
2031  }
2032  }
2033  else
2034  {
2035  base = 10;
2036  }
2037 
2038  rv = 0;
2039  for (; len > 0; ++p, --len)
2040  {
2041  rv *= base;
2042  if (isdigit(*p)) { rv += *p - '0'; }
2043  else if (isupper(*p)) { rv += *p - 'A' + 10; }
2044  else { rv += *p - 'a' + 10; }
2045  }
2046 
2047  return rv;
2048 }
2049 
2050 /************************************************************************/
2051 /* */
2052 /* devisid -- add an "is XXX" to the current device */
2053 /* */
2054 /************************************************************************/
2055 
2056 void devisid(char *tname) {
2057  int currdev; /* The current device */
2058  int i;
2059 
2060  if (strlen(tname) >= MAXNAME) {
2061  fprintf(stderr,"string %s is too long on line %d\n",
2062  tname, linectr);
2063  exit(1);
2064  }
2065  /* Verify the type exists */
2066 
2067  for (i=0; i<ntypes; i++) {
2068  if (strcmp(tname, dtypes[i].tname) == 0) {
2069  break;
2070  }
2071  }
2072  if (i >= ntypes) {
2073  fprintf(stderr, "Illegal type name %s on line %d\n",
2074  tname, linectr);
2075  exit(1);
2076  }
2077  currdev = ndevs - 1;
2078  strcpy(devs[currdev].tname, tname);
2079 
2080  return;
2081 }
2082 
2083 
2084 /************************************************************************/
2085 /* */
2086 /* devonid -- add an "on XXX" to the current device, lookup the type, */
2087 /* and copy attributes into the device from the type */
2088 /* */
2089 /************************************************************************/
2090 
2091 void devonid(char *onname) {
2092  int currdev; /* The current device */
2093  int i;
2094  struct dev_ent *dptr; /* Pointer to current device */
2095  struct dev_ent *tptr; /* Pointer to a type */
2096  char tmp[MAXNAME]; /* Holds the device name during */
2097  /* copy */
2098 
2099  if (strlen(onname) >= MAXNAME) {
2100  fprintf(stderr,"string %s is too long on line %d\n",
2101  onname, linectr);
2102  exit(1);
2103  }
2104  if (ndevs <=0) {
2105  fprintf(stderr,"Internal error 3\n");
2106  exit(1);
2107  }
2108  currdev = ndevs - 1;
2109  dptr = &devs[currdev];
2110 
2111  strcpy(dptr->ison, onname);
2112 
2113  /* Lookup the device type */
2114 
2115  for (i=0; i<ntypes; i++) {
2116  tptr = &dtypes[i];
2117  if ( (strcmp(dptr->tname,tptr->tname) == 0 ) &&
2118  (strcmp(dptr->ison, tptr->ison) == 0 ) ){
2119 
2120  /* The specified type matches the ith entry, so */
2121  /* set all attributes equal to the ones in the */
2122  /* type definition. */
2123 
2124  strcpy(tmp, dptr->name);
2125  bcopy (tptr, dptr, sizeof(struct dev_ent));
2126  /* Increment the minor device number for the */
2127  /* next time the type is used */
2128  tptr->minor++;
2129  strcpy(dptr->name, tmp);
2130  return;
2131  }
2132  }
2133 
2134  fprintf(stderr, "Ileagal device specification on line %d\n", linectr);
2135  exit(1);
2136 }
2137 
2138 
2139 /************************************************************************/
2140 /* */
2141 /* getattrid -- pick up and save the attribute string from an id */
2142 /* */
2143 /************************************************************************/
2144 
2145 void getattrid(char *str) {
2146 
2147  if (strlen(str) >= MAXNAME) {
2148  fprintf(stderr,"atribute string %s is too long on line %d\n",
2149  str, linectr);
2150  exit(1);
2151  }
2152  strcpy(saveattrid, str);
2153  return;
2154 }
2155 
2156 
2157 /************************************************************************/
2158 /* */
2159 /* newdev -- allocate an entry in devs, initialize, and fill in the name*/
2160 /* */
2161 /************************************************************************/
2162 
2163 void newdev(char *name) {
2164 
2165  struct dev_ent *dptr; /* Ptr. to an entry in devs */
2166  int i;
2167 
2168  if (ndevs >= NDEVS) {
2169  fprintf(stderr,"Too many devices on line %d", linectr);
2170  exit(1);
2171  }
2172  if (strlen(name) >= MAXNAME) {
2173  fprintf(stderr,"Device name %s is too long on line %d\n",
2174  name, linectr);
2175  exit(1);
2176  }
2177 
2178  /* Verify that the device name is unique */
2179 
2180  for (i=0; i<ndevs; i++) {
2181  if (strcmp(name, devs[i].name) == 0) {
2182  fprintf(stderr, "Duplicate device name %s on line %d\n",
2183  name, linectr);
2184  exit(1);
2185  }
2186  }
2187 
2188  dptr = &devs[ndevs];
2189 
2190  /* Initialize fields in the entry */
2191 
2192  bzero((void *)dptr, sizeof(struct dev_ent));
2193  strcpy(dptr->name, name);
2194  ndevs++;
2195  return;
2196 }
2197 
2198 
2199 /************************************************************************/
2200 /* */
2201 /* newtype -- allocate an entry in the type array and fill in the name */
2202 /* */
2203 /************************************************************************/
2204 
2205 int newtype(char *name) {
2206 
2207  struct dev_ent *dptr; /* Ptr. to an entry in dtypes */
2208  int i; /* Index into the type table */
2209 
2210  if (ntypes >= NTYPES) {
2211  fprintf(stderr,"Too many types on line %d", linectr);
2212  exit(1);
2213  }
2214  if (strlen(name) >= MAXNAME) {
2215  fprintf(stderr,"Type name %s is too long on line %d\n",
2216  name, linectr);
2217  exit(1);
2218  }
2219 
2220  /* Verify that the type name is unique */
2221 
2222  for (i=0; i<ntypes; i++) {
2223  if (strcmp(name, dtypes[i].tname) == 0) {
2224  fprintf(stderr, "Duplicate type name %s on line %d\n",
2225  name, linectr);
2226  exit(1);
2227  }
2228  }
2229 
2230  dptr = &dtypes[ntypes];
2231 
2232  /* Initialize fields in the entry */
2233 
2234  bzero((void *)dptr, sizeof(struct dev_ent));
2235  strcpy(dptr->tname, name);
2236  strncpy(dptr->intr, "ioerr", 5);
2237  strncpy(dptr->init, "ioerr", 5);
2238  strncpy(dptr->open, "ioerr", 5);
2239  strncpy(dptr->close, "ioerr", 5);
2240  strncpy(dptr->read, "ioerr", 5);
2241  strncpy(dptr->write, "ioerr", 5);
2242  strncpy(dptr->control, "ioerr", 5);
2243  strncpy(dptr->seek, "ioerr", 5);
2244  strncpy(dptr->getc, "ioerr", 5);
2245  strncpy(dptr->putc, "ioerr", 5);
2246 
2247  return ntypes++;
2248 }
2249 
2250 
2251 /************************************************************************/
2252 /* */
2253 /* yyerror - print an error message with the line number */
2254 /* */
2255 /************************************************************************/
2256 
2257 void yyerror(char *s) {
2258 
2259  fprintf(stderr, "Syntax error in %s on line %d\n", doing, linectr);
2260 }
static const yytype_uint8 yystos[]
Definition: y.tab.c:665
yytokentype
Definition: y.tab.c:213
#define NULL
連結リスト用のNULLポインタ
Definition: kernel.h:68
#define YYPOPSTACK(N)
#define YYEMPTY
Definition: y.tab.c:696
short yytype_int16
Definition: y.tab.c:300
static const yytype_uint8 yytable[]
Definition: y.tab.c:647
#define GETC
Definition: y.tab.c:256
#define YYSIZE_T
Definition: y.tab.c:310
#define INFILE
Definition: y.tab.c:94
#define CSR
Definition: y.tab.c:244
int32 strncmp(const char *, const char *, int32)
char * strncpy(char *, const char *, int32)
文字列s1に文字列s2をN文字(Byte)分コピーする。
Definition: strncpy.c:15
#define YYSTACK_ALLOC_MAXIMUM
Definition: y.tab.c:417
#define YY_IGNORE_MAYBE_UNINITIALIZED_END
Definition: y.tab.c:368
FILE * confc
Definition: y.tab.c:102
int YYSTYPE
Definition: y.tab.c:261
#define YYUSE(E)
Definition: y.tab.c:350
#define INIT
Definition: y.tab.c:247
char open[MAXNAME]
Definition: y.tab.c:118
#define INTR
Definition: y.tab.c:246
static const yytype_int8 yycheck[]
Definition: y.tab.c:655
char name[MAXNAME]
Definition: y.tab.c:110
#define CONFC
Definition: y.tab.c:91
#define YYDPRINTF(Args)
Definition: y.tab.c:852
#define isdigit(c)
文字が10進数の数字かどうかをチェックするマクロ
Definition: ctype.h:78
void addattr(int, int)
Definition: y.tab.c:1958
#define READ
Definition: y.tab.c:250
#define OPEN
Definition: y.tab.c:248
int csr
Definition: y.tab.c:114
int irq
Definition: y.tab.c:115
#define YY_NULLPTR
Definition: y.tab.c:189
#define stderr
Definition: stdio.h:17
#define OCTAL
Definition: y.tab.c:241
char seek[MAXNAME]
Definition: y.tab.c:123
#define isupper(c)
文字がアルファベットの大文字かどうかをチェックするマクロ
Definition: ctype.h:62
「文字種類の判定」や「文字変換」を行う関数マクロを提供する。
int strlen(char *str)
NULL終端された文字列の長さを返す。NULL終端は長さに含まない。
Definition: strlen.c:11
#define YYSTACK_BYTES(N)
Definition: y.tab.c:459
int ntypes
Definition: y.tab.c:132
static int input(void)
#define YYSTACK_FREE
Definition: y.tab.c:415
#define YYMAXDEPTH
Definition: y.tab.c:872
static const yytype_uint8 yytranslate[]
Definition: y.tab.c:527
int ndevs
Definition: y.tab.c:135
char write[MAXNAME]
Definition: y.tab.c:121
unsigned char yytype_uint8
Definition: y.tab.c:282
#define YYFINAL
Definition: y.tab.c:504
int32 printf(const char *,...)
Definition: printf.c:13
char ison[MAXNAME]
Definition: y.tab.c:112
Definition: y.tab.c:109
void newdev(char *)
Definition: y.tab.c:2163
int minor
Definition: y.tab.c:126
static const yytype_int8 yydefgoto[]
Definition: y.tab.c:638
signed char yytype_int8
Definition: y.tab.c:288
#define YY_(Msgid)
Definition: y.tab.c:326
void exit(void)
現在実行中のプロセスを終了させる。
Definition: exit.c:11
YYSTYPE yylval
Definition: y.tab.c:1127
int addton(char *)
Definition: y.tab.c:1994
char getc[MAXNAME]
Definition: y.tab.c:124
int config_atoi(char *, int)
Definition: y.tab.c:2016
unsigned short yytype_uint16
Definition: y.tab.c:294
int yyleng
#define YYINITDEPTH
Definition: y.tab.c:861
void yyerror(char *)
Definition: y.tab.c:2257
int linectr
Definition: y.tab.c:100
#define YYERROR
Definition: y.tab.c:701
int yychar
Definition: y.tab.c:1124
#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Definition: y.tab.c:367
int main(int argc, char **argv)
Definition: y.tab.c:1753
#define ON
Definition: y.tab.c:255
yytype_int16 yyss_alloc
Definition: y.tab.c:450
void * malloc(YYSIZE_T)
#define IFBRK
Definition: y.tab.c:239
#define MAXNAME
Definition: y.tab.c:95
#define SEEK
Definition: y.tab.c:252
char intr[MAXNAME]
Definition: y.tab.c:116
YYSTYPE yyvs_alloc
Definition: y.tab.c:451
int yyparse(void)
Definition: y.tab.c:1137
#define YY_REDUCE_PRINT(Rule)
Definition: y.tab.c:855
char init[MAXNAME]
Definition: y.tab.c:117
関数の返り値に関する定義
#define YYTERROR
Definition: y.tab.c:724
static const yytype_uint8 yydefact[]
Definition: y.tab.c:620
void devisid(char *)
Definition: y.tab.c:2056
#define IRQ
Definition: y.tab.c:245
char tname[MAXNAME]
Definition: y.tab.c:111
char saveattrid[MAXNAME]
Definition: y.tab.c:160
int yylex(void)
char * devstab[]
Definition: y.tab.c:137
char * doing
Definition: y.tab.c:107
#define CLOSE
Definition: y.tab.c:249
static const yytype_uint8 yyr1[]
Definition: y.tab.c:676
#define INTEGER
Definition: y.tab.c:242
#define YYACCEPT
Definition: y.tab.c:699
char read[MAXNAME]
Definition: y.tab.c:120
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
Definition: y.tab.c:470
#define CONFH
Definition: y.tab.c:92
flexにより生成された字句解析
Definition: y.tab.c:448
static const yytype_int8 yypgoto[]
Definition: y.tab.c:631
int brkcount
Definition: y.tab.c:105
FILE * confh
Definition: y.tab.c:103
#define stdin
Definition: stdio.h:15
char putc[MAXNAME]
Definition: y.tab.c:125
#define YY_STACK_PRINT(Bottom, Top)
Definition: y.tab.c:854
void devonid(char *)
Definition: y.tab.c:2091
int newtype(char *)
Definition: y.tab.c:2205
#define YYNTOKENS
Definition: y.tab.c:509
#define YYEOF
Definition: y.tab.c:697
int strcpy(char *tar, char *src)
文字列Aに文字列B(NULL終端を含めて)をコピーする。
Definition: strcpy.c:12
#define yypact_value_is_default(Yystate)
Definition: y.tab.c:597
char close[MAXNAME]
Definition: y.tab.c:119
char control[MAXNAME]
Definition: y.tab.c:122
#define COLON
Definition: y.tab.c:240
#define NDEVS
Definition: y.tab.c:97
void getattrid(char *)
Definition: y.tab.c:2145
#define YYSTACK_ALLOC
Definition: y.tab.c:414
char * yytext
void free(void *)
void bzero(void *, int)
Byteブロック領域の先頭N bytesを数値ゼロで埋める。
Definition: bzero.c:12
#define IDENT
Definition: y.tab.c:243
#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
Definition: y.tab.c:853
#define YYLAST
Definition: y.tab.c:506
#define CONTROL
Definition: y.tab.c:253
int32 fprintf(int, char *,...)
Definition: fprintf.c:14
static const yytype_uint8 yyr2[]
Definition: y.tab.c:685
#define WRITE
Definition: y.tab.c:251
static void yydestruct(const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Definition: y.tab.c:1108
#define DEFBRK
Definition: y.tab.c:238
int yynerrs
Definition: y.tab.c:1129
int tindex
Definition: y.tab.c:113
#define IS
Definition: y.tab.c:254
#define yytable_value_is_error(Yytable_value)
Definition: y.tab.c:602
#define YYABORT
Definition: y.tab.c:700
static const yytype_int8 yypact[]
Definition: y.tab.c:607
struct dev_ent dtypes[NTYPES]
Definition: y.tab.c:131
struct dev_ent devs[NDEVS]
Definition: y.tab.c:134
int strcmp(char *str1, char *str2)
二つの文字列を比較し、その結果を返す。
Definition: strcmp.c:12
#define NTYPES
Definition: y.tab.c:98
#define YYTRANSLATE(YYX)
Definition: y.tab.c:522
#define PUTC
Definition: y.tab.c:257