libqasm
library for handling cQASM files
cqasm-version-parser.cpp
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 3.0. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2013 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"
48 
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51 
52 /* Pure parsers. */
53 #define YYPURE 2
54 
55 /* Push parsers. */
56 #define YYPUSH 0
57 
58 /* Pull parsers. */
59 #define YYPULL 1
60 
61 /* Substitute the type names. */
62 #define YYSTYPE CQASM_VERSIONSTYPE
63 #define YYLTYPE CQASM_VERSIONLTYPE
64 /* Substitute the variable and function names. */
65 #define yyparse cqasm_versionparse
66 #define yylex cqasm_versionlex
67 #define yyerror cqasm_versionerror
68 #define yydebug cqasm_versiondebug
69 #define yynerrs cqasm_versionnerrs
70 
71 
72 /* Copy the first part of user declarations. */
73 
74 #line 75 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/cbuild/src/cqasm/cqasm-version-parser.cpp" /* yacc.c:339 */
75 
76 # ifndef YY_NULL
77 # if defined __cplusplus && 201103L <= __cplusplus
78 # define YY_NULL nullptr
79 # else
80 # define YY_NULL 0
81 # endif
82 # endif
83 
84 /* Enabling verbose error messages. */
85 #ifdef YYERROR_VERBOSE
86 # undef YYERROR_VERBOSE
87 # define YYERROR_VERBOSE 1
88 #else
89 # define YYERROR_VERBOSE 0
90 #endif
91 
92 /* In a future release of Bison, this section will be replaced
93  by #include "cqasm-version-parser.hpp". */
94 #ifndef YY_CQASM_VERSION_HOME_DOCS_CHECKOUTS_READTHEDOCS_ORG_USER_BUILDS_LIBQASM_CHECKOUTS_LATEST_CBUILD_SRC_CQASM_CQASM_VERSION_PARSER_HPP_INCLUDED
95 # define YY_CQASM_VERSION_HOME_DOCS_CHECKOUTS_READTHEDOCS_ORG_USER_BUILDS_LIBQASM_CHECKOUTS_LATEST_CBUILD_SRC_CQASM_CQASM_VERSION_PARSER_HPP_INCLUDED
96 /* Debug traces. */
97 #ifndef CQASM_VERSIONDEBUG
98 # if defined YYDEBUG
99 #if YYDEBUG
100 # define CQASM_VERSIONDEBUG 1
101 # else
102 # define CQASM_VERSIONDEBUG 0
103 # endif
104 # else /* ! defined YYDEBUG */
105 # define CQASM_VERSIONDEBUG 0
106 # endif /* ! defined YYDEBUG */
107 #endif /* ! defined CQASM_VERSIONDEBUG */
108 #if CQASM_VERSIONDEBUG
109 extern int cqasm_versiondebug;
110 #endif
111 /* "%code requires" blocks. */
112 #line 5 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/src/cqasm/src/cqasm-version-parser.y" /* yacc.c:355 */
113 
118  #include <memory>
119  #include <cstdio>
120  #include <cstdint>
121  #include "cqasm-error.hpp"
122  #include "cqasm-version.hpp"
123  using namespace cqasm::version;
124  typedef void* yyscan_t;
125 
126  #define YYSTYPE CQASM_VERSIONSTYPE
127  #define YYLTYPE CQASM_VERSIONLTYPE
128 
129 
130 #line 131 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/cbuild/src/cqasm/cqasm-version-parser.cpp" /* yacc.c:355 */
131 
132 /* Token type. */
133 #ifndef CQASM_VERSIONTOKENTYPE
134 # define CQASM_VERSIONTOKENTYPE
136  {
137  VERSION = 258,
138  INT_LITERAL = 259,
139  UNKNOWN = 260,
141  };
142 #endif
143 
144 /* Value type. */
145 #if ! defined CQASM_VERSIONSTYPE && ! defined CQASM_VERSIONSTYPE_IS_DECLARED
148 {
149 #line 32 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/src/cqasm/src/cqasm-version-parser.y" /* yacc.c:355 */
150 
151  char *str;
153 
154 #line 155 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/cbuild/src/cqasm/cqasm-version-parser.cpp" /* yacc.c:355 */
155 };
156 # define CQASM_VERSIONSTYPE_IS_TRIVIAL 1
157 # define CQASM_VERSIONSTYPE_IS_DECLARED 1
158 #endif
159 
160 /* Location type. */
161 #if ! defined CQASM_VERSIONLTYPE && ! defined CQASM_VERSIONLTYPE_IS_DECLARED
164 {
169 };
170 # define CQASM_VERSIONLTYPE_IS_DECLARED 1
171 # define CQASM_VERSIONLTYPE_IS_TRIVIAL 1
172 #endif
173 
174 
175 
177 
178 #endif /* !YY_CQASM_VERSION_HOME_DOCS_CHECKOUTS_READTHEDOCS_ORG_USER_BUILDS_LIBQASM_CHECKOUTS_LATEST_CBUILD_SRC_CQASM_CQASM_VERSION_PARSER_HPP_INCLUDED */
179 
180 /* Copy the second part of user declarations. */
181 
182 #line 183 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/cbuild/src/cqasm/cqasm-version-parser.cpp" /* yacc.c:358 */
183 /* Unqualified %code blocks. */
184 #line 23 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/src/cqasm/src/cqasm-version-parser.y" /* yacc.c:359 */
185 
186  int yylex(YYSTYPE* yylvalp, YYLTYPE* yyllocp, yyscan_t scanner);
187  void yyerror(YYLTYPE* yyllocp, yyscan_t scanner, cqasm::version::ParseHelper &helper, const char* msg);
188 
189 #line 190 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/cbuild/src/cqasm/cqasm-version-parser.cpp" /* yacc.c:359 */
190 
191 #ifdef short
192 # undef short
193 #endif
194 
195 #ifdef YYTYPE_UINT8
196 typedef YYTYPE_UINT8 yytype_uint8;
197 #else
198 typedef unsigned char yytype_uint8;
199 #endif
200 
201 #ifdef YYTYPE_INT8
202 typedef YYTYPE_INT8 yytype_int8;
203 #else
204 typedef signed char yytype_int8;
205 #endif
206 
207 #ifdef YYTYPE_UINT16
208 typedef YYTYPE_UINT16 yytype_uint16;
209 #else
210 typedef unsigned short int yytype_uint16;
211 #endif
212 
213 #ifdef YYTYPE_INT16
214 typedef YYTYPE_INT16 yytype_int16;
215 #else
216 typedef short int yytype_int16;
217 #endif
218 
219 #ifndef YYSIZE_T
220 # ifdef __SIZE_TYPE__
221 # define YYSIZE_T __SIZE_TYPE__
222 # elif defined size_t
223 # define YYSIZE_T size_t
224 # elif ! defined YYSIZE_T
225 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
226 # define YYSIZE_T size_t
227 # else
228 # define YYSIZE_T unsigned int
229 # endif
230 #endif
231 
232 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
233 
234 #ifndef YY_
235 # if defined YYENABLE_NLS && YYENABLE_NLS
236 # if ENABLE_NLS
237 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
238 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
239 # endif
240 # endif
241 # ifndef YY_
242 # define YY_(Msgid) Msgid
243 # endif
244 #endif
245 
246 #ifndef __attribute__
247 /* This feature is available in gcc versions 2.5 and later. */
248 # if (! defined __GNUC__ || __GNUC__ < 2 \
249  || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
250 # define __attribute__(Spec) /* empty */
251 # endif
252 #endif
253 
254 /* Suppress unused-variable warnings by "using" E. */
255 #if ! defined lint || defined __GNUC__
256 # define YYUSE(E) ((void) (E))
257 #else
258 # define YYUSE(E) /* empty */
259 #endif
260 
261 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
262 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
263 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
264  _Pragma ("GCC diagnostic push") \
265  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
266  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
267 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
268  _Pragma ("GCC diagnostic pop")
269 #else
270 # define YY_INITIAL_VALUE(Value) Value
271 #endif
272 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
273 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
274 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
275 #endif
276 #ifndef YY_INITIAL_VALUE
277 # define YY_INITIAL_VALUE(Value) /* Nothing. */
278 #endif
279 
280 
281 #if ! defined yyoverflow || YYERROR_VERBOSE
282 
283 /* The parser invokes alloca or malloc; define the necessary symbols. */
284 
285 # ifdef YYSTACK_USE_ALLOCA
286 # if YYSTACK_USE_ALLOCA
287 # ifdef __GNUC__
288 # define YYSTACK_ALLOC __builtin_alloca
289 # elif defined __BUILTIN_VA_ARG_INCR
290 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
291 # elif defined _AIX
292 # define YYSTACK_ALLOC __alloca
293 # elif defined _MSC_VER
294 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
295 # define alloca _alloca
296 # else
297 # define YYSTACK_ALLOC alloca
298 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
299 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
300  /* Use EXIT_SUCCESS as a witness for stdlib.h. */
301 # ifndef EXIT_SUCCESS
302 # define EXIT_SUCCESS 0
303 # endif
304 # endif
305 # endif
306 # endif
307 # endif
308 
309 # ifdef YYSTACK_ALLOC
310  /* Pacify GCC's 'empty if-body' warning. */
311 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
312 # ifndef YYSTACK_ALLOC_MAXIMUM
313  /* The OS might guarantee only one guard page at the bottom of the stack,
314  and a page size can be as small as 4096 bytes. So we cannot safely
315  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
316  to allow for a few compiler-allocated temporary stack slots. */
317 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
318 # endif
319 # else
320 # define YYSTACK_ALLOC YYMALLOC
321 # define YYSTACK_FREE YYFREE
322 # ifndef YYSTACK_ALLOC_MAXIMUM
323 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
324 # endif
325 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
326  && ! ((defined YYMALLOC || defined malloc) \
327  && (defined YYFREE || defined free)))
328 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
329 # ifndef EXIT_SUCCESS
330 # define EXIT_SUCCESS 0
331 # endif
332 # endif
333 # ifndef YYMALLOC
334 # define YYMALLOC malloc
335 # if ! defined malloc && ! defined EXIT_SUCCESS
336 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
337 # endif
338 # endif
339 # ifndef YYFREE
340 # define YYFREE free
341 # if ! defined free && ! defined EXIT_SUCCESS
342 void free (void *); /* INFRINGES ON USER NAME SPACE */
343 # endif
344 # endif
345 # endif
346 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
347 
348 
349 #if (! defined yyoverflow \
350  && (! defined __cplusplus \
351  || (defined CQASM_VERSIONLTYPE_IS_TRIVIAL && CQASM_VERSIONLTYPE_IS_TRIVIAL \
352  && defined CQASM_VERSIONSTYPE_IS_TRIVIAL && CQASM_VERSIONSTYPE_IS_TRIVIAL)))
353 
354 /* A type that is properly aligned for any stack member. */
355 union yyalloc
356 {
357  yytype_int16 yyss_alloc;
358  YYSTYPE yyvs_alloc;
359  YYLTYPE yyls_alloc;
360 };
361 
362 /* The size of the maximum gap between one aligned stack and the next. */
363 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
364 
365 /* The size of an array large to enough to hold all stacks, each with
366  N elements. */
367 # define YYSTACK_BYTES(N) \
368  ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
369  + 2 * YYSTACK_GAP_MAXIMUM)
370 
371 # define YYCOPY_NEEDED 1
372 
373 /* Relocate STACK from its old location to the new one. The
374  local variables YYSIZE and YYSTACKSIZE give the old and new number of
375  elements in the stack, and YYPTR gives the new location of the
376  stack. Advance YYPTR to a properly aligned location for the next
377  stack. */
378 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
379  do \
380  { \
381  YYSIZE_T yynewbytes; \
382  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
383  Stack = &yyptr->Stack_alloc; \
384  yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
385  yyptr += yynewbytes / sizeof (*yyptr); \
386  } \
387  while (0)
388 
389 #endif
390 
391 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
392 /* Copy COUNT objects from SRC to DST. The source and destination do
393  not overlap. */
394 # ifndef YYCOPY
395 # if defined __GNUC__ && 1 < __GNUC__
396 # define YYCOPY(Dst, Src, Count) \
397  __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
398 # else
399 # define YYCOPY(Dst, Src, Count) \
400  do \
401  { \
402  YYSIZE_T yyi; \
403  for (yyi = 0; yyi < (Count); yyi++) \
404  (Dst)[yyi] = (Src)[yyi]; \
405  } \
406  while (0)
407 # endif
408 # endif
409 #endif /* !YYCOPY_NEEDED */
410 
411 /* YYFINAL -- State number of the termination state. */
412 #define YYFINAL 5
413 /* YYLAST -- Last index in YYTABLE. */
414 #define YYLAST 4
415 
416 /* YYNTOKENS -- Number of terminals. */
417 #define YYNTOKENS 8
418 /* YYNNTS -- Number of nonterminals. */
419 #define YYNNTS 3
420 /* YYNRULES -- Number of rules. */
421 #define YYNRULES 4
422 /* YYNSTATES -- Number of states. */
423 #define YYNSTATES 8
424 
425 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
426  by yylex, with out-of-bounds checking. */
427 #define YYUNDEFTOK 2
428 #define YYMAXUTOK 261
429 
430 #define YYTRANSLATE(YYX) \
431  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
432 
433 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
434  as returned by yylex, without out-of-bounds checking. */
435 static const yytype_uint8 yytranslate[] =
436 {
437  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
438  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
440  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
441  2, 2, 2, 2, 2, 2, 7, 2, 2, 2,
442  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
443  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
444  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
447  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
448  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
449  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
453  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
455  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
456  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
457  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
458  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
459  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
460  2, 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, 1, 2, 3, 4,
463  5, 6
464 };
465 
466 #if CQASM_VERSIONDEBUG
467  /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
468 static const yytype_uint8 yyrline[] =
469 {
470  0, 53, 53, 54, 57
471 };
472 #endif
473 
474 #if CQASM_VERSIONDEBUG || YYERROR_VERBOSE || 0
475 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
476  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
477 static const char *const yytname[] =
478 {
479  "$end", "error", "$undefined", "VERSION", "INT_LITERAL", "UNKNOWN",
480  "END_OF_FILE", "'.'", "$accept", "Version", "Root", YY_NULL
481 };
482 #endif
483 
484 # ifdef YYPRINT
485 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
486  (internal) symbol number NUM (which must be that of a token). */
487 static const yytype_uint16 yytoknum[] =
488 {
489  0, 256, 257, 258, 259, 260, 261, 46
490 };
491 # endif
492 
493 #define YYPACT_NINF -5
494 
495 #define yypact_value_is_default(Yystate) \
496  (!!((Yystate) == (-5)))
497 
498 #define YYTABLE_NINF -1
499 
500 #define yytable_value_is_error(Yytable_value) \
501  0
502 
503  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
504  STATE-NUM. */
505 static const yytype_int8 yypact[] =
506 {
507  -3, -2, 1, -5, -4, -5, 0, -5
508 };
509 
510  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
511  Performed when YYTABLE does not specify something else to do. Zero
512  means the default is an error. */
513 static const yytype_uint8 yydefact[] =
514 {
515  0, 0, 0, 2, 4, 1, 0, 3
516 };
517 
518  /* YYPGOTO[NTERM-NUM]. */
519 static const yytype_int8 yypgoto[] =
520 {
521  -5, -5, -5
522 };
523 
524  /* YYDEFGOTO[NTERM-NUM]. */
525 static const yytype_int8 yydefgoto[] =
526 {
527  -1, 4, 2
528 };
529 
530  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
531  positive, shift that token. If negative, reduce the rule whose
532  number is the opposite. If YYTABLE_NINF, syntax error. */
533 static const yytype_uint8 yytable[] =
534 {
535  1, 5, 3, 6, 7
536 };
537 
538 static const yytype_uint8 yycheck[] =
539 {
540  3, 0, 4, 7, 4
541 };
542 
543  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
544  symbol of state STATE-NUM. */
545 static const yytype_uint8 yystos[] =
546 {
547  0, 3, 10, 4, 9, 0, 7, 4
548 };
549 
550  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
551 static const yytype_uint8 yyr1[] =
552 {
553  0, 8, 9, 9, 10
554 };
555 
556  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
557 static const yytype_uint8 yyr2[] =
558 {
559  0, 2, 1, 3, 2
560 };
561 
562 
563 #define yyerrok (yyerrstatus = 0)
564 #define yyclearin (yychar = YYEMPTY)
565 #define YYEMPTY (-2)
566 #define YYEOF 0
567 
568 #define YYACCEPT goto yyacceptlab
569 #define YYABORT goto yyabortlab
570 #define YYERROR goto yyerrorlab
571 
572 
573 #define YYRECOVERING() (!!yyerrstatus)
574 
575 #define YYBACKUP(Token, Value) \
576 do \
577  if (yychar == YYEMPTY) \
578  { \
579  yychar = (Token); \
580  yylval = (Value); \
581  YYPOPSTACK (yylen); \
582  yystate = *yyssp; \
583  goto yybackup; \
584  } \
585  else \
586  { \
587  yyerror (&yylloc, scanner, helper, YY_("syntax error: cannot back up")); \
588  YYERROR; \
589  } \
590 while (0)
591 
592 /* Error token number */
593 #define YYTERROR 1
594 #define YYERRCODE 256
595 
596 
597 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
598  If N is 0, then set CURRENT to the empty location which ends
599  the previous symbol: RHS[0] (always defined). */
600 
601 #ifndef YYLLOC_DEFAULT
602 # define YYLLOC_DEFAULT(Current, Rhs, N) \
603  do \
604  if (N) \
605  { \
606  (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
607  (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
608  (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
609  (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
610  } \
611  else \
612  { \
613  (Current).first_line = (Current).last_line = \
614  YYRHSLOC (Rhs, 0).last_line; \
615  (Current).first_column = (Current).last_column = \
616  YYRHSLOC (Rhs, 0).last_column; \
617  } \
618  while (0)
619 #endif
620 
621 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
622 
623 
624 /* Enable debugging if requested. */
625 #if CQASM_VERSIONDEBUG
626 
627 # ifndef YYFPRINTF
628 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
629 # define YYFPRINTF fprintf
630 # endif
631 
632 # define YYDPRINTF(Args) \
633 do { \
634  if (yydebug) \
635  YYFPRINTF Args; \
636 } while (0)
637 
638 
639 /* YY_LOCATION_PRINT -- Print the location on the stream.
640  This macro was not mandated originally: define only if we know
641  we won't break user code: when these are the locations we know. */
642 
643 #ifndef YY_LOCATION_PRINT
644 # if defined CQASM_VERSIONLTYPE_IS_TRIVIAL && CQASM_VERSIONLTYPE_IS_TRIVIAL
645 
646 /* Print *YYLOCP on YYO. Private, do not rely on its existence. */
647 
648 __attribute__((__unused__))
649 static unsigned
650 yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
651 {
652  unsigned res = 0;
653  int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
654  if (0 <= yylocp->first_line)
655  {
656  res += YYFPRINTF (yyo, "%d", yylocp->first_line);
657  if (0 <= yylocp->first_column)
658  res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
659  }
660  if (0 <= yylocp->last_line)
661  {
662  if (yylocp->first_line < yylocp->last_line)
663  {
664  res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
665  if (0 <= end_col)
666  res += YYFPRINTF (yyo, ".%d", end_col);
667  }
668  else if (0 <= end_col && yylocp->first_column < end_col)
669  res += YYFPRINTF (yyo, "-%d", end_col);
670  }
671  return res;
672  }
673 
674 # define YY_LOCATION_PRINT(File, Loc) \
675  yy_location_print_ (File, &(Loc))
676 
677 # else
678 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
679 # endif
680 #endif
681 
682 
683 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
684 do { \
685  if (yydebug) \
686  { \
687  YYFPRINTF (stderr, "%s ", Title); \
688  yy_symbol_print (stderr, \
689  Type, Value, Location, scanner, helper); \
690  YYFPRINTF (stderr, "\n"); \
691  } \
692 } while (0)
693 
694 
695 /*----------------------------------------.
696 | Print this symbol's value on YYOUTPUT. |
697 `----------------------------------------*/
698 
699 static void
700 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, yyscan_t scanner, cqasm::version::ParseHelper &helper)
701 {
702  FILE *yyo = yyoutput;
703  YYUSE (yyo);
704  YYUSE (yylocationp);
705  YYUSE (scanner);
706  YYUSE (helper);
707  if (!yyvaluep)
708  return;
709 # ifdef YYPRINT
710  if (yytype < YYNTOKENS)
711  YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
712 # endif
713  YYUSE (yytype);
714 }
715 
716 
717 /*--------------------------------.
718 | Print this symbol on YYOUTPUT. |
719 `--------------------------------*/
720 
721 static void
722 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, yyscan_t scanner, cqasm::version::ParseHelper &helper)
723 {
724  YYFPRINTF (yyoutput, "%s %s (",
725  yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
726 
727  YY_LOCATION_PRINT (yyoutput, *yylocationp);
728  YYFPRINTF (yyoutput, ": ");
729  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, scanner, helper);
730  YYFPRINTF (yyoutput, ")");
731 }
732 
733 /*------------------------------------------------------------------.
734 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
735 | TOP (included). |
736 `------------------------------------------------------------------*/
737 
738 static void
739 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
740 {
741  YYFPRINTF (stderr, "Stack now");
742  for (; yybottom <= yytop; yybottom++)
743  {
744  int yybot = *yybottom;
745  YYFPRINTF (stderr, " %d", yybot);
746  }
747  YYFPRINTF (stderr, "\n");
748 }
749 
750 # define YY_STACK_PRINT(Bottom, Top) \
751 do { \
752  if (yydebug) \
753  yy_stack_print ((Bottom), (Top)); \
754 } while (0)
755 
756 
757 /*------------------------------------------------.
758 | Report that the YYRULE is going to be reduced. |
759 `------------------------------------------------*/
760 
761 static void
762 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, yyscan_t scanner, cqasm::version::ParseHelper &helper)
763 {
764  unsigned long int yylno = yyrline[yyrule];
765  int yynrhs = yyr2[yyrule];
766  int yyi;
767  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
768  yyrule - 1, yylno);
769  /* The symbols being reduced. */
770  for (yyi = 0; yyi < yynrhs; yyi++)
771  {
772  YYFPRINTF (stderr, " $%d = ", yyi + 1);
773  yy_symbol_print (stderr,
774  yystos[yyssp[yyi + 1 - yynrhs]],
775  &(yyvsp[(yyi + 1) - (yynrhs)])
776  , &(yylsp[(yyi + 1) - (yynrhs)]) , scanner, helper);
777  YYFPRINTF (stderr, "\n");
778  }
779 }
780 
781 # define YY_REDUCE_PRINT(Rule) \
782 do { \
783  if (yydebug) \
784  yy_reduce_print (yyssp, yyvsp, yylsp, Rule, scanner, helper); \
785 } while (0)
786 
787 /* Nonzero means print parse trace. It is left uninitialized so that
788  multiple parsers can coexist. */
789 int yydebug;
790 #else /* !CQASM_VERSIONDEBUG */
791 # define YYDPRINTF(Args)
792 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
793 # define YY_STACK_PRINT(Bottom, Top)
794 # define YY_REDUCE_PRINT(Rule)
795 #endif /* !CQASM_VERSIONDEBUG */
796 
797 
798 /* YYINITDEPTH -- initial size of the parser's stacks. */
799 #ifndef YYINITDEPTH
800 # define YYINITDEPTH 200
801 #endif
802 
803 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
804  if the built-in stack extension method is used).
805 
806  Do not make this value too large; the results are undefined if
807  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
808  evaluated with infinite-precision integer arithmetic. */
809 
810 #ifndef YYMAXDEPTH
811 # define YYMAXDEPTH 10000
812 #endif
813 
814 
815 #if YYERROR_VERBOSE
816 
817 # ifndef yystrlen
818 # if defined __GLIBC__ && defined _STRING_H
819 # define yystrlen strlen
820 # else
821 /* Return the length of YYSTR. */
822 static YYSIZE_T
823 yystrlen (const char *yystr)
824 {
825  YYSIZE_T yylen;
826  for (yylen = 0; yystr[yylen]; yylen++)
827  continue;
828  return yylen;
829 }
830 # endif
831 # endif
832 
833 # ifndef yystpcpy
834 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
835 # define yystpcpy stpcpy
836 # else
837 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
838  YYDEST. */
839 static char *
840 yystpcpy (char *yydest, const char *yysrc)
841 {
842  char *yyd = yydest;
843  const char *yys = yysrc;
844 
845  while ((*yyd++ = *yys++) != '\0')
846  continue;
847 
848  return yyd - 1;
849 }
850 # endif
851 # endif
852 
853 # ifndef yytnamerr
854 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
855  quotes and backslashes, so that it's suitable for yyerror. The
856  heuristic is that double-quoting is unnecessary unless the string
857  contains an apostrophe, a comma, or backslash (other than
858  backslash-backslash). YYSTR is taken from yytname. If YYRES is
859  null, do not copy; instead, return the length of what the result
860  would have been. */
861 static YYSIZE_T
862 yytnamerr (char *yyres, const char *yystr)
863 {
864  if (*yystr == '"')
865  {
866  YYSIZE_T yyn = 0;
867  char const *yyp = yystr;
868 
869  for (;;)
870  switch (*++yyp)
871  {
872  case '\'':
873  case ',':
874  goto do_not_strip_quotes;
875 
876  case '\\':
877  if (*++yyp != '\\')
878  goto do_not_strip_quotes;
879  /* Fall through. */
880  default:
881  if (yyres)
882  yyres[yyn] = *yyp;
883  yyn++;
884  break;
885 
886  case '"':
887  if (yyres)
888  yyres[yyn] = '\0';
889  return yyn;
890  }
891  do_not_strip_quotes: ;
892  }
893 
894  if (! yyres)
895  return yystrlen (yystr);
896 
897  return yystpcpy (yyres, yystr) - yyres;
898 }
899 # endif
900 
901 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
902  about the unexpected token YYTOKEN for the state stack whose top is
903  YYSSP.
904 
905  Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
906  not large enough to hold the message. In that case, also set
907  *YYMSG_ALLOC to the required number of bytes. Return 2 if the
908  required number of bytes is too large to store. */
909 static int
910 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
911  yytype_int16 *yyssp, int yytoken)
912 {
913  YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
914  YYSIZE_T yysize = yysize0;
915  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
916  /* Internationalized format string. */
917  const char *yyformat = YY_NULL;
918  /* Arguments of yyformat. */
919  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
920  /* Number of reported tokens (one for the "unexpected", one per
921  "expected"). */
922  int yycount = 0;
923 
924  /* There are many possibilities here to consider:
925  - If this state is a consistent state with a default action, then
926  the only way this function was invoked is if the default action
927  is an error action. In that case, don't check for expected
928  tokens because there are none.
929  - The only way there can be no lookahead present (in yychar) is if
930  this state is a consistent state with a default action. Thus,
931  detecting the absence of a lookahead is sufficient to determine
932  that there is no unexpected or expected token to report. In that
933  case, just report a simple "syntax error".
934  - Don't assume there isn't a lookahead just because this state is a
935  consistent state with a default action. There might have been a
936  previous inconsistent state, consistent state with a non-default
937  action, or user semantic action that manipulated yychar.
938  - Of course, the expected token list depends on states to have
939  correct lookahead information, and it depends on the parser not
940  to perform extra reductions after fetching a lookahead from the
941  scanner and before detecting a syntax error. Thus, state merging
942  (from LALR or IELR) and default reductions corrupt the expected
943  token list. However, the list is correct for canonical LR with
944  one exception: it will still contain any token that will not be
945  accepted due to an error action in a later state.
946  */
947  if (yytoken != YYEMPTY)
948  {
949  int yyn = yypact[*yyssp];
950  yyarg[yycount++] = yytname[yytoken];
951  if (!yypact_value_is_default (yyn))
952  {
953  /* Start YYX at -YYN if negative to avoid negative indexes in
954  YYCHECK. In other words, skip the first -YYN actions for
955  this state because they are default actions. */
956  int yyxbegin = yyn < 0 ? -yyn : 0;
957  /* Stay within bounds of both yycheck and yytname. */
958  int yychecklim = YYLAST - yyn + 1;
959  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
960  int yyx;
961 
962  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
963  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
964  && !yytable_value_is_error (yytable[yyx + yyn]))
965  {
966  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
967  {
968  yycount = 1;
969  yysize = yysize0;
970  break;
971  }
972  yyarg[yycount++] = yytname[yyx];
973  {
974  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
975  if (! (yysize <= yysize1
976  && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
977  return 2;
978  yysize = yysize1;
979  }
980  }
981  }
982  }
983 
984  switch (yycount)
985  {
986 # define YYCASE_(N, S) \
987  case N: \
988  yyformat = S; \
989  break
990  YYCASE_(0, YY_("syntax error"));
991  YYCASE_(1, YY_("syntax error, unexpected %s"));
992  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
993  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
994  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
995  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
996 # undef YYCASE_
997  }
998 
999  {
1000  YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1001  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1002  return 2;
1003  yysize = yysize1;
1004  }
1005 
1006  if (*yymsg_alloc < yysize)
1007  {
1008  *yymsg_alloc = 2 * yysize;
1009  if (! (yysize <= *yymsg_alloc
1010  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1011  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1012  return 1;
1013  }
1014 
1015  /* Avoid sprintf, as that infringes on the user's name space.
1016  Don't have undefined behavior even if the translation
1017  produced a string with the wrong number of "%s"s. */
1018  {
1019  char *yyp = *yymsg;
1020  int yyi = 0;
1021  while ((*yyp = *yyformat) != '\0')
1022  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1023  {
1024  yyp += yytnamerr (yyp, yyarg[yyi++]);
1025  yyformat += 2;
1026  }
1027  else
1028  {
1029  yyp++;
1030  yyformat++;
1031  }
1032  }
1033  return 0;
1034 }
1035 #endif /* YYERROR_VERBOSE */
1036 
1037 /*-----------------------------------------------.
1038 | Release the memory associated to this symbol. |
1039 `-----------------------------------------------*/
1040 
1041 static void
1042 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, yyscan_t scanner, cqasm::version::ParseHelper &helper)
1043 {
1044  YYUSE (yyvaluep);
1045  YYUSE (yylocationp);
1046  YYUSE (scanner);
1047  YYUSE (helper);
1048  if (!yymsg)
1049  yymsg = "Deleting";
1050  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1051 
1053  YYUSE (yytype);
1055 }
1056 
1057 
1058 
1059 
1060 /*----------.
1061 | yyparse. |
1062 `----------*/
1063 
1064 int
1066 {
1067 /* The lookahead symbol. */
1068 int yychar;
1069 
1070 
1071 /* The semantic value of the lookahead symbol. */
1072 /* Default value used for initialization, for pacifying older GCCs
1073  or non-GCC compilers. */
1074 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1075 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1076 
1077 /* Location data for the lookahead symbol. */
1078 static YYLTYPE yyloc_default
1079 # if defined CQASM_VERSIONLTYPE_IS_TRIVIAL && CQASM_VERSIONLTYPE_IS_TRIVIAL
1080  = { 1, 1, 1, 1 }
1081 # endif
1082 ;
1083 YYLTYPE yylloc = yyloc_default;
1084 
1085  /* Number of syntax errors so far. */
1086  int yynerrs;
1087 
1088  int yystate;
1089  /* Number of tokens to shift before error messages enabled. */
1090  int yyerrstatus;
1091 
1092  /* The stacks and their tools:
1093  'yyss': related to states.
1094  'yyvs': related to semantic values.
1095  'yyls': related to locations.
1096 
1097  Refer to the stacks through separate pointers, to allow yyoverflow
1098  to reallocate them elsewhere. */
1099 
1100  /* The state stack. */
1101  yytype_int16 yyssa[YYINITDEPTH];
1102  yytype_int16 *yyss;
1103  yytype_int16 *yyssp;
1104 
1105  /* The semantic value stack. */
1106  YYSTYPE yyvsa[YYINITDEPTH];
1107  YYSTYPE *yyvs;
1108  YYSTYPE *yyvsp;
1109 
1110  /* The location stack. */
1111  YYLTYPE yylsa[YYINITDEPTH];
1112  YYLTYPE *yyls;
1113  YYLTYPE *yylsp;
1114 
1115  /* The locations where the error started and ended. */
1116  YYLTYPE yyerror_range[3];
1117 
1118  YYSIZE_T yystacksize;
1119 
1120  int yyn;
1121  int yyresult;
1122  /* Lookahead token as an internal (translated) token number. */
1123  int yytoken = 0;
1124  /* The variables used to return semantic value and location from the
1125  action routines. */
1126  YYSTYPE yyval;
1127  YYLTYPE yyloc;
1128 
1129 #if YYERROR_VERBOSE
1130  /* Buffer for error messages, and its allocated size. */
1131  char yymsgbuf[128];
1132  char *yymsg = yymsgbuf;
1133  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1134 #endif
1135 
1136 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1137 
1138  /* The number of symbols on the RHS of the reduced rule.
1139  Keep to zero when no symbol should be popped. */
1140  int yylen = 0;
1141 
1142  yyssp = yyss = yyssa;
1143  yyvsp = yyvs = yyvsa;
1144  yylsp = yyls = yylsa;
1145  yystacksize = YYINITDEPTH;
1146 
1147  YYDPRINTF ((stderr, "Starting parse\n"));
1148 
1149  yystate = 0;
1150  yyerrstatus = 0;
1151  yynerrs = 0;
1152  yychar = YYEMPTY; /* Cause a token to be read. */
1153  yylsp[0] = yylloc;
1154  goto yysetstate;
1155 
1156 /*------------------------------------------------------------.
1157 | yynewstate -- Push a new state, which is found in yystate. |
1158 `------------------------------------------------------------*/
1159  yynewstate:
1160  /* In all cases, when you get here, the value and location stacks
1161  have just been pushed. So pushing a state here evens the stacks. */
1162  yyssp++;
1163 
1164  yysetstate:
1165  *yyssp = yystate;
1166 
1167  if (yyss + yystacksize - 1 <= yyssp)
1168  {
1169  /* Get the current used size of the three stacks, in elements. */
1170  YYSIZE_T yysize = yyssp - yyss + 1;
1171 
1172 #ifdef yyoverflow
1173  {
1174  /* Give user a chance to reallocate the stack. Use copies of
1175  these so that the &'s don't force the real ones into
1176  memory. */
1177  YYSTYPE *yyvs1 = yyvs;
1178  yytype_int16 *yyss1 = yyss;
1179  YYLTYPE *yyls1 = yyls;
1180 
1181  /* Each stack pointer address is followed by the size of the
1182  data in use in that stack, in bytes. This used to be a
1183  conditional around just the two extra args, but that might
1184  be undefined if yyoverflow is a macro. */
1185  yyoverflow (YY_("memory exhausted"),
1186  &yyss1, yysize * sizeof (*yyssp),
1187  &yyvs1, yysize * sizeof (*yyvsp),
1188  &yyls1, yysize * sizeof (*yylsp),
1189  &yystacksize);
1190 
1191  yyls = yyls1;
1192  yyss = yyss1;
1193  yyvs = yyvs1;
1194  }
1195 #else /* no yyoverflow */
1196 # ifndef YYSTACK_RELOCATE
1197  goto yyexhaustedlab;
1198 # else
1199  /* Extend the stack our own way. */
1200  if (YYMAXDEPTH <= yystacksize)
1201  goto yyexhaustedlab;
1202  yystacksize *= 2;
1203  if (YYMAXDEPTH < yystacksize)
1204  yystacksize = YYMAXDEPTH;
1205 
1206  {
1207  yytype_int16 *yyss1 = yyss;
1208  union yyalloc *yyptr =
1209  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1210  if (! yyptr)
1211  goto yyexhaustedlab;
1212  YYSTACK_RELOCATE (yyss_alloc, yyss);
1213  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1214  YYSTACK_RELOCATE (yyls_alloc, yyls);
1215 # undef YYSTACK_RELOCATE
1216  if (yyss1 != yyssa)
1217  YYSTACK_FREE (yyss1);
1218  }
1219 # endif
1220 #endif /* no yyoverflow */
1221 
1222  yyssp = yyss + yysize - 1;
1223  yyvsp = yyvs + yysize - 1;
1224  yylsp = yyls + yysize - 1;
1225 
1226  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1227  (unsigned long int) yystacksize));
1228 
1229  if (yyss + yystacksize - 1 <= yyssp)
1230  YYABORT;
1231  }
1232 
1233  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1234 
1235  if (yystate == YYFINAL)
1236  YYACCEPT;
1237 
1238  goto yybackup;
1239 
1240 /*-----------.
1241 | yybackup. |
1242 `-----------*/
1243 yybackup:
1244 
1245  /* Do appropriate processing given the current state. Read a
1246  lookahead token if we need one and don't already have one. */
1247 
1248  /* First try to decide what to do without reference to lookahead token. */
1249  yyn = yypact[yystate];
1250  if (yypact_value_is_default (yyn))
1251  goto yydefault;
1252 
1253  /* Not known => get a lookahead token if don't already have one. */
1254 
1255  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1256  if (yychar == YYEMPTY)
1257  {
1258  YYDPRINTF ((stderr, "Reading a token: "));
1259  yychar = yylex (&yylval, &yylloc, scanner);
1260  }
1261 
1262  if (yychar <= YYEOF)
1263  {
1264  yychar = yytoken = YYEOF;
1265  YYDPRINTF ((stderr, "Now at end of input.\n"));
1266  }
1267  else
1268  {
1269  yytoken = YYTRANSLATE (yychar);
1270  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1271  }
1272 
1273  /* If the proper action on seeing token YYTOKEN is to reduce or to
1274  detect an error, take that action. */
1275  yyn += yytoken;
1276  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1277  goto yydefault;
1278  yyn = yytable[yyn];
1279  if (yyn <= 0)
1280  {
1281  if (yytable_value_is_error (yyn))
1282  goto yyerrlab;
1283  yyn = -yyn;
1284  goto yyreduce;
1285  }
1286 
1287  /* Count tokens shifted since error; after three, turn off error
1288  status. */
1289  if (yyerrstatus)
1290  yyerrstatus--;
1291 
1292  /* Shift the lookahead token. */
1293  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1294 
1295  /* Discard the shifted token. */
1296  yychar = YYEMPTY;
1297 
1298  yystate = yyn;
1300  *++yyvsp = yylval;
1302  *++yylsp = yylloc;
1303  goto yynewstate;
1304 
1305 
1306 /*-----------------------------------------------------------.
1307 | yydefault -- do the default action for the current state. |
1308 `-----------------------------------------------------------*/
1309 yydefault:
1310  yyn = yydefact[yystate];
1311  if (yyn == 0)
1312  goto yyerrlab;
1313  goto yyreduce;
1314 
1315 
1316 /*-----------------------------.
1317 | yyreduce -- Do a reduction. |
1318 `-----------------------------*/
1319 yyreduce:
1320  /* yyn is the number of a rule to reduce with. */
1321  yylen = yyr2[yyn];
1322 
1323  /* If YYLEN is nonzero, implement the default value of the action:
1324  '$$ = $1'.
1325 
1326  Otherwise, the following line sets YYVAL to garbage.
1327  This behavior is undocumented and Bison
1328  users should not rely upon it. Assigning to YYVAL
1329  unconditionally makes the parser a bit smaller, and it avoids a
1330  GCC warning that YYVAL may be used uninitialized. */
1331  yyval = yyvsp[1-yylen];
1332 
1333  /* Default location. */
1334  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1335  YY_REDUCE_PRINT (yyn);
1336  switch (yyn)
1337  {
1338  case 2:
1339 #line 53 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/src/cqasm/src/cqasm-version-parser.y" /* yacc.c:1661 */
1340  { helper.version.push_back(std::atoll((yyvsp[0].str))); std::free((yyvsp[0].str)); }
1341 #line 1342 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/cbuild/src/cqasm/cqasm-version-parser.cpp" /* yacc.c:1661 */
1342  break;
1343 
1344  case 3:
1345 #line 54 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/src/cqasm/src/cqasm-version-parser.y" /* yacc.c:1661 */
1346  { helper.version.push_back(std::atoll((yyvsp[0].str))); std::free((yyvsp[0].str)); }
1347 #line 1348 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/cbuild/src/cqasm/cqasm-version-parser.cpp" /* yacc.c:1661 */
1348  break;
1349 
1350  case 4:
1351 #line 57 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/src/cqasm/src/cqasm-version-parser.y" /* yacc.c:1661 */
1352  {}
1353 #line 1354 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/cbuild/src/cqasm/cqasm-version-parser.cpp" /* yacc.c:1661 */
1354  break;
1355 
1356 
1357 #line 1358 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/cbuild/src/cqasm/cqasm-version-parser.cpp" /* yacc.c:1661 */
1358  default: break;
1359  }
1360  /* User semantic actions sometimes alter yychar, and that requires
1361  that yytoken be updated with the new translation. We take the
1362  approach of translating immediately before every use of yytoken.
1363  One alternative is translating here after every semantic action,
1364  but that translation would be missed if the semantic action invokes
1365  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1366  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1367  incorrect destructor might then be invoked immediately. In the
1368  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1369  to an incorrect destructor call or verbose syntax error message
1370  before the lookahead is translated. */
1371  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1372 
1373  YYPOPSTACK (yylen);
1374  yylen = 0;
1375  YY_STACK_PRINT (yyss, yyssp);
1376 
1377  *++yyvsp = yyval;
1378  *++yylsp = yyloc;
1379 
1380  /* Now 'shift' the result of the reduction. Determine what state
1381  that goes to, based on the state we popped back to and the rule
1382  number reduced by. */
1383 
1384  yyn = yyr1[yyn];
1385 
1386  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1387  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1388  yystate = yytable[yystate];
1389  else
1390  yystate = yydefgoto[yyn - YYNTOKENS];
1391 
1392  goto yynewstate;
1393 
1394 
1395 /*--------------------------------------.
1396 | yyerrlab -- here on detecting error. |
1397 `--------------------------------------*/
1398 yyerrlab:
1399  /* Make sure we have latest lookahead translation. See comments at
1400  user semantic actions for why this is necessary. */
1401  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1402 
1403  /* If not already recovering from an error, report this error. */
1404  if (!yyerrstatus)
1405  {
1406  ++yynerrs;
1407 #if ! YYERROR_VERBOSE
1408  yyerror (&yylloc, scanner, helper, YY_("syntax error"));
1409 #else
1410 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1411  yyssp, yytoken)
1412  {
1413  char const *yymsgp = YY_("syntax error");
1414  int yysyntax_error_status;
1415  yysyntax_error_status = YYSYNTAX_ERROR;
1416  if (yysyntax_error_status == 0)
1417  yymsgp = yymsg;
1418  else if (yysyntax_error_status == 1)
1419  {
1420  if (yymsg != yymsgbuf)
1421  YYSTACK_FREE (yymsg);
1422  yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1423  if (!yymsg)
1424  {
1425  yymsg = yymsgbuf;
1426  yymsg_alloc = sizeof yymsgbuf;
1427  yysyntax_error_status = 2;
1428  }
1429  else
1430  {
1431  yysyntax_error_status = YYSYNTAX_ERROR;
1432  yymsgp = yymsg;
1433  }
1434  }
1435  yyerror (&yylloc, scanner, helper, yymsgp);
1436  if (yysyntax_error_status == 2)
1437  goto yyexhaustedlab;
1438  }
1439 # undef YYSYNTAX_ERROR
1440 #endif
1441  }
1442 
1443  yyerror_range[1] = yylloc;
1444 
1445  if (yyerrstatus == 3)
1446  {
1447  /* If just tried and failed to reuse lookahead token after an
1448  error, discard it. */
1449 
1450  if (yychar <= YYEOF)
1451  {
1452  /* Return failure if at end of input. */
1453  if (yychar == YYEOF)
1454  YYABORT;
1455  }
1456  else
1457  {
1458  yydestruct ("Error: discarding",
1459  yytoken, &yylval, &yylloc, scanner, helper);
1460  yychar = YYEMPTY;
1461  }
1462  }
1463 
1464  /* Else will try to reuse lookahead token after shifting the error
1465  token. */
1466  goto yyerrlab1;
1467 
1468 
1469 /*---------------------------------------------------.
1470 | yyerrorlab -- error raised explicitly by YYERROR. |
1471 `---------------------------------------------------*/
1472 yyerrorlab:
1473 
1474  /* Pacify compilers like GCC when the user code never invokes
1475  YYERROR and the label yyerrorlab therefore never appears in user
1476  code. */
1477  if (/*CONSTCOND*/ 0)
1478  goto yyerrorlab;
1479 
1480  yyerror_range[1] = yylsp[1-yylen];
1481  /* Do not reclaim the symbols of the rule whose action triggered
1482  this YYERROR. */
1483  YYPOPSTACK (yylen);
1484  yylen = 0;
1485  YY_STACK_PRINT (yyss, yyssp);
1486  yystate = *yyssp;
1487  goto yyerrlab1;
1488 
1489 
1490 /*-------------------------------------------------------------.
1491 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1492 `-------------------------------------------------------------*/
1493 yyerrlab1:
1494  yyerrstatus = 3; /* Each real token shifted decrements this. */
1495 
1496  for (;;)
1497  {
1498  yyn = yypact[yystate];
1499  if (!yypact_value_is_default (yyn))
1500  {
1501  yyn += YYTERROR;
1502  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1503  {
1504  yyn = yytable[yyn];
1505  if (0 < yyn)
1506  break;
1507  }
1508  }
1509 
1510  /* Pop the current state because it cannot handle the error token. */
1511  if (yyssp == yyss)
1512  YYABORT;
1513 
1514  yyerror_range[1] = *yylsp;
1515  yydestruct ("Error: popping",
1516  yystos[yystate], yyvsp, yylsp, scanner, helper);
1517  YYPOPSTACK (1);
1518  yystate = *yyssp;
1519  YY_STACK_PRINT (yyss, yyssp);
1520  }
1521 
1523  *++yyvsp = yylval;
1525 
1526  yyerror_range[2] = yylloc;
1527  /* Using YYLLOC is tempting, but would change the location of
1528  the lookahead. YYLOC is available though. */
1529  YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
1530  *++yylsp = yyloc;
1531 
1532  /* Shift the error token. */
1533  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1534 
1535  yystate = yyn;
1536  goto yynewstate;
1537 
1538 
1539 /*-------------------------------------.
1540 | yyacceptlab -- YYACCEPT comes here. |
1541 `-------------------------------------*/
1542 yyacceptlab:
1543  yyresult = 0;
1544  goto yyreturn;
1545 
1546 /*-----------------------------------.
1547 | yyabortlab -- YYABORT comes here. |
1548 `-----------------------------------*/
1549 yyabortlab:
1550  yyresult = 1;
1551  goto yyreturn;
1552 
1553 #if !defined yyoverflow || YYERROR_VERBOSE
1554 /*-------------------------------------------------.
1555 | yyexhaustedlab -- memory exhaustion comes here. |
1556 `-------------------------------------------------*/
1557 yyexhaustedlab:
1558  yyerror (&yylloc, scanner, helper, YY_("memory exhausted"));
1559  yyresult = 2;
1560  /* Fall through. */
1561 #endif
1562 
1563 yyreturn:
1564  if (yychar != YYEMPTY)
1565  {
1566  /* Make sure we have latest lookahead translation. See comments at
1567  user semantic actions for why this is necessary. */
1568  yytoken = YYTRANSLATE (yychar);
1569  yydestruct ("Cleanup: discarding lookahead",
1570  yytoken, &yylval, &yylloc, scanner, helper);
1571  }
1572  /* Do not reclaim the symbols of the rule whose action triggered
1573  this YYABORT or YYACCEPT. */
1574  YYPOPSTACK (yylen);
1575  YY_STACK_PRINT (yyss, yyssp);
1576  while (yyssp != yyss)
1577  {
1578  yydestruct ("Cleanup: popping",
1579  yystos[*yyssp], yyvsp, yylsp, scanner, helper);
1580  YYPOPSTACK (1);
1581  }
1582 #ifndef yyoverflow
1583  if (yyss != yyssa)
1584  YYSTACK_FREE (yyss);
1585 #endif
1586 #if YYERROR_VERBOSE
1587  if (yymsg != yymsgbuf)
1588  YYSTACK_FREE (yymsg);
1589 #endif
1590  return yyresult;
1591 }
1592 #line 60 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/src/cqasm/src/cqasm-version-parser.y" /* yacc.c:1906 */
1593 
1594 
1595 void yyerror(YYLTYPE* yyllocp, yyscan_t unused, cqasm::version::ParseHelper &helper, const char* msg) {
1596  (void)unused;
1597  std::ostringstream sb;
1598  sb << helper.filename
1599  << ":" << yyllocp->first_line
1600  << ":" << yyllocp->first_column
1601  << ": " << msg;
1602  helper.push_error(sb.str());
1603 }
#define yytable_value_is_error(Yytable_value)
cqasm_versiontokentype
#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
#define YYINITDEPTH
#define YYEMPTY
#define yyerror
#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
Defines utilities for detecting and dealing with cQASM language versions.
#define YYSTACK_ALLOC_MAXIMUM
#define YYTRANSLATE(YYX)
void free(void *)
Version version
The parse result.
#define yypact_value_is_default(Yystate)
#define YYNTOKENS
void * yyscan_t
#define yylex
void * malloc(YYSIZE_T)
#define YYLLOC_DEFAULT(Current, Rhs, N)
#define YYSTACK_ALLOC
int cqasm_versionparse(yyscan_t scanner, cqasm::version::ParseHelper &helper)
#define YYSTYPE
#define YYUSE(E)
Version number primitive used within the AST and semantic trees.
void * yyscan_t
#define YYSYNTAX_ERROR
#define YY_(Msgid)
unsigned char yytype_uint8
signed char yytype_int8
#define YYSTACK_BYTES(N)
Internal helper class for parsing cQASM file versions.
unsigned char yytype_uint8
yytype_int16 yyss_alloc
#define YYLAST
#define YYDPRINTF(Args)
unsigned short int yytype_uint16
YYSTYPE yyvs_alloc
#define YYMAXDEPTH
#define yylloc
#define YY_NULL
#define YYSTACK_FREE
std::string filename
Name of the file being parsed.
#define YY_IGNORE_MAYBE_UNINITIALIZED_END
#define YY_REDUCE_PRINT(Rule)
#define yylval
Contains custom exception objects used by libqasm.
#define YYACCEPT
short int yytype_int16
#define YYEOF
#define YYABORT
#define yynerrs
#define YYLTYPE
static void push_error(const std::string &error)
Pushes an error.
#define YY_INITIAL_VALUE(Value)
#define YYSIZE_T
YYLTYPE yyls_alloc
#define YYCASE_(N, S)
Namespace for detecting and dealing with cQASM language versions.
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
unsigned short int yytype_uint16
#define YY_STACK_PRINT(Bottom, Top)
signed char yytype_int8
short int yytype_int16
#define __attribute__(Spec)
#define yyparse
#define YYFINAL
#define YYPOPSTACK(N)
#define YYTERROR
#define yydebug