Imported Upstream version 2.0.90
[platform/upstream/kbd.git] / src / libkeymap / parser.c
1 /* A Bison parser, made by GNU Bison 3.0.5.  */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5    Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
6
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20 /* As a special exception, you may create a larger work that contains
21    part or all of the Bison parser skeleton and distribute that work
22    under terms of your choice, so long as that work isn't itself a
23    parser generator using the skeleton or a modified version thereof
24    as a parser skeleton.  Alternatively, if you modify or redistribute
25    the parser skeleton itself, you may (at your option) remove this
26    special exception, which will cause the skeleton and the resulting
27    Bison output files to be licensed under the GNU General Public
28    License without this special exception.
29
30    This special exception was added by the Free Software Foundation in
31    version 2.2 of Bison.  */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34    simplifying the original so-called "semantic" parser.  */
35
36 /* All symbols defined below should begin with yy or YY, to avoid
37    infringing on user name space.  This should be done even for local
38    variables, as they might otherwise be expanded by user macros.
39    There are some unavoidable exceptions within include files to
40    define necessary library symbols; they are noted "INFRINGES ON
41    USER NAME SPACE" below.  */
42
43 /* Identify Bison output.  */
44 #define YYBISON 1
45
46 /* Bison version.  */
47 #define YYBISON_VERSION "3.0.5"
48
49 /* Skeleton name.  */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers.  */
53 #define YYPURE 1
54
55 /* Push parsers.  */
56 #define YYPUSH 0
57
58 /* Pull parsers.  */
59 #define YYPULL 1
60
61
62
63
64 /* Copy the first part of user declarations.  */
65 #line 12 "parser.y" /* yacc.c:339  */
66
67 #include "config.h"
68 #include "libcommon.h"
69
70 #include "contextP.h"
71 #include "ksyms.h"
72 #include "modifiers.h"
73
74 #include "parser.h"
75 #include "analyze.h"
76
77 #line 78 "parser.c" /* yacc.c:339  */
78
79 # ifndef YY_NULLPTR
80 #  if defined __cplusplus && 201103L <= __cplusplus
81 #   define YY_NULLPTR nullptr
82 #  else
83 #   define YY_NULLPTR 0
84 #  endif
85 # endif
86
87 /* Enabling verbose error messages.  */
88 #ifdef YYERROR_VERBOSE
89 # undef YYERROR_VERBOSE
90 # define YYERROR_VERBOSE 1
91 #else
92 # define YYERROR_VERBOSE 1
93 #endif
94
95 /* In a future release of Bison, this section will be replaced
96    by #include "y.tab.h".  */
97 #ifndef YY_YY_PARSER_H_INCLUDED
98 # define YY_YY_PARSER_H_INCLUDED
99 /* Debug traces.  */
100 #ifndef YYDEBUG
101 # define YYDEBUG 1
102 #endif
103 #if YYDEBUG
104 extern int yydebug;
105 #endif
106 /* "%code requires" blocks.  */
107 #line 24 "parser.y" /* yacc.c:355  */
108
109 #include <kbdfile.h>
110 #include "keymap.h"
111
112 #ifndef STRDATA_STRUCT
113 #define STRDATA_STRUCT
114 #define MAX_PARSER_STRING 512
115 struct strdata {
116         unsigned long len;
117         unsigned char data[MAX_PARSER_STRING];
118 };
119 #endif
120
121 #line 122 "parser.c" /* yacc.c:355  */
122
123 /* Token type.  */
124 #ifndef YYTOKENTYPE
125 # define YYTOKENTYPE
126   enum yytokentype
127   {
128     EOL = 258,
129     NUMBER = 259,
130     LITERAL = 260,
131     CHARSET = 261,
132     KEYMAPS = 262,
133     KEYCODE = 263,
134     EQUALS = 264,
135     PLAIN = 265,
136     SHIFT = 266,
137     CONTROL = 267,
138     ALT = 268,
139     ALTGR = 269,
140     SHIFTL = 270,
141     SHIFTR = 271,
142     CTRLL = 272,
143     CTRLR = 273,
144     CAPSSHIFT = 274,
145     COMMA = 275,
146     DASH = 276,
147     STRING = 277,
148     STRLITERAL = 278,
149     COMPOSE = 279,
150     TO = 280,
151     CCHAR = 281,
152     ERROR = 282,
153     PLUS = 283,
154     UNUMBER = 284,
155     ALT_IS_META = 285,
156     STRINGS = 286,
157     AS = 287,
158     USUAL = 288,
159     ON = 289,
160     FOR = 290
161   };
162 #endif
163 /* Tokens.  */
164 #define EOL 258
165 #define NUMBER 259
166 #define LITERAL 260
167 #define CHARSET 261
168 #define KEYMAPS 262
169 #define KEYCODE 263
170 #define EQUALS 264
171 #define PLAIN 265
172 #define SHIFT 266
173 #define CONTROL 267
174 #define ALT 268
175 #define ALTGR 269
176 #define SHIFTL 270
177 #define SHIFTR 271
178 #define CTRLL 272
179 #define CTRLR 273
180 #define CAPSSHIFT 274
181 #define COMMA 275
182 #define DASH 276
183 #define STRING 277
184 #define STRLITERAL 278
185 #define COMPOSE 279
186 #define TO 280
187 #define CCHAR 281
188 #define ERROR 282
189 #define PLUS 283
190 #define UNUMBER 284
191 #define ALT_IS_META 285
192 #define STRINGS 286
193 #define AS 287
194 #define USUAL 288
195 #define ON 289
196 #define FOR 290
197
198 /* Value type.  */
199 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
200
201 union YYSTYPE
202 {
203 #line 57 "parser.y" /* yacc.c:355  */
204
205         int num;
206         struct strdata str;
207
208 #line 209 "parser.c" /* yacc.c:355  */
209 };
210
211 typedef union YYSTYPE YYSTYPE;
212 # define YYSTYPE_IS_TRIVIAL 1
213 # define YYSTYPE_IS_DECLARED 1
214 #endif
215
216
217
218 int yyparse (void *scanner, struct lk_ctx *ctx);
219
220 #endif /* !YY_YY_PARSER_H_INCLUDED  */
221
222 /* Copy the second part of user declarations.  */
223 #line 70 "parser.y" /* yacc.c:358  */
224
225 static int
226 yyerror(yyscan_t scanner __attribute__ ((unused)),
227         struct lk_ctx *ctx, const char *s)
228 {
229         ERR(ctx, "%s", s);
230         return 0;
231 }
232
233 static int
234 strings_as_usual(struct lk_ctx *ctx)
235 {
236         /*
237          * 26 strings, mostly inspired by the VT100 family
238          */
239         const char *stringvalues[30] = {
240                 /* F1 .. F20 */
241                 "\033[[A",  "\033[[B",  "\033[[C",  "\033[[D",  "\033[[E",
242                 "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~",
243                 "\033[23~", "\033[24~", "\033[25~", "\033[26~",
244                 "\033[28~", "\033[29~",
245                 "\033[31~", "\033[32~", "\033[33~", "\033[34~",
246                 /* Find,    Insert,     Remove,     Select,     Prior */
247                 "\033[1~",  "\033[2~",  "\033[3~",  "\033[4~",  "\033[5~",
248                 /* Next,    Macro,      Help,       Do,         Pause */
249                 "\033[6~",  0,          0,          0,          0
250         };
251         unsigned char i;
252
253         for (i = 0; i < 30; i++) {
254                 if (stringvalues[i]) {
255                         struct kbsentry ke;
256                         ke.kb_func = i;
257                         strncpy((char *)ke.kb_string, stringvalues[i], sizeof(ke.kb_string));
258                         ke.kb_string[sizeof(ke.kb_string) - 1] = 0;
259
260                         if (lk_add_func(ctx, &ke) == -1)
261                                 return -1;
262                 }
263         }
264         return 0;
265 }
266
267 static int
268 compose_as_usual(struct lk_ctx *ctx, char *charset)
269 {
270         if (charset && strcmp(charset, "iso-8859-1")) {
271                 ERR(ctx, _("loadkeys: don't know how to compose for %s"), charset);
272                 return -1;
273
274         } else {
275                 struct ccc {
276                         unsigned char c1, c2, c3;
277                 } def_latin1_composes[68] = {
278                         { '`', 'A', 0300 }, { '`', 'a', 0340 },
279                         { '\'', 'A', 0301 }, { '\'', 'a', 0341 },
280                         { '^', 'A', 0302 }, { '^', 'a', 0342 },
281                         { '~', 'A', 0303 }, { '~', 'a', 0343 },
282                         { '"', 'A', 0304 }, { '"', 'a', 0344 },
283                         { 'O', 'A', 0305 }, { 'o', 'a', 0345 },
284                         { '0', 'A', 0305 }, { '0', 'a', 0345 },
285                         { 'A', 'A', 0305 }, { 'a', 'a', 0345 },
286                         { 'A', 'E', 0306 }, { 'a', 'e', 0346 },
287                         { ',', 'C', 0307 }, { ',', 'c', 0347 },
288                         { '`', 'E', 0310 }, { '`', 'e', 0350 },
289                         { '\'', 'E', 0311 }, { '\'', 'e', 0351 },
290                         { '^', 'E', 0312 }, { '^', 'e', 0352 },
291                         { '"', 'E', 0313 }, { '"', 'e', 0353 },
292                         { '`', 'I', 0314 }, { '`', 'i', 0354 },
293                         { '\'', 'I', 0315 }, { '\'', 'i', 0355 },
294                         { '^', 'I', 0316 }, { '^', 'i', 0356 },
295                         { '"', 'I', 0317 }, { '"', 'i', 0357 },
296                         { '-', 'D', 0320 }, { '-', 'd', 0360 },
297                         { '~', 'N', 0321 }, { '~', 'n', 0361 },
298                         { '`', 'O', 0322 }, { '`', 'o', 0362 },
299                         { '\'', 'O', 0323 }, { '\'', 'o', 0363 },
300                         { '^', 'O', 0324 }, { '^', 'o', 0364 },
301                         { '~', 'O', 0325 }, { '~', 'o', 0365 },
302                         { '"', 'O', 0326 }, { '"', 'o', 0366 },
303                         { '/', 'O', 0330 }, { '/', 'o', 0370 },
304                         { '`', 'U', 0331 }, { '`', 'u', 0371 },
305                         { '\'', 'U', 0332 }, { '\'', 'u', 0372 },
306                         { '^', 'U', 0333 }, { '^', 'u', 0373 },
307                         { '"', 'U', 0334 }, { '"', 'u', 0374 },
308                         { '\'', 'Y', 0335 }, { '\'', 'y', 0375 },
309                         { 'T', 'H', 0336 }, { 't', 'h', 0376 },
310                         { 's', 's', 0337 }, { '"', 'y', 0377 },
311                         { 's', 'z', 0337 }, { 'i', 'j', 0377 }
312                 };
313                 int i;
314                 for (i = 0; i < 68; i++) {
315                         struct lk_kbdiacr ptr;
316                         struct ccc c = def_latin1_composes[i];
317
318                         ptr.diacr  = c.c1;
319                         ptr.base   = c.c2;
320                         ptr.result = c.c3;
321
322                         if (lk_append_compose(ctx, &ptr) == -1)
323                                 return -1;
324                 }
325         }
326         return 0;
327 }
328
329
330 #line 331 "parser.c" /* yacc.c:358  */
331
332 #ifdef short
333 # undef short
334 #endif
335
336 #ifdef YYTYPE_UINT8
337 typedef YYTYPE_UINT8 yytype_uint8;
338 #else
339 typedef unsigned char yytype_uint8;
340 #endif
341
342 #ifdef YYTYPE_INT8
343 typedef YYTYPE_INT8 yytype_int8;
344 #else
345 typedef signed char yytype_int8;
346 #endif
347
348 #ifdef YYTYPE_UINT16
349 typedef YYTYPE_UINT16 yytype_uint16;
350 #else
351 typedef unsigned short int yytype_uint16;
352 #endif
353
354 #ifdef YYTYPE_INT16
355 typedef YYTYPE_INT16 yytype_int16;
356 #else
357 typedef short int yytype_int16;
358 #endif
359
360 #ifndef YYSIZE_T
361 # ifdef __SIZE_TYPE__
362 #  define YYSIZE_T __SIZE_TYPE__
363 # elif defined size_t
364 #  define YYSIZE_T size_t
365 # elif ! defined YYSIZE_T
366 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
367 #  define YYSIZE_T size_t
368 # else
369 #  define YYSIZE_T unsigned int
370 # endif
371 #endif
372
373 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
374
375 #ifndef YY_
376 # if defined YYENABLE_NLS && YYENABLE_NLS
377 #  if ENABLE_NLS
378 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
379 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
380 #  endif
381 # endif
382 # ifndef YY_
383 #  define YY_(Msgid) Msgid
384 # endif
385 #endif
386
387 #ifndef YY_ATTRIBUTE
388 # if (defined __GNUC__                                               \
389       && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
390      || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
391 #  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
392 # else
393 #  define YY_ATTRIBUTE(Spec) /* empty */
394 # endif
395 #endif
396
397 #ifndef YY_ATTRIBUTE_PURE
398 # define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
399 #endif
400
401 #ifndef YY_ATTRIBUTE_UNUSED
402 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
403 #endif
404
405 #if !defined _Noreturn \
406      && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
407 # if defined _MSC_VER && 1200 <= _MSC_VER
408 #  define _Noreturn __declspec (noreturn)
409 # else
410 #  define _Noreturn YY_ATTRIBUTE ((__noreturn__))
411 # endif
412 #endif
413
414 /* Suppress unused-variable warnings by "using" E.  */
415 #if ! defined lint || defined __GNUC__
416 # define YYUSE(E) ((void) (E))
417 #else
418 # define YYUSE(E) /* empty */
419 #endif
420
421 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
422 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
423 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
424     _Pragma ("GCC diagnostic push") \
425     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
426     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
427 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
428     _Pragma ("GCC diagnostic pop")
429 #else
430 # define YY_INITIAL_VALUE(Value) Value
431 #endif
432 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
433 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
434 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
435 #endif
436 #ifndef YY_INITIAL_VALUE
437 # define YY_INITIAL_VALUE(Value) /* Nothing. */
438 #endif
439
440
441 #if ! defined yyoverflow || YYERROR_VERBOSE
442
443 /* The parser invokes alloca or malloc; define the necessary symbols.  */
444
445 # ifdef YYSTACK_USE_ALLOCA
446 #  if YYSTACK_USE_ALLOCA
447 #   ifdef __GNUC__
448 #    define YYSTACK_ALLOC __builtin_alloca
449 #   elif defined __BUILTIN_VA_ARG_INCR
450 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
451 #   elif defined _AIX
452 #    define YYSTACK_ALLOC __alloca
453 #   elif defined _MSC_VER
454 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
455 #    define alloca _alloca
456 #   else
457 #    define YYSTACK_ALLOC alloca
458 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
459 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
460       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
461 #     ifndef EXIT_SUCCESS
462 #      define EXIT_SUCCESS 0
463 #     endif
464 #    endif
465 #   endif
466 #  endif
467 # endif
468
469 # ifdef YYSTACK_ALLOC
470    /* Pacify GCC's 'empty if-body' warning.  */
471 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
472 #  ifndef YYSTACK_ALLOC_MAXIMUM
473     /* The OS might guarantee only one guard page at the bottom of the stack,
474        and a page size can be as small as 4096 bytes.  So we cannot safely
475        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
476        to allow for a few compiler-allocated temporary stack slots.  */
477 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
478 #  endif
479 # else
480 #  define YYSTACK_ALLOC YYMALLOC
481 #  define YYSTACK_FREE YYFREE
482 #  ifndef YYSTACK_ALLOC_MAXIMUM
483 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
484 #  endif
485 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
486        && ! ((defined YYMALLOC || defined malloc) \
487              && (defined YYFREE || defined free)))
488 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
489 #   ifndef EXIT_SUCCESS
490 #    define EXIT_SUCCESS 0
491 #   endif
492 #  endif
493 #  ifndef YYMALLOC
494 #   define YYMALLOC malloc
495 #   if ! defined malloc && ! defined EXIT_SUCCESS
496 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
497 #   endif
498 #  endif
499 #  ifndef YYFREE
500 #   define YYFREE free
501 #   if ! defined free && ! defined EXIT_SUCCESS
502 void free (void *); /* INFRINGES ON USER NAME SPACE */
503 #   endif
504 #  endif
505 # endif
506 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
507
508
509 #if (! defined yyoverflow \
510      && (! defined __cplusplus \
511          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
512
513 /* A type that is properly aligned for any stack member.  */
514 union yyalloc
515 {
516   yytype_int16 yyss_alloc;
517   YYSTYPE yyvs_alloc;
518 };
519
520 /* The size of the maximum gap between one aligned stack and the next.  */
521 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
522
523 /* The size of an array large to enough to hold all stacks, each with
524    N elements.  */
525 # define YYSTACK_BYTES(N) \
526      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
527       + YYSTACK_GAP_MAXIMUM)
528
529 # define YYCOPY_NEEDED 1
530
531 /* Relocate STACK from its old location to the new one.  The
532    local variables YYSIZE and YYSTACKSIZE give the old and new number of
533    elements in the stack, and YYPTR gives the new location of the
534    stack.  Advance YYPTR to a properly aligned location for the next
535    stack.  */
536 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
537     do                                                                  \
538       {                                                                 \
539         YYSIZE_T yynewbytes;                                            \
540         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
541         Stack = &yyptr->Stack_alloc;                                    \
542         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
543         yyptr += yynewbytes / sizeof (*yyptr);                          \
544       }                                                                 \
545     while (0)
546
547 #endif
548
549 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
550 /* Copy COUNT objects from SRC to DST.  The source and destination do
551    not overlap.  */
552 # ifndef YYCOPY
553 #  if defined __GNUC__ && 1 < __GNUC__
554 #   define YYCOPY(Dst, Src, Count) \
555       __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
556 #  else
557 #   define YYCOPY(Dst, Src, Count)              \
558       do                                        \
559         {                                       \
560           YYSIZE_T yyi;                         \
561           for (yyi = 0; yyi < (Count); yyi++)   \
562             (Dst)[yyi] = (Src)[yyi];            \
563         }                                       \
564       while (0)
565 #  endif
566 # endif
567 #endif /* !YYCOPY_NEEDED */
568
569 /* YYFINAL -- State number of the termination state.  */
570 #define YYFINAL  2
571 /* YYLAST -- Last index in YYTABLE.  */
572 #define YYLAST   85
573
574 /* YYNTOKENS -- Number of terminals.  */
575 #define YYNTOKENS  36
576 /* YYNNTS -- Number of nonterminals.  */
577 #define YYNNTS  19
578 /* YYNRULES -- Number of rules.  */
579 #define YYNRULES  50
580 /* YYNSTATES -- Number of states.  */
581 #define YYNSTATES  90
582
583 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
584    by yylex, with out-of-bounds checking.  */
585 #define YYUNDEFTOK  2
586 #define YYMAXUTOK   290
587
588 #define YYTRANSLATE(YYX)                                                \
589   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
590
591 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
592    as returned by yylex, without out-of-bounds checking.  */
593 static const yytype_uint8 yytranslate[] =
594 {
595        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
596        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
597        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
598        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
599        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
600        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
601        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
602        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
603        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
604        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
605        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
606        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
607        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
608        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
609        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
610        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
611        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
612        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
613        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
614        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
615        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
616        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
617        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
618        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
619        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
620        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
621        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
622       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
623       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
624       35
625 };
626
627 #if YYDEBUG
628   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
629 static const yytype_uint16 yyrline[] =
630 {
631        0,   178,   178,   179,   181,   182,   183,   184,   185,   186,
632      187,   188,   189,   191,   208,   213,   220,   225,   231,   236,
633      237,   239,   247,   253,   275,   285,   296,   297,   299,   359,
634      365,   372,   373,   375,   376,   377,   378,   379,   380,   381,
635      382,   383,   387,   388,   390,   396,   397,   398,   399,   400,
636      401
637 };
638 #endif
639
640 #if YYDEBUG || YYERROR_VERBOSE || 1
641 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
642    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
643 static const char *const yytname[] =
644 {
645   "$end", "error", "$undefined", "EOL", "NUMBER", "LITERAL", "CHARSET",
646   "KEYMAPS", "KEYCODE", "EQUALS", "PLAIN", "SHIFT", "CONTROL", "ALT",
647   "ALTGR", "SHIFTL", "SHIFTR", "CTRLL", "CTRLR", "CAPSSHIFT", "COMMA",
648   "DASH", "STRING", "STRLITERAL", "COMPOSE", "TO", "CCHAR", "ERROR",
649   "PLUS", "UNUMBER", "ALT_IS_META", "STRINGS", "AS", "USUAL", "ON", "FOR",
650   "$accept", "keytable", "line", "charsetline", "altismetaline",
651   "usualstringsline", "usualcomposeline", "keymapline", "range", "range0",
652   "strline", "compline", "compsym", "singleline", "modifiers", "modifier",
653   "rvalue0", "rvalue1", "rvalue", YY_NULLPTR
654 };
655 #endif
656
657 # ifdef YYPRINT
658 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
659    (internal) symbol number NUM (which must be that of a token).  */
660 static const yytype_uint16 yytoknum[] =
661 {
662        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
663      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
664      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
665      285,   286,   287,   288,   289,   290
666 };
667 # endif
668
669 #define YYPACT_NINF -31
670
671 #define yypact_value_is_default(Yystate) \
672   (!!((Yystate) == (-31)))
673
674 #define YYTABLE_NINF -1
675
676 #define yytable_value_is_error(Yytable_value) \
677   0
678
679   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
680      STATE-NUM.  */
681 static const yytype_int8 yypact[] =
682 {
683      -31,     3,   -31,   -31,   -22,    -2,     4,    -1,   -31,   -31,
684      -31,   -31,   -31,   -31,   -31,   -31,   -31,     7,    10,    35,
685        8,   -31,   -31,   -31,   -31,   -31,   -31,   -31,   -31,   -31,
686       45,   -31,    41,    24,    32,   -31,    42,    46,    56,   -31,
687      -31,    21,    20,   -31,    33,    63,   -31,   -31,    64,   -31,
688       -2,    19,    60,    47,    -3,    48,    68,    65,   -31,   -31,
689      -31,   -31,    26,   -31,    69,    19,   -31,    19,    72,   -31,
690       53,     0,   -31,    19,   -31,   -31,   -31,   -31,   -31,    74,
691      -31,    75,    76,    77,    78,   -31,   -31,   -31,   -31,   -31
692 };
693
694   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
695      Performed when YYTABLE does not specify something else to do.  Zero
696      means the default is an error.  */
697 static const yytype_uint8 yydefact[] =
698 {
699        2,     0,     1,     4,     0,     0,     0,     0,    33,    34,
700       35,    36,    37,    38,    39,    40,    41,     0,     0,     0,
701        0,     3,     5,     6,     7,     8,     9,    11,    12,    10,
702        0,    32,     0,    22,     0,    20,     0,     0,     0,    26,
703       27,     0,     0,    14,     0,     0,    31,    13,     0,    18,
704        0,    42,     0,     0,     0,     0,     0,     0,    21,    19,
705       45,    49,     0,    47,     0,    42,    44,     0,     0,    17,
706        0,     0,    15,     0,    46,    50,    48,    28,    43,     0,
707       23,     0,     0,     0,     0,    30,    16,    24,    25,    29
708 };
709
710   /* YYPGOTO[NTERM-NUM].  */
711 static const yytype_int8 yypgoto[] =
712 {
713      -31,   -31,   -31,   -31,   -31,   -31,   -31,   -31,   -31,    34,
714      -31,   -31,    40,   -31,   -31,    55,    18,   -31,   -30
715 };
716
717   /* YYDEFGOTO[NTERM-NUM].  */
718 static const yytype_int8 yydefgoto[] =
719 {
720       -1,     1,    21,    22,    23,    24,    25,    26,    34,    35,
721       27,    28,    42,    29,    30,    31,    64,    65,    66
722 };
723
724   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
725      positive, shift that token.  If negative, reduce the rule whose
726      number is the opposite.  If YYTABLE_NINF, syntax error.  */
727 static const yytype_uint8 yytable[] =
728 {
729       69,    32,    33,     2,    60,    61,     3,    37,    36,     4,
730        5,     6,    38,     7,     8,     9,    10,    11,    12,    13,
731       14,    15,    16,    60,    61,    17,    82,    18,    62,    63,
732       74,    75,    70,    19,    20,    49,    39,    79,    43,    40,
733       44,    83,    41,    84,    47,    48,    39,    62,    63,    40,
734       52,    51,    50,    45,    54,    76,     8,     9,    10,    11,
735       12,    13,    14,    15,    16,    53,    56,    57,    58,    67,
736       68,    72,    77,    71,    73,    80,    81,    85,    86,    87,
737       88,    89,    55,    78,    59,    46
738 };
739
740 static const yytype_uint8 yycheck[] =
741 {
742        3,    23,     4,     0,     4,     5,     3,     8,     4,     6,
743        7,     8,     5,    10,    11,    12,    13,    14,    15,    16,
744       17,    18,    19,     4,     5,    22,    26,    24,    28,    29,
745        4,     5,    35,    30,    31,     3,    26,    67,     3,    29,
746       32,    71,    32,    73,     3,    21,    26,    28,    29,    29,
747        4,     9,    20,     8,    33,    29,    11,    12,    13,    14,
748       15,    16,    17,    18,    19,     9,    33,     4,     4,     9,
749       23,     3,     3,    25,     9,     3,    23,     3,     3,     3,
750        3,     3,    42,    65,    50,    30
751 };
752
753   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
754      symbol of state STATE-NUM.  */
755 static const yytype_uint8 yystos[] =
756 {
757        0,    37,     0,     3,     6,     7,     8,    10,    11,    12,
758       13,    14,    15,    16,    17,    18,    19,    22,    24,    30,
759       31,    38,    39,    40,    41,    42,    43,    46,    47,    49,
760       50,    51,    23,     4,    44,    45,     4,     8,     5,    26,
761       29,    32,    48,     3,    32,     8,    51,     3,    21,     3,
762       20,     9,     4,     9,    33,    48,    33,     4,     4,    45,
763        4,     5,    28,    29,    52,    53,    54,     9,    23,     3,
764       35,    25,     3,     9,     4,     5,    29,     3,    52,    54,
765        3,    23,    26,    54,    54,     3,     3,     3,     3,     3
766 };
767
768   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
769 static const yytype_uint8 yyr1[] =
770 {
771        0,    36,    37,    37,    38,    38,    38,    38,    38,    38,
772       38,    38,    38,    39,    40,    41,    42,    42,    43,    44,
773       44,    45,    45,    46,    47,    47,    48,    48,    49,    49,
774       49,    50,    50,    51,    51,    51,    51,    51,    51,    51,
775       51,    51,    52,    52,    53,    54,    54,    54,    54,    54,
776       54
777 };
778
779   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
780 static const yytype_uint8 yyr2[] =
781 {
782        0,     2,     0,     2,     1,     1,     1,     1,     1,     1,
783        1,     1,     1,     3,     2,     4,     6,     4,     3,     3,
784        1,     3,     1,     5,     6,     6,     1,     1,     5,     6,
785        6,     2,     1,     1,     1,     1,     1,     1,     1,     1,
786        1,     1,     0,     2,     1,     1,     2,     1,     2,     1,
787        2
788 };
789
790
791 #define yyerrok         (yyerrstatus = 0)
792 #define yyclearin       (yychar = YYEMPTY)
793 #define YYEMPTY         (-2)
794 #define YYEOF           0
795
796 #define YYACCEPT        goto yyacceptlab
797 #define YYABORT         goto yyabortlab
798 #define YYERROR         goto yyerrorlab
799
800
801 #define YYRECOVERING()  (!!yyerrstatus)
802
803 #define YYBACKUP(Token, Value)                                  \
804 do                                                              \
805   if (yychar == YYEMPTY)                                        \
806     {                                                           \
807       yychar = (Token);                                         \
808       yylval = (Value);                                         \
809       YYPOPSTACK (yylen);                                       \
810       yystate = *yyssp;                                         \
811       goto yybackup;                                            \
812     }                                                           \
813   else                                                          \
814     {                                                           \
815       yyerror (scanner, ctx, YY_("syntax error: cannot back up")); \
816       YYERROR;                                                  \
817     }                                                           \
818 while (0)
819
820 /* Error token number */
821 #define YYTERROR        1
822 #define YYERRCODE       256
823
824
825
826 /* Enable debugging if requested.  */
827 #if YYDEBUG
828
829 # ifndef YYFPRINTF
830 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
831 #  define YYFPRINTF fprintf
832 # endif
833
834 # define YYDPRINTF(Args)                        \
835 do {                                            \
836   if (yydebug)                                  \
837     YYFPRINTF Args;                             \
838 } while (0)
839
840 /* This macro is provided for backward compatibility. */
841 #ifndef YY_LOCATION_PRINT
842 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
843 #endif
844
845
846 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
847 do {                                                                      \
848   if (yydebug)                                                            \
849     {                                                                     \
850       YYFPRINTF (stderr, "%s ", Title);                                   \
851       yy_symbol_print (stderr,                                            \
852                   Type, Value, scanner, ctx); \
853       YYFPRINTF (stderr, "\n");                                           \
854     }                                                                     \
855 } while (0)
856
857
858 /*----------------------------------------.
859 | Print this symbol's value on YYOUTPUT.  |
860 `----------------------------------------*/
861
862 static void
863 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct lk_ctx *ctx)
864 {
865   FILE *yyo = yyoutput;
866   YYUSE (yyo);
867   YYUSE (scanner);
868   YYUSE (ctx);
869   if (!yyvaluep)
870     return;
871 # ifdef YYPRINT
872   if (yytype < YYNTOKENS)
873     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
874 # endif
875   YYUSE (yytype);
876 }
877
878
879 /*--------------------------------.
880 | Print this symbol on YYOUTPUT.  |
881 `--------------------------------*/
882
883 static void
884 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct lk_ctx *ctx)
885 {
886   YYFPRINTF (yyoutput, "%s %s (",
887              yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
888
889   yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx);
890   YYFPRINTF (yyoutput, ")");
891 }
892
893 /*------------------------------------------------------------------.
894 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
895 | TOP (included).                                                   |
896 `------------------------------------------------------------------*/
897
898 static void
899 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
900 {
901   YYFPRINTF (stderr, "Stack now");
902   for (; yybottom <= yytop; yybottom++)
903     {
904       int yybot = *yybottom;
905       YYFPRINTF (stderr, " %d", yybot);
906     }
907   YYFPRINTF (stderr, "\n");
908 }
909
910 # define YY_STACK_PRINT(Bottom, Top)                            \
911 do {                                                            \
912   if (yydebug)                                                  \
913     yy_stack_print ((Bottom), (Top));                           \
914 } while (0)
915
916
917 /*------------------------------------------------.
918 | Report that the YYRULE is going to be reduced.  |
919 `------------------------------------------------*/
920
921 static void
922 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, void *scanner, struct lk_ctx *ctx)
923 {
924   unsigned long int yylno = yyrline[yyrule];
925   int yynrhs = yyr2[yyrule];
926   int yyi;
927   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
928              yyrule - 1, yylno);
929   /* The symbols being reduced.  */
930   for (yyi = 0; yyi < yynrhs; yyi++)
931     {
932       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
933       yy_symbol_print (stderr,
934                        yystos[yyssp[yyi + 1 - yynrhs]],
935                        &(yyvsp[(yyi + 1) - (yynrhs)])
936                                               , scanner, ctx);
937       YYFPRINTF (stderr, "\n");
938     }
939 }
940
941 # define YY_REDUCE_PRINT(Rule)          \
942 do {                                    \
943   if (yydebug)                          \
944     yy_reduce_print (yyssp, yyvsp, Rule, scanner, ctx); \
945 } while (0)
946
947 /* Nonzero means print parse trace.  It is left uninitialized so that
948    multiple parsers can coexist.  */
949 int yydebug;
950 #else /* !YYDEBUG */
951 # define YYDPRINTF(Args)
952 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
953 # define YY_STACK_PRINT(Bottom, Top)
954 # define YY_REDUCE_PRINT(Rule)
955 #endif /* !YYDEBUG */
956
957
958 /* YYINITDEPTH -- initial size of the parser's stacks.  */
959 #ifndef YYINITDEPTH
960 # define YYINITDEPTH 200
961 #endif
962
963 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
964    if the built-in stack extension method is used).
965
966    Do not make this value too large; the results are undefined if
967    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
968    evaluated with infinite-precision integer arithmetic.  */
969
970 #ifndef YYMAXDEPTH
971 # define YYMAXDEPTH 10000
972 #endif
973
974
975 #if YYERROR_VERBOSE
976
977 # ifndef yystrlen
978 #  if defined __GLIBC__ && defined _STRING_H
979 #   define yystrlen strlen
980 #  else
981 /* Return the length of YYSTR.  */
982 static YYSIZE_T
983 yystrlen (const char *yystr)
984 {
985   YYSIZE_T yylen;
986   for (yylen = 0; yystr[yylen]; yylen++)
987     continue;
988   return yylen;
989 }
990 #  endif
991 # endif
992
993 # ifndef yystpcpy
994 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
995 #   define yystpcpy stpcpy
996 #  else
997 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
998    YYDEST.  */
999 static char *
1000 yystpcpy (char *yydest, const char *yysrc)
1001 {
1002   char *yyd = yydest;
1003   const char *yys = yysrc;
1004
1005   while ((*yyd++ = *yys++) != '\0')
1006     continue;
1007
1008   return yyd - 1;
1009 }
1010 #  endif
1011 # endif
1012
1013 # ifndef yytnamerr
1014 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1015    quotes and backslashes, so that it's suitable for yyerror.  The
1016    heuristic is that double-quoting is unnecessary unless the string
1017    contains an apostrophe, a comma, or backslash (other than
1018    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1019    null, do not copy; instead, return the length of what the result
1020    would have been.  */
1021 static YYSIZE_T
1022 yytnamerr (char *yyres, const char *yystr)
1023 {
1024   if (*yystr == '"')
1025     {
1026       YYSIZE_T yyn = 0;
1027       char const *yyp = yystr;
1028
1029       for (;;)
1030         switch (*++yyp)
1031           {
1032           case '\'':
1033           case ',':
1034             goto do_not_strip_quotes;
1035
1036           case '\\':
1037             if (*++yyp != '\\')
1038               goto do_not_strip_quotes;
1039             /* Fall through.  */
1040           default:
1041             if (yyres)
1042               yyres[yyn] = *yyp;
1043             yyn++;
1044             break;
1045
1046           case '"':
1047             if (yyres)
1048               yyres[yyn] = '\0';
1049             return yyn;
1050           }
1051     do_not_strip_quotes: ;
1052     }
1053
1054   if (! yyres)
1055     return yystrlen (yystr);
1056
1057   return yystpcpy (yyres, yystr) - yyres;
1058 }
1059 # endif
1060
1061 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1062    about the unexpected token YYTOKEN for the state stack whose top is
1063    YYSSP.
1064
1065    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1066    not large enough to hold the message.  In that case, also set
1067    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1068    required number of bytes is too large to store.  */
1069 static int
1070 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1071                 yytype_int16 *yyssp, int yytoken)
1072 {
1073   YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1074   YYSIZE_T yysize = yysize0;
1075   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1076   /* Internationalized format string. */
1077   const char *yyformat = YY_NULLPTR;
1078   /* Arguments of yyformat. */
1079   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1080   /* Number of reported tokens (one for the "unexpected", one per
1081      "expected"). */
1082   int yycount = 0;
1083
1084   /* There are many possibilities here to consider:
1085      - If this state is a consistent state with a default action, then
1086        the only way this function was invoked is if the default action
1087        is an error action.  In that case, don't check for expected
1088        tokens because there are none.
1089      - The only way there can be no lookahead present (in yychar) is if
1090        this state is a consistent state with a default action.  Thus,
1091        detecting the absence of a lookahead is sufficient to determine
1092        that there is no unexpected or expected token to report.  In that
1093        case, just report a simple "syntax error".
1094      - Don't assume there isn't a lookahead just because this state is a
1095        consistent state with a default action.  There might have been a
1096        previous inconsistent state, consistent state with a non-default
1097        action, or user semantic action that manipulated yychar.
1098      - Of course, the expected token list depends on states to have
1099        correct lookahead information, and it depends on the parser not
1100        to perform extra reductions after fetching a lookahead from the
1101        scanner and before detecting a syntax error.  Thus, state merging
1102        (from LALR or IELR) and default reductions corrupt the expected
1103        token list.  However, the list is correct for canonical LR with
1104        one exception: it will still contain any token that will not be
1105        accepted due to an error action in a later state.
1106   */
1107   if (yytoken != YYEMPTY)
1108     {
1109       int yyn = yypact[*yyssp];
1110       yyarg[yycount++] = yytname[yytoken];
1111       if (!yypact_value_is_default (yyn))
1112         {
1113           /* Start YYX at -YYN if negative to avoid negative indexes in
1114              YYCHECK.  In other words, skip the first -YYN actions for
1115              this state because they are default actions.  */
1116           int yyxbegin = yyn < 0 ? -yyn : 0;
1117           /* Stay within bounds of both yycheck and yytname.  */
1118           int yychecklim = YYLAST - yyn + 1;
1119           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1120           int yyx;
1121
1122           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1123             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1124                 && !yytable_value_is_error (yytable[yyx + yyn]))
1125               {
1126                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1127                   {
1128                     yycount = 1;
1129                     yysize = yysize0;
1130                     break;
1131                   }
1132                 yyarg[yycount++] = yytname[yyx];
1133                 {
1134                   YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1135                   if (! (yysize <= yysize1
1136                          && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1137                     return 2;
1138                   yysize = yysize1;
1139                 }
1140               }
1141         }
1142     }
1143
1144   switch (yycount)
1145     {
1146 # define YYCASE_(N, S)                      \
1147       case N:                               \
1148         yyformat = S;                       \
1149       break
1150     default: /* Avoid compiler warnings. */
1151       YYCASE_(0, YY_("syntax error"));
1152       YYCASE_(1, YY_("syntax error, unexpected %s"));
1153       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1154       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1155       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1156       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1157 # undef YYCASE_
1158     }
1159
1160   {
1161     YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1162     if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1163       return 2;
1164     yysize = yysize1;
1165   }
1166
1167   if (*yymsg_alloc < yysize)
1168     {
1169       *yymsg_alloc = 2 * yysize;
1170       if (! (yysize <= *yymsg_alloc
1171              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1172         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1173       return 1;
1174     }
1175
1176   /* Avoid sprintf, as that infringes on the user's name space.
1177      Don't have undefined behavior even if the translation
1178      produced a string with the wrong number of "%s"s.  */
1179   {
1180     char *yyp = *yymsg;
1181     int yyi = 0;
1182     while ((*yyp = *yyformat) != '\0')
1183       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1184         {
1185           yyp += yytnamerr (yyp, yyarg[yyi++]);
1186           yyformat += 2;
1187         }
1188       else
1189         {
1190           yyp++;
1191           yyformat++;
1192         }
1193   }
1194   return 0;
1195 }
1196 #endif /* YYERROR_VERBOSE */
1197
1198 /*-----------------------------------------------.
1199 | Release the memory associated to this symbol.  |
1200 `-----------------------------------------------*/
1201
1202 static void
1203 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *scanner, struct lk_ctx *ctx)
1204 {
1205   YYUSE (yyvaluep);
1206   YYUSE (scanner);
1207   YYUSE (ctx);
1208   if (!yymsg)
1209     yymsg = "Deleting";
1210   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1211
1212   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1213   YYUSE (yytype);
1214   YY_IGNORE_MAYBE_UNINITIALIZED_END
1215 }
1216
1217
1218
1219
1220 /*----------.
1221 | yyparse.  |
1222 `----------*/
1223
1224 int
1225 yyparse (void *scanner, struct lk_ctx *ctx)
1226 {
1227 /* The lookahead symbol.  */
1228 int yychar;
1229
1230
1231 /* The semantic value of the lookahead symbol.  */
1232 /* Default value used for initialization, for pacifying older GCCs
1233    or non-GCC compilers.  */
1234 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1235 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1236
1237     /* Number of syntax errors so far.  */
1238     int yynerrs;
1239
1240     int yystate;
1241     /* Number of tokens to shift before error messages enabled.  */
1242     int yyerrstatus;
1243
1244     /* The stacks and their tools:
1245        'yyss': related to states.
1246        'yyvs': related to semantic values.
1247
1248        Refer to the stacks through separate pointers, to allow yyoverflow
1249        to reallocate them elsewhere.  */
1250
1251     /* The state stack.  */
1252     yytype_int16 yyssa[YYINITDEPTH];
1253     yytype_int16 *yyss;
1254     yytype_int16 *yyssp;
1255
1256     /* The semantic value stack.  */
1257     YYSTYPE yyvsa[YYINITDEPTH];
1258     YYSTYPE *yyvs;
1259     YYSTYPE *yyvsp;
1260
1261     YYSIZE_T yystacksize;
1262
1263   int yyn;
1264   int yyresult;
1265   /* Lookahead token as an internal (translated) token number.  */
1266   int yytoken = 0;
1267   /* The variables used to return semantic value and location from the
1268      action routines.  */
1269   YYSTYPE yyval;
1270
1271 #if YYERROR_VERBOSE
1272   /* Buffer for error messages, and its allocated size.  */
1273   char yymsgbuf[128];
1274   char *yymsg = yymsgbuf;
1275   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1276 #endif
1277
1278 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1279
1280   /* The number of symbols on the RHS of the reduced rule.
1281      Keep to zero when no symbol should be popped.  */
1282   int yylen = 0;
1283
1284   yyssp = yyss = yyssa;
1285   yyvsp = yyvs = yyvsa;
1286   yystacksize = YYINITDEPTH;
1287
1288   YYDPRINTF ((stderr, "Starting parse\n"));
1289
1290   yystate = 0;
1291   yyerrstatus = 0;
1292   yynerrs = 0;
1293   yychar = YYEMPTY; /* Cause a token to be read.  */
1294   goto yysetstate;
1295
1296 /*------------------------------------------------------------.
1297 | yynewstate -- Push a new state, which is found in yystate.  |
1298 `------------------------------------------------------------*/
1299  yynewstate:
1300   /* In all cases, when you get here, the value and location stacks
1301      have just been pushed.  So pushing a state here evens the stacks.  */
1302   yyssp++;
1303
1304  yysetstate:
1305   *yyssp = yystate;
1306
1307   if (yyss + yystacksize - 1 <= yyssp)
1308     {
1309       /* Get the current used size of the three stacks, in elements.  */
1310       YYSIZE_T yysize = yyssp - yyss + 1;
1311
1312 #ifdef yyoverflow
1313       {
1314         /* Give user a chance to reallocate the stack.  Use copies of
1315            these so that the &'s don't force the real ones into
1316            memory.  */
1317         YYSTYPE *yyvs1 = yyvs;
1318         yytype_int16 *yyss1 = yyss;
1319
1320         /* Each stack pointer address is followed by the size of the
1321            data in use in that stack, in bytes.  This used to be a
1322            conditional around just the two extra args, but that might
1323            be undefined if yyoverflow is a macro.  */
1324         yyoverflow (YY_("memory exhausted"),
1325                     &yyss1, yysize * sizeof (*yyssp),
1326                     &yyvs1, yysize * sizeof (*yyvsp),
1327                     &yystacksize);
1328
1329         yyss = yyss1;
1330         yyvs = yyvs1;
1331       }
1332 #else /* no yyoverflow */
1333 # ifndef YYSTACK_RELOCATE
1334       goto yyexhaustedlab;
1335 # else
1336       /* Extend the stack our own way.  */
1337       if (YYMAXDEPTH <= yystacksize)
1338         goto yyexhaustedlab;
1339       yystacksize *= 2;
1340       if (YYMAXDEPTH < yystacksize)
1341         yystacksize = YYMAXDEPTH;
1342
1343       {
1344         yytype_int16 *yyss1 = yyss;
1345         union yyalloc *yyptr =
1346           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1347         if (! yyptr)
1348           goto yyexhaustedlab;
1349         YYSTACK_RELOCATE (yyss_alloc, yyss);
1350         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1351 #  undef YYSTACK_RELOCATE
1352         if (yyss1 != yyssa)
1353           YYSTACK_FREE (yyss1);
1354       }
1355 # endif
1356 #endif /* no yyoverflow */
1357
1358       yyssp = yyss + yysize - 1;
1359       yyvsp = yyvs + yysize - 1;
1360
1361       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1362                   (unsigned long int) yystacksize));
1363
1364       if (yyss + yystacksize - 1 <= yyssp)
1365         YYABORT;
1366     }
1367
1368   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1369
1370   if (yystate == YYFINAL)
1371     YYACCEPT;
1372
1373   goto yybackup;
1374
1375 /*-----------.
1376 | yybackup.  |
1377 `-----------*/
1378 yybackup:
1379
1380   /* Do appropriate processing given the current state.  Read a
1381      lookahead token if we need one and don't already have one.  */
1382
1383   /* First try to decide what to do without reference to lookahead token.  */
1384   yyn = yypact[yystate];
1385   if (yypact_value_is_default (yyn))
1386     goto yydefault;
1387
1388   /* Not known => get a lookahead token if don't already have one.  */
1389
1390   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1391   if (yychar == YYEMPTY)
1392     {
1393       YYDPRINTF ((stderr, "Reading a token: "));
1394       yychar = yylex (&yylval, scanner);
1395     }
1396
1397   if (yychar <= YYEOF)
1398     {
1399       yychar = yytoken = YYEOF;
1400       YYDPRINTF ((stderr, "Now at end of input.\n"));
1401     }
1402   else
1403     {
1404       yytoken = YYTRANSLATE (yychar);
1405       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1406     }
1407
1408   /* If the proper action on seeing token YYTOKEN is to reduce or to
1409      detect an error, take that action.  */
1410   yyn += yytoken;
1411   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1412     goto yydefault;
1413   yyn = yytable[yyn];
1414   if (yyn <= 0)
1415     {
1416       if (yytable_value_is_error (yyn))
1417         goto yyerrlab;
1418       yyn = -yyn;
1419       goto yyreduce;
1420     }
1421
1422   /* Count tokens shifted since error; after three, turn off error
1423      status.  */
1424   if (yyerrstatus)
1425     yyerrstatus--;
1426
1427   /* Shift the lookahead token.  */
1428   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1429
1430   /* Discard the shifted token.  */
1431   yychar = YYEMPTY;
1432
1433   yystate = yyn;
1434   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1435   *++yyvsp = yylval;
1436   YY_IGNORE_MAYBE_UNINITIALIZED_END
1437
1438   goto yynewstate;
1439
1440
1441 /*-----------------------------------------------------------.
1442 | yydefault -- do the default action for the current state.  |
1443 `-----------------------------------------------------------*/
1444 yydefault:
1445   yyn = yydefact[yystate];
1446   if (yyn == 0)
1447     goto yyerrlab;
1448   goto yyreduce;
1449
1450
1451 /*-----------------------------.
1452 | yyreduce -- Do a reduction.  |
1453 `-----------------------------*/
1454 yyreduce:
1455   /* yyn is the number of a rule to reduce with.  */
1456   yylen = yyr2[yyn];
1457
1458   /* If YYLEN is nonzero, implement the default value of the action:
1459      '$$ = $1'.
1460
1461      Otherwise, the following line sets YYVAL to garbage.
1462      This behavior is undocumented and Bison
1463      users should not rely upon it.  Assigning to YYVAL
1464      unconditionally makes the parser a bit smaller, and it avoids a
1465      GCC warning that YYVAL may be used uninitialized.  */
1466   yyval = yyvsp[1-yylen];
1467
1468
1469   YY_REDUCE_PRINT (yyn);
1470   switch (yyn)
1471     {
1472         case 13:
1473 #line 192 "parser.y" /* yacc.c:1648  */
1474     {
1475                                 if (lk_set_charset(ctx, (char *) (yyvsp[-1].str).data)) {
1476                                         ERR(ctx,
1477                                                 _("unknown charset %s - ignoring charset request\n"),
1478                                                 (char *) (yyvsp[-1].str).data);
1479                                         YYERROR;
1480                                 }
1481                                 ctx->keywords |= LK_KEYWORD_CHARSET;
1482
1483                                 /* Unicode: The first 256 code points were made
1484                                    identical to the content of ISO 8859-1 */
1485                                 if (ctx->flags & LK_FLAG_PREFER_UNICODE &&
1486                                     !strcasecmp((char *) (yyvsp[-1].str).data, "iso-8859-1"))
1487                                         ctx->flags ^= LK_FLAG_PREFER_UNICODE;
1488                         }
1489 #line 1490 "parser.c" /* yacc.c:1648  */
1490     break;
1491
1492   case 14:
1493 #line 209 "parser.y" /* yacc.c:1648  */
1494     {
1495                                 ctx->keywords |= LK_KEYWORD_ALTISMETA;
1496                         }
1497 #line 1498 "parser.c" /* yacc.c:1648  */
1498     break;
1499
1500   case 15:
1501 #line 214 "parser.y" /* yacc.c:1648  */
1502     {
1503                                 if (strings_as_usual(ctx) == -1)
1504                                         YYERROR;
1505                                 ctx->keywords |= LK_KEYWORD_STRASUSUAL;
1506                         }
1507 #line 1508 "parser.c" /* yacc.c:1648  */
1508     break;
1509
1510   case 16:
1511 #line 221 "parser.y" /* yacc.c:1648  */
1512     {
1513                                 if (compose_as_usual(ctx, (char *) (yyvsp[-1].str).data) == -1)
1514                                         YYERROR;
1515                         }
1516 #line 1517 "parser.c" /* yacc.c:1648  */
1517     break;
1518
1519   case 17:
1520 #line 226 "parser.y" /* yacc.c:1648  */
1521     {
1522                                 if (compose_as_usual(ctx, 0) == -1)
1523                                         YYERROR;
1524                         }
1525 #line 1526 "parser.c" /* yacc.c:1648  */
1526     break;
1527
1528   case 18:
1529 #line 232 "parser.y" /* yacc.c:1648  */
1530     {
1531                                 ctx->keywords |= LK_KEYWORD_KEYMAPS;
1532                         }
1533 #line 1534 "parser.c" /* yacc.c:1648  */
1534     break;
1535
1536   case 21:
1537 #line 240 "parser.y" /* yacc.c:1648  */
1538     {
1539                                 int i;
1540                                 for (i = (yyvsp[-2].num); i <= (yyvsp[0].num); i++) {
1541                                         if (lk_add_map(ctx, i) == -1)
1542                                                 YYERROR;
1543                                 }
1544                         }
1545 #line 1546 "parser.c" /* yacc.c:1648  */
1546     break;
1547
1548   case 22:
1549 #line 248 "parser.y" /* yacc.c:1648  */
1550     {
1551                                 if (lk_add_map(ctx, (yyvsp[0].num)) == -1)
1552                                         YYERROR;
1553                         }
1554 #line 1555 "parser.c" /* yacc.c:1648  */
1555     break;
1556
1557   case 23:
1558 #line 254 "parser.y" /* yacc.c:1648  */
1559     {
1560                                 struct kbsentry ke;
1561
1562                                 if (KTYP((yyvsp[-3].num)) != KT_FN) {
1563                                         ERR(ctx, _("'%s' is not a function key symbol"),
1564                                                 get_sym(ctx, KTYP((yyvsp[-3].num)), KVAL((yyvsp[-3].num))));
1565                                         YYERROR;
1566                                 }
1567
1568                                 ke.kb_func = (unsigned char) KVAL((yyvsp[-3].num));
1569
1570                                 strncpy((char *) ke.kb_string,
1571                                         (char *) (yyvsp[-1].str).data,
1572                                         sizeof(ke.kb_string));
1573
1574                                 ke.kb_string[sizeof(ke.kb_string) - 1] = 0;
1575
1576                                 if (lk_add_func(ctx, &ke) == -1)
1577                                         YYERROR;
1578                         }
1579 #line 1580 "parser.c" /* yacc.c:1648  */
1580     break;
1581
1582   case 24:
1583 #line 276 "parser.y" /* yacc.c:1648  */
1584     {
1585                                 struct lk_kbdiacr ptr;
1586                                 ptr.diacr  = (unsigned int) (yyvsp[-4].num);
1587                                 ptr.base   = (unsigned int) (yyvsp[-3].num);
1588                                 ptr.result = (unsigned int) (yyvsp[-1].num);
1589
1590                                 if (lk_append_compose(ctx, &ptr) == -1)
1591                                         YYERROR;
1592                         }
1593 #line 1594 "parser.c" /* yacc.c:1648  */
1594     break;
1595
1596   case 25:
1597 #line 286 "parser.y" /* yacc.c:1648  */
1598     {
1599                                 struct lk_kbdiacr ptr;
1600                                 ptr.diacr  = (unsigned int) (yyvsp[-4].num);
1601                                 ptr.base   = (unsigned int) (yyvsp[-3].num);
1602                                 ptr.result = (unsigned int) (yyvsp[-1].num);
1603
1604                                 if (lk_append_compose(ctx, &ptr) == -1)
1605                                         YYERROR;
1606                         }
1607 #line 1608 "parser.c" /* yacc.c:1648  */
1608     break;
1609
1610   case 26:
1611 #line 296 "parser.y" /* yacc.c:1648  */
1612     {   (yyval.num) = (yyvsp[0].num);           }
1613 #line 1614 "parser.c" /* yacc.c:1648  */
1614     break;
1615
1616   case 27:
1617 #line 297 "parser.y" /* yacc.c:1648  */
1618     {   (yyval.num) = (yyvsp[0].num) ^ 0xf000;  }
1619 #line 1620 "parser.c" /* yacc.c:1648  */
1620     break;
1621
1622   case 28:
1623 #line 300 "parser.y" /* yacc.c:1648  */
1624     {
1625                                 int j, i, keycode;
1626                                 int *val;
1627
1628                                 if (ctx->key_line->count == 1) {
1629                                         char one = 1;
1630                                         /* Some files do not have a keymaps line, and
1631                                          * we have to wait until all input has been read
1632                                          * before we know which maps to fill. */
1633                                         lk_array_set(ctx->key_constant, (yyvsp[-3].num), &one);
1634
1635                                         /* On the other hand, we now have include files,
1636                                          * and it should be possible to override lines
1637                                          * from an include file. So, kill old defs. */
1638                                         for (j = 0; j < ctx->keymap->total; j++) {
1639                                                 if (!lk_map_exists(ctx, j))
1640                                                         continue;
1641
1642                                                 if (lk_del_key(ctx, j, (yyvsp[-3].num)) < 0)
1643                                                         YYERROR;
1644                                         }
1645                                 }
1646
1647                                 if (ctx->keywords & LK_KEYWORD_KEYMAPS) {
1648                                         i = 0;
1649
1650                                         for (j = 0; j < ctx->keymap->total; j++) {
1651                                                 if (!lk_map_exists(ctx, j))
1652                                                         continue;
1653
1654                                                 if (ctx->key_line->count != 1 || i == 0) {
1655                                                         keycode = K_HOLE;
1656
1657                                                         if (i < ctx->key_line->count) {
1658                                                                 val = lk_array_get(ctx->key_line, i);
1659                                                                 keycode = *val;
1660                                                         }
1661
1662                                                         if (lk_add_key(ctx, j, (yyvsp[-3].num), keycode) < 0)
1663                                                                 YYERROR;
1664                                                 }
1665                                                 i++;
1666                                         }
1667
1668                                         if (i < ctx->key_line->count) {
1669                                                 ERR(ctx, _("too many (%ld) entries on one line"),
1670                                                         ctx->key_line->count);
1671                                                 YYERROR;
1672                                         }
1673                                 } else {
1674                                         for (i = 0; i < ctx->key_line->count; i++) {
1675                                                 val = lk_array_get(ctx->key_line, i);
1676
1677                                                 if (lk_add_key(ctx, i, (yyvsp[-3].num), *val) < 0)
1678                                                         YYERROR;
1679                                         }
1680                                 }
1681                         }
1682 #line 1683 "parser.c" /* yacc.c:1648  */
1683     break;
1684
1685   case 29:
1686 #line 360 "parser.y" /* yacc.c:1648  */
1687     {
1688                                 if (lk_add_key(ctx, ctx->mod, (yyvsp[-3].num), (yyvsp[-1].num)) < 0)
1689                                         YYERROR;
1690                                 ctx->mod = 0;
1691                         }
1692 #line 1693 "parser.c" /* yacc.c:1648  */
1693     break;
1694
1695   case 30:
1696 #line 366 "parser.y" /* yacc.c:1648  */
1697     {
1698                                 if (lk_add_key(ctx, 0, (yyvsp[-3].num), (yyvsp[-1].num)) < 0)
1699                                         YYERROR;
1700                                 ctx->mod = 0;
1701                         }
1702 #line 1703 "parser.c" /* yacc.c:1648  */
1703     break;
1704
1705   case 33:
1706 #line 375 "parser.y" /* yacc.c:1648  */
1707     { ctx->mod |= M_SHIFT;      }
1708 #line 1709 "parser.c" /* yacc.c:1648  */
1709     break;
1710
1711   case 34:
1712 #line 376 "parser.y" /* yacc.c:1648  */
1713     { ctx->mod |= M_CTRL;       }
1714 #line 1715 "parser.c" /* yacc.c:1648  */
1715     break;
1716
1717   case 35:
1718 #line 377 "parser.y" /* yacc.c:1648  */
1719     { ctx->mod |= M_ALT;                }
1720 #line 1721 "parser.c" /* yacc.c:1648  */
1721     break;
1722
1723   case 36:
1724 #line 378 "parser.y" /* yacc.c:1648  */
1725     { ctx->mod |= M_ALTGR;      }
1726 #line 1727 "parser.c" /* yacc.c:1648  */
1727     break;
1728
1729   case 37:
1730 #line 379 "parser.y" /* yacc.c:1648  */
1731     { ctx->mod |= M_SHIFTL;     }
1732 #line 1733 "parser.c" /* yacc.c:1648  */
1733     break;
1734
1735   case 38:
1736 #line 380 "parser.y" /* yacc.c:1648  */
1737     { ctx->mod |= M_SHIFTR;     }
1738 #line 1739 "parser.c" /* yacc.c:1648  */
1739     break;
1740
1741   case 39:
1742 #line 381 "parser.y" /* yacc.c:1648  */
1743     { ctx->mod |= M_CTRLL;      }
1744 #line 1745 "parser.c" /* yacc.c:1648  */
1745     break;
1746
1747   case 40:
1748 #line 382 "parser.y" /* yacc.c:1648  */
1749     { ctx->mod |= M_CTRLR;      }
1750 #line 1751 "parser.c" /* yacc.c:1648  */
1751     break;
1752
1753   case 41:
1754 #line 383 "parser.y" /* yacc.c:1648  */
1755     { ctx->mod |= M_CAPSSHIFT;  }
1756 #line 1757 "parser.c" /* yacc.c:1648  */
1757     break;
1758
1759   case 44:
1760 #line 391 "parser.y" /* yacc.c:1648  */
1761     {
1762                                 int val = (yyvsp[0].num);
1763                                 lk_array_append(ctx->key_line, &val);
1764                         }
1765 #line 1766 "parser.c" /* yacc.c:1648  */
1766     break;
1767
1768   case 45:
1769 #line 396 "parser.y" /* yacc.c:1648  */
1770     { (yyval.num) = convert_code(ctx, (yyvsp[0].num), TO_AUTO);         }
1771 #line 1772 "parser.c" /* yacc.c:1648  */
1772     break;
1773
1774   case 46:
1775 #line 397 "parser.y" /* yacc.c:1648  */
1776     { (yyval.num) = add_capslock(ctx, (yyvsp[0].num));                  }
1777 #line 1778 "parser.c" /* yacc.c:1648  */
1778     break;
1779
1780   case 47:
1781 #line 398 "parser.y" /* yacc.c:1648  */
1782     { (yyval.num) = convert_code(ctx, (yyvsp[0].num)^0xf000, TO_AUTO);  }
1783 #line 1784 "parser.c" /* yacc.c:1648  */
1784     break;
1785
1786   case 48:
1787 #line 399 "parser.y" /* yacc.c:1648  */
1788     { (yyval.num) = add_capslock(ctx, (yyvsp[0].num)^0xf000);           }
1789 #line 1790 "parser.c" /* yacc.c:1648  */
1790     break;
1791
1792   case 49:
1793 #line 400 "parser.y" /* yacc.c:1648  */
1794     { (yyval.num) = (yyvsp[0].num);                                     }
1795 #line 1796 "parser.c" /* yacc.c:1648  */
1796     break;
1797
1798   case 50:
1799 #line 401 "parser.y" /* yacc.c:1648  */
1800     { (yyval.num) = add_capslock(ctx, (yyvsp[0].num));                  }
1801 #line 1802 "parser.c" /* yacc.c:1648  */
1802     break;
1803
1804
1805 #line 1806 "parser.c" /* yacc.c:1648  */
1806       default: break;
1807     }
1808   /* User semantic actions sometimes alter yychar, and that requires
1809      that yytoken be updated with the new translation.  We take the
1810      approach of translating immediately before every use of yytoken.
1811      One alternative is translating here after every semantic action,
1812      but that translation would be missed if the semantic action invokes
1813      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1814      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1815      incorrect destructor might then be invoked immediately.  In the
1816      case of YYERROR or YYBACKUP, subsequent parser actions might lead
1817      to an incorrect destructor call or verbose syntax error message
1818      before the lookahead is translated.  */
1819   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1820
1821   YYPOPSTACK (yylen);
1822   yylen = 0;
1823   YY_STACK_PRINT (yyss, yyssp);
1824
1825   *++yyvsp = yyval;
1826
1827   /* Now 'shift' the result of the reduction.  Determine what state
1828      that goes to, based on the state we popped back to and the rule
1829      number reduced by.  */
1830
1831   yyn = yyr1[yyn];
1832
1833   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1834   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1835     yystate = yytable[yystate];
1836   else
1837     yystate = yydefgoto[yyn - YYNTOKENS];
1838
1839   goto yynewstate;
1840
1841
1842 /*--------------------------------------.
1843 | yyerrlab -- here on detecting error.  |
1844 `--------------------------------------*/
1845 yyerrlab:
1846   /* Make sure we have latest lookahead translation.  See comments at
1847      user semantic actions for why this is necessary.  */
1848   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1849
1850   /* If not already recovering from an error, report this error.  */
1851   if (!yyerrstatus)
1852     {
1853       ++yynerrs;
1854 #if ! YYERROR_VERBOSE
1855       yyerror (scanner, ctx, YY_("syntax error"));
1856 #else
1857 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1858                                         yyssp, yytoken)
1859       {
1860         char const *yymsgp = YY_("syntax error");
1861         int yysyntax_error_status;
1862         yysyntax_error_status = YYSYNTAX_ERROR;
1863         if (yysyntax_error_status == 0)
1864           yymsgp = yymsg;
1865         else if (yysyntax_error_status == 1)
1866           {
1867             if (yymsg != yymsgbuf)
1868               YYSTACK_FREE (yymsg);
1869             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1870             if (!yymsg)
1871               {
1872                 yymsg = yymsgbuf;
1873                 yymsg_alloc = sizeof yymsgbuf;
1874                 yysyntax_error_status = 2;
1875               }
1876             else
1877               {
1878                 yysyntax_error_status = YYSYNTAX_ERROR;
1879                 yymsgp = yymsg;
1880               }
1881           }
1882         yyerror (scanner, ctx, yymsgp);
1883         if (yysyntax_error_status == 2)
1884           goto yyexhaustedlab;
1885       }
1886 # undef YYSYNTAX_ERROR
1887 #endif
1888     }
1889
1890
1891
1892   if (yyerrstatus == 3)
1893     {
1894       /* If just tried and failed to reuse lookahead token after an
1895          error, discard it.  */
1896
1897       if (yychar <= YYEOF)
1898         {
1899           /* Return failure if at end of input.  */
1900           if (yychar == YYEOF)
1901             YYABORT;
1902         }
1903       else
1904         {
1905           yydestruct ("Error: discarding",
1906                       yytoken, &yylval, scanner, ctx);
1907           yychar = YYEMPTY;
1908         }
1909     }
1910
1911   /* Else will try to reuse lookahead token after shifting the error
1912      token.  */
1913   goto yyerrlab1;
1914
1915
1916 /*---------------------------------------------------.
1917 | yyerrorlab -- error raised explicitly by YYERROR.  |
1918 `---------------------------------------------------*/
1919 yyerrorlab:
1920
1921   /* Pacify compilers like GCC when the user code never invokes
1922      YYERROR and the label yyerrorlab therefore never appears in user
1923      code.  */
1924   if (/*CONSTCOND*/ 0)
1925      goto yyerrorlab;
1926
1927   /* Do not reclaim the symbols of the rule whose action triggered
1928      this YYERROR.  */
1929   YYPOPSTACK (yylen);
1930   yylen = 0;
1931   YY_STACK_PRINT (yyss, yyssp);
1932   yystate = *yyssp;
1933   goto yyerrlab1;
1934
1935
1936 /*-------------------------------------------------------------.
1937 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1938 `-------------------------------------------------------------*/
1939 yyerrlab1:
1940   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1941
1942   for (;;)
1943     {
1944       yyn = yypact[yystate];
1945       if (!yypact_value_is_default (yyn))
1946         {
1947           yyn += YYTERROR;
1948           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1949             {
1950               yyn = yytable[yyn];
1951               if (0 < yyn)
1952                 break;
1953             }
1954         }
1955
1956       /* Pop the current state because it cannot handle the error token.  */
1957       if (yyssp == yyss)
1958         YYABORT;
1959
1960
1961       yydestruct ("Error: popping",
1962                   yystos[yystate], yyvsp, scanner, ctx);
1963       YYPOPSTACK (1);
1964       yystate = *yyssp;
1965       YY_STACK_PRINT (yyss, yyssp);
1966     }
1967
1968   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1969   *++yyvsp = yylval;
1970   YY_IGNORE_MAYBE_UNINITIALIZED_END
1971
1972
1973   /* Shift the error token.  */
1974   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1975
1976   yystate = yyn;
1977   goto yynewstate;
1978
1979
1980 /*-------------------------------------.
1981 | yyacceptlab -- YYACCEPT comes here.  |
1982 `-------------------------------------*/
1983 yyacceptlab:
1984   yyresult = 0;
1985   goto yyreturn;
1986
1987 /*-----------------------------------.
1988 | yyabortlab -- YYABORT comes here.  |
1989 `-----------------------------------*/
1990 yyabortlab:
1991   yyresult = 1;
1992   goto yyreturn;
1993
1994 #if !defined yyoverflow || YYERROR_VERBOSE
1995 /*-------------------------------------------------.
1996 | yyexhaustedlab -- memory exhaustion comes here.  |
1997 `-------------------------------------------------*/
1998 yyexhaustedlab:
1999   yyerror (scanner, ctx, YY_("memory exhausted"));
2000   yyresult = 2;
2001   /* Fall through.  */
2002 #endif
2003
2004 yyreturn:
2005   if (yychar != YYEMPTY)
2006     {
2007       /* Make sure we have latest lookahead translation.  See comments at
2008          user semantic actions for why this is necessary.  */
2009       yytoken = YYTRANSLATE (yychar);
2010       yydestruct ("Cleanup: discarding lookahead",
2011                   yytoken, &yylval, scanner, ctx);
2012     }
2013   /* Do not reclaim the symbols of the rule whose action triggered
2014      this YYABORT or YYACCEPT.  */
2015   YYPOPSTACK (yylen);
2016   YY_STACK_PRINT (yyss, yyssp);
2017   while (yyssp != yyss)
2018     {
2019       yydestruct ("Cleanup: popping",
2020                   yystos[*yyssp], yyvsp, scanner, ctx);
2021       YYPOPSTACK (1);
2022     }
2023 #ifndef yyoverflow
2024   if (yyss != yyssa)
2025     YYSTACK_FREE (yyss);
2026 #endif
2027 #if YYERROR_VERBOSE
2028   if (yymsg != yymsgbuf)
2029     YYSTACK_FREE (yymsg);
2030 #endif
2031   return yyresult;
2032 }
2033 #line 403 "parser.y" /* yacc.c:1907  */
2034
2035
2036 int
2037 lk_parse_keymap(struct lk_ctx *ctx, struct kbdfile *fp)
2038 {
2039         yyscan_t scanner;
2040         int rc = -1;
2041
2042         ctx->mod = 0;
2043
2044         yylex_init_extra(ctx, &scanner);
2045
2046         INFO(ctx, _("Loading %s"), kbdfile_get_pathname(fp));
2047
2048         if (stack_push(ctx, fp, scanner) == -1)
2049                 goto fail;
2050
2051         if (yyparse(scanner, ctx))
2052                 goto fail;
2053
2054         rc = 0;
2055
2056 fail:
2057         stack_pop(ctx, scanner);
2058
2059         yylex_destroy(scanner);
2060         return rc;
2061 }