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