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