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