The Pedigree Project 0.1
parser.c
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20/* A Bison parser, made by GNU Bison 2.4.1. */
21
22/* Skeleton implementation for Bison's Yacc-like parsers in C
23
24 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
25 Free Software Foundation, Inc.
26
27 This program is free software: you can redistribute it and/or modify
28 it under the terms of the GNU General Public License as published by
29 the Free Software Foundation, either version 3 of the License, or
30 (at your option) any later version.
31
32 This program is distributed in the hope that it will be useful,
33 but WITHOUT ANY WARRANTY; without even the implied warranty of
34 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 GNU General Public License for more details.
36
37 You should have received a copy of the GNU General Public License
38 along with this program. If not, see <http://www.gnu.org/licenses/>. */
39
40/* As a special exception, you may create a larger work that contains
41 part or all of the Bison parser skeleton and distribute that work
42 under terms of your choice, so long as that work isn't itself a
43 parser generator using the skeleton or a modified version thereof
44 as a parser skeleton. Alternatively, if you modify or redistribute
45 the parser skeleton itself, you may (at your option) remove this
46 special exception, which will cause the skeleton and the resulting
47 Bison output files to be licensed under the GNU General Public
48 License without this special exception.
49
50 This special exception was added by the Free Software Foundation in
51 version 2.2 of Bison. */
52
53/* C LALR(1) parser skeleton written by Richard Stallman, by
54 simplifying the original so-called "semantic" parser. */
55
56/* All symbols defined below should begin with yy or YY, to avoid
57 infringing on user name space. This should be done even for local
58 variables, as they might otherwise be expanded by user macros.
59 There are some unavoidable exceptions within include files to
60 define necessary library symbols; they are noted "INFRINGES ON
61 USER NAME SPACE" below. */
62
63/* Identify Bison output. */
64#define YYBISON 1
65
66/* Bison version. */
67#define YYBISON_VERSION "2.4.1"
68
69/* Skeleton name. */
70#define YYSKELETON_NAME "yacc.c"
71
72/* Pure parsers. */
73#define YYPURE 0
74
75/* Push parsers. */
76#define YYPUSH 0
77
78/* Pull parsers. */
79#define YYPULL 1
80
81/* Using locations. */
82#define YYLSP_NEEDED 0
83
84/* Copy the first part of user declarations. */
85
86/* Line 189 of yacc.c */
87#line 1 "parser.y"
88
89#include <stdio.h>
90#include <stdlib.h>
91#include <string.h>
92#include <unistd.h>
93
94#include "cmd.h"
95
96extern int yylex(void);
97extern int yyerror(const char*);
98
99extern cmd_t* cmds[MAX_CMDS];
100extern int n_cmds;
101
102struct cmd_list {
103 struct cmd* cmd;
104 struct cmd_list* next;
105};
106
107char* quote_char(char c);
108void combine_strings(char* dest, const char* head, const char* tail);
109cmd_t* make_cmd(unsigned int scancode, unsigned int upoint, char* val);
110void set_cmds(unsigned int scancode, struct cmd_list* cl);
111struct cmd_list* add_to_cmd_list(struct cmd_list* cl, cmd_t* c);
112
113void add_define(char* str, int n);
114int lookup_define(char* str);
115
116/* Line 189 of yacc.c */
117#line 103 "parser.c"
118
119/* Enabling traces. */
120#ifndef YYDEBUG
121#define YYDEBUG 0
122#endif
123
124/* Enabling verbose error messages. */
125#ifdef YYERROR_VERBOSE
126#undef YYERROR_VERBOSE
127#define YYERROR_VERBOSE 1
128#else
129#define YYERROR_VERBOSE 0
130#endif
131
132/* Enabling the token table. */
133#ifndef YYTOKEN_TABLE
134#define YYTOKEN_TABLE 0
135#endif
136
137/* Tokens. */
138#ifndef YYTOKENTYPE
139#define YYTOKENTYPE
140/* Put the tokens into the symbol table, so that GDB and other debuggers
141 know about them. */
142enum yytokentype {
143 NEWLINE = 258,
144 QUOTE = 259,
145 STRING = 260,
146 CTRL = 261,
147 SHIFT = 262,
148 ALT = 263,
149 ALTGR = 264,
150 CTRL_SHIFT = 265,
151 SHIFT_ALT = 266,
152 CTRL_ALT = 267,
153 CTRL_SHIFT_ALT = 268,
154 SHIFT_ALTGR = 269,
155 CTRL_ALTGR = 270,
156 CTRL_SHIFT_ALTGR = 271,
157 SET_COMBINE = 272,
158 COMBINE = 273,
159 OPEN_SQ = 274,
160 CLOSE_SQ = 275,
161 DEFINE = 276,
162 QUOTED_CHAR = 277,
163 CODE_POINT = 278,
164 NUM = 279,
165 ERROR = 280,
166 END = 281
167};
168#endif
169/* Tokens. */
170#define NEWLINE 258
171#define QUOTE 259
172#define STRING 260
173#define CTRL 261
174#define SHIFT 262
175#define ALT 263
176#define ALTGR 264
177#define CTRL_SHIFT 265
178#define SHIFT_ALT 266
179#define CTRL_ALT 267
180#define CTRL_SHIFT_ALT 268
181#define SHIFT_ALTGR 269
182#define CTRL_ALTGR 270
183#define CTRL_SHIFT_ALTGR 271
184#define SET_COMBINE 272
185#define COMBINE 273
186#define OPEN_SQ 274
187#define CLOSE_SQ 275
188#define DEFINE 276
189#define QUOTED_CHAR 277
190#define CODE_POINT 278
191#define NUM 279
192#define ERROR 280
193#define END 281
194
195#if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED
196typedef union YYSTYPE {
197/* Line 214 of yacc.c */
198#line 31 "parser.y"
199
200 int n;
201 char str[256];
202 char c;
203 struct cmd* cmd;
204 struct cmd_list* cmd_list;
205
206/* Line 214 of yacc.c */
207#line 201 "parser.c"
208} YYSTYPE;
209#define YYSTYPE_IS_TRIVIAL 1
210#define yystype YYSTYPE /* obsolescent; will be withdrawn */
211#define YYSTYPE_IS_DECLARED 1
212#endif
213
214/* Copy the second part of user declarations. */
215
216/* Line 264 of yacc.c */
217#line 213 "parser.c"
218
219#ifdef short
220#undef short
221#endif
222
223#ifdef YYTYPE_UINT8
224typedef YYTYPE_UINT8 yytype_uint8;
225#else
226typedef unsigned char yytype_uint8;
227#endif
228
229#ifdef YYTYPE_INT8
230typedef YYTYPE_INT8 yytype_int8;
231#elif (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
232typedef signed char yytype_int8;
233#else
234typedef short int yytype_int8;
235#endif
236
237#ifdef YYTYPE_UINT16
238typedef YYTYPE_UINT16 yytype_uint16;
239#else
240typedef unsigned short int yytype_uint16;
241#endif
242
243#ifdef YYTYPE_INT16
244typedef YYTYPE_INT16 yytype_int16;
245#else
246typedef short int yytype_int16;
247#endif
248
249#ifndef YYSIZE_T
250#ifdef __SIZE_TYPE__
251#define YYSIZE_T __SIZE_TYPE__
252#elif defined size_t
253#define YYSIZE_T size_t
254#elif !defined YYSIZE_T && \
255 (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
256#include <stddef.h> /* INFRINGES ON USER NAME SPACE */
257#define YYSIZE_T size_t
258#else
259#define YYSIZE_T unsigned int
260#endif
261#endif
262
263#define YYSIZE_MAXIMUM ((YYSIZE_T) - 1)
264
265#ifndef YY_
266#if YYENABLE_NLS
267#if ENABLE_NLS
268#include <libintl.h> /* INFRINGES ON USER NAME SPACE */
269#define YY_(msgid) dgettext("bison-runtime", msgid)
270#endif
271#endif
272#ifndef YY_
273#define YY_(msgid) msgid
274#endif
275#endif
276
277/* Suppress unused-variable warnings by "using" E. */
278#if !defined lint || defined __GNUC__
279#define YYUSE(e) ((void)(e))
280#else
281#define YYUSE(e) /* empty */
282#endif
283
284/* Identity function, used to suppress warnings about constant conditions. */
285#ifndef lint
286#define YYID(n) (n)
287#else
288#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
289static int YYID(int yyi)
290#else
291static int YYID(yyi)
292int yyi;
293#endif
294{
295 return yyi;
296}
297#endif
298
299#if !defined yyoverflow || YYERROR_VERBOSE
300
301/* The parser invokes alloca or malloc; define the necessary symbols. */
302
303#ifdef YYSTACK_USE_ALLOCA
304#if YYSTACK_USE_ALLOCA
305#ifdef __GNUC__
306#define YYSTACK_ALLOC __builtin_alloca
307#elif defined __BUILTIN_VA_ARG_INCR
308#include <alloca.h> /* INFRINGES ON USER NAME SPACE */
309#elif defined _AIX
310#define YYSTACK_ALLOC __alloca
311#elif defined _MSC_VER
312#include <malloc.h> /* INFRINGES ON USER NAME SPACE */
313#define alloca _alloca
314#else
315#define YYSTACK_ALLOC alloca
316#if !defined _ALLOCA_H && !defined _STDLIB_H && \
317 (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
318#include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
319#ifndef _STDLIB_H
320#define _STDLIB_H 1
321#endif
322#endif
323#endif
324#endif
325#endif
326
327#ifdef YYSTACK_ALLOC
328/* Pacify GCC's `empty if-body' warning. */
329#define YYSTACK_FREE(Ptr) \
330 do { /* empty */ \
331 ; \
332 } while (YYID(0))
333#ifndef YYSTACK_ALLOC_MAXIMUM
334/* The OS might guarantee only one guard page at the bottom of the stack,
335 and a page size can be as small as 4096 bytes. So we cannot safely
336 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
337 to allow for a few compiler-allocated temporary stack slots. */
338#define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
339#endif
340#else
341#define YYSTACK_ALLOC YYMALLOC
342#define YYSTACK_FREE YYFREE
343#ifndef YYSTACK_ALLOC_MAXIMUM
344#define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
345#endif
346#if (defined __cplusplus && !defined _STDLIB_H && \
347 !((defined YYMALLOC || defined malloc) && (defined YYFREE || defined free)))
348#include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
349#ifndef _STDLIB_H
350#define _STDLIB_H 1
351#endif
352#endif
353#ifndef YYMALLOC
354#define YYMALLOC malloc
355#if !defined malloc && !defined _STDLIB_H && \
356 (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
357void* malloc(YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
358#endif
359#endif
360#ifndef YYFREE
361#define YYFREE free
362#if !defined free && !defined _STDLIB_H && \
363 (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
364void free(void*); /* INFRINGES ON USER NAME SPACE */
365#endif
366#endif
367#endif
368#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
369
370#if (!defined yyoverflow && \
371 (!defined __cplusplus || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
372
373/* A type that is properly aligned for any stack member. */
374union yyalloc {
375 yytype_int16 yyss_alloc;
376 YYSTYPE yyvs_alloc;
377};
378
379/* The size of the maximum gap between one aligned stack and the next. */
380#define YYSTACK_GAP_MAXIMUM (sizeof(union yyalloc) - 1)
381
382/* The size of an array large to enough to hold all stacks, each with
383 N elements. */
384#define YYSTACK_BYTES(N) ((N) * (sizeof(yytype_int16) + sizeof(YYSTYPE)) + YYSTACK_GAP_MAXIMUM)
385
386/* Copy COUNT objects from FROM to TO. The source and destination do
387 not overlap. */
388#ifndef YYCOPY
389#if defined __GNUC__ && 1 < __GNUC__
390#define YYCOPY(To, From, Count) __builtin_memcpy(To, From, (Count) * sizeof(*(From)))
391#else
392#define YYCOPY(To, From, Count) \
393 do { \
394 YYSIZE_T yyi; \
395 for (yyi = 0; yyi < (Count); yyi++) \
396 (To)[yyi] = (From)[yyi]; \
397 } while (YYID(0))
398#endif
399#endif
400
401/* Relocate STACK from its old location to the new one. The
402 local variables YYSIZE and YYSTACKSIZE give the old and new number of
403 elements in the stack, and YYPTR gives the new location of the
404 stack. Advance YYPTR to a properly aligned location for the next
405 stack. */
406#define YYSTACK_RELOCATE(Stack_alloc, Stack) \
407 do { \
408 YYSIZE_T yynewbytes; \
409 YYCOPY(&yyptr->Stack_alloc, Stack, yysize); \
410 Stack = &yyptr->Stack_alloc; \
411 yynewbytes = yystacksize * sizeof(*Stack) + YYSTACK_GAP_MAXIMUM; \
412 yyptr += yynewbytes / sizeof(*yyptr); \
413 } while (YYID(0))
414
415#endif
416
417/* YYFINAL -- State number of the termination state. */
418#define YYFINAL 31
419/* YYLAST -- Last index in YYTABLE. */
420#define YYLAST 72
421
422/* YYNTOKENS -- Number of terminals. */
423#define YYNTOKENS 27
424/* YYNNTS -- Number of nonterminals. */
425#define YYNNTS 10
426/* YYNRULES -- Number of rules. */
427#define YYNRULES 34
428/* YYNRULES -- Number of states. */
429#define YYNSTATES 72
430
431/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
432#define YYUNDEFTOK 2
433#define YYMAXUTOK 281
434
435#define YYTRANSLATE(YYX) ((unsigned int)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
436
437/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
438static const yytype_uint8 yytranslate[] = {
439 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
440 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
441 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
442 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
447 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
448 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
449 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
450
451#if YYDEBUG
452/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
453 YYRHS. */
454static const yytype_uint8 yyprhs[] = {0, 0, 3, 7, 10, 12, 16, 20, 23, 24, 27, 29,
455 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 64,
456 66, 72, 78, 80, 82, 84, 92, 100, 104, 105, 108};
457
458/* YYRHS -- A `-1'-separated list of the rules' RHS. */
459static const yytype_int8 yyrhs[] = {
460 28, 0, -1, 29, 3, 28, -1, 3, 28, -1, 26, -1, 21, 5, 24, -1, 21, 5, 23, -1, 24, 30, -1,
461 -1, 31, 30, -1, 32, -1, 6, 32, -1, 7, 32, -1, 10, 32, -1, 8, 32, -1, 9, 32, -1, 12, 32,
462 -1, 11, 32, -1, 13, 32, -1, 15, 32, -1, 14, 32, -1, 16, 32, -1, 33, -1, 34, -1, 18, 19, 24,
463 20, 33, -1, 18, 19, 5, 20, 33, -1, 23, -1, 35, -1, 5, -1, 17, 19, 24, 20, 19, 23, 20, -1,
464 17, 19, 5, 20, 19, 23, 20, -1, 4, 36, 4, -1, -1, 5, 36, -1, 22, 36, -1};
465
466/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
467static const yytype_uint8 yyrline[] = {0, 51, 51, 52, 53, 56, 57, 58, 61, 62, 65, 66,
468 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 79, 80,
469 81, 82, 85, 86, 87, 90, 91, 94, 97, 98, 99};
470#endif
471
472#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
473/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
474 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
475static const char* const yytname[] = {"$end",
476 "error",
477 "$undefined",
478 "NEWLINE",
479 "QUOTE",
480 "STRING",
481 "CTRL",
482 "SHIFT",
483 "ALT",
484 "ALTGR",
485 "CTRL_SHIFT",
486 "SHIFT_ALT",
487 "CTRL_ALT",
488 "CTRL_SHIFT_ALT",
489 "SHIFT_ALTGR",
490 "CTRL_ALTGR",
491 "CTRL_SHIFT_ALTGR",
492 "SET_COMBINE",
493 "COMBINE",
494 "OPEN_SQ",
495 "CLOSE_SQ",
496 "DEFINE",
497 "QUOTED_CHAR",
498 "CODE_POINT",
499 "NUM",
500 "ERROR",
501 "END",
502 "$accept",
503 "command",
504 "command_part",
505 "sections",
506 "section",
507 "combine",
508 "point",
509 "set_combination",
510 "string",
511 "string_internal",
512 0};
513#endif
514
515#ifdef YYPRINT
516/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
517 token YYLEX-NUM. */
518static const yytype_uint16 yytoknum[] = {0, 256, 257, 258, 259, 260, 261, 262, 263,
519 264, 265, 266, 267, 268, 269, 270, 271, 272,
520 273, 274, 275, 276, 277, 278, 279, 280, 281};
521#endif
522
523/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
524static const yytype_uint8 yyr1[] = {0, 27, 28, 28, 28, 29, 29, 29, 30, 30, 31, 31,
525 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32,
526 32, 32, 33, 33, 33, 34, 34, 35, 36, 36, 36};
527
528/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
529static const yytype_uint8 yyr2[] = {0, 2, 3, 2, 1, 3, 3, 2, 0, 2, 1, 2, 2, 2, 2, 2, 2, 2,
530 2, 2, 2, 2, 1, 1, 5, 5, 1, 1, 1, 7, 7, 3, 0, 2, 2};
531
532/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
533 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
534 means the default is an error. */
535static const yytype_uint8 yydefact[] = {
536 0, 0, 0, 8, 4, 0, 0, 3, 0, 32, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
537 26, 7, 8, 10, 22, 23, 27, 1, 0, 6, 5, 32, 32, 0, 11, 12, 14, 15, 13, 17, 16, 18, 20, 19,
538 21, 0, 0, 9, 2, 33, 34, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 24, 0, 0, 30, 29};
539
540/* YYDEFGOTO[NTERM-NUM]. */
541static const yytype_int8 yydefgoto[] = {-1, 5, 6, 25, 26, 27, 28, 29, 30, 37};
542
543/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
544 STATE-NUM. */
545#define YYPACT_NINF -34
546static const yytype_int8 yypact[] = {
547 -2, -2, 30, 0, -34, 38, 37, -34, -21, 27, -34, 16, 16, 16, 16, 16, 16, 16,
548 16, 16, 16, 16, 24, 26, -34, -34, 0, -34, -34, -34, -34, -34, -2, -34, -34, 27,
549 27, 44, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, 22, 23, -34, -34, -34,
550 -34, -34, 41, 42, 43, 45, 47, 48, 21, 21, 18, 19, -34, -34, 49, 50, -34, -34};
551
552/* YYPGOTO[NTERM-NUM]. */
553static const yytype_int8 yypgoto[] = {-34, -1, -34, 46, -34, 39, -33, -34, -34, 1};
554
555/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
556 positive, shift that token. If negative, reduce the rule which
557 number is the opposite. If zero, do what YYDEFACT says.
558 If YYTABLE_NINF, syntax error. */
559#define YYTABLE_NINF -1
560static const yytype_uint8 yytable[] = {7, 1, 33, 34, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
561 20, 21, 22, 23, 2, 9, 10, 3, 24, 4, 9, 10, 56, 58, 66,
562 67, 52, 35, 22, 23, 8, 53, 54, 31, 24, 32, 68, 69, 49, 24,
563 50, 57, 59, 55, 36, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
564 48, 60, 61, 62, 0, 63, 64, 65, 0, 70, 71, 0, 51};
565
566static const yytype_int8 yycheck[] = {1, 3, 23, 24, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
567 15, 16, 17, 18, 21, 4, 5, 24, 23, 26, 4, 5, 5, 5, 62,
568 63, 32, 5, 17, 18, 5, 35, 36, 0, 23, 3, 23, 23, 19, 23,
569 19, 24, 24, 4, 22, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
570 21, 20, 20, 20, -1, 20, 19, 19, -1, 20, 20, -1, 26};
571
572/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
573 symbol of state STATE-NUM. */
574static const yytype_uint8 yystos[] = {
575 0, 3, 21, 24, 26, 28, 29, 28, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
576 23, 30, 31, 32, 33, 34, 35, 0, 3, 23, 24, 5, 22, 36, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
577 32, 19, 19, 30, 28, 36, 36, 4, 5, 24, 5, 24, 20, 20, 20, 20, 19, 19, 33, 33, 23, 23, 20, 20};
578
579#define yyerrok (yyerrstatus = 0)
580#define yyclearin (yychar = YYEMPTY)
581#define YYEMPTY (-2)
582#define YYEOF 0
583
584#define YYACCEPT goto yyacceptlab
585#define YYABORT goto yyabortlab
586#define YYERROR goto yyerrorlab
587
588/* Like YYERROR except do call yyerror. This remains here temporarily
589 to ease the transition to the new meaning of YYERROR, for GCC.
590 Once GCC version 2 has supplanted version 1, this can go. */
591
592#define YYFAIL goto yyerrlab
593
594#define YYRECOVERING() (!!yyerrstatus)
595
596#define YYBACKUP(Token, Value) \
597 do \
598 if (yychar == YYEMPTY && yylen == 1) { \
599 yychar = (Token); \
600 yylval = (Value); \
601 yytoken = YYTRANSLATE(yychar); \
602 YYPOPSTACK(1); \
603 goto yybackup; \
604 } else { \
605 yyerror(YY_("syntax error: cannot back up")); \
606 YYERROR; \
607 } \
608 while (YYID(0))
609
610#define YYTERROR 1
611#define YYERRCODE 256
612
613/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
614 If N is 0, then set CURRENT to the empty location which ends
615 the previous symbol: RHS[0] (always defined). */
616
617#define YYRHSLOC(Rhs, K) ((Rhs)[K])
618#ifndef YYLLOC_DEFAULT
619#define YYLLOC_DEFAULT(Current, Rhs, N) \
620 do \
621 if (YYID(N)) { \
622 (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
623 (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
624 (Current).last_line = YYRHSLOC(Rhs, N).last_line; \
625 (Current).last_column = YYRHSLOC(Rhs, N).last_column; \
626 } else { \
627 (Current).first_line = (Current).last_line = YYRHSLOC(Rhs, 0).last_line; \
628 (Current).first_column = (Current).last_column = YYRHSLOC(Rhs, 0).last_column; \
629 } \
630 while (YYID(0))
631#endif
632
633/* YY_LOCATION_PRINT -- Print the location on the stream.
634 This macro was not mandated originally: define only if we know
635 we won't break user code: when these are the locations we know. */
636
637#ifndef YY_LOCATION_PRINT
638#if YYLTYPE_IS_TRIVIAL
639#define YY_LOCATION_PRINT(File, Loc) \
640 fprintf(File, "%d.%d-%d.%d", (Loc).first_line, (Loc).first_column, (Loc).last_line, \
641 (Loc).last_column)
642#else
643#define YY_LOCATION_PRINT(File, Loc) ((void)0)
644#endif
645#endif
646
647/* YYLEX -- calling `yylex' with the right arguments. */
648
649#ifdef YYLEX_PARAM
650#define YYLEX yylex(YYLEX_PARAM)
651#else
652#define YYLEX yylex()
653#endif
654
655/* Enable debugging if requested. */
656#if YYDEBUG
657
658#ifndef YYFPRINTF
659#include <stdio.h> /* INFRINGES ON USER NAME SPACE */
660#define YYFPRINTF fprintf
661#endif
662
663#define YYDPRINTF(Args) \
664 do { \
665 if (yydebug) \
666 YYFPRINTF Args; \
667 } while (YYID(0))
668
669#define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
670 do { \
671 if (yydebug) { \
672 YYFPRINTF(stderr, "%s ", Title); \
673 yy_symbol_print(stderr, Type, Value); \
674 YYFPRINTF(stderr, "\n"); \
675 } \
676 } while (YYID(0))
677
678/*--------------------------------.
679| Print this symbol on YYOUTPUT. |
680`--------------------------------*/
681
682/*ARGSUSED*/
683#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
684static void yy_symbol_value_print(FILE* yyoutput, int yytype, YYSTYPE const* const yyvaluep)
685#else
686static void yy_symbol_value_print(yyoutput, yytype, yyvaluep) FILE* yyoutput;
687int yytype;
688YYSTYPE const* const yyvaluep;
689#endif
690{
691 if (!yyvaluep)
692 return;
693#ifdef YYPRINT
694 if (yytype < YYNTOKENS)
695 YYPRINT(yyoutput, yytoknum[yytype], *yyvaluep);
696#else
697 YYUSE(yyoutput);
698#endif
699 switch (yytype) {
700 default:
701 break;
702 }
703}
704
705/*--------------------------------.
706| Print this symbol on YYOUTPUT. |
707`--------------------------------*/
708
709#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
710static void yy_symbol_print(FILE* yyoutput, int yytype, YYSTYPE const* const yyvaluep)
711#else
712static void yy_symbol_print(yyoutput, yytype, yyvaluep) FILE* yyoutput;
713int yytype;
714YYSTYPE const* const yyvaluep;
715#endif
716{
717 if (yytype < YYNTOKENS)
718 YYFPRINTF(yyoutput, "token %s (", yytname[yytype]);
719 else
720 YYFPRINTF(yyoutput, "nterm %s (", yytname[yytype]);
721
722 yy_symbol_value_print(yyoutput, yytype, yyvaluep);
723 YYFPRINTF(yyoutput, ")");
724}
725
726/*------------------------------------------------------------------.
727| yy_stack_print -- Print the state stack from its BOTTOM up to its |
728| TOP (included). |
729`------------------------------------------------------------------*/
730
731#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
732static void yy_stack_print(yytype_int16* yybottom, yytype_int16* yytop)
733#else
734static void yy_stack_print(yybottom, yytop) yytype_int16* yybottom;
735yytype_int16* yytop;
736#endif
737{
738 YYFPRINTF(stderr, "Stack now");
739 for (; yybottom <= yytop; yybottom++) {
740 int yybot = *yybottom;
741 YYFPRINTF(stderr, " %d", yybot);
742 }
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 (YYID(0))
751
752/*------------------------------------------------.
753| Report that the YYRULE is going to be reduced. |
754`------------------------------------------------*/
755
756#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
757static void yy_reduce_print(YYSTYPE* yyvsp, int yyrule)
758#else
759static void yy_reduce_print(yyvsp, yyrule) YYSTYPE* yyvsp;
760int yyrule;
761#endif
762{
763 int yynrhs = yyr2[yyrule];
764 int yyi;
765 unsigned long int yylno = yyrline[yyrule];
766 YYFPRINTF(stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno);
767 /* The symbols being reduced. */
768 for (yyi = 0; yyi < yynrhs; yyi++) {
769 YYFPRINTF(stderr, " $%d = ", yyi + 1);
770 yy_symbol_print(stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]));
771 YYFPRINTF(stderr, "\n");
772 }
773}
774
775#define YY_REDUCE_PRINT(Rule) \
776 do { \
777 if (yydebug) \
778 yy_reduce_print(yyvsp, Rule); \
779 } while (YYID(0))
780
781/* Nonzero means print parse trace. It is left uninitialized so that
782 multiple parsers can coexist. */
783int yydebug;
784#else /* !YYDEBUG */
785#define YYDPRINTF(Args)
786#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
787#define YY_STACK_PRINT(Bottom, Top)
788#define YY_REDUCE_PRINT(Rule)
789#endif /* !YYDEBUG */
790
791/* YYINITDEPTH -- initial size of the parser's stacks. */
792#ifndef YYINITDEPTH
793#define YYINITDEPTH 200
794#endif
795
796/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
797 if the built-in stack extension method is used).
798
799 Do not make this value too large; the results are undefined if
800 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
801 evaluated with infinite-precision integer arithmetic. */
802
803#ifndef YYMAXDEPTH
804#define YYMAXDEPTH 10000
805#endif
806
807#if YYERROR_VERBOSE
808
809#ifndef yystrlen
810#if defined __GLIBC__ && defined _STRING_H
811#define yystrlen strlen
812#else
813/* Return the length of YYSTR. */
814#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
815static YYSIZE_T yystrlen(const char* yystr)
816#else
817static YYSIZE_T yystrlen(yystr) const char* yystr;
818#endif
819{
820 YYSIZE_T yylen;
821 for (yylen = 0; yystr[yylen]; yylen++)
822 continue;
823 return yylen;
824}
825#endif
826#endif
827
828#ifndef yystpcpy
829#if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
830#define yystpcpy stpcpy
831#else
832/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
833 YYDEST. */
834#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
835static char* yystpcpy(char* yydest, const char* yysrc)
836#else
837static char* yystpcpy(yydest, yysrc)
838char* yydest;
839const char* yysrc;
840#endif
841{
842 char* yyd = yydest;
843 const char* yys = yysrc;
844
845 while ((*yyd++ = *yys++) != '\0')
846 continue;
847
848 return yyd - 1;
849}
850#endif
851#endif
852
853#ifndef yytnamerr
854/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
855 quotes and backslashes, so that it's suitable for yyerror. The
856 heuristic is that double-quoting is unnecessary unless the string
857 contains an apostrophe, a comma, or backslash (other than
858 backslash-backslash). YYSTR is taken from yytname. If YYRES is
859 null, do not copy; instead, return the length of what the result
860 would have been. */
861static YYSIZE_T yytnamerr(char* yyres, const char* yystr) {
862 if (*yystr == '"') {
863 YYSIZE_T yyn = 0;
864 char const* yyp = yystr;
865
866 for (;;)
867 switch (*++yyp) {
868 case '\'':
869 case ',':
870 goto do_not_strip_quotes;
871
872 case '\\':
873 if (*++yyp != '\\')
874 goto do_not_strip_quotes;
875 /* Fall through. */
876 default:
877 if (yyres)
878 yyres[yyn] = *yyp;
879 yyn++;
880 break;
881
882 case '"':
883 if (yyres)
884 yyres[yyn] = '\0';
885 return yyn;
886 }
887 do_not_strip_quotes:;
888 }
889
890 if (!yyres)
891 return yystrlen(yystr);
892
893 return yystpcpy(yyres, yystr) - yyres;
894}
895#endif
896
897/* Copy into YYRESULT an error message about the unexpected token
898 YYCHAR while in state YYSTATE. Return the number of bytes copied,
899 including the terminating null byte. If YYRESULT is null, do not
900 copy anything; just return the number of bytes that would be
901 copied. As a special case, return 0 if an ordinary "syntax error"
902 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
903 size calculation. */
904static YYSIZE_T yysyntax_error(char* yyresult, int yystate, int yychar) {
905 int yyn = yypact[yystate];
906
907 if (!(YYPACT_NINF < yyn && yyn <= YYLAST))
908 return 0;
909 else {
910 int yytype = YYTRANSLATE(yychar);
911 YYSIZE_T yysize0 = yytnamerr(0, yytname[yytype]);
912 YYSIZE_T yysize = yysize0;
913 YYSIZE_T yysize1;
914 int yysize_overflow = 0;
915 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
916 char const* yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
917 int yyx;
918
919#if 0
920 /* This is so xgettext sees the translatable formats that are
921 constructed on the fly. */
922 YY_("syntax error, unexpected %s");
923 YY_("syntax error, unexpected %s, expecting %s");
924 YY_("syntax error, unexpected %s, expecting %s or %s");
925 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
926 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
927#endif
928 char* yyfmt;
929 char const* yyf;
930 static char const yyunexpected[] = "syntax error, unexpected %s";
931 static char const yyexpecting[] = ", expecting %s";
932 static char const yyor[] = " or %s";
933 char yyformat[sizeof yyunexpected + sizeof yyexpecting - 1 +
934 ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) * (sizeof yyor - 1))];
935 char const* yyprefix = yyexpecting;
936
937 /* Start YYX at -YYN if negative to avoid negative indexes in
938 YYCHECK. */
939 int yyxbegin = yyn < 0 ? -yyn : 0;
940
941 /* Stay within bounds of both yycheck and yytname. */
942 int yychecklim = YYLAST - yyn + 1;
943 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
944 int yycount = 1;
945
946 yyarg[0] = yytname[yytype];
947 yyfmt = yystpcpy(yyformat, yyunexpected);
948
949 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
950 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
951 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) {
952 yycount = 1;
953 yysize = yysize0;
954 yyformat[sizeof yyunexpected - 1] = '\0';
955 break;
956 }
957 yyarg[yycount++] = yytname[yyx];
958 yysize1 = yysize + yytnamerr(0, yytname[yyx]);
959 yysize_overflow |= (yysize1 < yysize);
960 yysize = yysize1;
961 yyfmt = yystpcpy(yyfmt, yyprefix);
962 yyprefix = yyor;
963 }
964
965 yyf = YY_(yyformat);
966 yysize1 = yysize + yystrlen(yyf);
967 yysize_overflow |= (yysize1 < yysize);
968 yysize = yysize1;
969
970 if (yysize_overflow)
971 return YYSIZE_MAXIMUM;
972
973 if (yyresult) {
974 /* Avoid sprintf, as that infringes on the user's name space.
975 Don't have undefined behavior even if the translation
976 produced a string with the wrong number of "%s"s. */
977 char* yyp = yyresult;
978 int yyi = 0;
979 while ((*yyp = *yyf) != '\0') {
980 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) {
981 yyp += yytnamerr(yyp, yyarg[yyi++]);
982 yyf += 2;
983 } else {
984 yyp++;
985 yyf++;
986 }
987 }
988 }
989 return yysize;
990 }
991}
992#endif /* YYERROR_VERBOSE */
993
994/*-----------------------------------------------.
995| Release the memory associated to this symbol. |
996`-----------------------------------------------*/
997
998/*ARGSUSED*/
999#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
1000static void yydestruct(const char* yymsg, int yytype, YYSTYPE* yyvaluep)
1001#else
1002static void yydestruct(yymsg, yytype, yyvaluep) const char* yymsg;
1003int yytype;
1004YYSTYPE* yyvaluep;
1005#endif
1006{
1007 YYUSE(yyvaluep);
1008
1009 if (!yymsg)
1010 yymsg = "Deleting";
1011 YY_SYMBOL_PRINT(yymsg, yytype, yyvaluep, yylocationp);
1012
1013 switch (yytype) {
1014 default:
1015 break;
1016 }
1017}
1018
1019/* Prevent warnings from -Wmissing-prototypes. */
1020#ifdef YYPARSE_PARAM
1021#if defined __STDC__ || defined __cplusplus
1022int yyparse(void* YYPARSE_PARAM);
1023#else
1024int yyparse();
1025#endif
1026#else /* ! YYPARSE_PARAM */
1027#if defined __STDC__ || defined __cplusplus
1028int yyparse(void);
1029#else
1030int yyparse();
1031#endif
1032#endif /* ! YYPARSE_PARAM */
1033
1034/* The lookahead symbol. */
1035int yychar;
1036
1037/* The semantic value of the lookahead symbol. */
1038YYSTYPE yylval;
1039
1040/* Number of syntax errors so far. */
1041int yynerrs;
1042
1043/*-------------------------.
1044| yyparse or yypush_parse. |
1045`-------------------------*/
1046
1047#ifdef YYPARSE_PARAM
1048#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
1049int yyparse(void* YYPARSE_PARAM)
1050#else
1051int yyparse(YYPARSE_PARAM) void* YYPARSE_PARAM;
1052#endif
1053#else /* ! YYPARSE_PARAM */
1054#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
1055int yyparse(void)
1056#else
1057int yyparse()
1058
1059#endif
1060#endif
1061{
1062 int yystate;
1063 /* Number of tokens to shift before error messages enabled. */
1064 int yyerrstatus;
1065
1066 /* The stacks and their tools:
1067 `yyss': related to states.
1068 `yyvs': related to semantic values.
1069
1070 Refer to the stacks thru separate pointers, to allow yyoverflow
1071 to reallocate them elsewhere. */
1072
1073 /* The state stack. */
1074 yytype_int16 yyssa[YYINITDEPTH];
1075 yytype_int16* yyss;
1076 yytype_int16* yyssp;
1077
1078 /* The semantic value stack. */
1079 YYSTYPE yyvsa[YYINITDEPTH];
1080 YYSTYPE* yyvs;
1081 YYSTYPE* yyvsp;
1082
1083 YYSIZE_T yystacksize;
1084
1085 int yyn;
1086 int yyresult;
1087 /* Lookahead token as an internal (translated) token number. */
1088 int yytoken;
1089 /* The variables used to return semantic value and location from the
1090 action routines. */
1091 YYSTYPE yyval;
1092
1093#if YYERROR_VERBOSE
1094 /* Buffer for error messages, and its allocated size. */
1095 char yymsgbuf[128];
1096 char* yymsg = yymsgbuf;
1097 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1098#endif
1099
1100#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1101
1102 /* The number of symbols on the RHS of the reduced rule.
1103 Keep to zero when no symbol should be popped. */
1104 int yylen = 0;
1105
1106 yytoken = 0;
1107 yyss = yyssa;
1108 yyvs = yyvsa;
1109 yystacksize = YYINITDEPTH;
1110
1111 YYDPRINTF((stderr, "Starting parse\n"));
1112
1113 yystate = 0;
1114 yyerrstatus = 0;
1115 yynerrs = 0;
1116 yychar = YYEMPTY; /* Cause a token to be read. */
1117
1118 /* Initialize stack pointers.
1119 Waste one element of value and location stack
1120 so that they stay on the same level as the state stack.
1121 The wasted elements are never initialized. */
1122 yyssp = yyss;
1123 yyvsp = yyvs;
1124
1125 goto yysetstate;
1126
1127/*------------------------------------------------------------.
1128| yynewstate -- Push a new state, which is found in yystate. |
1129`------------------------------------------------------------*/
1130yynewstate:
1131 /* In all cases, when you get here, the value and location stacks
1132 have just been pushed. So pushing a state here evens the stacks. */
1133 yyssp++;
1134
1135yysetstate:
1136 *yyssp = yystate;
1137
1138 if (yyss + yystacksize - 1 <= yyssp) {
1139 /* Get the current used size of the three stacks, in elements. */
1140 YYSIZE_T yysize = yyssp - yyss + 1;
1141
1142#ifdef yyoverflow
1143 {
1144 /* Give user a chance to reallocate the stack. Use copies of
1145 these so that the &'s don't force the real ones into
1146 memory. */
1147 YYSTYPE* yyvs1 = yyvs;
1148 yytype_int16* yyss1 = yyss;
1149
1150 /* Each stack pointer address is followed by the size of the
1151 data in use in that stack, in bytes. This used to be a
1152 conditional around just the two extra args, but that might
1153 be undefined if yyoverflow is a macro. */
1154 yyoverflow(YY_("memory exhausted"), &yyss1, yysize * sizeof(*yyssp), &yyvs1,
1155 yysize * sizeof(*yyvsp), &yystacksize);
1156
1157 yyss = yyss1;
1158 yyvs = yyvs1;
1159 }
1160#else /* no yyoverflow */
1161#ifndef YYSTACK_RELOCATE
1162 goto yyexhaustedlab;
1163#else
1164 /* Extend the stack our own way. */
1165 if (YYMAXDEPTH <= yystacksize)
1166 goto yyexhaustedlab;
1167 yystacksize *= 2;
1168 if (YYMAXDEPTH < yystacksize)
1169 yystacksize = YYMAXDEPTH;
1170
1171 {
1172 yytype_int16* yyss1 = yyss;
1173 union yyalloc* yyptr = (union yyalloc*)YYSTACK_ALLOC(YYSTACK_BYTES(yystacksize));
1174 if (!yyptr)
1175 goto yyexhaustedlab;
1176 YYSTACK_RELOCATE(yyss_alloc, yyss);
1177 YYSTACK_RELOCATE(yyvs_alloc, yyvs);
1178#undef YYSTACK_RELOCATE
1179 if (yyss1 != yyssa)
1180 YYSTACK_FREE(yyss1);
1181 }
1182#endif
1183#endif /* no yyoverflow */
1184
1185 yyssp = yyss + yysize - 1;
1186 yyvsp = yyvs + yysize - 1;
1187
1188 YYDPRINTF((stderr, "Stack size increased to %lu\n", (unsigned long int)yystacksize));
1189
1190 if (yyss + yystacksize - 1 <= yyssp)
1191 YYABORT;
1192 }
1193
1194 YYDPRINTF((stderr, "Entering state %d\n", yystate));
1195
1196 if (yystate == YYFINAL)
1197 YYACCEPT;
1198
1199 goto yybackup;
1200
1201/*-----------.
1202| yybackup. |
1203`-----------*/
1204yybackup:
1205
1206 /* Do appropriate processing given the current state. Read a
1207 lookahead token if we need one and don't already have one. */
1208
1209 /* First try to decide what to do without reference to lookahead token. */
1210 yyn = yypact[yystate];
1211 if (yyn == YYPACT_NINF)
1212 goto yydefault;
1213
1214 /* Not known => get a lookahead token if don't already have one. */
1215
1216 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1217 if (yychar == YYEMPTY) {
1218 YYDPRINTF((stderr, "Reading a token: "));
1219 yychar = YYLEX;
1220 }
1221
1222 if (yychar <= YYEOF) {
1223 yychar = yytoken = YYEOF;
1224 YYDPRINTF((stderr, "Now at end of input.\n"));
1225 } else {
1226 yytoken = YYTRANSLATE(yychar);
1227 YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc);
1228 }
1229
1230 /* If the proper action on seeing token YYTOKEN is to reduce or to
1231 detect an error, take that action. */
1232 yyn += yytoken;
1233 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1234 goto yydefault;
1235 yyn = yytable[yyn];
1236 if (yyn <= 0) {
1237 if (yyn == 0 || yyn == YYTABLE_NINF)
1238 goto yyerrlab;
1239 yyn = -yyn;
1240 goto yyreduce;
1241 }
1242
1243 /* Count tokens shifted since error; after three, turn off error
1244 status. */
1245 if (yyerrstatus)
1246 yyerrstatus--;
1247
1248 /* Shift the lookahead token. */
1249 YY_SYMBOL_PRINT("Shifting", yytoken, &yylval, &yylloc);
1250
1251 /* Discard the shifted token. */
1252 yychar = YYEMPTY;
1253
1254 yystate = yyn;
1255 *++yyvsp = yylval;
1256
1257 goto yynewstate;
1258
1259/*-----------------------------------------------------------.
1260| yydefault -- do the default action for the current state. |
1261`-----------------------------------------------------------*/
1262yydefault:
1263 yyn = yydefact[yystate];
1264 if (yyn == 0)
1265 goto yyerrlab;
1266 goto yyreduce;
1267
1268/*-----------------------------.
1269| yyreduce -- Do a reduction. |
1270`-----------------------------*/
1271yyreduce:
1272 /* yyn is the number of a rule to reduce with. */
1273 yylen = yyr2[yyn];
1274
1275 /* If YYLEN is nonzero, implement the default value of the action:
1276 `$$ = $1'.
1277
1278 Otherwise, the following line sets YYVAL to garbage.
1279 This behavior is undocumented and Bison
1280 users should not rely upon it. Assigning to YYVAL
1281 unconditionally makes the parser a bit smaller, and it avoids a
1282 GCC warning that YYVAL may be used uninitialized. */
1283 yyval = yyvsp[1 - yylen];
1284
1285 YY_REDUCE_PRINT(yyn);
1286 switch (yyn) {
1287 case 3:
1288/* Line 1455 of yacc.c */
1289#line 52 "parser.y"
1290 {
1291 } break;
1292
1293 case 4:
1294/* Line 1455 of yacc.c */
1295#line 53 "parser.y"
1296 {
1297 YYACCEPT;
1298 } break;
1299
1300 case 5:
1301/* Line 1455 of yacc.c */
1302#line 56 "parser.y"
1303 {
1304 (yyval.cmd_list) = 0;
1305 add_define((yyvsp[(2) - (3)].str), (yyvsp[(3) - (3)].n));
1306 } break;
1307
1308 case 6:
1309/* Line 1455 of yacc.c */
1310#line 57 "parser.y"
1311 {
1312 (yyval.cmd_list) = 0;
1313 add_define((yyvsp[(2) - (3)].str), (yyvsp[(3) - (3)].n));
1314 } break;
1315
1316 case 7:
1317/* Line 1455 of yacc.c */
1318#line 58 "parser.y"
1319 {
1320 (yyval.cmd_list) = (yyvsp[(2) - (2)].cmd_list);
1321 set_cmds((yyvsp[(1) - (2)].n), (yyval.cmd_list));
1322 } break;
1323
1324 case 8:
1325/* Line 1455 of yacc.c */
1326#line 61 "parser.y"
1327 {
1328 (yyval.cmd_list) = 0;
1329 } break;
1330
1331 case 9:
1332/* Line 1455 of yacc.c */
1333#line 62 "parser.y"
1334 {
1335 (yyval.cmd_list) = add_to_cmd_list((yyvsp[(2) - (2)].cmd_list), (yyvsp[(1) - (2)].cmd));
1336 } break;
1337
1338 case 10:
1339/* Line 1455 of yacc.c */
1340#line 65 "parser.y"
1341 {
1342 (yyval.cmd) = (yyvsp[(1) - (1)].cmd);
1343 } break;
1344
1345 case 11:
1346/* Line 1455 of yacc.c */
1347#line 66 "parser.y"
1348 {
1349 (yyval.cmd) = (yyvsp[(2) - (2)].cmd);
1350 (yyval.cmd)->modifiers = CTRL_I;
1351 } break;
1352
1353 case 12:
1354/* Line 1455 of yacc.c */
1355#line 67 "parser.y"
1356 {
1357 (yyval.cmd) = (yyvsp[(2) - (2)].cmd);
1358 (yyval.cmd)->modifiers = SHIFT_I;
1359 } break;
1360
1361 case 13:
1362/* Line 1455 of yacc.c */
1363#line 68 "parser.y"
1364 {
1365 (yyval.cmd) = (yyvsp[(2) - (2)].cmd);
1366 (yyval.cmd)->modifiers = CTRL_I | SHIFT_I;
1367 } break;
1368
1369 case 14:
1370/* Line 1455 of yacc.c */
1371#line 69 "parser.y"
1372 {
1373 (yyval.cmd) = (yyvsp[(2) - (2)].cmd);
1374 (yyval.cmd)->modifiers = ALT_I;
1375 } break;
1376
1377 case 15:
1378/* Line 1455 of yacc.c */
1379#line 70 "parser.y"
1380 {
1381 (yyval.cmd) = (yyvsp[(2) - (2)].cmd);
1382 (yyval.cmd)->modifiers = ALTGR_I;
1383 } break;
1384
1385 case 16:
1386/* Line 1455 of yacc.c */
1387#line 71 "parser.y"
1388 {
1389 (yyval.cmd) = (yyvsp[(2) - (2)].cmd);
1390 (yyval.cmd)->modifiers = CTRL_I | ALT_I;
1391 } break;
1392
1393 case 17:
1394/* Line 1455 of yacc.c */
1395#line 72 "parser.y"
1396 {
1397 (yyval.cmd) = (yyvsp[(2) - (2)].cmd);
1398 (yyval.cmd)->modifiers = SHIFT_I | ALT_I;
1399 } break;
1400
1401 case 18:
1402/* Line 1455 of yacc.c */
1403#line 73 "parser.y"
1404 {
1405 (yyval.cmd) = (yyvsp[(2) - (2)].cmd);
1406 (yyval.cmd)->modifiers = CTRL_I | SHIFT_I | ALT_I;
1407 } break;
1408
1409 case 19:
1410/* Line 1455 of yacc.c */
1411#line 74 "parser.y"
1412 {
1413 (yyval.cmd) = (yyvsp[(2) - (2)].cmd);
1414 (yyval.cmd)->modifiers = CTRL_I | ALTGR_I;
1415 } break;
1416
1417 case 20:
1418/* Line 1455 of yacc.c */
1419#line 75 "parser.y"
1420 {
1421 (yyval.cmd) = (yyvsp[(2) - (2)].cmd);
1422 (yyval.cmd)->modifiers = SHIFT_I | ALTGR_I;
1423 } break;
1424
1425 case 21:
1426/* Line 1455 of yacc.c */
1427#line 76 "parser.y"
1428 {
1429 (yyval.cmd) = (yyvsp[(2) - (2)].cmd);
1430 (yyval.cmd)->modifiers = CTRL_I | SHIFT_I | ALTGR_I;
1431 } break;
1432
1433 case 22:
1434/* Line 1455 of yacc.c */
1435#line 79 "parser.y"
1436 {
1437 (yyval.cmd) = (yyvsp[(1) - (1)].cmd);
1438 } break;
1439
1440 case 23:
1441/* Line 1455 of yacc.c */
1442#line 80 "parser.y"
1443 {
1444 (yyval.cmd) = (yyvsp[(1) - (1)].cmd);
1445 } break;
1446
1447 case 24:
1448/* Line 1455 of yacc.c */
1449#line 81 "parser.y"
1450 {
1451 (yyval.cmd) = (yyvsp[(5) - (5)].cmd);
1452 (yyval.cmd)->combinators = (yyvsp[(3) - (5)].n);
1453 } break;
1454
1455 case 25:
1456/* Line 1455 of yacc.c */
1457#line 82 "parser.y"
1458 {
1459 (yyval.cmd) = (yyvsp[(5) - (5)].cmd);
1460 (yyval.cmd)->combinators = lookup_define((yyvsp[(3) - (5)].str));
1461 } break;
1462
1463 case 26:
1464/* Line 1455 of yacc.c */
1465#line 85 "parser.y"
1466 {
1467 (yyval.cmd) = make_cmd(0, (yyvsp[(1) - (1)].n), (char*)"");
1468 } break;
1469
1470 case 27:
1471/* Line 1455 of yacc.c */
1472#line 86 "parser.y"
1473 {
1474 (yyval.cmd) = make_cmd(0, 0, (yyvsp[(1) - (1)].str));
1475 } break;
1476
1477 case 28:
1478/* Line 1455 of yacc.c */
1479#line 87 "parser.y"
1480 {
1481 (yyval.cmd) = make_cmd(0, lookup_define((yyvsp[(1) - (1)].str)), (char*)"");
1482 } break;
1483
1484 case 29:
1485/* Line 1455 of yacc.c */
1486#line 90 "parser.y"
1487 {
1488 (yyval.cmd) = make_cmd(0, (yyvsp[(6) - (7)].n), (char*)"");
1489 (yyval.cmd)->set_modifiers = (yyvsp[(3) - (7)].n);
1490 } break;
1491
1492 case 30:
1493/* Line 1455 of yacc.c */
1494#line 91 "parser.y"
1495 {
1496 (yyval.cmd) = make_cmd(0, (yyvsp[(6) - (7)].n), (char*)"");
1497 (yyval.cmd)->set_modifiers = lookup_define((yyvsp[(3) - (7)].str));
1498 } break;
1499
1500 case 31:
1501/* Line 1455 of yacc.c */
1502#line 94 "parser.y"
1503 {
1504 strcpy((yyval.str), (yyvsp[(2) - (3)].str));
1505 } break;
1506
1507 case 32:
1508/* Line 1455 of yacc.c */
1509#line 97 "parser.y"
1510 {
1511 strcpy((yyval.str), "");
1512 } break;
1513
1514 case 33:
1515/* Line 1455 of yacc.c */
1516#line 98 "parser.y"
1517 {
1518 combine_strings((yyval.str), (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str));
1519 } break;
1520
1521 case 34:
1522/* Line 1455 of yacc.c */
1523#line 99 "parser.y"
1524 {
1525 combine_strings((yyval.str), quote_char((yyvsp[(1) - (2)].c)), (yyvsp[(2) - (2)].str));
1526 } break;
1527
1528/* Line 1455 of yacc.c */
1529#line 1682 "parser.c"
1530 default:
1531 break;
1532 }
1533 YY_SYMBOL_PRINT("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1534
1535 YYPOPSTACK(yylen);
1536 yylen = 0;
1537 YY_STACK_PRINT(yyss, yyssp);
1538
1539 *++yyvsp = yyval;
1540
1541 /* Now `shift' the result of the reduction. Determine what state
1542 that goes to, based on the state we popped back to and the rule
1543 number reduced by. */
1544
1545 yyn = yyr1[yyn];
1546
1547 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1548 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1549 yystate = yytable[yystate];
1550 else
1551 yystate = yydefgoto[yyn - YYNTOKENS];
1552
1553 goto yynewstate;
1554
1555/*------------------------------------.
1556| yyerrlab -- here on detecting error |
1557`------------------------------------*/
1558yyerrlab:
1559 /* If not already recovering from an error, report this error. */
1560 if (!yyerrstatus) {
1561 ++yynerrs;
1562#if !YYERROR_VERBOSE
1563 yyerror(YY_("syntax error"));
1564#else
1565 {
1566 YYSIZE_T yysize = yysyntax_error(0, yystate, yychar);
1567 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) {
1568 YYSIZE_T yyalloc = 2 * yysize;
1569 if (!(yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1570 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1571 if (yymsg != yymsgbuf)
1572 YYSTACK_FREE(yymsg);
1573 yymsg = (char*)YYSTACK_ALLOC(yyalloc);
1574 if (yymsg)
1575 yymsg_alloc = yyalloc;
1576 else {
1577 yymsg = yymsgbuf;
1578 yymsg_alloc = sizeof yymsgbuf;
1579 }
1580 }
1581
1582 if (0 < yysize && yysize <= yymsg_alloc) {
1583 (void)yysyntax_error(yymsg, yystate, yychar);
1584 yyerror(yymsg);
1585 } else {
1586 yyerror(YY_("syntax error"));
1587 if (yysize != 0)
1588 goto yyexhaustedlab;
1589 }
1590 }
1591#endif
1592 }
1593
1594 if (yyerrstatus == 3) {
1595 /* If just tried and failed to reuse lookahead token after an
1596 error, discard it. */
1597
1598 if (yychar <= YYEOF) {
1599 /* Return failure if at end of input. */
1600 if (yychar == YYEOF)
1601 YYABORT;
1602 } else {
1603 yydestruct("Error: discarding", yytoken, &yylval);
1604 yychar = YYEMPTY;
1605 }
1606 }
1607
1608 /* Else will try to reuse lookahead token after shifting the error
1609 token. */
1610 goto yyerrlab1;
1611
1612/*---------------------------------------------------.
1613| yyerrorlab -- error raised explicitly by YYERROR. |
1614`---------------------------------------------------*/
1615yyerrorlab:
1616
1617 /* Pacify compilers like GCC when the user code never invokes
1618 YYERROR and the label yyerrorlab therefore never appears in user
1619 code. */
1620 if (/*CONSTCOND*/ 0)
1621 goto yyerrorlab;
1622
1623 /* Do not reclaim the symbols of the rule which action triggered
1624 this YYERROR. */
1625 YYPOPSTACK(yylen);
1626 yylen = 0;
1627 YY_STACK_PRINT(yyss, yyssp);
1628 yystate = *yyssp;
1629 goto yyerrlab1;
1630
1631/*-------------------------------------------------------------.
1632| yyerrlab1 -- common code for both syntax error and YYERROR. |
1633`-------------------------------------------------------------*/
1634yyerrlab1:
1635 yyerrstatus = 3; /* Each real token shifted decrements this. */
1636
1637 for (;;) {
1638 yyn = yypact[yystate];
1639 if (yyn != YYPACT_NINF) {
1640 yyn += YYTERROR;
1641 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
1642 yyn = yytable[yyn];
1643 if (0 < yyn)
1644 break;
1645 }
1646 }
1647
1648 /* Pop the current state because it cannot handle the error token. */
1649 if (yyssp == yyss)
1650 YYABORT;
1651
1652 yydestruct("Error: popping", yystos[yystate], yyvsp);
1653 YYPOPSTACK(1);
1654 yystate = *yyssp;
1655 YY_STACK_PRINT(yyss, yyssp);
1656 }
1657
1658 *++yyvsp = yylval;
1659
1660 /* Shift the error token. */
1661 YY_SYMBOL_PRINT("Shifting", yystos[yyn], yyvsp, yylsp);
1662
1663 yystate = yyn;
1664 goto yynewstate;
1665
1666/*-------------------------------------.
1667| yyacceptlab -- YYACCEPT comes here. |
1668`-------------------------------------*/
1669yyacceptlab:
1670 yyresult = 0;
1671 goto yyreturn;
1672
1673/*-----------------------------------.
1674| yyabortlab -- YYABORT comes here. |
1675`-----------------------------------*/
1676yyabortlab:
1677 yyresult = 1;
1678 goto yyreturn;
1679
1680#if !defined(yyoverflow) || YYERROR_VERBOSE
1681/*-------------------------------------------------.
1682| yyexhaustedlab -- memory exhaustion comes here. |
1683`-------------------------------------------------*/
1684yyexhaustedlab:
1685 yyerror(YY_("memory exhausted"));
1686 yyresult = 2;
1687/* Fall through. */
1688#endif
1689
1690yyreturn:
1691 if (yychar != YYEMPTY)
1692 yydestruct("Cleanup: discarding lookahead", yytoken, &yylval);
1693 /* Do not reclaim the symbols of the rule which action triggered
1694 this YYABORT or YYACCEPT. */
1695 YYPOPSTACK(yylen);
1696 YY_STACK_PRINT(yyss, yyssp);
1697 while (yyssp != yyss) {
1698 yydestruct("Cleanup: popping", yystos[*yyssp], yyvsp);
1699 YYPOPSTACK(1);
1700 }
1701#ifndef yyoverflow
1702 if (yyss != yyssa)
1703 YYSTACK_FREE(yyss);
1704#endif
1705#if YYERROR_VERBOSE
1706 if (yymsg != yymsgbuf)
1707 YYSTACK_FREE(yymsg);
1708#endif
1709 /* Make sure YYID is used. */
1710 return YYID(yyresult);
1711}
1712
1713/* Line 1675 of yacc.c */
1714#line 102 "parser.y"
1715
1716char* quote_char(char c) {
1717 switch (c) {
1718 case 'e':
1719 return (char*)"\e";
1720 default:
1721 return (char*)"?";
1722 }
1723}
1724
1725void combine_strings(char* dest, const char* head, const char* tail) {
1726 size_t head_len = strlen(head);
1727 size_t tail_len = strlen(tail);
1728 if (head_len >= 256 || tail_len >= (256 - head_len)) {
1729 fprintf(stderr, "Keymap string is too long.\n");
1730 exit(1);
1731 }
1732
1733 memcpy(dest, head, head_len);
1734 memcpy(dest + head_len, tail, tail_len + 1);
1735}
1736
1737struct cmd_list* add_to_cmd_list(struct cmd_list* cl, cmd_t* c) {
1738 struct cmd_list* cl2 = (struct cmd_list*)malloc(sizeof(struct cmd_list));
1739 cl2->cmd = c;
1740 cl2->next = 0;
1741
1742 if (cl == 0)
1743 return cl2;
1744 else {
1745 struct cmd_list* cl3 = cl;
1746 while (cl3->next)
1747 cl3 = cl3->next;
1748 cl3->next = cl2;
1749 return cl;
1750 }
1751}
1752
1753cmd_t* make_cmd(unsigned int scancode, unsigned int unicode_point, char* val) {
1754 if (n_cmds >= MAX_CMDS) {
1755 fprintf(stderr, "Too many keymap commands.\n");
1756 exit(1);
1757 }
1758 if (val && strlen(val) > sizeof(unicode_point)) {
1759 fprintf(stderr, "Special key values cannot exceed four bytes.\n");
1760 exit(1);
1761 }
1762
1763 cmd_t* c = (cmd_t*)malloc(sizeof(cmd_t));
1764 c->scancode = scancode;
1765 c->unicode_point = unicode_point;
1766 if (val)
1767 c->val = strdup(val);
1768 else
1769 c->val = 0;
1770 c->modifiers = 0;
1771
1772 cmds[n_cmds++] = c;
1773 return c;
1774}
1775
1776void set_cmds(unsigned int scancode, struct cmd_list* cl) {
1777 while (cl) {
1778 cl->cmd->scancode = scancode;
1779 cl = cl->next;
1780 }
1781}
1782
1783struct def {
1784 char str[32];
1785 int n;
1786} defines[1024];
1787int ndefines = 0;
1788
1789void add_define(char* str, int n) {
1790 if (ndefines >= (int)(sizeof(defines) / sizeof(defines[0]))) {
1791 fprintf(stderr, "Too many keymap definitions.\n");
1792 exit(1);
1793 }
1794 if (strlen(str) >= sizeof(defines[0].str)) {
1795 fprintf(stderr, "Keymap definition name is too long.\n");
1796 exit(1);
1797 }
1798
1799 memset(defines[ndefines].str, 0, 32);
1800 strcpy(defines[ndefines].str, str);
1801 defines[ndefines++].n = n;
1802}
1803
1804int lookup_define(char* str) {
1805 int i;
1806 for (i = 0; i < ndefines; i++) {
1807 if (!strcmp(defines[i].str, str))
1808 return defines[i].n;
1809 }
1810 fprintf(stderr, "Error: define `%s' not found.\n", str);
1811 exit(1);
1812}
Definition cmd.h:30
Definition parser.c:1783