Graphviz 13.0.0~dev.20250523.0001
Loading...
Searching...
No Matches
exparse.c
Go to the documentation of this file.
1/* A Bison parser, made by GNU Bison 3.5.1. */
2
3/* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
6 Inc.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21/* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34/* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
36
37/* All symbols defined below should begin with yy or YY, to avoid
38 infringing on user name space. This should be done even for local
39 variables, as they might otherwise be expanded by user macros.
40 There are some unavoidable exceptions within include files to
41 define necessary library symbols; they are noted "INFRINGES ON
42 USER NAME SPACE" below. */
43
44/* Undocumented macros, especially those whose name start with YY_,
45 are private implementation details. Do not rely on them. */
46
47/* Identify Bison output. */
48#define YYBISON 1
49
50/* Bison version. */
51#define YYBISON_VERSION "3.5.1"
52
53/* Skeleton name. */
54#define YYSKELETON_NAME "yacc.c"
55
56/* Pure parsers. */
57#define YYPURE 0
58
59/* Push parsers. */
60#define YYPUSH 0
61
62/* Pull parsers. */
63#define YYPULL 1
64
65/* Substitute the type names. */
66#define YYSTYPE EX_STYPE
67/* Substitute the variable and function names. */
68#define yyparse ex_parse
69#define yylex ex_lex
70#define yyerror ex_error
71#define yydebug ex_debug
72#define yynerrs ex_nerrs
73#define yylval ex_lval
74#define yychar ex_char
75
76/* First part of user prologue. */
77#line 19 "../../lib/expr/exparse.y"
78
79
80/*
81 * Glenn Fowler
82 * AT&T Research
83 *
84 * expression library grammar and compiler
85 */
86
87#include <assert.h>
88#include <expr/exop.h>
89#include <stdbool.h>
90#include <stdio.h>
91#include <stdlib.h>
92#include <string.h>
93#include <ast/ast.h>
94#include <util/gv_ctype.h>
95#include <util/streq.h>
96
97
98#line 99 "exparse.c"
99
100# ifndef YY_CAST
101# ifdef __cplusplus
102# define YY_CAST(Type, Val) static_cast<Type> (Val)
103# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
104# else
105# define YY_CAST(Type, Val) ((Type) (Val))
106# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
107# endif
108# endif
109# ifndef YY_NULLPTR
110# if defined __cplusplus
111# if 201103L <= __cplusplus
112# define YY_NULLPTR nullptr
113# else
114# define YY_NULLPTR 0
115# endif
116# else
117# define YY_NULLPTR ((void*)0)
118# endif
119# endif
120
121/* Enabling verbose error messages. */
122#ifdef YYERROR_VERBOSE
123# undef YYERROR_VERBOSE
124# define YYERROR_VERBOSE 1
125#else
126# define YYERROR_VERBOSE 0
127#endif
128
129/* Use api.header.include to #include this header
130 instead of duplicating it here. */
131#ifndef YY_EX_EXPARSE_H_INCLUDED
132# define YY_EX_EXPARSE_H_INCLUDED
133/* Debug traces. */
134#ifndef EX_DEBUG
135# if defined YYDEBUG
136#if YYDEBUG
137# define EX_DEBUG 1
138# else
139# define EX_DEBUG 0
140# endif
141# else /* ! defined YYDEBUG */
142# define EX_DEBUG 1
143# endif /* ! defined YYDEBUG */
144#endif /* ! defined EX_DEBUG */
145#if EX_DEBUG
146extern int ex_debug;
147#endif
148
149/* Token type. */
150#ifndef EX_TOKENTYPE
151# define EX_TOKENTYPE
153 {
154 MINTOKEN = 258,
155 INTEGER = 259,
156 UNSIGNED = 260,
158 FLOATING = 262,
159 STRING = 263,
160 VOIDTYPE = 264,
161 ADDRESS = 265,
162 ARRAY = 266,
163 BREAK = 267,
164 CALL = 268,
165 CASE = 269,
166 CONSTANT = 270,
167 CONTINUE = 271,
168 DECLARE = 272,
169 DEFAULT = 273,
170 DYNAMIC = 274,
171 ELSE = 275,
172 EXIT = 276,
173 FOR = 277,
174 FUNCTION = 278,
175 GSUB = 279,
176 ITERATE = 280,
177 ITERATOR = 281,
178 ID = 282,
179 IF = 283,
180 LABEL = 284,
181 MEMBER = 285,
182 NAME = 286,
183 POS = 287,
184 PRAGMA = 288,
185 PRE = 289,
186 PRINT = 290,
187 PRINTF = 291,
189 QUERY = 293,
190 RAND = 294,
191 RETURN = 295,
192 SCANF = 296,
193 SPLIT = 297,
194 SPRINTF = 298,
195 SRAND = 299,
196 SSCANF = 300,
197 SUB = 301,
198 SUBSTR = 302,
199 SWITCH = 303,
200 TOKENS = 304,
201 UNSET = 305,
202 WHILE = 306,
203 F2I = 307,
204 F2S = 308,
205 I2F = 309,
206 I2S = 310,
207 S2B = 311,
208 S2F = 312,
209 S2I = 313,
210 F2X = 314,
211 I2X = 315,
212 S2X = 316,
213 X2F = 317,
214 X2I = 318,
215 X2S = 319,
216 X2X = 320,
217 XPRINT = 321,
218 OR = 322,
219 AND = 323,
220 EQ = 324,
221 NE = 325,
222 LE = 326,
223 GE = 327,
224 LSH = 328,
225 RSH = 329,
226 IN_OP = 330,
227 UNARY = 331,
228 INC = 332,
229 DEC = 333,
230 CAST = 334,
231 MAXTOKEN = 335
232 };
233#endif
234/* Tokens. */
235#define MINTOKEN 258
236#define INTEGER 259
237#define UNSIGNED 260
238#define CHARACTER 261
239#define FLOATING 262
240#define STRING 263
241#define VOIDTYPE 264
242#define ADDRESS 265
243#define ARRAY 266
244#define BREAK 267
245#define CALL 268
246#define CASE 269
247#define CONSTANT 270
248#define CONTINUE 271
249#define DECLARE 272
250#define DEFAULT 273
251#define DYNAMIC 274
252#define ELSE 275
253#define EXIT 276
254#define FOR 277
255#define FUNCTION 278
256#define GSUB 279
257#define ITERATE 280
258#define ITERATOR 281
259#define ID 282
260#define IF 283
261#define LABEL 284
262#define MEMBER 285
263#define NAME 286
264#define POS 287
265#define PRAGMA 288
266#define PRE 289
267#define PRINT 290
268#define PRINTF 291
269#define PROCEDURE 292
270#define QUERY 293
271#define RAND 294
272#define RETURN 295
273#define SCANF 296
274#define SPLIT 297
275#define SPRINTF 298
276#define SRAND 299
277#define SSCANF 300
278#define SUB 301
279#define SUBSTR 302
280#define SWITCH 303
281#define TOKENS 304
282#define UNSET 305
283#define WHILE 306
284#define F2I 307
285#define F2S 308
286#define I2F 309
287#define I2S 310
288#define S2B 311
289#define S2F 312
290#define S2I 313
291#define F2X 314
292#define I2X 315
293#define S2X 316
294#define X2F 317
295#define X2I 318
296#define X2S 319
297#define X2X 320
298#define XPRINT 321
299#define OR 322
300#define AND 323
301#define EQ 324
302#define NE 325
303#define LE 326
304#define GE 327
305#define LSH 328
306#define RSH 329
307#define IN_OP 330
308#define UNARY 331
309#define INC 332
310#define DEC 333
311#define CAST 334
312#define MAXTOKEN 335
313
314/* Value type. */
315#if ! defined EX_STYPE && ! defined EX_STYPE_IS_DECLARED
317{
318#line 41 "../../lib/expr/exparse.y"
319
321 double floating;
323 struct Exid_s* id;
324 long long integer;
325 int op;
326 char* string;
327
328#line 329 "exparse.c"
329
330};
331typedef union EX_STYPE EX_STYPE;
332# define EX_STYPE_IS_TRIVIAL 1
333# define EX_STYPE_IS_DECLARED 1
334#endif
335
336
337extern EX_STYPE ex_lval;
338
339int ex_parse (void);
340
341#endif /* !YY_EX_EXPARSE_H_INCLUDED */
342
343/* Second part of user prologue. */
344#line 169 "../../lib/expr/exparse.y"
345
346
347#include <expr/exgram.h>
348
349void ex_error(const char *message);
350
351
352#line 353 "exparse.c"
353
354
355#ifdef short
356# undef short
357#endif
358
359/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
360 <limits.h> and (if available) <stdint.h> are included
361 so that the code can choose integer types of a good width. */
362
363#ifndef __PTRDIFF_MAX__
364# include <limits.h> /* INFRINGES ON USER NAME SPACE */
365# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
366# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
367# define YY_STDINT_H
368# endif
369#endif
370
371/* Narrow types that promote to a signed type and that can represent a
372 signed or unsigned integer of at least N bits. In tables they can
373 save space and decrease cache pressure. Promoting to a signed type
374 helps avoid bugs in integer arithmetic. */
375
376#ifdef __INT_LEAST8_MAX__
377typedef __INT_LEAST8_TYPE__ yytype_int8;
378#elif defined YY_STDINT_H
379typedef int_least8_t yytype_int8;
380#else
381typedef signed char yytype_int8;
382#endif
383
384#ifdef __INT_LEAST16_MAX__
385typedef __INT_LEAST16_TYPE__ yytype_int16;
386#elif defined YY_STDINT_H
387typedef int_least16_t yytype_int16;
388#else
389typedef short yytype_int16;
390#endif
391
392#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
393typedef __UINT_LEAST8_TYPE__ yytype_uint8;
394#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
395 && UINT_LEAST8_MAX <= INT_MAX)
396typedef uint_least8_t yytype_uint8;
397#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
398typedef unsigned char yytype_uint8;
399#else
400typedef short yytype_uint8;
401#endif
402
403#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
404typedef __UINT_LEAST16_TYPE__ yytype_uint16;
405#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
406 && UINT_LEAST16_MAX <= INT_MAX)
407typedef uint_least16_t yytype_uint16;
408#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
409typedef unsigned short yytype_uint16;
410#else
411typedef int yytype_uint16;
412#endif
413
414#ifndef YYPTRDIFF_T
415# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
416# define YYPTRDIFF_T __PTRDIFF_TYPE__
417# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
418# elif defined PTRDIFF_MAX
419# ifndef ptrdiff_t
420# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
421# endif
422# define YYPTRDIFF_T ptrdiff_t
423# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
424# else
425# define YYPTRDIFF_T long
426# define YYPTRDIFF_MAXIMUM LONG_MAX
427# endif
428#endif
429
430#ifndef YYSIZE_T
431# ifdef __SIZE_TYPE__
432# define YYSIZE_T __SIZE_TYPE__
433# elif defined size_t
434# define YYSIZE_T size_t
435# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
436# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
437# define YYSIZE_T size_t
438# else
439# define YYSIZE_T unsigned
440# endif
441#endif
442
443#define YYSIZE_MAXIMUM \
444 YY_CAST (YYPTRDIFF_T, \
445 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
446 ? YYPTRDIFF_MAXIMUM \
447 : YY_CAST (YYSIZE_T, -1)))
448
449#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
450
451/* Stored state numbers (used for stacks). */
453
454/* State numbers in computations. */
455typedef int yy_state_fast_t;
456
457#ifndef YY_
458# if defined YYENABLE_NLS && YYENABLE_NLS
459# if ENABLE_NLS
460# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
461# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
462# endif
463# endif
464# ifndef YY_
465# define YY_(Msgid) Msgid
466# endif
467#endif
468
469#ifndef YY_ATTRIBUTE_PURE
470# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
471# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
472# else
473# define YY_ATTRIBUTE_PURE
474# endif
475#endif
476
477#ifndef YY_ATTRIBUTE_UNUSED
478# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
479# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
480# else
481# define YY_ATTRIBUTE_UNUSED
482# endif
483#endif
484
485/* Suppress unused-variable warnings by "using" E. */
486#if ! defined lint || defined __GNUC__
487# define YYUSE(E) ((void) (E))
488#else
489# define YYUSE(E) /* empty */
490#endif
491
492#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
493/* Suppress an incorrect diagnostic about yylval being uninitialized. */
494# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
495 _Pragma ("GCC diagnostic push") \
496 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
497 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
498# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
499 _Pragma ("GCC diagnostic pop")
500#else
501# define YY_INITIAL_VALUE(Value) Value
502#endif
503#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
504# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
505# define YY_IGNORE_MAYBE_UNINITIALIZED_END
506#endif
507#ifndef YY_INITIAL_VALUE
508# define YY_INITIAL_VALUE(Value) /* Nothing. */
509#endif
510
511#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
512# define YY_IGNORE_USELESS_CAST_BEGIN \
513 _Pragma ("GCC diagnostic push") \
514 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
515# define YY_IGNORE_USELESS_CAST_END \
516 _Pragma ("GCC diagnostic pop")
517#endif
518#ifndef YY_IGNORE_USELESS_CAST_BEGIN
519# define YY_IGNORE_USELESS_CAST_BEGIN
520# define YY_IGNORE_USELESS_CAST_END
521#endif
522
523
524#define YY_ASSERT(E) ((void) (0 && (E)))
525
526#if ! defined yyoverflow || YYERROR_VERBOSE
527
528/* The parser invokes alloca or malloc; define the necessary symbols. */
529
530# ifdef YYSTACK_USE_ALLOCA
531# if YYSTACK_USE_ALLOCA
532# ifdef __GNUC__
533# define YYSTACK_ALLOC __builtin_alloca
534# elif defined __BUILTIN_VA_ARG_INCR
535# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
536# elif defined _AIX
537# define YYSTACK_ALLOC __alloca
538# elif defined _MSC_VER
539# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
540# define alloca _alloca
541# else
542# define YYSTACK_ALLOC alloca
543# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
544# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
545 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
546# ifndef EXIT_SUCCESS
547# define EXIT_SUCCESS 0
548# endif
549# endif
550# endif
551# endif
552# endif
553
554# ifdef YYSTACK_ALLOC
555 /* Pacify GCC's 'empty if-body' warning. */
556# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
557# ifndef YYSTACK_ALLOC_MAXIMUM
558 /* The OS might guarantee only one guard page at the bottom of the stack,
559 and a page size can be as small as 4096 bytes. So we cannot safely
560 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
561 to allow for a few compiler-allocated temporary stack slots. */
562# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
563# endif
564# else
565# define YYSTACK_ALLOC YYMALLOC
566# define YYSTACK_FREE YYFREE
567# ifndef YYSTACK_ALLOC_MAXIMUM
568# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
569# endif
570# if (defined __cplusplus && ! defined EXIT_SUCCESS \
571 && ! ((defined YYMALLOC || defined malloc) \
572 && (defined YYFREE || defined free)))
573# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
574# ifndef EXIT_SUCCESS
575# define EXIT_SUCCESS 0
576# endif
577# endif
578# ifndef YYMALLOC
579# define YYMALLOC malloc
580# if ! defined malloc && ! defined EXIT_SUCCESS
581void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
582# endif
583# endif
584# ifndef YYFREE
585# define YYFREE free
586# if ! defined free && ! defined EXIT_SUCCESS
587void free (void *); /* INFRINGES ON USER NAME SPACE */
588# endif
589# endif
590# endif
591#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
592
593
594#if (! defined yyoverflow \
595 && (! defined __cplusplus \
596 || (defined EX_STYPE_IS_TRIVIAL && EX_STYPE_IS_TRIVIAL)))
597
598/* A type that is properly aligned for any stack member. */
599union yyalloc
600{
601 yy_state_t yyss_alloc;
602 YYSTYPE yyvs_alloc;
603};
604
605/* The size of the maximum gap between one aligned stack and the next. */
606# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
607
608/* The size of an array large to enough to hold all stacks, each with
609 N elements. */
610# define YYSTACK_BYTES(N) \
611 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
612 + YYSTACK_GAP_MAXIMUM)
613
614# define YYCOPY_NEEDED 1
615
616/* Relocate STACK from its old location to the new one. The
617 local variables YYSIZE and YYSTACKSIZE give the old and new number of
618 elements in the stack, and YYPTR gives the new location of the
619 stack. Advance YYPTR to a properly aligned location for the next
620 stack. */
621# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
622 do \
623 { \
624 YYPTRDIFF_T yynewbytes; \
625 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
626 Stack = &yyptr->Stack_alloc; \
627 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
628 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
629 } \
630 while (0)
631
632#endif
633
634#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
635/* Copy COUNT objects from SRC to DST. The source and destination do
636 not overlap. */
637# ifndef YYCOPY
638# if defined __GNUC__ && 1 < __GNUC__
639# define YYCOPY(Dst, Src, Count) \
640 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
641# else
642# define YYCOPY(Dst, Src, Count) \
643 do \
644 { \
645 YYPTRDIFF_T yyi; \
646 for (yyi = 0; yyi < (Count); yyi++) \
647 (Dst)[yyi] = (Src)[yyi]; \
648 } \
649 while (0)
650# endif
651# endif
652#endif /* !YYCOPY_NEEDED */
653
654/* YYFINAL -- State number of the termination state. */
655#define YYFINAL 3
656/* YYLAST -- Last index in YYTABLE. */
657#define YYLAST 1120
658
659/* YYNTOKENS -- Number of terminals. */
660#define YYNTOKENS 106
661/* YYNNTS -- Number of nonterminals. */
662#define YYNNTS 42
663/* YYNRULES -- Number of rules. */
664#define YYNRULES 141
665/* YYNSTATES -- Number of states. */
666#define YYNSTATES 285
667
668#define YYUNDEFTOK 2
669#define YYMAXUTOK 335
670
671
672/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
673 as returned by yylex, with out-of-bounds checking. */
674#define YYTRANSLATE(YYX) \
675 (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
676
677/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
678 as returned by yylex. */
679static const yytype_int8 yytranslate[] =
680{
681 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
682 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
683 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
684 2, 2, 2, 90, 2, 92, 2, 89, 75, 2,
685 97, 102, 87, 84, 67, 85, 105, 88, 2, 2,
686 2, 2, 2, 2, 2, 2, 2, 2, 70, 101,
687 78, 68, 79, 69, 2, 2, 2, 2, 2, 2,
688 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
689 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
690 2, 103, 2, 104, 74, 2, 2, 2, 2, 2,
691 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
692 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
693 2, 2, 2, 99, 73, 100, 91, 2, 2, 2,
694 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
695 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
696 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
697 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
698 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
699 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
700 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
701 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
702 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
703 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
704 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
705 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
706 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
707 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
708 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
709 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
710 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
711 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
712 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
713 65, 66, 71, 72, 76, 77, 80, 81, 82, 83,
714 86, 93, 94, 95, 96, 98
715};
716
717#if EX_DEBUG
718 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
719static const yytype_int16 yyrline[] =
720{
721 0, 179, 179, 197, 198, 201, 201, 236, 239, 254,
722 258, 262, 262, 267, 277, 290, 305, 318, 326, 337,
723 347, 347, 357, 369, 373, 386, 402, 405, 436, 437,
724 440, 458, 464, 465, 472, 472, 520, 521, 522, 523,
725 526, 527, 531, 534, 541, 544, 547, 551, 555, 608,
726 612, 616, 620, 624, 628, 632, 636, 640, 644, 648,
727 652, 656, 660, 664, 668, 681, 685, 695, 695, 695,
728 736, 756, 763, 768, 772, 776, 780, 784, 788, 792,
729 796, 800, 804, 808, 812, 818, 822, 826, 832, 837,
730 841, 866, 902, 922, 930, 938, 949, 958, 962, 966,
731 969, 970, 972, 980, 985, 990, 995, 1002, 1003, 1004,
732 1007, 1008, 1011, 1015, 1033, 1046, 1049, 1053, 1067, 1070,
733 1077, 1080, 1088, 1093, 1100, 1103, 1109, 1112, 1116, 1127,
734 1127, 1143, 1146, 1158, 1178, 1182, 1188, 1191, 1198, 1199,
735 1211, 1199
736};
737#endif
738
739#if EX_DEBUG || YYERROR_VERBOSE || 1
740/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
741 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
742static const char *const yytname[] =
743{
744 "$end", "error", "$undefined", "MINTOKEN", "INTEGER", "UNSIGNED",
745 "CHARACTER", "FLOATING", "STRING", "VOIDTYPE", "ADDRESS", "ARRAY",
746 "BREAK", "CALL", "CASE", "CONSTANT", "CONTINUE", "DECLARE", "DEFAULT",
747 "DYNAMIC", "ELSE", "EXIT", "FOR", "FUNCTION", "GSUB", "ITERATE",
748 "ITERATOR", "ID", "IF", "LABEL", "MEMBER", "NAME", "POS", "PRAGMA",
749 "PRE", "PRINT", "PRINTF", "PROCEDURE", "QUERY", "RAND", "RETURN",
750 "SCANF", "SPLIT", "SPRINTF", "SRAND", "SSCANF", "SUB", "SUBSTR",
751 "SWITCH", "TOKENS", "UNSET", "WHILE", "F2I", "F2S", "I2F", "I2S", "S2B",
752 "S2F", "S2I", "F2X", "I2X", "S2X", "X2F", "X2I", "X2S", "X2X", "XPRINT",
753 "','", "'='", "'?'", "':'", "OR", "AND", "'|'", "'^'", "'&'", "EQ", "NE",
754 "'<'", "'>'", "LE", "GE", "LSH", "RSH", "'+'", "'-'", "IN_OP", "'*'",
755 "'/'", "'%'", "'!'", "'~'", "'#'", "UNARY", "INC", "DEC", "CAST", "'('",
756 "MAXTOKEN", "'{'", "'}'", "';'", "')'", "'['", "']'", "'.'", "$accept",
757 "program", "action_list", "action", "$@1", "statement_list", "statement",
758 "$@2", "$@3", "switch_list", "switch_item", "case_list", "case_item",
759 "dcl_list", "dcl_item", "$@4", "dcl_name", "name", "else_opt",
760 "expr_opt", "expr", "$@5", "$@6", "splitop", "constant", "print", "scan",
761 "variable", "array", "index", "args", "arg_list", "formals",
762 "formal_list", "formal_item", "$@7", "members", "member", "assign",
763 "initialize", "$@8", "$@9", YY_NULLPTR
764};
765#endif
766
767# ifdef YYPRINT
768/* YYTOKNUM[NUM] -- (External) token number corresponding to the
769 (internal) symbol number NUM (which must be that of a token). */
770static const yytype_int16 yytoknum[] =
771{
772 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
773 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
774 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
775 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
776 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
777 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
778 315, 316, 317, 318, 319, 320, 321, 44, 61, 63,
779 58, 322, 323, 124, 94, 38, 324, 325, 60, 62,
780 326, 327, 328, 329, 43, 45, 330, 42, 47, 37,
781 33, 126, 35, 331, 332, 333, 334, 40, 335, 123,
782 125, 59, 41, 91, 93, 46
783};
784# endif
785
786#define YYPACT_NINF (-181)
787
788#define yypact_value_is_default(Yyn) \
789 ((Yyn) == YYPACT_NINF)
790
791#define YYTABLE_NINF (-126)
792
793#define yytable_value_is_error(Yyn) \
794 ((Yyn) == YYTABLE_NINF)
795
796 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
797 STATE-NUM. */
798static const yytype_int16 yypact[] =
799{
800 -181, 9, 231, -181, -181, -181, -181, -181, -71, 713,
801 -181, 713, -181, -69, -62, -44, -41, -39, -34, -17,
802 1, -181, 8, -181, 11, -181, 14, 713, -181, -181,
803 -181, 21, -181, 28, 30, 31, -181, 33, 36, 73,
804 713, 713, 713, 713, 101, 73, 73, 619, -181, 64,
805 -181, 35, 893, 40, -181, 46, 47, -55, 713, 44,
806 48, 72, 713, -17, 713, 713, 713, 713, 73, -11,
807 -181, -181, 713, 713, 713, 45, 55, 127, 713, 713,
808 713, 133, 713, -181, -181, -181, -181, -181, -181, -181,
809 -181, -181, 57, 314, 329, 83, -181, -181, 713, -181,
810 713, 713, 713, 713, 713, 713, 713, 713, 713, 713,
811 713, 713, 713, 713, 713, 104, 713, 713, 713, 713,
812 713, 713, 713, -181, -181, -181, 937, 53, 93, -181,
813 -181, -181, -181, -181, -181, -50, -181, -181, 216, -181,
814 411, 60, 19, 75, 76, 77, 99, -181, 508, 78,
815 86, -181, -181, -181, 600, 103, 105, 893, -57, 694,
816 713, -181, -181, -181, 937, 713, 955, 972, 988, 1003,
817 1017, 1031, 1031, 112, 112, 112, 112, 98, 98, 52,
818 52, -181, -181, -181, -181, -181, 916, 106, 111, 937,
819 -181, 713, 72, -181, 100, -181, -181, 713, 523, -181,
820 -181, 523, -2, -181, 523, -181, -181, -181, -181, -181,
821 113, 713, -181, 523, -181, -181, 870, 807, -181, -181,
822 937, -181, -15, -45, 119, -181, -181, -181, 186, 115,
823 788, -181, 231, -181, -53, 121, -181, -181, -181, -181,
824 713, 523, -181, -181, -181, 713, 713, -181, -181, 206,
825 124, -181, -6, 937, 836, 125, -181, 161, -181, 523,
826 102, 160, -181, -181, 108, -181, -181, -4, 129, 220,
827 -181, 163, -181, 231, -181, -181, -181, -181, 141, -181,
828 -181, -181, -181, 426, -181
829};
830
831 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
832 Performed when YYTABLE does not specify something else to do. Zero
833 means the default is an error. */
834static const yytype_uint8 yydefact[] =
835{
836 7, 0, 3, 1, 104, 106, 103, 105, 0, 44,
837 102, 44, 11, 118, 0, 0, 0, 0, 0, 131,
838 0, 114, 0, 107, 0, 108, 0, 44, 110, 100,
839 109, 0, 111, 0, 0, 0, 101, 0, 0, 0,
840 0, 0, 0, 0, 0, 0, 0, 0, 7, 2,
841 8, 0, 45, 0, 99, 0, 0, 136, 120, 0,
842 0, 0, 0, 131, 0, 44, 120, 120, 0, 0,
843 112, 132, 0, 120, 120, 0, 0, 0, 120, 120,
844 0, 0, 0, 76, 75, 74, 70, 73, 72, 71,
845 93, 97, 0, 0, 44, 0, 4, 10, 0, 67,
846 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
847 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
848 120, 120, 0, 94, 98, 92, 122, 0, 121, 22,
849 23, 37, 39, 38, 36, 0, 32, 34, 0, 113,
850 0, 0, 136, 0, 0, 0, 134, 135, 0, 0,
851 0, 85, 24, 86, 0, 0, 0, 20, 0, 0,
852 0, 46, 9, 5, 66, 0, 65, 64, 61, 62,
853 60, 58, 59, 48, 55, 56, 57, 53, 54, 63,
854 49, 96, 95, 50, 51, 52, 0, 0, 0, 137,
855 77, 0, 0, 12, 115, 119, 84, 44, 44, 78,
856 79, 44, 0, 133, 44, 89, 88, 87, 80, 81,
857 0, 0, 17, 44, 47, 7, 0, 0, 90, 91,
858 123, 33, 0, 136, 0, 14, 16, 134, 42, 0,
859 0, 19, 6, 68, 118, 0, 116, 139, 138, 35,
860 44, 44, 13, 25, 18, 0, 0, 82, 117, 124,
861 0, 43, 0, 69, 0, 129, 140, 126, 127, 44,
862 0, 0, 21, 26, 7, 28, 83, 0, 0, 0,
863 15, 0, 31, 27, 29, 41, 40, 130, 0, 129,
864 128, 30, 7, 44, 141
865};
866
867 /* YYPGOTO[NTERM-NUM]. */
868static const yytype_int16 yypgoto[] =
869{
870 -181, -181, -181, -181, -181, -48, -180, -181, -181, -181,
871 -181, -181, -23, -181, 59, -181, -181, -181, -181, -8,
872 -36, -181, -181, -181, -16, -181, -181, 51, -181, -181,
873 -19, -181, -181, -181, -24, -181, 193, 114, 26, -181,
874 -181, -181
875};
876
877 /* YYDEFGOTO[NTERM-NUM]. */
878static const yytype_int16 yydefgoto[] =
879{
880 -1, 1, 49, 96, 215, 2, 50, 61, 210, 252,
881 263, 264, 265, 135, 136, 194, 137, 277, 242, 51,
882 52, 165, 245, 53, 54, 55, 56, 57, 223, 63,
883 127, 128, 256, 257, 258, 267, 70, 71, 125, 239,
884 249, 268
885};
886
887 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
888 positive, shift that token. If negative, reduce the rule whose
889 number is the opposite. If YYTABLE_NINF, syntax error. */
890static const yytype_int16 yytable[] =
891{
892 94, 59, 235, 60, 84, 85, 86, 87, 260, 3,
893 211, 93, 261, 122, 246, 275, 146, 192, 225, 76,
894 147, 226, 126, 122, 228, 227, 138, 276, 140, 147,
895 126, 126, 58, 231, 62, 64, 148, 126, 126, 123,
896 124, 154, 126, 126, 157, 212, 159, 143, 144, 247,
897 62, 193, 237, 65, 149, 150, 66, 141, 67, 155,
898 156, 251, 164, 68, 166, 167, 168, 169, 170, 171,
899 172, 173, 174, 175, 176, 177, 178, 179, 180, 270,
900 183, 184, 185, 186, 126, 126, 189, 122, 69, 236,
901 83, 131, 13, 95, 262, 132, 90, 91, 72, 133,
902 19, 187, 188, 134, 21, 73, 4, 5, 74, 6,
903 7, 75, 88, 123, 124, 181, 142, 10, 77, 145,
904 89, 198, 260, 182, 214, 78, 261, 79, 80, 216,
905 81, 4, 5, 82, 6, 7, 97, 119, 8, 116,
906 117, 118, 10, 120, 121, 129, 13, 151, 14, 130,
907 16, 17, 158, 163, 19, 220, 152, 190, 21, 160,
908 191, 197, 22, 23, 24, 25, 26, 232, 28, 29,
909 30, 31, 32, 33, 34, 230, 36, 199, 200, 201,
910 205, 164, 113, 114, 115, 116, 117, 118, 206, 224,
911 -126, -126, -126, -126, 111, 112, 113, 114, 115, 116,
912 117, 118, 39, 222, 202, 208, 241, 209, 218, 253,
913 254, 40, 41, 219, 243, 229, 273, 42, 43, 44,
914 240, 45, 46, 255, 47, 248, 259, -125, 269, 153,
915 272, 278, 250, 281, 283, 4, 5, 279, 6, 7,
916 282, 274, 8, 9, 271, 280, 10, 11, 12, 238,
917 13, 221, 14, 15, 16, 17, 139, 18, 19, 20,
918 203, 0, 21, 0, 0, 0, 22, 23, 24, 25,
919 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
920 36, 37, 38, 98, 0, 99, 0, 100, 101, 102,
921 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
922 113, 114, 115, 116, 117, 118, 39, 0, 0, 0,
923 0, 0, 0, 0, 0, 40, 41, 0, 0, 0,
924 195, 42, 43, 44, 0, 45, 46, 0, 47, 0,
925 48, 0, -44, 4, 5, 0, 6, 7, 0, 0,
926 8, 9, 0, 0, 10, 11, 12, 0, 13, 0,
927 14, 15, 16, 17, 0, 18, 19, 20, 0, 0,
928 21, 0, 0, 0, 22, 23, 24, 25, 26, 27,
929 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
930 38, 98, 0, 99, 0, 100, 101, 102, 103, 104,
931 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
932 115, 116, 117, 118, 39, 0, 0, 0, 0, 0,
933 0, 0, 0, 40, 41, 0, 161, 0, 0, 42,
934 43, 44, 0, 45, 46, 0, 47, 0, 48, 162,
935 4, 5, 0, 6, 7, 0, 0, 8, 9, 0,
936 0, 10, 11, 12, 0, 13, 0, 14, 15, 16,
937 17, 0, 18, 19, 20, 0, 0, 21, 0, 0,
938 0, 22, 23, 24, 25, 26, 27, 28, 29, 30,
939 31, 32, 33, 34, 35, 36, 37, 38, 98, 0,
940 99, 0, 100, 101, 102, 103, 104, 105, 106, 107,
941 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
942 118, 39, 0, 0, 0, 0, 0, 0, 0, 0,
943 40, 41, 0, 196, 0, 0, 42, 43, 44, 0,
944 45, 46, 0, 47, 0, 48, 284, 4, 5, 0,
945 6, 7, 0, 0, 8, 9, 0, 0, 10, 11,
946 12, 0, 13, 0, 14, 15, 16, 17, 0, 18,
947 19, 20, 0, 0, 21, 0, 0, 0, 22, 23,
948 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
949 34, 35, 36, 37, 38, 98, 0, 99, 0, 100,
950 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
951 111, 112, 113, 114, 115, 116, 117, 118, 39, 0,
952 0, 0, 0, 0, 0, 0, 0, 40, 41, 0,
953 204, 0, 0, 42, 43, 44, 0, 45, 46, 0,
954 47, 0, 48, 4, 5, 0, 6, 7, 0, 0,
955 8, 0, 0, 0, 10, 0, 92, 0, 13, 0,
956 14, 0, 16, 17, 0, 0, 19, 0, 0, 0,
957 21, 0, 0, 0, 22, 23, 24, 25, 26, 0,
958 28, 29, 30, 31, 32, 33, 34, 98, 36, 99,
959 0, 100, 101, 102, 103, 104, 105, 106, 107, 108,
960 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
961 0, 0, 0, 0, 39, 0, 0, 0, 0, 0,
962 0, 0, 207, 40, 41, 0, 0, 0, 0, 42,
963 43, 44, 0, 45, 46, 0, 47, 4, 5, 0,
964 6, 7, 0, 0, 8, 0, 0, 0, 10, 0,
965 0, 0, 13, 0, 14, 0, 16, 17, 0, 0,
966 19, 0, 0, 0, 21, 0, 0, 0, 22, 23,
967 24, 25, 26, 0, 28, 29, 30, 31, 32, 33,
968 34, 98, 36, 99, 0, 100, 101, 102, 103, 104,
969 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
970 115, 116, 117, 118, 0, 0, 0, 0, 39, 0,
971 0, 0, 0, 0, 0, 0, 213, 40, 41, 0,
972 0, 0, 0, 42, 43, 44, 0, 45, 46, 0,
973 47, 4, 5, 0, 6, 7, 0, 0, 8, 0,
974 0, 0, 10, 0, 0, 0, 234, 0, 14, 0,
975 16, 17, 0, 0, 19, 0, 0, 0, 21, 0,
976 0, 0, 22, 23, 24, 25, 26, 0, 28, 29,
977 30, 31, 32, 33, 34, 98, 36, 99, 0, 100,
978 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
979 111, 112, 113, 114, 115, 116, 117, 118, 0, 0,
980 0, 0, 39, 0, 0, 0, 0, 0, 0, 0,
981 244, 40, 41, 0, 0, 0, 0, 42, 43, 44,
982 0, 45, 46, 98, 47, 99, 0, 100, 101, 102,
983 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
984 113, 114, 115, 116, 117, 118, 0, 0, 0, 0,
985 0, 0, 0, 0, 0, 0, 0, 98, 266, 99,
986 233, 100, 101, 102, 103, 104, 105, 106, 107, 108,
987 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
988 98, 0, 99, 0, 100, 101, 102, 103, 104, 105,
989 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
990 116, 117, 118, 217, 0, 99, 0, 100, 101, 102,
991 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
992 113, 114, 115, 116, 117, 118, 99, 0, 100, 101,
993 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
994 112, 113, 114, 115, 116, 117, 118, 101, 102, 103,
995 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
996 114, 115, 116, 117, 118, 102, 103, 104, 105, 106,
997 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
998 117, 118, 103, 104, 105, 106, 107, 108, 109, 110,
999 111, 112, 113, 114, 115, 116, 117, 118, 104, 105,
1000 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
1001 116, 117, 118, 105, 106, 107, 108, 109, 110, 111,
1002 112, 113, 114, 115, 116, 117, 118, -126, -126, 107,
1003 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
1004 118
1005};
1006
1007static const yytype_int16 yycheck[] =
1008{
1009 48, 9, 17, 11, 40, 41, 42, 43, 14, 0,
1010 67, 47, 18, 68, 67, 19, 27, 67, 198, 27,
1011 31, 201, 58, 68, 204, 27, 62, 31, 64, 31,
1012 66, 67, 103, 213, 103, 97, 72, 73, 74, 94,
1013 95, 77, 78, 79, 80, 102, 82, 66, 67, 102,
1014 103, 101, 97, 97, 73, 74, 97, 65, 97, 78,
1015 79, 241, 98, 97, 100, 101, 102, 103, 104, 105,
1016 106, 107, 108, 109, 110, 111, 112, 113, 114, 259,
1017 116, 117, 118, 119, 120, 121, 122, 68, 105, 104,
1018 39, 19, 19, 29, 100, 23, 45, 46, 97, 27,
1019 27, 120, 121, 31, 31, 97, 4, 5, 97, 7,
1020 8, 97, 11, 94, 95, 11, 65, 15, 97, 68,
1021 19, 102, 14, 19, 160, 97, 18, 97, 97, 165,
1022 97, 4, 5, 97, 7, 8, 101, 97, 11, 87,
1023 88, 89, 15, 97, 97, 101, 19, 102, 21, 101,
1024 23, 24, 19, 70, 27, 191, 101, 104, 31, 102,
1025 67, 101, 35, 36, 37, 38, 39, 215, 41, 42,
1026 43, 44, 45, 46, 47, 211, 49, 102, 102, 102,
1027 102, 217, 84, 85, 86, 87, 88, 89, 102, 197,
1028 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
1029 88, 89, 75, 103, 105, 102, 20, 102, 102, 245,
1030 246, 84, 85, 102, 99, 102, 264, 90, 91, 92,
1031 101, 94, 95, 17, 97, 104, 102, 102, 67, 102,
1032 70, 102, 240, 70, 282, 4, 5, 17, 7, 8,
1033 99, 264, 11, 12, 260, 269, 15, 16, 17, 223,
1034 19, 192, 21, 22, 23, 24, 63, 26, 27, 28,
1035 146, -1, 31, -1, -1, -1, 35, 36, 37, 38,
1036 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
1037 49, 50, 51, 67, -1, 69, -1, 71, 72, 73,
1038 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
1039 84, 85, 86, 87, 88, 89, 75, -1, -1, -1,
1040 -1, -1, -1, -1, -1, 84, 85, -1, -1, -1,
1041 104, 90, 91, 92, -1, 94, 95, -1, 97, -1,
1042 99, -1, 101, 4, 5, -1, 7, 8, -1, -1,
1043 11, 12, -1, -1, 15, 16, 17, -1, 19, -1,
1044 21, 22, 23, 24, -1, 26, 27, 28, -1, -1,
1045 31, -1, -1, -1, 35, 36, 37, 38, 39, 40,
1046 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
1047 51, 67, -1, 69, -1, 71, 72, 73, 74, 75,
1048 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1049 86, 87, 88, 89, 75, -1, -1, -1, -1, -1,
1050 -1, -1, -1, 84, 85, -1, 102, -1, -1, 90,
1051 91, 92, -1, 94, 95, -1, 97, -1, 99, 100,
1052 4, 5, -1, 7, 8, -1, -1, 11, 12, -1,
1053 -1, 15, 16, 17, -1, 19, -1, 21, 22, 23,
1054 24, -1, 26, 27, 28, -1, -1, 31, -1, -1,
1055 -1, 35, 36, 37, 38, 39, 40, 41, 42, 43,
1056 44, 45, 46, 47, 48, 49, 50, 51, 67, -1,
1057 69, -1, 71, 72, 73, 74, 75, 76, 77, 78,
1058 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1059 89, 75, -1, -1, -1, -1, -1, -1, -1, -1,
1060 84, 85, -1, 102, -1, -1, 90, 91, 92, -1,
1061 94, 95, -1, 97, -1, 99, 100, 4, 5, -1,
1062 7, 8, -1, -1, 11, 12, -1, -1, 15, 16,
1063 17, -1, 19, -1, 21, 22, 23, 24, -1, 26,
1064 27, 28, -1, -1, 31, -1, -1, -1, 35, 36,
1065 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1066 47, 48, 49, 50, 51, 67, -1, 69, -1, 71,
1067 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1068 82, 83, 84, 85, 86, 87, 88, 89, 75, -1,
1069 -1, -1, -1, -1, -1, -1, -1, 84, 85, -1,
1070 102, -1, -1, 90, 91, 92, -1, 94, 95, -1,
1071 97, -1, 99, 4, 5, -1, 7, 8, -1, -1,
1072 11, -1, -1, -1, 15, -1, 17, -1, 19, -1,
1073 21, -1, 23, 24, -1, -1, 27, -1, -1, -1,
1074 31, -1, -1, -1, 35, 36, 37, 38, 39, -1,
1075 41, 42, 43, 44, 45, 46, 47, 67, 49, 69,
1076 -1, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1077 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
1078 -1, -1, -1, -1, 75, -1, -1, -1, -1, -1,
1079 -1, -1, 102, 84, 85, -1, -1, -1, -1, 90,
1080 91, 92, -1, 94, 95, -1, 97, 4, 5, -1,
1081 7, 8, -1, -1, 11, -1, -1, -1, 15, -1,
1082 -1, -1, 19, -1, 21, -1, 23, 24, -1, -1,
1083 27, -1, -1, -1, 31, -1, -1, -1, 35, 36,
1084 37, 38, 39, -1, 41, 42, 43, 44, 45, 46,
1085 47, 67, 49, 69, -1, 71, 72, 73, 74, 75,
1086 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1087 86, 87, 88, 89, -1, -1, -1, -1, 75, -1,
1088 -1, -1, -1, -1, -1, -1, 102, 84, 85, -1,
1089 -1, -1, -1, 90, 91, 92, -1, 94, 95, -1,
1090 97, 4, 5, -1, 7, 8, -1, -1, 11, -1,
1091 -1, -1, 15, -1, -1, -1, 19, -1, 21, -1,
1092 23, 24, -1, -1, 27, -1, -1, -1, 31, -1,
1093 -1, -1, 35, 36, 37, 38, 39, -1, 41, 42,
1094 43, 44, 45, 46, 47, 67, 49, 69, -1, 71,
1095 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1096 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
1097 -1, -1, 75, -1, -1, -1, -1, -1, -1, -1,
1098 102, 84, 85, -1, -1, -1, -1, 90, 91, 92,
1099 -1, 94, 95, 67, 97, 69, -1, 71, 72, 73,
1100 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
1101 84, 85, 86, 87, 88, 89, -1, -1, -1, -1,
1102 -1, -1, -1, -1, -1, -1, -1, 67, 102, 69,
1103 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1104 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
1105 67, -1, 69, -1, 71, 72, 73, 74, 75, 76,
1106 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1107 87, 88, 89, 67, -1, 69, -1, 71, 72, 73,
1108 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
1109 84, 85, 86, 87, 88, 89, 69, -1, 71, 72,
1110 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
1111 83, 84, 85, 86, 87, 88, 89, 72, 73, 74,
1112 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1113 85, 86, 87, 88, 89, 73, 74, 75, 76, 77,
1114 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
1115 88, 89, 74, 75, 76, 77, 78, 79, 80, 81,
1116 82, 83, 84, 85, 86, 87, 88, 89, 75, 76,
1117 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1118 87, 88, 89, 76, 77, 78, 79, 80, 81, 82,
1119 83, 84, 85, 86, 87, 88, 89, 76, 77, 78,
1120 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1121 89
1122};
1123
1124 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1125 symbol of state STATE-NUM. */
1126static const yytype_uint8 yystos[] =
1127{
1128 0, 107, 111, 0, 4, 5, 7, 8, 11, 12,
1129 15, 16, 17, 19, 21, 22, 23, 24, 26, 27,
1130 28, 31, 35, 36, 37, 38, 39, 40, 41, 42,
1131 43, 44, 45, 46, 47, 48, 49, 50, 51, 75,
1132 84, 85, 90, 91, 92, 94, 95, 97, 99, 108,
1133 112, 125, 126, 129, 130, 131, 132, 133, 103, 125,
1134 125, 113, 103, 135, 97, 97, 97, 97, 97, 105,
1135 142, 143, 97, 97, 97, 97, 125, 97, 97, 97,
1136 97, 97, 97, 133, 126, 126, 126, 126, 11, 19,
1137 133, 133, 17, 126, 111, 29, 109, 101, 67, 69,
1138 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1139 81, 82, 83, 84, 85, 86, 87, 88, 89, 97,
1140 97, 97, 68, 94, 95, 144, 126, 136, 137, 101,
1141 101, 19, 23, 27, 31, 119, 120, 122, 126, 142,
1142 126, 125, 133, 136, 136, 133, 27, 31, 126, 136,
1143 136, 102, 101, 102, 126, 136, 136, 126, 19, 126,
1144 102, 102, 100, 70, 126, 127, 126, 126, 126, 126,
1145 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1146 126, 11, 19, 126, 126, 126, 126, 136, 136, 126,
1147 104, 67, 67, 101, 121, 104, 102, 101, 102, 102,
1148 102, 102, 105, 143, 102, 102, 102, 102, 102, 102,
1149 114, 67, 102, 102, 126, 110, 126, 67, 102, 102,
1150 126, 120, 103, 134, 125, 112, 112, 27, 112, 102,
1151 126, 112, 111, 70, 19, 17, 104, 97, 144, 145,
1152 101, 20, 124, 99, 102, 128, 67, 102, 104, 146,
1153 125, 112, 115, 126, 126, 17, 138, 139, 140, 102,
1154 14, 18, 100, 116, 117, 118, 102, 141, 147, 67,
1155 112, 130, 70, 111, 118, 19, 31, 123, 102, 17,
1156 140, 70, 99, 111, 100
1157};
1158
1159 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1160static const yytype_uint8 yyr1[] =
1161{
1162 0, 106, 107, 108, 108, 110, 109, 111, 111, 112,
1163 112, 113, 112, 112, 112, 112, 112, 112, 112, 112,
1164 114, 112, 112, 112, 112, 115, 115, 116, 117, 117,
1165 118, 118, 119, 119, 121, 120, 122, 122, 122, 122,
1166 123, 123, 124, 124, 125, 125, 126, 126, 126, 126,
1167 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1168 126, 126, 126, 126, 126, 126, 126, 127, 128, 126,
1169 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1170 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1171 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1172 129, 129, 130, 130, 130, 130, 130, 131, 131, 131,
1173 132, 132, 133, 133, 133, 134, 134, 134, 135, 135,
1174 136, 136, 137, 137, 138, 138, 138, 139, 139, 141,
1175 140, 142, 142, 142, 143, 143, 144, 144, 145, 146,
1176 147, 145
1177};
1178
1179 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
1180static const yytype_int8 yyr2[] =
1181{
1182 0, 2, 2, 0, 2, 0, 4, 0, 2, 3,
1183 2, 0, 4, 6, 5, 9, 5, 4, 6, 5,
1184 0, 8, 3, 3, 3, 0, 2, 2, 1, 2,
1185 3, 2, 1, 3, 0, 4, 1, 1, 1, 1,
1186 1, 1, 0, 2, 0, 1, 3, 4, 3, 3,
1187 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1188 3, 3, 3, 3, 3, 3, 3, 0, 0, 7,
1189 2, 2, 2, 2, 2, 2, 2, 4, 4, 4,
1190 4, 4, 6, 8, 4, 3, 3, 4, 4, 4,
1191 4, 4, 2, 2, 2, 3, 3, 2, 2, 1,
1192 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1193 1, 1, 2, 3, 1, 0, 2, 3, 0, 3,
1194 0, 1, 1, 3, 0, 1, 1, 1, 3, 0,
1195 3, 0, 1, 3, 2, 2, 0, 2, 1, 0,
1196 0, 8
1197};
1198
1199
1200#define yyerrok (yyerrstatus = 0)
1201#define yyclearin (yychar = YYEMPTY)
1202#define YYEMPTY (-2)
1203#define YYEOF 0
1204
1205#define YYACCEPT goto yyacceptlab
1206#define YYABORT goto yyabortlab
1207#define YYERROR goto yyerrorlab
1208
1209
1210#define YYRECOVERING() (!!yyerrstatus)
1211
1212#define YYBACKUP(Token, Value) \
1213 do \
1214 if (yychar == YYEMPTY) \
1215 { \
1216 yychar = (Token); \
1217 yylval = (Value); \
1218 YYPOPSTACK (yylen); \
1219 yystate = *yyssp; \
1220 goto yybackup; \
1221 } \
1222 else \
1223 { \
1224 yyerror (YY_("syntax error: cannot back up")); \
1225 YYERROR; \
1226 } \
1227 while (0)
1228
1229/* Error token number */
1230#define YYTERROR 1
1231#define YYERRCODE 256
1232
1233
1234
1235/* Enable debugging if requested. */
1236#if EX_DEBUG
1237
1238# ifndef YYFPRINTF
1239# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1240# define YYFPRINTF fprintf
1241# endif
1242
1243# define YYDPRINTF(Args) \
1244do { \
1245 if (yydebug) \
1246 YYFPRINTF Args; \
1247} while (0)
1248
1249/* This macro is provided for backward compatibility. */
1250#ifndef YY_LOCATION_PRINT
1251# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1252#endif
1253
1254
1255# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1256do { \
1257 if (yydebug) \
1258 { \
1259 YYFPRINTF (stderr, "%s ", Title); \
1260 yy_symbol_print (stderr, \
1261 Type, Value); \
1262 YYFPRINTF (stderr, "\n"); \
1263 } \
1264} while (0)
1265
1266
1267/*-----------------------------------.
1268| Print this symbol's value on YYO. |
1269`-----------------------------------*/
1270
1271static void
1272yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep)
1273{
1274 FILE *yyoutput = yyo;
1275 YYUSE (yyoutput);
1276 if (!yyvaluep)
1277 return;
1278# ifdef YYPRINT
1279 if (yytype < YYNTOKENS)
1280 YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
1281# endif
1283 YYUSE (yytype);
1285}
1286
1287
1288/*---------------------------.
1289| Print this symbol on YYO. |
1290`---------------------------*/
1291
1292static void
1293yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep)
1294{
1295 YYFPRINTF (yyo, "%s %s (",
1296 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
1297
1298 yy_symbol_value_print (yyo, yytype, yyvaluep);
1299 YYFPRINTF (yyo, ")");
1300}
1301
1302/*------------------------------------------------------------------.
1303| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1304| TOP (included). |
1305`------------------------------------------------------------------*/
1306
1307static void
1308yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
1309{
1310 YYFPRINTF (stderr, "Stack now");
1311 for (; yybottom <= yytop; yybottom++)
1312 {
1313 int yybot = *yybottom;
1314 YYFPRINTF (stderr, " %d", yybot);
1315 }
1316 YYFPRINTF (stderr, "\n");
1317}
1318
1319# define YY_STACK_PRINT(Bottom, Top) \
1320do { \
1321 if (yydebug) \
1322 yy_stack_print ((Bottom), (Top)); \
1323} while (0)
1324
1325
1326/*------------------------------------------------.
1327| Report that the YYRULE is going to be reduced. |
1328`------------------------------------------------*/
1329
1330static void
1331yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, int yyrule)
1332{
1333 int yylno = yyrline[yyrule];
1334 int yynrhs = yyr2[yyrule];
1335 int yyi;
1336 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
1337 yyrule - 1, yylno);
1338 /* The symbols being reduced. */
1339 for (yyi = 0; yyi < yynrhs; yyi++)
1340 {
1341 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1342 yy_symbol_print (stderr,
1343 yystos[+yyssp[yyi + 1 - yynrhs]],
1344 &yyvsp[(yyi + 1) - (yynrhs)]
1345 );
1346 YYFPRINTF (stderr, "\n");
1347 }
1348}
1349
1350# define YY_REDUCE_PRINT(Rule) \
1351do { \
1352 if (yydebug) \
1353 yy_reduce_print (yyssp, yyvsp, Rule); \
1354} while (0)
1355
1356/* Nonzero means print parse trace. It is left uninitialized so that
1357 multiple parsers can coexist. */
1358int yydebug;
1359#else /* !EX_DEBUG */
1360# define YYDPRINTF(Args)
1361# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1362# define YY_STACK_PRINT(Bottom, Top)
1363# define YY_REDUCE_PRINT(Rule)
1364#endif /* !EX_DEBUG */
1365
1366
1367/* YYINITDEPTH -- initial size of the parser's stacks. */
1368#ifndef YYINITDEPTH
1369# define YYINITDEPTH 200
1370#endif
1371
1372/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1373 if the built-in stack extension method is used).
1374
1375 Do not make this value too large; the results are undefined if
1376 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1377 evaluated with infinite-precision integer arithmetic. */
1378
1379#ifndef YYMAXDEPTH
1380# define YYMAXDEPTH 10000
1381#endif
1382
1383
1384#if YYERROR_VERBOSE
1385
1386# ifndef yystrlen
1387# if defined __GLIBC__ && defined _STRING_H
1388# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
1389# else
1390/* Return the length of YYSTR. */
1391static YYPTRDIFF_T
1392yystrlen (const char *yystr)
1393{
1394 YYPTRDIFF_T yylen;
1395 for (yylen = 0; yystr[yylen]; yylen++)
1396 continue;
1397 return yylen;
1398}
1399# endif
1400# endif
1401
1402# ifndef yystpcpy
1403# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1404# define yystpcpy stpcpy
1405# else
1406/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1407 YYDEST. */
1408static char *
1409yystpcpy (char *yydest, const char *yysrc)
1410{
1411 char *yyd = yydest;
1412 const char *yys = yysrc;
1413
1414 while ((*yyd++ = *yys++) != '\0')
1415 continue;
1416
1417 return yyd - 1;
1418}
1419# endif
1420# endif
1421
1422# ifndef yytnamerr
1423/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1424 quotes and backslashes, so that it's suitable for yyerror. The
1425 heuristic is that double-quoting is unnecessary unless the string
1426 contains an apostrophe, a comma, or backslash (other than
1427 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1428 null, do not copy; instead, return the length of what the result
1429 would have been. */
1430static YYPTRDIFF_T
1431yytnamerr (char *yyres, const char *yystr)
1432{
1433 if (*yystr == '"')
1434 {
1435 YYPTRDIFF_T yyn = 0;
1436 char const *yyp = yystr;
1437
1438 for (;;)
1439 switch (*++yyp)
1440 {
1441 case '\'':
1442 case ',':
1443 goto do_not_strip_quotes;
1444
1445 case '\\':
1446 if (*++yyp != '\\')
1447 goto do_not_strip_quotes;
1448 else
1449 goto append;
1450
1451 append:
1452 default:
1453 if (yyres)
1454 yyres[yyn] = *yyp;
1455 yyn++;
1456 break;
1457
1458 case '"':
1459 if (yyres)
1460 yyres[yyn] = '\0';
1461 return yyn;
1462 }
1463 do_not_strip_quotes: ;
1464 }
1465
1466 if (yyres)
1467 return yystpcpy (yyres, yystr) - yyres;
1468 else
1469 return yystrlen (yystr);
1470}
1471# endif
1472
1473/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1474 about the unexpected token YYTOKEN for the state stack whose top is
1475 YYSSP.
1476
1477 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1478 not large enough to hold the message. In that case, also set
1479 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1480 required number of bytes is too large to store. */
1481static int
1482yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
1483 yy_state_t *yyssp, int yytoken)
1484{
1485 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1486 /* Internationalized format string. */
1487 const char *yyformat = YY_NULLPTR;
1488 /* Arguments of yyformat: reported tokens (one for the "unexpected",
1489 one per "expected"). */
1490 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1491 /* Actual size of YYARG. */
1492 int yycount = 0;
1493 /* Cumulated lengths of YYARG. */
1494 YYPTRDIFF_T yysize = 0;
1495
1496 /* There are many possibilities here to consider:
1497 - If this state is a consistent state with a default action, then
1498 the only way this function was invoked is if the default action
1499 is an error action. In that case, don't check for expected
1500 tokens because there are none.
1501 - The only way there can be no lookahead present (in yychar) is if
1502 this state is a consistent state with a default action. Thus,
1503 detecting the absence of a lookahead is sufficient to determine
1504 that there is no unexpected or expected token to report. In that
1505 case, just report a simple "syntax error".
1506 - Don't assume there isn't a lookahead just because this state is a
1507 consistent state with a default action. There might have been a
1508 previous inconsistent state, consistent state with a non-default
1509 action, or user semantic action that manipulated yychar.
1510 - Of course, the expected token list depends on states to have
1511 correct lookahead information, and it depends on the parser not
1512 to perform extra reductions after fetching a lookahead from the
1513 scanner and before detecting a syntax error. Thus, state merging
1514 (from LALR or IELR) and default reductions corrupt the expected
1515 token list. However, the list is correct for canonical LR with
1516 one exception: it will still contain any token that will not be
1517 accepted due to an error action in a later state.
1518 */
1519 if (yytoken != YYEMPTY)
1520 {
1521 int yyn = yypact[+*yyssp];
1522 YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1523 yysize = yysize0;
1524 yyarg[yycount++] = yytname[yytoken];
1525 if (!yypact_value_is_default (yyn))
1526 {
1527 /* Start YYX at -YYN if negative to avoid negative indexes in
1528 YYCHECK. In other words, skip the first -YYN actions for
1529 this state because they are default actions. */
1530 int yyxbegin = yyn < 0 ? -yyn : 0;
1531 /* Stay within bounds of both yycheck and yytname. */
1532 int yychecklim = YYLAST - yyn + 1;
1533 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1534 int yyx;
1535
1536 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1537 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1538 && !yytable_value_is_error (yytable[yyx + yyn]))
1539 {
1540 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1541 {
1542 yycount = 1;
1543 yysize = yysize0;
1544 break;
1545 }
1546 yyarg[yycount++] = yytname[yyx];
1547 {
1548 YYPTRDIFF_T yysize1
1549 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1550 if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1551 yysize = yysize1;
1552 else
1553 return 2;
1554 }
1555 }
1556 }
1557 }
1558
1559 switch (yycount)
1560 {
1561# define YYCASE_(N, S) \
1562 case N: \
1563 yyformat = S; \
1564 break
1565 default: /* Avoid compiler warnings. */
1566 YYCASE_(0, YY_("syntax error"));
1567 YYCASE_(1, YY_("syntax error, unexpected %s"));
1568 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1569 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1570 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1571 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1572# undef YYCASE_
1573 }
1574
1575 {
1576 /* Don't count the "%s"s in the final size, but reserve room for
1577 the terminator. */
1578 YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1;
1579 if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1580 yysize = yysize1;
1581 else
1582 return 2;
1583 }
1584
1585 if (*yymsg_alloc < yysize)
1586 {
1587 *yymsg_alloc = 2 * yysize;
1588 if (! (yysize <= *yymsg_alloc
1589 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1590 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1591 return 1;
1592 }
1593
1594 /* Avoid sprintf, as that infringes on the user's name space.
1595 Don't have undefined behavior even if the translation
1596 produced a string with the wrong number of "%s"s. */
1597 {
1598 char *yyp = *yymsg;
1599 int yyi = 0;
1600 while ((*yyp = *yyformat) != '\0')
1601 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1602 {
1603 yyp += yytnamerr (yyp, yyarg[yyi++]);
1604 yyformat += 2;
1605 }
1606 else
1607 {
1608 ++yyp;
1609 ++yyformat;
1610 }
1611 }
1612 return 0;
1613}
1614#endif /* YYERROR_VERBOSE */
1615
1616/*-----------------------------------------------.
1617| Release the memory associated to this symbol. |
1618`-----------------------------------------------*/
1619
1620static void
1621yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1622{
1623 YYUSE (yyvaluep);
1624 if (!yymsg)
1625 yymsg = "Deleting";
1626 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1627
1629 YYUSE (yytype);
1631}
1632
1633
1634
1635
1636/* The lookahead symbol. */
1638
1639/* The semantic value of the lookahead symbol. */
1641/* Number of syntax errors so far. */
1643
1644
1645/*----------.
1646| yyparse. |
1647`----------*/
1648
1649int
1651{
1652 yy_state_fast_t yystate;
1653 /* Number of tokens to shift before error messages enabled. */
1654 int yyerrstatus;
1655
1656 /* The stacks and their tools:
1657 'yyss': related to states.
1658 'yyvs': related to semantic values.
1659
1660 Refer to the stacks through separate pointers, to allow yyoverflow
1661 to reallocate them elsewhere. */
1662
1663 /* The state stack. */
1664 yy_state_t yyssa[YYINITDEPTH];
1665 yy_state_t *yyss;
1666 yy_state_t *yyssp;
1667
1668 /* The semantic value stack. */
1669 YYSTYPE yyvsa[YYINITDEPTH];
1670 YYSTYPE *yyvs;
1671 YYSTYPE *yyvsp;
1672
1673 YYPTRDIFF_T yystacksize;
1674
1675 int yyn;
1676 int yyresult;
1677 /* Lookahead token as an internal (translated) token number. */
1678 int yytoken = 0;
1679 /* The variables used to return semantic value and location from the
1680 action routines. */
1681 YYSTYPE yyval;
1682
1683#if YYERROR_VERBOSE
1684 /* Buffer for error messages, and its allocated size. */
1685 char yymsgbuf[128];
1686 char *yymsg = yymsgbuf;
1687 YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
1688#endif
1689
1690#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1691
1692 /* The number of symbols on the RHS of the reduced rule.
1693 Keep to zero when no symbol should be popped. */
1694 int yylen = 0;
1695
1696 yyssp = yyss = yyssa;
1697 yyvsp = yyvs = yyvsa;
1698 yystacksize = YYINITDEPTH;
1699
1700 YYDPRINTF ((stderr, "Starting parse\n"));
1701
1702 yystate = 0;
1703 yyerrstatus = 0;
1704 yynerrs = 0;
1705 yychar = YYEMPTY; /* Cause a token to be read. */
1706 goto yysetstate;
1707
1708
1709/*------------------------------------------------------------.
1710| yynewstate -- push a new state, which is found in yystate. |
1711`------------------------------------------------------------*/
1712yynewstate:
1713 /* In all cases, when you get here, the value and location stacks
1714 have just been pushed. So pushing a state here evens the stacks. */
1715 yyssp++;
1716
1717
1718/*--------------------------------------------------------------------.
1719| yysetstate -- set current state (the top of the stack) to yystate. |
1720`--------------------------------------------------------------------*/
1721yysetstate:
1722 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1723 YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1725 *yyssp = YY_CAST (yy_state_t, yystate);
1727
1728 if (yyss + yystacksize - 1 <= yyssp)
1729#if !defined yyoverflow && !defined YYSTACK_RELOCATE
1730 goto yyexhaustedlab;
1731#else
1732 {
1733 /* Get the current used size of the three stacks, in elements. */
1734 YYPTRDIFF_T yysize = yyssp - yyss + 1;
1735
1736# if defined yyoverflow
1737 {
1738 /* Give user a chance to reallocate the stack. Use copies of
1739 these so that the &'s don't force the real ones into
1740 memory. */
1741 yy_state_t *yyss1 = yyss;
1742 YYSTYPE *yyvs1 = yyvs;
1743
1744 /* Each stack pointer address is followed by the size of the
1745 data in use in that stack, in bytes. This used to be a
1746 conditional around just the two extra args, but that might
1747 be undefined if yyoverflow is a macro. */
1748 yyoverflow (YY_("memory exhausted"),
1749 &yyss1, yysize * YYSIZEOF (*yyssp),
1750 &yyvs1, yysize * YYSIZEOF (*yyvsp),
1751 &yystacksize);
1752 yyss = yyss1;
1753 yyvs = yyvs1;
1754 }
1755# else /* defined YYSTACK_RELOCATE */
1756 /* Extend the stack our own way. */
1757 if (YYMAXDEPTH <= yystacksize)
1758 goto yyexhaustedlab;
1759 yystacksize *= 2;
1760 if (YYMAXDEPTH < yystacksize)
1761 yystacksize = YYMAXDEPTH;
1762
1763 {
1764 yy_state_t *yyss1 = yyss;
1765 union yyalloc *yyptr =
1766 YY_CAST (union yyalloc *,
1767 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1768 if (! yyptr)
1769 goto yyexhaustedlab;
1770 YYSTACK_RELOCATE (yyss_alloc, yyss);
1771 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1772# undef YYSTACK_RELOCATE
1773 if (yyss1 != yyssa)
1774 YYSTACK_FREE (yyss1);
1775 }
1776# endif
1777
1778 yyssp = yyss + yysize - 1;
1779 yyvsp = yyvs + yysize - 1;
1780
1782 YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1783 YY_CAST (long, yystacksize)));
1785
1786 if (yyss + yystacksize - 1 <= yyssp)
1787 YYABORT;
1788 }
1789#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1790
1791 if (yystate == YYFINAL)
1792 YYACCEPT;
1793
1794 goto yybackup;
1795
1796
1797/*-----------.
1798| yybackup. |
1799`-----------*/
1800yybackup:
1801 /* Do appropriate processing given the current state. Read a
1802 lookahead token if we need one and don't already have one. */
1803
1804 /* First try to decide what to do without reference to lookahead token. */
1805 yyn = yypact[yystate];
1806 if (yypact_value_is_default (yyn))
1807 goto yydefault;
1808
1809 /* Not known => get a lookahead token if don't already have one. */
1810
1811 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1812 if (yychar == YYEMPTY)
1813 {
1814 YYDPRINTF ((stderr, "Reading a token: "));
1815 yychar = yylex ();
1816 }
1817
1818 if (yychar <= YYEOF)
1819 {
1820 yychar = yytoken = YYEOF;
1821 YYDPRINTF ((stderr, "Now at end of input.\n"));
1822 }
1823 else
1824 {
1825 yytoken = YYTRANSLATE (yychar);
1826 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1827 }
1828
1829 /* If the proper action on seeing token YYTOKEN is to reduce or to
1830 detect an error, take that action. */
1831 yyn += yytoken;
1832 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1833 goto yydefault;
1834 yyn = yytable[yyn];
1835 if (yyn <= 0)
1836 {
1837 if (yytable_value_is_error (yyn))
1838 goto yyerrlab;
1839 yyn = -yyn;
1840 goto yyreduce;
1841 }
1842
1843 /* Count tokens shifted since error; after three, turn off error
1844 status. */
1845 if (yyerrstatus)
1846 yyerrstatus--;
1847
1848 /* Shift the lookahead token. */
1849 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1850 yystate = yyn;
1852 *++yyvsp = yylval;
1854
1855 /* Discard the shifted token. */
1856 yychar = YYEMPTY;
1857 goto yynewstate;
1858
1859
1860/*-----------------------------------------------------------.
1861| yydefault -- do the default action for the current state. |
1862`-----------------------------------------------------------*/
1863yydefault:
1864 yyn = yydefact[yystate];
1865 if (yyn == 0)
1866 goto yyerrlab;
1867 goto yyreduce;
1868
1869
1870/*-----------------------------.
1871| yyreduce -- do a reduction. |
1872`-----------------------------*/
1873yyreduce:
1874 /* yyn is the number of a rule to reduce with. */
1875 yylen = yyr2[yyn];
1876
1877 /* If YYLEN is nonzero, implement the default value of the action:
1878 '$$ = $1'.
1879
1880 Otherwise, the following line sets YYVAL to garbage.
1881 This behavior is undocumented and Bison
1882 users should not rely upon it. Assigning to YYVAL
1883 unconditionally makes the parser a bit smaller, and it avoids a
1884 GCC warning that YYVAL may be used uninitialized. */
1885 yyval = yyvsp[1-yylen];
1886
1887
1888 YY_REDUCE_PRINT (yyn);
1889 switch (yyn)
1890 {
1891 case 2:
1892#line 180 "../../lib/expr/exparse.y"
1893 {
1894 if ((yyvsp[-1].expr)) {
1895 if (expr.program->main.value)
1896 exfreenode(expr.program, expr.program->main.value);
1897 if ((yyvsp[-1].expr)->op == S2B)
1898 {
1899 Exnode_t *x = (yyvsp[-1].expr);
1900 (yyvsp[-1].expr) = x->data.operand.left;
1901 x->data.operand.left = 0;
1903 }
1904 expr.program->main.lex = PROCEDURE;
1905 expr.program->main.value = exnewnode(expr.program, PROCEDURE, true, (yyvsp[-1].expr)->type, NULL, (yyvsp[-1].expr));
1906 }
1907 }
1908#line 1909 "exparse.c"
1909 break;
1910
1911 case 5:
1912#line 201 "../../lib/expr/exparse.y"
1913 {
1914 if (expr.procedure)
1915 exerror("no nested function definitions");
1916 (yyvsp[-1].id)->lex = PROCEDURE;
1917 expr.procedure = (yyvsp[-1].id)->value = exnewnode(expr.program, PROCEDURE, true, (yyvsp[-1].id)->type, NULL, NULL);
1919 static Dtdisc_t disc = {.key = offsetof(Exid_t, name)};
1920 if (expr.assigned && !streq((yyvsp[-1].id)->name, "begin"))
1921 {
1922 if (!(expr.procedure->data.procedure.frame = dtopen(&disc, Dtset)) ||
1923 !dtview(expr.procedure->data.procedure.frame, expr.program->symbols))
1924 exnospace();
1925 expr.program->symbols = expr.program->frame = expr.procedure->data.procedure.frame;
1926 }
1927 }
1928#line 1929 "exparse.c"
1929 break;
1930
1931 case 6:
1932#line 216 "../../lib/expr/exparse.y"
1933 {
1935 if (expr.program->frame)
1936 {
1937 expr.program->symbols = expr.program->frame->view;
1938 dtview(expr.program->frame, NULL);
1939 expr.program->frame = NULL;
1940 }
1941 if ((yyvsp[0].expr) && (yyvsp[0].expr)->op == S2B)
1942 {
1943 Exnode_t *x = (yyvsp[0].expr);
1944 (yyvsp[0].expr) = x->data.operand.left;
1945 x->data.operand.left = 0;
1947 }
1948 (yyvsp[-3].id)->value->data.procedure.body = excast(expr.program, (yyvsp[0].expr), (yyvsp[-3].id)->type, NULL, 0);
1949 }
1950#line 1951 "exparse.c"
1951 break;
1952
1953 case 7:
1954#line 236 "../../lib/expr/exparse.y"
1955 {
1956 (yyval.expr) = 0;
1957 }
1958#line 1959 "exparse.c"
1959 break;
1960
1961 case 8:
1962#line 240 "../../lib/expr/exparse.y"
1963 {
1964 if (!(yyvsp[-1].expr))
1965 (yyval.expr) = (yyvsp[0].expr);
1966 else if (!(yyvsp[0].expr))
1967 (yyval.expr) = (yyvsp[-1].expr);
1968 else if ((yyvsp[-1].expr)->op == CONSTANT)
1969 {
1970 exfreenode(expr.program, (yyvsp[-1].expr));
1971 (yyval.expr) = (yyvsp[0].expr);
1972 }
1973 else (yyval.expr) = exnewnode(expr.program, ';', true, (yyvsp[0].expr)->type, (yyvsp[-1].expr), (yyvsp[0].expr));
1974 }
1975#line 1976 "exparse.c"
1976 break;
1977
1978 case 9:
1979#line 255 "../../lib/expr/exparse.y"
1980 {
1981 (yyval.expr) = (yyvsp[-1].expr);
1982 }
1983#line 1984 "exparse.c"
1984 break;
1985
1986 case 10:
1987#line 259 "../../lib/expr/exparse.y"
1988 {
1989 (yyval.expr) = ((yyvsp[-1].expr) && (yyvsp[-1].expr)->type == STRING) ? exnewnode(expr.program, S2B, true, INTEGER, (yyvsp[-1].expr), NULL) : (yyvsp[-1].expr);
1990 }
1991#line 1992 "exparse.c"
1992 break;
1993
1994 case 11:
1995#line 262 "../../lib/expr/exparse.y"
1996 {expr.declare = (yyvsp[0].id)->type;}
1997#line 1998 "exparse.c"
1998 break;
1999
2000 case 12:
2001#line 263 "../../lib/expr/exparse.y"
2002 {
2003 (yyval.expr) = (yyvsp[-1].expr);
2004 expr.declare = 0;
2005 }
2006#line 2007 "exparse.c"
2007 break;
2008
2009 case 13:
2010#line 268 "../../lib/expr/exparse.y"
2011 {
2012 if (exisAssign ((yyvsp[-3].expr)))
2013 exwarn ("assignment used as boolean in if statement");
2014 if ((yyvsp[-3].expr)->type == STRING)
2015 (yyvsp[-3].expr) = exnewnode(expr.program, S2B, true, INTEGER, (yyvsp[-3].expr), NULL);
2016 else if (!INTEGRAL((yyvsp[-3].expr)->type))
2017 (yyvsp[-3].expr) = excast(expr.program, (yyvsp[-3].expr), INTEGER, NULL, 0);
2018 (yyval.expr) = exnewnode(expr.program, (yyvsp[-5].id)->index, true, INTEGER, (yyvsp[-3].expr), exnewnode(expr.program, ':', true, (yyvsp[-1].expr) ? (yyvsp[-1].expr)->type : 0, (yyvsp[-1].expr), (yyvsp[0].expr)));
2019 }
2020#line 2021 "exparse.c"
2021 break;
2022
2023 case 14:
2024#line 278 "../../lib/expr/exparse.y"
2025 {
2026 (yyval.expr) = exnewnode(expr.program, ITERATE, false, INTEGER, NULL, NULL);
2027 (yyval.expr)->data.generate.array = (yyvsp[-2].expr);
2028 if (!(yyvsp[-2].expr)->data.variable.index || (yyvsp[-2].expr)->data.variable.index->op != DYNAMIC)
2029 exerror("simple index variable expected");
2030 (yyval.expr)->data.generate.index = (yyvsp[-2].expr)->data.variable.index->data.variable.symbol;
2031 if ((yyvsp[-2].expr)->op == ID && (yyval.expr)->data.generate.index->type != INTEGER)
2032 exerror("integer index variable expected");
2033 exfreenode(expr.program, (yyvsp[-2].expr)->data.variable.index);
2034 (yyvsp[-2].expr)->data.variable.index = 0;
2035 (yyval.expr)->data.generate.statement = (yyvsp[0].expr);
2036 }
2037#line 2038 "exparse.c"
2038 break;
2039
2040 case 15:
2041#line 291 "../../lib/expr/exparse.y"
2042 {
2043 if (!(yyvsp[-4].expr))
2044 {
2045 (yyvsp[-4].expr) = exnewnode(expr.program, CONSTANT, false, INTEGER, NULL, NULL);
2046 (yyvsp[-4].expr)->data.constant.value.integer = 1;
2047 }
2048 else if ((yyvsp[-4].expr)->type == STRING)
2049 (yyvsp[-4].expr) = exnewnode(expr.program, S2B, true, INTEGER, (yyvsp[-4].expr), NULL);
2050 else if (!INTEGRAL((yyvsp[-4].expr)->type))
2051 (yyvsp[-4].expr) = excast(expr.program, (yyvsp[-4].expr), INTEGER, NULL, 0);
2052 (yyval.expr) = exnewnode(expr.program, (yyvsp[-8].id)->index, true, INTEGER, (yyvsp[-4].expr), exnewnode(expr.program, ';', 1, 0, (yyvsp[-2].expr), (yyvsp[0].expr)));
2053 if ((yyvsp[-6].expr))
2054 (yyval.expr) = exnewnode(expr.program, ';', true, INTEGER, (yyvsp[-6].expr), (yyval.expr));
2055 }
2056#line 2057 "exparse.c"
2057 break;
2058
2059 case 16:
2060#line 306 "../../lib/expr/exparse.y"
2061 {
2062 (yyval.expr) = exnewnode(expr.program, ITERATOR, false, INTEGER, NULL, NULL);
2063 (yyval.expr)->data.generate.array = (yyvsp[-2].expr);
2064 if (!(yyvsp[-2].expr)->data.variable.index || (yyvsp[-2].expr)->data.variable.index->op != DYNAMIC)
2065 exerror("simple index variable expected");
2066 (yyval.expr)->data.generate.index = (yyvsp[-2].expr)->data.variable.index->data.variable.symbol;
2067 if ((yyvsp[-2].expr)->op == ID && (yyval.expr)->data.generate.index->type != INTEGER)
2068 exerror("integer index variable expected");
2069 exfreenode(expr.program, (yyvsp[-2].expr)->data.variable.index);
2070 (yyvsp[-2].expr)->data.variable.index = 0;
2071 (yyval.expr)->data.generate.statement = (yyvsp[0].expr);
2072 }
2073#line 2074 "exparse.c"
2074 break;
2075
2076 case 17:
2077#line 319 "../../lib/expr/exparse.y"
2078 {
2079 if ((yyvsp[-1].id)->local == NULL)
2080 exerror("cannot apply unset to non-array %s", (yyvsp[-1].id)->name);
2081 (yyval.expr) = exnewnode(expr.program, UNSET, false, INTEGER, NULL, NULL);
2082 (yyval.expr)->data.variable.symbol = (yyvsp[-1].id);
2083 (yyval.expr)->data.variable.index = NULL;
2084 }
2085#line 2086 "exparse.c"
2086 break;
2087
2088 case 18:
2089#line 327 "../../lib/expr/exparse.y"
2090 {
2091 if ((yyvsp[-3].id)->local == NULL)
2092 exerror("cannot apply unset to non-array %s", (yyvsp[-3].id)->name);
2093 if (((yyvsp[-3].id)->index_type > 0) && ((yyvsp[-1].expr)->type != (yyvsp[-3].id)->index_type))
2094 exerror("%s indices must have type %s, not %s",
2095 (yyvsp[-3].id)->name, extypename(expr.program, (yyvsp[-3].id)->index_type),extypename(expr.program, (yyvsp[-1].expr)->type));
2096 (yyval.expr) = exnewnode(expr.program, UNSET, false, INTEGER, NULL, NULL);
2097 (yyval.expr)->data.variable.symbol = (yyvsp[-3].id);
2098 (yyval.expr)->data.variable.index = (yyvsp[-1].expr);
2099 }
2100#line 2101 "exparse.c"
2101 break;
2102
2103 case 19:
2104#line 338 "../../lib/expr/exparse.y"
2105 {
2106 if (exisAssign ((yyvsp[-2].expr)))
2107 exwarn ("assignment used as boolean in while statement");
2108 if ((yyvsp[-2].expr)->type == STRING)
2109 (yyvsp[-2].expr) = exnewnode(expr.program, S2B, true, INTEGER, (yyvsp[-2].expr), NULL);
2110 else if (!INTEGRAL((yyvsp[-2].expr)->type))
2111 (yyvsp[-2].expr) = excast(expr.program, (yyvsp[-2].expr), INTEGER, NULL, 0);
2112 (yyval.expr) = exnewnode(expr.program, (yyvsp[-4].id)->index, true, INTEGER, (yyvsp[-2].expr), exnewnode(expr.program, ';', true, 0, NULL, (yyvsp[0].expr)));
2113 }
2114#line 2115 "exparse.c"
2115 break;
2116
2117 case 20:
2118#line 347 "../../lib/expr/exparse.y"
2119 {expr.declare=(yyvsp[0].expr)->type;}
2120#line 2121 "exparse.c"
2121 break;
2122
2123 case 21:
2124#line 348 "../../lib/expr/exparse.y"
2125 {
2126 Switch_t* sw = expr.swstate;
2127
2128 (yyval.expr) = exnewnode(expr.program, (yyvsp[-7].id)->index, true, INTEGER, (yyvsp[-5].expr), exnewnode(expr.program, DEFAULT, true, 0, sw->defcase, sw->firstcase));
2130 free(sw->base);
2131 free(sw);
2132 expr.declare = 0;
2133 }
2134#line 2135 "exparse.c"
2135 break;
2136
2137 case 22:
2138#line 358 "../../lib/expr/exparse.y"
2139 {
2140 loopop:
2141 if (!(yyvsp[-1].expr))
2142 {
2143 (yyvsp[-1].expr) = exnewnode(expr.program, CONSTANT, false, INTEGER, NULL, NULL);
2144 (yyvsp[-1].expr)->data.constant.value.integer = 1;
2145 }
2146 else if (!INTEGRAL((yyvsp[-1].expr)->type))
2147 (yyvsp[-1].expr) = excast(expr.program, (yyvsp[-1].expr), INTEGER, NULL, 0);
2148 (yyval.expr) = exnewnode(expr.program, (yyvsp[-2].id)->index, true, INTEGER, (yyvsp[-1].expr), NULL);
2149 }
2150#line 2151 "exparse.c"
2151 break;
2152
2153 case 23:
2154#line 370 "../../lib/expr/exparse.y"
2155 {
2156 goto loopop;
2157 }
2158#line 2159 "exparse.c"
2159 break;
2160
2161 case 24:
2162#line 374 "../../lib/expr/exparse.y"
2163 {
2164 if ((yyvsp[-1].expr))
2165 {
2166 if (expr.procedure && !expr.procedure->type)
2167 exerror("return in void function");
2168 (yyvsp[-1].expr) = excast(expr.program, (yyvsp[-1].expr), expr.procedure ? expr.procedure->type : INTEGER, NULL, 0);
2169 }
2170 (yyval.expr) = exnewnode(expr.program, RETURN, true, (yyvsp[-1].expr) ? (yyvsp[-1].expr)->type : 0, (yyvsp[-1].expr), NULL);
2171 }
2172#line 2173 "exparse.c"
2173 break;
2174
2175 case 25:
2176#line 386 "../../lib/expr/exparse.y"
2177 {
2178 Switch_t* sw;
2179
2180 if (!(sw = calloc(1, sizeof(Switch_t)))) {
2181 exnospace();
2182 } else {
2183 expr.swstate = sw;
2184 sw->type = expr.declare;
2185 size_t n = 8;
2186 if (!(sw->base = calloc(n, sizeof(Extype_t*)))) {
2187 exnospace();
2188 n = 0;
2189 }
2190 sw->cap = n;
2191 }
2192 }
2193#line 2194 "exparse.c"
2194 break;
2195
2196 case 27:
2197#line 406 "../../lib/expr/exparse.y"
2198 {
2199 Switch_t* sw = expr.swstate;
2200
2201 (yyval.expr) = exnewnode(expr.program, CASE, true, 0, (yyvsp[0].expr), NULL);
2202 if (sw->cur > 0)
2203 {
2204 if (sw->lastcase)
2205 sw->lastcase->data.select.next = (yyval.expr);
2206 else
2207 sw->firstcase = (yyval.expr);
2208 sw->lastcase = (yyval.expr);
2209 const size_t n = sw->cap;
2210 sw->cur = 0;
2211 (yyval.expr)->data.select.constant = exalloc(expr.program, (n + 1) * sizeof(Extype_t*));
2212 memcpy((yyval.expr)->data.select.constant, sw->base, n * sizeof(Extype_t*));
2213 (yyval.expr)->data.select.constant[n] = 0;
2214 }
2215 else
2216 (yyval.expr)->data.select.constant = 0;
2217 if (sw->def)
2218 {
2219 sw->def = 0;
2220 if (sw->defcase)
2221 exerror("duplicate default in switch");
2222 else
2223 sw->defcase = (yyvsp[0].expr);
2224 }
2225 }
2226#line 2227 "exparse.c"
2227 break;
2228
2229 case 30:
2230#line 441 "../../lib/expr/exparse.y"
2231 {
2232 if (expr.swstate->cur >= expr.swstate->cap)
2233 {
2234 size_t n = expr.swstate->cap;
2235 if (!(expr.swstate->base = realloc(expr.swstate->base, sizeof(Extype_t*) * 2 * n)))
2236 {
2237 exerror("too many case labels for switch");
2238 n = 0;
2239 }
2240 expr.swstate->cap = 2 * n;
2241 }
2242 if (expr.swstate->base != NULL)
2243 {
2244 (yyvsp[-1].expr) = excast(expr.program, (yyvsp[-1].expr), expr.swstate->type, NULL, 0);
2245 expr.swstate->base[expr.swstate->cur++] = &(yyvsp[-1].expr)->data.constant.value;
2246 }
2247 }
2248#line 2249 "exparse.c"
2249 break;
2250
2251 case 31:
2252#line 459 "../../lib/expr/exparse.y"
2253 {
2254 expr.swstate->def = 1;
2255 }
2256#line 2257 "exparse.c"
2257 break;
2258
2259 case 33:
2260#line 466 "../../lib/expr/exparse.y"
2261 {
2262 if ((yyvsp[0].expr))
2263 (yyval.expr) = (yyvsp[-2].expr) ? exnewnode(expr.program, ',', true, (yyvsp[0].expr)->type, (yyvsp[-2].expr), (yyvsp[0].expr)) : (yyvsp[0].expr);
2264 }
2265#line 2266 "exparse.c"
2266 break;
2267
2268 case 34:
2269#line 472 "../../lib/expr/exparse.y"
2270 {checkName ((yyvsp[0].id)); expr.id=(yyvsp[0].id);}
2271#line 2272 "exparse.c"
2272 break;
2273
2274 case 35:
2275#line 473 "../../lib/expr/exparse.y"
2276 {
2277 (yyval.expr) = 0;
2278 if (!(yyvsp[-3].id)->type || expr.declare)
2279 (yyvsp[-3].id)->type = expr.declare;
2280 if ((yyvsp[0].expr) && (yyvsp[0].expr)->op == PROCEDURE)
2281 {
2282 (yyvsp[-3].id)->lex = PROCEDURE;
2283 (yyvsp[-3].id)->type = (yyvsp[0].expr)->type;
2284 (yyvsp[-3].id)->value = (yyvsp[0].expr);
2285 }
2286 else
2287 {
2288 if ((yyvsp[-3].id)->type == 0) {
2289 exerror("%s: a variable cannot be void typed", (yyvsp[-3].id)->name);
2290 }
2291 (yyvsp[-3].id)->lex = DYNAMIC;
2292 (yyvsp[-3].id)->value = exnewnode(expr.program, 0, false, 0, NULL, NULL);
2293 if ((yyvsp[-1].integer) && (yyvsp[-3].id)->local == NULL)
2294 {
2295 static Dtdisc_t disc_key = {
2296 .key = offsetof(Exassoc_t, key),
2297 .size = sizeof(Extype_t),
2298 .comparf = cmpKey,
2299 };
2300 static Dtdisc_t disc_name = {.key = offsetof(Exassoc_t, name)};
2301 Dtdisc_t *const disc = (yyvsp[-1].integer) == INTEGER ? &disc_key : &disc_name;
2302 if (!((yyvsp[-3].id)->local = dtopen(disc, Dtoset)))
2303 exerror("%s: cannot initialize associative array", (yyvsp[-3].id)->name);
2304 (yyvsp[-3].id)->index_type = (yyvsp[-1].integer); /* -1 indicates no typechecking */
2305 }
2306 if ((yyvsp[0].expr))
2307 {
2308 if ((yyvsp[0].expr)->type != (yyvsp[-3].id)->type)
2309 {
2310 (yyvsp[0].expr)->type = (yyvsp[-3].id)->type;
2311 (yyvsp[0].expr)->data.operand.right = excast(expr.program, (yyvsp[0].expr)->data.operand.right, (yyvsp[-3].id)->type, NULL, 0);
2312 }
2313 (yyvsp[0].expr)->data.operand.left = exnewnode(expr.program, DYNAMIC, false, (yyvsp[-3].id)->type, NULL, NULL);
2314 (yyvsp[0].expr)->data.operand.left->data.variable.symbol = (yyvsp[-3].id);
2315 (yyval.expr) = (yyvsp[0].expr);
2316 }
2317 else if (!(yyvsp[-1].integer))
2318 (yyvsp[-3].id)->value->data.value = exzero((yyvsp[-3].id)->type);
2319 }
2320 }
2321#line 2322 "exparse.c"
2322 break;
2323
2324 case 42:
2325#line 531 "../../lib/expr/exparse.y"
2326 {
2327 (yyval.expr) = 0;
2328 }
2329#line 2330 "exparse.c"
2330 break;
2331
2332 case 43:
2333#line 535 "../../lib/expr/exparse.y"
2334 {
2335 (yyval.expr) = (yyvsp[0].expr);
2336 }
2337#line 2338 "exparse.c"
2338 break;
2339
2340 case 44:
2341#line 541 "../../lib/expr/exparse.y"
2342 {
2343 (yyval.expr) = 0;
2344 }
2345#line 2346 "exparse.c"
2346 break;
2347
2348 case 46:
2349#line 548 "../../lib/expr/exparse.y"
2350 {
2351 (yyval.expr) = (yyvsp[-1].expr);
2352 }
2353#line 2354 "exparse.c"
2354 break;
2355
2356 case 47:
2357#line 552 "../../lib/expr/exparse.y"
2358 {
2359 (yyval.expr) = ((yyvsp[0].expr)->type == (yyvsp[-2].id)->type) ? (yyvsp[0].expr) : excast(expr.program, (yyvsp[0].expr), (yyvsp[-2].id)->type, NULL, 0);
2360 }
2361#line 2362 "exparse.c"
2362 break;
2363
2364 case 48:
2365#line 556 "../../lib/expr/exparse.y"
2366 {
2367 long rel;
2368
2369 relational:
2370 rel = INTEGER;
2371 goto coerce;
2372 binary:
2373 rel = 0;
2374 coerce:
2375 if (!(yyvsp[-2].expr)->type)
2376 {
2377 if (!(yyvsp[0].expr)->type)
2378 (yyvsp[-2].expr)->type = (yyvsp[0].expr)->type = rel ? STRING : INTEGER;
2379 else
2380 (yyvsp[-2].expr)->type = (yyvsp[0].expr)->type;
2381 }
2382 else if (!(yyvsp[0].expr)->type)
2383 (yyvsp[0].expr)->type = (yyvsp[-2].expr)->type;
2384 if ((yyvsp[-2].expr)->type != (yyvsp[0].expr)->type)
2385 {
2386 if ((yyvsp[-2].expr)->type == STRING)
2387 (yyvsp[-2].expr) = excast(expr.program, (yyvsp[-2].expr), (yyvsp[0].expr)->type, (yyvsp[0].expr), 0);
2388 else if ((yyvsp[0].expr)->type == STRING)
2389 (yyvsp[0].expr) = excast(expr.program, (yyvsp[0].expr), (yyvsp[-2].expr)->type, (yyvsp[-2].expr), 0);
2390 else if ((yyvsp[-2].expr)->type == FLOATING)
2391 (yyvsp[0].expr) = excast(expr.program, (yyvsp[0].expr), FLOATING, (yyvsp[-2].expr), 0);
2392 else if ((yyvsp[0].expr)->type == FLOATING)
2393 (yyvsp[-2].expr) = excast(expr.program, (yyvsp[-2].expr), FLOATING, (yyvsp[0].expr), 0);
2394 }
2395 if (!rel)
2396 rel = ((yyvsp[-2].expr)->type == STRING) ? STRING : (((yyvsp[-2].expr)->type == UNSIGNED) ? UNSIGNED : (yyvsp[0].expr)->type);
2397 (yyval.expr) = exnewnode(expr.program, (yyvsp[-1].op), true, rel, (yyvsp[-2].expr), (yyvsp[0].expr));
2398 if (!expr.program->errors && (yyvsp[-2].expr)->op == CONSTANT && (yyvsp[0].expr)->op == CONSTANT)
2399 {
2400 (yyval.expr)->data.constant.value = exeval(expr.program, (yyval.expr), NULL);
2401 /* If a constant string, re-allocate from program heap. This is because the
2402 * value was constructed from string operators, which create a value in the
2403 * temporary heap, which is cleared when exeval is called again.
2404 */
2405 if ((yyval.expr)->type == STRING) {
2406 (yyval.expr)->data.constant.value.string =
2407 vmstrdup(expr.program->vm, (yyval.expr)->data.constant.value.string);
2408 }
2409 (yyval.expr)->binary = false;
2410 (yyval.expr)->op = CONSTANT;
2411 exfreenode(expr.program, (yyvsp[-2].expr));
2412 exfreenode(expr.program, (yyvsp[0].expr));
2413 }
2414 else if (!BUILTIN((yyvsp[-2].expr)->type) || !BUILTIN((yyvsp[0].expr)->type)) {
2415 checkBinary(expr.program, (yyvsp[-2].expr), (yyval.expr), (yyvsp[0].expr));
2416 }
2417 }
2418#line 2419 "exparse.c"
2419 break;
2420
2421 case 49:
2422#line 609 "../../lib/expr/exparse.y"
2423 {
2424 goto binary;
2425 }
2426#line 2427 "exparse.c"
2427 break;
2428
2429 case 50:
2430#line 613 "../../lib/expr/exparse.y"
2431 {
2432 goto binary;
2433 }
2434#line 2435 "exparse.c"
2435 break;
2436
2437 case 51:
2438#line 617 "../../lib/expr/exparse.y"
2439 {
2440 goto binary;
2441 }
2442#line 2443 "exparse.c"
2443 break;
2444
2445 case 52:
2446#line 621 "../../lib/expr/exparse.y"
2447 {
2448 goto binary;
2449 }
2450#line 2451 "exparse.c"
2451 break;
2452
2453 case 53:
2454#line 625 "../../lib/expr/exparse.y"
2455 {
2456 goto binary;
2457 }
2458#line 2459 "exparse.c"
2459 break;
2460
2461 case 54:
2462#line 629 "../../lib/expr/exparse.y"
2463 {
2464 goto binary;
2465 }
2466#line 2467 "exparse.c"
2467 break;
2468
2469 case 55:
2470#line 633 "../../lib/expr/exparse.y"
2471 {
2472 goto relational;
2473 }
2474#line 2475 "exparse.c"
2475 break;
2476
2477 case 56:
2478#line 637 "../../lib/expr/exparse.y"
2479 {
2480 goto relational;
2481 }
2482#line 2483 "exparse.c"
2483 break;
2484
2485 case 57:
2486#line 641 "../../lib/expr/exparse.y"
2487 {
2488 goto relational;
2489 }
2490#line 2491 "exparse.c"
2491 break;
2492
2493 case 58:
2494#line 645 "../../lib/expr/exparse.y"
2495 {
2496 goto relational;
2497 }
2498#line 2499 "exparse.c"
2499 break;
2500
2501 case 59:
2502#line 649 "../../lib/expr/exparse.y"
2503 {
2504 goto relational;
2505 }
2506#line 2507 "exparse.c"
2507 break;
2508
2509 case 60:
2510#line 653 "../../lib/expr/exparse.y"
2511 {
2512 goto binary;
2513 }
2514#line 2515 "exparse.c"
2515 break;
2516
2517 case 61:
2518#line 657 "../../lib/expr/exparse.y"
2519 {
2520 goto binary;
2521 }
2522#line 2523 "exparse.c"
2523 break;
2524
2525 case 62:
2526#line 661 "../../lib/expr/exparse.y"
2527 {
2528 goto binary;
2529 }
2530#line 2531 "exparse.c"
2531 break;
2532
2533 case 63:
2534#line 665 "../../lib/expr/exparse.y"
2535 {
2536 goto binary;
2537 }
2538#line 2539 "exparse.c"
2539 break;
2540
2541 case 64:
2542#line 669 "../../lib/expr/exparse.y"
2543 {
2544 logical:
2545 if ((yyvsp[-2].expr)->type == STRING)
2546 (yyvsp[-2].expr) = exnewnode(expr.program, S2B, true, INTEGER, (yyvsp[-2].expr), NULL);
2547 else if (!BUILTIN((yyvsp[-2].expr)->type))
2548 (yyvsp[-2].expr) = excast(expr.program, (yyvsp[-2].expr), INTEGER, NULL, 0);
2549 if ((yyvsp[0].expr)->type == STRING)
2550 (yyvsp[0].expr) = exnewnode(expr.program, S2B, true, INTEGER, (yyvsp[0].expr), NULL);
2551 else if (!BUILTIN((yyvsp[0].expr)->type))
2552 (yyvsp[0].expr) = excast(expr.program, (yyvsp[0].expr), INTEGER, NULL, 0);
2553 goto binary;
2554 }
2555#line 2556 "exparse.c"
2556 break;
2557
2558 case 65:
2559#line 682 "../../lib/expr/exparse.y"
2560 {
2561 goto logical;
2562 }
2563#line 2564 "exparse.c"
2564 break;
2565
2566 case 66:
2567#line 686 "../../lib/expr/exparse.y"
2568 {
2569 if ((yyvsp[-2].expr)->op == CONSTANT)
2570 {
2571 exfreenode(expr.program, (yyvsp[-2].expr));
2572 (yyval.expr) = (yyvsp[0].expr);
2573 }
2574 else
2575 (yyval.expr) = exnewnode(expr.program, ',', true, (yyvsp[0].expr)->type, (yyvsp[-2].expr), (yyvsp[0].expr));
2576 }
2577#line 2578 "exparse.c"
2578 break;
2579
2580 case 67:
2581#line 695 "../../lib/expr/exparse.y"
2582 {expr.nolabel=1;}
2583#line 2584 "exparse.c"
2584 break;
2585
2586 case 68:
2587#line 695 "../../lib/expr/exparse.y"
2588 {expr.nolabel=0;}
2589#line 2590 "exparse.c"
2590 break;
2591
2592 case 69:
2593#line 696 "../../lib/expr/exparse.y"
2594 {
2595 if (!(yyvsp[-3].expr)->type)
2596 {
2597 if (!(yyvsp[0].expr)->type)
2598 (yyvsp[-3].expr)->type = (yyvsp[0].expr)->type = INTEGER;
2599 else
2600 (yyvsp[-3].expr)->type = (yyvsp[0].expr)->type;
2601 }
2602 else if (!(yyvsp[0].expr)->type)
2603 (yyvsp[0].expr)->type = (yyvsp[-3].expr)->type;
2604 if ((yyvsp[-6].expr)->type == STRING)
2605 (yyvsp[-6].expr) = exnewnode(expr.program, S2B, true, INTEGER, (yyvsp[-6].expr), NULL);
2606 else if (!INTEGRAL((yyvsp[-6].expr)->type))
2607 (yyvsp[-6].expr) = excast(expr.program, (yyvsp[-6].expr), INTEGER, NULL, 0);
2608 if ((yyvsp[-3].expr)->type != (yyvsp[0].expr)->type)
2609 {
2610 if ((yyvsp[-3].expr)->type == STRING || (yyvsp[0].expr)->type == STRING)
2611 exerror("if statement string type mismatch");
2612 else if ((yyvsp[-3].expr)->type == FLOATING)
2613 (yyvsp[0].expr) = excast(expr.program, (yyvsp[0].expr), FLOATING, NULL, 0);
2614 else if ((yyvsp[0].expr)->type == FLOATING)
2615 (yyvsp[-3].expr) = excast(expr.program, (yyvsp[-3].expr), FLOATING, NULL, 0);
2616 }
2617 if ((yyvsp[-6].expr)->op == CONSTANT)
2618 {
2619 if ((yyvsp[-6].expr)->data.constant.value.integer)
2620 {
2621 (yyval.expr) = (yyvsp[-3].expr);
2622 exfreenode(expr.program, (yyvsp[0].expr));
2623 }
2624 else
2625 {
2626 (yyval.expr) = (yyvsp[0].expr);
2627 exfreenode(expr.program, (yyvsp[-3].expr));
2628 }
2629 exfreenode(expr.program, (yyvsp[-6].expr));
2630 }
2631 else
2632 (yyval.expr) = exnewnode(expr.program, '?', true, (yyvsp[-3].expr)->type, (yyvsp[-6].expr), exnewnode(expr.program, ':', true, (yyvsp[-3].expr)->type, (yyvsp[-3].expr), (yyvsp[0].expr)));
2633 }
2634#line 2635 "exparse.c"
2635 break;
2636
2637 case 70:
2638#line 737 "../../lib/expr/exparse.y"
2639 {
2640 iunary:
2641 if ((yyvsp[0].expr)->type == STRING)
2642 (yyvsp[0].expr) = exnewnode(expr.program, S2B, true, INTEGER, (yyvsp[0].expr), NULL);
2643 else if (!INTEGRAL((yyvsp[0].expr)->type))
2644 (yyvsp[0].expr) = excast(expr.program, (yyvsp[0].expr), INTEGER, NULL, 0);
2645 unary:
2646 (yyval.expr) = exnewnode(expr.program, (yyvsp[-1].op), true, (yyvsp[0].expr)->type == UNSIGNED ? INTEGER : (yyvsp[0].expr)->type, (yyvsp[0].expr), NULL);
2647 if ((yyvsp[0].expr)->op == CONSTANT)
2648 {
2649 (yyval.expr)->data.constant.value = exeval(expr.program, (yyval.expr), NULL);
2650 (yyval.expr)->binary = false;
2651 (yyval.expr)->op = CONSTANT;
2652 exfreenode(expr.program, (yyvsp[0].expr));
2653 }
2654 else if (!BUILTIN((yyvsp[0].expr)->type)) {
2655 checkBinary(expr.program, (yyvsp[0].expr), (yyval.expr), 0);
2656 }
2657 }
2658#line 2659 "exparse.c"
2659 break;
2660
2661 case 71:
2662#line 757 "../../lib/expr/exparse.y"
2663 {
2664 if ((yyvsp[0].id)->local == NULL)
2665 exerror("cannot apply '#' operator to non-array %s", (yyvsp[0].id)->name);
2666 (yyval.expr) = exnewnode(expr.program, '#', false, INTEGER, NULL, NULL);
2667 (yyval.expr)->data.variable.symbol = (yyvsp[0].id);
2668 }
2669#line 2670 "exparse.c"
2670 break;
2671
2672 case 72:
2673#line 764 "../../lib/expr/exparse.y"
2674 {
2675 (yyval.expr) = exnewnode(expr.program, '#', false, INTEGER, NULL, NULL);
2676 (yyval.expr)->data.variable.symbol = (yyvsp[0].id);
2677 }
2678#line 2679 "exparse.c"
2679 break;
2680
2681 case 73:
2682#line 769 "../../lib/expr/exparse.y"
2683 {
2684 goto iunary;
2685 }
2686#line 2687 "exparse.c"
2687 break;
2688
2689 case 74:
2690#line 773 "../../lib/expr/exparse.y"
2691 {
2692 goto unary;
2693 }
2694#line 2695 "exparse.c"
2695 break;
2696
2697 case 75:
2698#line 777 "../../lib/expr/exparse.y"
2699 {
2700 (yyval.expr) = (yyvsp[0].expr);
2701 }
2702#line 2703 "exparse.c"
2703 break;
2704
2705 case 76:
2706#line 781 "../../lib/expr/exparse.y"
2707 {
2708 (yyval.expr) = exnewnode(expr.program, ADDRESS, false, T((yyvsp[0].expr)->type), (yyvsp[0].expr), NULL);
2709 }
2710#line 2711 "exparse.c"
2711 break;
2712
2713 case 77:
2714#line 785 "../../lib/expr/exparse.y"
2715 {
2716 (yyval.expr) = exnewnode(expr.program, ARRAY, true, T((yyvsp[-3].id)->type), call(0, (yyvsp[-3].id), (yyvsp[-1].expr)), (yyvsp[-1].expr));
2717 }
2718#line 2719 "exparse.c"
2719 break;
2720
2721 case 78:
2722#line 789 "../../lib/expr/exparse.y"
2723 {
2724 (yyval.expr) = exnewnode(expr.program, FUNCTION, true, T((yyvsp[-3].id)->type), call(0, (yyvsp[-3].id), (yyvsp[-1].expr)), (yyvsp[-1].expr));
2725 }
2726#line 2727 "exparse.c"
2727 break;
2728
2729 case 79:
2730#line 793 "../../lib/expr/exparse.y"
2731 {
2732 (yyval.expr) = exnewsub (expr.program, (yyvsp[-1].expr), GSUB);
2733 }
2734#line 2735 "exparse.c"
2735 break;
2736
2737 case 80:
2738#line 797 "../../lib/expr/exparse.y"
2739 {
2740 (yyval.expr) = exnewsub (expr.program, (yyvsp[-1].expr), SUB);
2741 }
2742#line 2743 "exparse.c"
2743 break;
2744
2745 case 81:
2746#line 801 "../../lib/expr/exparse.y"
2747 {
2748 (yyval.expr) = exnewsubstr (expr.program, (yyvsp[-1].expr));
2749 }
2750#line 2751 "exparse.c"
2751 break;
2752
2753 case 82:
2754#line 805 "../../lib/expr/exparse.y"
2755 {
2756 (yyval.expr) = exnewsplit (expr.program, (yyvsp[-5].id)->index, (yyvsp[-1].id), (yyvsp[-3].expr), NULL);
2757 }
2758#line 2759 "exparse.c"
2759 break;
2760
2761 case 83:
2762#line 809 "../../lib/expr/exparse.y"
2763 {
2764 (yyval.expr) = exnewsplit (expr.program, (yyvsp[-7].id)->index, (yyvsp[-3].id), (yyvsp[-5].expr), (yyvsp[-1].expr));
2765 }
2766#line 2767 "exparse.c"
2767 break;
2768
2769 case 84:
2770#line 813 "../../lib/expr/exparse.y"
2771 {
2772 if (!INTEGRAL((yyvsp[-1].expr)->type))
2773 (yyvsp[-1].expr) = excast(expr.program, (yyvsp[-1].expr), INTEGER, NULL, 0);
2774 (yyval.expr) = exnewnode(expr.program, EXIT, true, INTEGER, (yyvsp[-1].expr), NULL);
2775 }
2776#line 2777 "exparse.c"
2777 break;
2778
2779 case 85:
2780#line 819 "../../lib/expr/exparse.y"
2781 {
2782 (yyval.expr) = exnewnode(expr.program, RAND, false, FLOATING, NULL, NULL);
2783 }
2784#line 2785 "exparse.c"
2785 break;
2786
2787 case 86:
2788#line 823 "../../lib/expr/exparse.y"
2789 {
2790 (yyval.expr) = exnewnode(expr.program, SRAND, false, INTEGER, NULL, NULL);
2791 }
2792#line 2793 "exparse.c"
2793 break;
2794
2795 case 87:
2796#line 827 "../../lib/expr/exparse.y"
2797 {
2798 if (!INTEGRAL((yyvsp[-1].expr)->type))
2799 (yyvsp[-1].expr) = excast(expr.program, (yyvsp[-1].expr), INTEGER, NULL, 0);
2800 (yyval.expr) = exnewnode(expr.program, SRAND, true, INTEGER, (yyvsp[-1].expr), NULL);
2801 }
2802#line 2803 "exparse.c"
2803 break;
2804
2805 case 88:
2806#line 833 "../../lib/expr/exparse.y"
2807 {
2808 (yyval.expr) = exnewnode(expr.program, CALL, true, (yyvsp[-3].id)->type, NULL, (yyvsp[-1].expr));
2809 (yyval.expr)->data.call.procedure = (yyvsp[-3].id);
2810 }
2811#line 2812 "exparse.c"
2812 break;
2813
2814 case 89:
2815#line 838 "../../lib/expr/exparse.y"
2816 {
2817 (yyval.expr) = exprint(expr.program, (yyvsp[-3].id), (yyvsp[-1].expr));
2818 }
2819#line 2820 "exparse.c"
2820 break;
2821
2822 case 90:
2823#line 842 "../../lib/expr/exparse.y"
2824 {
2825 (yyval.expr) = exnewnode(expr.program, (yyvsp[-3].id)->index, false, (yyvsp[-3].id)->type, NULL, NULL);
2826 if ((yyvsp[-1].expr) && (yyvsp[-1].expr)->data.operand.left->type == INTEGER)
2827 {
2828 (yyval.expr)->data.print.descriptor = (yyvsp[-1].expr)->data.operand.left;
2829 (yyvsp[-1].expr) = (yyvsp[-1].expr)->data.operand.right;
2830 }
2831 else
2832 switch ((yyvsp[-3].id)->index)
2833 {
2834 case QUERY:
2835 (yyval.expr)->data.print.descriptor = exnewnode(expr.program, CONSTANT, false, INTEGER, NULL, NULL);
2836 (yyval.expr)->data.print.descriptor->data.constant.value.integer = 2;
2837 break;
2838 case PRINTF:
2839 (yyval.expr)->data.print.descriptor = exnewnode(expr.program, CONSTANT, false, INTEGER, NULL, NULL);
2840 (yyval.expr)->data.print.descriptor->data.constant.value.integer = 1;
2841 break;
2842 case SPRINTF:
2843 (yyval.expr)->data.print.descriptor = 0;
2844 break;
2845 }
2846 (yyval.expr)->data.print.args = preprint((yyvsp[-1].expr));
2847 }
2848#line 2849 "exparse.c"
2849 break;
2850
2851 case 91:
2852#line 867 "../../lib/expr/exparse.y"
2853 {
2854 Exnode_t* x;
2855
2856 (yyval.expr) = exnewnode(expr.program, (yyvsp[-3].id)->index, false, (yyvsp[-3].id)->type, NULL, NULL);
2857 if ((yyvsp[-1].expr) && (yyvsp[-1].expr)->data.operand.left->type == INTEGER)
2858 {
2859 (yyval.expr)->data.scan.descriptor = (yyvsp[-1].expr)->data.operand.left;
2860 (yyvsp[-1].expr) = (yyvsp[-1].expr)->data.operand.right;
2861 }
2862 else
2863 switch ((yyvsp[-3].id)->index)
2864 {
2865 case SCANF:
2866 (yyval.expr)->data.scan.descriptor = 0;
2867 break;
2868 case SSCANF:
2869 if ((yyvsp[-1].expr) && (yyvsp[-1].expr)->data.operand.left->type == STRING)
2870 {
2871 (yyval.expr)->data.scan.descriptor = (yyvsp[-1].expr)->data.operand.left;
2872 (yyvsp[-1].expr) = (yyvsp[-1].expr)->data.operand.right;
2873 }
2874 else
2875 exerror("%s: string argument expected", (yyvsp[-3].id)->name);
2876 break;
2877 }
2878 if (!(yyvsp[-1].expr) || !(yyvsp[-1].expr)->data.operand.left || (yyvsp[-1].expr)->data.operand.left->type != STRING)
2879 exerror("%s: format argument expected", (yyvsp[-3].id)->name);
2880 (yyval.expr)->data.scan.format = (yyvsp[-1].expr)->data.operand.left;
2881 for (x = (yyval.expr)->data.scan.args = (yyvsp[-1].expr)->data.operand.right; x; x = x->data.operand.right)
2882 {
2883 if (x->data.operand.left->op != ADDRESS)
2884 exerror("%s: address argument expected", (yyvsp[-3].id)->name);
2886 }
2887 }
2888#line 2889 "exparse.c"
2889 break;
2890
2891 case 92:
2892#line 903 "../../lib/expr/exparse.y"
2893 {
2894 if ((yyvsp[0].expr))
2895 {
2896 if ((yyvsp[-1].expr)->op == ID && !expr.program->disc->setf)
2897 exerror("%s: variable assignment not supported", (yyvsp[-1].expr)->data.variable.symbol->name);
2898 else
2899 {
2900 if (!(yyvsp[-1].expr)->type)
2901 (yyvsp[-1].expr)->type = (yyvsp[0].expr)->type;
2902 else if ((yyvsp[0].expr)->type != (yyvsp[-1].expr)->type)
2903 {
2904 (yyvsp[0].expr)->type = (yyvsp[-1].expr)->type;
2905 (yyvsp[0].expr)->data.operand.right = excast(expr.program, (yyvsp[0].expr)->data.operand.right, (yyvsp[-1].expr)->type, NULL, 0);
2906 }
2907 (yyvsp[0].expr)->data.operand.left = (yyvsp[-1].expr);
2908 (yyval.expr) = (yyvsp[0].expr);
2909 }
2910 }
2911 }
2912#line 2913 "exparse.c"
2913 break;
2914
2915 case 93:
2916#line 923 "../../lib/expr/exparse.y"
2917 {
2918 pre:
2919 if ((yyvsp[0].expr)->type == STRING)
2920 exerror("++ and -- invalid for string variables");
2921 (yyval.expr) = exnewnode(expr.program, (yyvsp[-1].op), false, (yyvsp[0].expr)->type, (yyvsp[0].expr), NULL);
2922 (yyval.expr)->subop = PRE;
2923 }
2924#line 2925 "exparse.c"
2925 break;
2926
2927 case 94:
2928#line 931 "../../lib/expr/exparse.y"
2929 {
2930 pos:
2931 if ((yyvsp[-1].expr)->type == STRING)
2932 exerror("++ and -- invalid for string variables");
2933 (yyval.expr) = exnewnode(expr.program, (yyvsp[0].op), false, (yyvsp[-1].expr)->type, (yyvsp[-1].expr), NULL);
2934 (yyval.expr)->subop = POS;
2935 }
2936#line 2937 "exparse.c"
2937 break;
2938
2939 case 95:
2940#line 939 "../../lib/expr/exparse.y"
2941 {
2942 if ((yyvsp[0].id)->local == NULL)
2943 exerror("cannot apply IN to non-array %s", (yyvsp[0].id)->name);
2944 if ((yyvsp[0].id)->index_type > 0 && (yyvsp[-2].expr)->type != (yyvsp[0].id)->index_type)
2945 exerror("%s indices must have type %s, not %s",
2946 (yyvsp[0].id)->name, extypename(expr.program, (yyvsp[0].id)->index_type),extypename(expr.program, (yyvsp[-2].expr)->type));
2947 (yyval.expr) = exnewnode(expr.program, IN_OP, false, INTEGER, NULL, NULL);
2948 (yyval.expr)->data.variable.symbol = (yyvsp[0].id);
2949 (yyval.expr)->data.variable.index = (yyvsp[-2].expr);
2950 }
2951#line 2952 "exparse.c"
2952 break;
2953
2954 case 96:
2955#line 950 "../../lib/expr/exparse.y"
2956 {
2957 if ((yyvsp[0].id)->index_type > 0 && (yyvsp[-2].expr)->type != (yyvsp[0].id)->index_type)
2958 exerror("%s indices must have type %s, not %s",
2959 (yyvsp[0].id)->name, extypename(expr.program, (yyvsp[0].id)->index_type),extypename(expr.program, (yyvsp[-2].expr)->type));
2960 (yyval.expr) = exnewnode(expr.program, IN_OP, false, INTEGER, NULL, NULL);
2961 (yyval.expr)->data.variable.symbol = (yyvsp[0].id);
2962 (yyval.expr)->data.variable.index = (yyvsp[-2].expr);
2963 }
2964#line 2965 "exparse.c"
2965 break;
2966
2967 case 97:
2968#line 959 "../../lib/expr/exparse.y"
2969 {
2970 goto pre;
2971 }
2972#line 2973 "exparse.c"
2973 break;
2974
2975 case 98:
2976#line 963 "../../lib/expr/exparse.y"
2977 {
2978 goto pos;
2979 }
2980#line 2981 "exparse.c"
2981 break;
2982
2983 case 102:
2984#line 973 "../../lib/expr/exparse.y"
2985 {
2986 (yyval.expr) = exnewnode(expr.program, CONSTANT, false, (yyvsp[0].id)->type, NULL, NULL);
2987 if (!expr.program->disc->reff)
2988 exerror("%s: identifier references not supported", (yyvsp[0].id)->name);
2989 else
2990 (yyval.expr)->data.constant.value = expr.program->disc->reff(expr.program, (yyval.expr), (yyvsp[0].id), NULL);
2991 }
2992#line 2993 "exparse.c"
2993 break;
2994
2995 case 103:
2996#line 981 "../../lib/expr/exparse.y"
2997 {
2998 (yyval.expr) = exnewnode(expr.program, CONSTANT, false, FLOATING, NULL, NULL);
2999 (yyval.expr)->data.constant.value.floating = (yyvsp[0].floating);
3000 }
3001#line 3002 "exparse.c"
3002 break;
3003
3004 case 104:
3005#line 986 "../../lib/expr/exparse.y"
3006 {
3007 (yyval.expr) = exnewnode(expr.program, CONSTANT, false, INTEGER, NULL, NULL);
3008 (yyval.expr)->data.constant.value.integer = (yyvsp[0].integer);
3009 }
3010#line 3011 "exparse.c"
3011 break;
3012
3013 case 105:
3014#line 991 "../../lib/expr/exparse.y"
3015 {
3016 (yyval.expr) = exnewnode(expr.program, CONSTANT, false, STRING, NULL, NULL);
3017 (yyval.expr)->data.constant.value.string = (yyvsp[0].string);
3018 }
3019#line 3020 "exparse.c"
3020 break;
3021
3022 case 106:
3023#line 996 "../../lib/expr/exparse.y"
3024 {
3025 (yyval.expr) = exnewnode(expr.program, CONSTANT, false, UNSIGNED, NULL, NULL);
3026 (yyval.expr)->data.constant.value.integer = (yyvsp[0].integer);
3027 }
3028#line 3029 "exparse.c"
3029 break;
3030
3031 case 112:
3032#line 1012 "../../lib/expr/exparse.y"
3033 {
3034 (yyval.expr) = makeVar(expr.program, (yyvsp[-1].id), 0, 0, (yyvsp[0].reference));
3035 }
3036#line 3037 "exparse.c"
3037 break;
3038
3039 case 113:
3040#line 1016 "../../lib/expr/exparse.y"
3041 {
3042 Exnode_t *n = exnewnode(expr.program, DYNAMIC, false, (yyvsp[-2].id)->type, NULL, NULL);
3043 n->data.variable.symbol = (yyvsp[-2].id);
3044 n->data.variable.reference = 0;
3045 if (((n->data.variable.index = (yyvsp[-1].expr)) == 0) != ((yyvsp[-2].id)->local == NULL))
3046 exerror("%s: is%s an array", (yyvsp[-2].id)->name, (yyvsp[-2].id)->local != NULL ? "" : " not");
3047 if ((yyvsp[-2].id)->local != NULL && (yyvsp[-2].id)->index_type > 0) {
3048 if ((yyvsp[-1].expr)->type != (yyvsp[-2].id)->index_type)
3049 exerror("%s: indices must have type %s, not %s",
3050 (yyvsp[-2].id)->name, extypename(expr.program, (yyvsp[-2].id)->index_type),extypename(expr.program, (yyvsp[-1].expr)->type));
3051 }
3052 if ((yyvsp[0].reference)) {
3053 n->data.variable.dyna = exnewnode(expr.program, 0, false, 0, NULL, NULL);
3054 (yyval.expr) = makeVar(expr.program, (yyvsp[-2].id), (yyvsp[-1].expr), n, (yyvsp[0].reference));
3055 }
3056 else (yyval.expr) = n;
3057 }
3058#line 3059 "exparse.c"
3059 break;
3060
3061 case 114:
3062#line 1034 "../../lib/expr/exparse.y"
3063 {
3064 (yyval.expr) = exnewnode(expr.program, ID, false, STRING, NULL, NULL);
3065 (yyval.expr)->data.variable.symbol = (yyvsp[0].id);
3066 (yyval.expr)->data.variable.reference = 0;
3067 (yyval.expr)->data.variable.index = 0;
3068 (yyval.expr)->data.variable.dyna = 0;
3069 if (!(expr.program->disc->flags & EX_UNDECLARED))
3070 exerror("unknown identifier");
3071 }
3072#line 3073 "exparse.c"
3073 break;
3074
3075 case 115:
3076#line 1046 "../../lib/expr/exparse.y"
3077 {
3078 (yyval.integer) = 0;
3079 }
3080#line 3081 "exparse.c"
3081 break;
3082
3083 case 116:
3084#line 1050 "../../lib/expr/exparse.y"
3085 {
3086 (yyval.integer) = -1;
3087 }
3088#line 3089 "exparse.c"
3089 break;
3090
3091 case 117:
3092#line 1054 "../../lib/expr/exparse.y"
3093 {
3094 /* If DECLARE is VOID, its type is 0, so this acts like
3095 * the empty case.
3096 */
3097 if (INTEGRAL((yyvsp[-1].id)->type))
3098 (yyval.integer) = INTEGER;
3099 else
3100 (yyval.integer) = (yyvsp[-1].id)->type;
3101
3102 }
3103#line 3104 "exparse.c"
3104 break;
3105
3106 case 118:
3107#line 1067 "../../lib/expr/exparse.y"
3108 {
3109 (yyval.expr) = 0;
3110 }
3111#line 3112 "exparse.c"
3112 break;
3113
3114 case 119:
3115#line 1071 "../../lib/expr/exparse.y"
3116 {
3117 (yyval.expr) = (yyvsp[-1].expr);
3118 }
3119#line 3120 "exparse.c"
3120 break;
3121
3122 case 120:
3123#line 1077 "../../lib/expr/exparse.y"
3124 {
3125 (yyval.expr) = 0;
3126 }
3127#line 3128 "exparse.c"
3128 break;
3129
3130 case 121:
3131#line 1081 "../../lib/expr/exparse.y"
3132 {
3133 (yyval.expr) = (yyvsp[0].expr)->data.operand.left;
3134 (yyvsp[0].expr)->data.operand.left = (yyvsp[0].expr)->data.operand.right = 0;
3135 exfreenode(expr.program, (yyvsp[0].expr));
3136 }
3137#line 3138 "exparse.c"
3138 break;
3139
3140 case 122:
3141#line 1089 "../../lib/expr/exparse.y"
3142 {
3143 (yyval.expr) = exnewnode(expr.program, ',', true, 0, exnewnode(expr.program, ',', true, (yyvsp[0].expr)->type, (yyvsp[0].expr), NULL), NULL);
3144 (yyval.expr)->data.operand.right = (yyval.expr)->data.operand.left;
3145 }
3146#line 3147 "exparse.c"
3147 break;
3148
3149 case 123:
3150#line 1094 "../../lib/expr/exparse.y"
3151 {
3152 (yyvsp[-2].expr)->data.operand.right = (yyvsp[-2].expr)->data.operand.right->data.operand.right = exnewnode(expr.program, ',', true, (yyvsp[-2].expr)->type, (yyvsp[0].expr), NULL);
3153 }
3154#line 3155 "exparse.c"
3155 break;
3156
3157 case 124:
3158#line 1100 "../../lib/expr/exparse.y"
3159 {
3160 (yyval.expr) = 0;
3161 }
3162#line 3163 "exparse.c"
3163 break;
3164
3165 case 125:
3166#line 1104 "../../lib/expr/exparse.y"
3167 {
3168 (yyval.expr) = 0;
3169 if ((yyvsp[0].id)->type)
3170 exerror("(void) expected");
3171 }
3172#line 3173 "exparse.c"
3173 break;
3174
3175 case 127:
3176#line 1113 "../../lib/expr/exparse.y"
3177 {
3178 (yyval.expr) = exnewnode(expr.program, ',', true, (yyvsp[0].expr)->type, (yyvsp[0].expr), NULL);
3179 }
3180#line 3181 "exparse.c"
3181 break;
3182
3183 case 128:
3184#line 1117 "../../lib/expr/exparse.y"
3185 {
3186 Exnode_t* x;
3187 Exnode_t* y;
3188
3189 (yyval.expr) = (yyvsp[-2].expr);
3190 for (x = (yyvsp[-2].expr); (y = x->data.operand.right); x = y);
3191 x->data.operand.right = exnewnode(expr.program, ',', true, (yyvsp[0].expr)->type, (yyvsp[0].expr), NULL);
3192 }
3193#line 3194 "exparse.c"
3194 break;
3195
3196 case 129:
3197#line 1127 "../../lib/expr/exparse.y"
3198 {expr.declare=(yyvsp[0].id)->type;}
3199#line 3200 "exparse.c"
3200 break;
3201
3202 case 130:
3203#line 1128 "../../lib/expr/exparse.y"
3204 {
3205 if ((yyvsp[-2].id)->type == 0) {
3206 exerror("%s: parameters to functions cannot be void typed", (yyvsp[0].id)->name);
3207 }
3208 (yyval.expr) = exnewnode(expr.program, ID, false, (yyvsp[-2].id)->type, NULL, NULL);
3209 (yyval.expr)->data.variable.symbol = (yyvsp[0].id);
3210 (yyvsp[0].id)->lex = DYNAMIC;
3211 (yyvsp[0].id)->type = (yyvsp[-2].id)->type;
3212 (yyvsp[0].id)->value = exnewnode(expr.program, 0, false, 0, NULL, NULL);
3213 expr.procedure->data.procedure.arity++;
3214 expr.declare = 0;
3215 }
3216#line 3217 "exparse.c"
3217 break;
3218
3219 case 131:
3220#line 1143 "../../lib/expr/exparse.y"
3221 {
3222 (yyval.reference) = expr.refs = 0;
3223 }
3224#line 3225 "exparse.c"
3225 break;
3226
3227 case 132:
3228#line 1147 "../../lib/expr/exparse.y"
3229 {
3230 Exref_t* r;
3231
3232 r = ALLOCATE(expr.program, Exref_t);
3233 *r = (Exref_t){0};
3234 r->symbol = (yyvsp[0].id);
3235 expr.refs = r;
3236 r->next = 0;
3237 r->index = 0;
3238 (yyval.reference) = expr.refs;
3239 }
3240#line 3241 "exparse.c"
3241 break;
3242
3243 case 133:
3244#line 1159 "../../lib/expr/exparse.y"
3245 {
3246 Exref_t* r;
3247 Exref_t* l;
3248
3249 r = ALLOCATE(expr.program, Exref_t);
3250 *r = (Exref_t){0};
3251 r->symbol = (yyvsp[0].id);
3252 r->index = 0;
3253 r->next = 0;
3254 l = ALLOCATE(expr.program, Exref_t);
3255 *l = (Exref_t){0};
3256 l->symbol = (yyvsp[-1].id);
3257 l->index = 0;
3258 l->next = r;
3259 expr.refs = l;
3260 (yyval.reference) = expr.refs;
3261 }
3262#line 3263 "exparse.c"
3263 break;
3264
3265 case 134:
3266#line 1179 "../../lib/expr/exparse.y"
3267 {
3268 (yyval.id) = (yyvsp[0].id);
3269 }
3270#line 3271 "exparse.c"
3271 break;
3272
3273 case 135:
3274#line 1183 "../../lib/expr/exparse.y"
3275 {
3276 (yyval.id) = (yyvsp[0].id);
3277 }
3278#line 3279 "exparse.c"
3279 break;
3280
3281 case 136:
3282#line 1188 "../../lib/expr/exparse.y"
3283 {
3284 (yyval.expr) = 0;
3285 }
3286#line 3287 "exparse.c"
3287 break;
3288
3289 case 137:
3290#line 1192 "../../lib/expr/exparse.y"
3291 {
3292 (yyval.expr) = exnewnode(expr.program, '=', true, (yyvsp[0].expr)->type, NULL, (yyvsp[0].expr));
3293 (yyval.expr)->subop = (yyvsp[-1].op);
3294 }
3295#line 3296 "exparse.c"
3296 break;
3297
3298 case 139:
3299#line 1199 "../../lib/expr/exparse.y"
3300 {
3301 if (expr.procedure)
3302 exerror("%s: nested function definitions not supported", expr.id->name);
3304 if (!streq(expr.id->name, "begin"))
3305 {
3306 static Dtdisc_t disc = {.key = offsetof(Exid_t, name)};
3307 if (!(expr.procedure->data.procedure.frame = dtopen(&disc, Dtset)) || !dtview(expr.procedure->data.procedure.frame, expr.program->symbols))
3308 exnospace();
3309 expr.program->symbols = expr.program->frame = expr.procedure->data.procedure.frame;
3310 }
3311 expr.declare = 0;
3312 }
3313#line 3314 "exparse.c"
3314 break;
3315
3316 case 140:
3317#line 1211 "../../lib/expr/exparse.y"
3318 {
3319 expr.id->lex = PROCEDURE;
3321 expr.declare = 0;
3322 }
3323#line 3324 "exparse.c"
3324 break;
3325
3326 case 141:
3327#line 1216 "../../lib/expr/exparse.y"
3328 {
3329 (yyval.expr) = expr.procedure;
3331 if (expr.program->frame)
3332 {
3333 expr.program->symbols = expr.program->frame->view;
3334 dtview(expr.program->frame, NULL);
3335 expr.program->frame = NULL;
3336 }
3337 // dictionary of locals no longer required, now that we have parsed the body
3338 (void)dtclose((yyval.expr)->data.procedure.frame);
3339 (yyval.expr)->data.procedure.frame = NULL;
3340 (yyval.expr)->data.procedure.args = (yyvsp[-5].expr);
3341 (yyval.expr)->data.procedure.body = excast(expr.program, (yyvsp[-1].expr), (yyval.expr)->type, NULL, 0);
3342
3343 /*
3344 * NOTE: procedure definition was slipped into the
3345 * declaration initializer statement production,
3346 * therefore requiring the statement terminator
3347 */
3348
3349 exunlex(expr.program, ';');
3350 }
3351#line 3352 "exparse.c"
3352 break;
3353
3354
3355#line 3356 "exparse.c"
3356
3357 default: break;
3358 }
3359 /* User semantic actions sometimes alter yychar, and that requires
3360 that yytoken be updated with the new translation. We take the
3361 approach of translating immediately before every use of yytoken.
3362 One alternative is translating here after every semantic action,
3363 but that translation would be missed if the semantic action invokes
3364 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
3365 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
3366 incorrect destructor might then be invoked immediately. In the
3367 case of YYERROR or YYBACKUP, subsequent parser actions might lead
3368 to an incorrect destructor call or verbose syntax error message
3369 before the lookahead is translated. */
3370 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
3371
3372 YYPOPSTACK (yylen);
3373 yylen = 0;
3374 YY_STACK_PRINT (yyss, yyssp);
3375
3376 *++yyvsp = yyval;
3377
3378 /* Now 'shift' the result of the reduction. Determine what state
3379 that goes to, based on the state we popped back to and the rule
3380 number reduced by. */
3381 {
3382 const int yylhs = yyr1[yyn] - YYNTOKENS;
3383 const int yyi = yypgoto[yylhs] + *yyssp;
3384 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
3385 ? yytable[yyi]
3386 : yydefgoto[yylhs]);
3387 }
3388
3389 goto yynewstate;
3390
3391
3392/*--------------------------------------.
3393| yyerrlab -- here on detecting error. |
3394`--------------------------------------*/
3395yyerrlab:
3396 /* Make sure we have latest lookahead translation. See comments at
3397 user semantic actions for why this is necessary. */
3398 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
3399
3400 /* If not already recovering from an error, report this error. */
3401 if (!yyerrstatus)
3402 {
3403 ++yynerrs;
3404#if ! YYERROR_VERBOSE
3405 yyerror (YY_("syntax error"));
3406#else
3407# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
3408 yyssp, yytoken)
3409 {
3410 char const *yymsgp = YY_("syntax error");
3411 int yysyntax_error_status;
3412 yysyntax_error_status = YYSYNTAX_ERROR;
3413 if (yysyntax_error_status == 0)
3414 yymsgp = yymsg;
3415 else if (yysyntax_error_status == 1)
3416 {
3417 if (yymsg != yymsgbuf)
3418 YYSTACK_FREE (yymsg);
3419 yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
3420 if (!yymsg)
3421 {
3422 yymsg = yymsgbuf;
3423 yymsg_alloc = sizeof yymsgbuf;
3424 yysyntax_error_status = 2;
3425 }
3426 else
3427 {
3428 yysyntax_error_status = YYSYNTAX_ERROR;
3429 yymsgp = yymsg;
3430 }
3431 }
3432 yyerror (yymsgp);
3433 if (yysyntax_error_status == 2)
3434 goto yyexhaustedlab;
3435 }
3436# undef YYSYNTAX_ERROR
3437#endif
3438 }
3439
3440
3441
3442 if (yyerrstatus == 3)
3443 {
3444 /* If just tried and failed to reuse lookahead token after an
3445 error, discard it. */
3446
3447 if (yychar <= YYEOF)
3448 {
3449 /* Return failure if at end of input. */
3450 if (yychar == YYEOF)
3451 YYABORT;
3452 }
3453 else
3454 {
3455 yydestruct ("Error: discarding",
3456 yytoken, &yylval);
3457 yychar = YYEMPTY;
3458 }
3459 }
3460
3461 /* Else will try to reuse lookahead token after shifting the error
3462 token. */
3463 goto yyerrlab1;
3464
3465
3466/*---------------------------------------------------.
3467| yyerrorlab -- error raised explicitly by YYERROR. |
3468`---------------------------------------------------*/
3469yyerrorlab:
3470 /* Pacify compilers when the user code never invokes YYERROR and the
3471 label yyerrorlab therefore never appears in user code. */
3472 if (0)
3473 YYERROR;
3474
3475 /* Do not reclaim the symbols of the rule whose action triggered
3476 this YYERROR. */
3477 YYPOPSTACK (yylen);
3478 yylen = 0;
3479 YY_STACK_PRINT (yyss, yyssp);
3480 yystate = *yyssp;
3481 goto yyerrlab1;
3482
3483
3484/*-------------------------------------------------------------.
3485| yyerrlab1 -- common code for both syntax error and YYERROR. |
3486`-------------------------------------------------------------*/
3487yyerrlab1:
3488 yyerrstatus = 3; /* Each real token shifted decrements this. */
3489
3490 for (;;)
3491 {
3492 yyn = yypact[yystate];
3493 if (!yypact_value_is_default (yyn))
3494 {
3495 yyn += YYTERROR;
3496 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
3497 {
3498 yyn = yytable[yyn];
3499 if (0 < yyn)
3500 break;
3501 }
3502 }
3503
3504 /* Pop the current state because it cannot handle the error token. */
3505 if (yyssp == yyss)
3506 YYABORT;
3507
3508
3509 yydestruct ("Error: popping",
3510 yystos[yystate], yyvsp);
3511 YYPOPSTACK (1);
3512 yystate = *yyssp;
3513 YY_STACK_PRINT (yyss, yyssp);
3514 }
3515
3517 *++yyvsp = yylval;
3519
3520
3521 /* Shift the error token. */
3522 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
3523
3524 yystate = yyn;
3525 goto yynewstate;
3526
3527
3528/*-------------------------------------.
3529| yyacceptlab -- YYACCEPT comes here. |
3530`-------------------------------------*/
3531yyacceptlab:
3532 yyresult = 0;
3533 goto yyreturn;
3534
3535
3536/*-----------------------------------.
3537| yyabortlab -- YYABORT comes here. |
3538`-----------------------------------*/
3539yyabortlab:
3540 yyresult = 1;
3541 goto yyreturn;
3542
3543
3544#if !defined yyoverflow || YYERROR_VERBOSE
3545/*-------------------------------------------------.
3546| yyexhaustedlab -- memory exhaustion comes here. |
3547`-------------------------------------------------*/
3548yyexhaustedlab:
3549 yyerror (YY_("memory exhausted"));
3550 yyresult = 2;
3551 /* Fall through. */
3552#endif
3553
3554
3555/*-----------------------------------------------------.
3556| yyreturn -- parsing is finished, return the result. |
3557`-----------------------------------------------------*/
3558yyreturn:
3559 if (yychar != YYEMPTY)
3560 {
3561 /* Make sure we have latest lookahead translation. See comments at
3562 user semantic actions for why this is necessary. */
3563 yytoken = YYTRANSLATE (yychar);
3564 yydestruct ("Cleanup: discarding lookahead",
3565 yytoken, &yylval);
3566 }
3567 /* Do not reclaim the symbols of the rule whose action triggered
3568 this YYABORT or YYACCEPT. */
3569 YYPOPSTACK (yylen);
3570 YY_STACK_PRINT (yyss, yyssp);
3571 while (yyssp != yyss)
3572 {
3573 yydestruct ("Cleanup: popping",
3574 yystos[+*yyssp], yyvsp);
3575 YYPOPSTACK (1);
3576 }
3577#ifndef yyoverflow
3578 if (yyss != yyssa)
3579 YYSTACK_FREE (yyss);
3580#endif
3581#if YYERROR_VERBOSE
3582 if (yymsg != yymsgbuf)
3583 YYSTACK_FREE (yymsg);
3584#endif
3585 return yyresult;
3586}
3587#line 1241 "../../lib/expr/exparse.y"
3588
3589
3590const char *exop(size_t index) {
3591
3592 /* yytname is generated by the %token-table directive */
3593
3594 /* find the index of MINTOKEN */
3595 size_t minid;
3596 for (minid = 0; yytname[minid] != NULL; ++minid) {
3597 if (strcmp(yytname[minid], "MINTOKEN") == 0) {
3598 break;
3599 }
3600 }
3601
3602 assert(yytname[minid] != NULL
3603 && "failed to find MINTOKEN; incorrect token list in exparse.y?");
3604
3605 /* find the requested token */
3606 {
3607 size_t i, j;
3608 for (i = j = minid; yytname[i] != NULL; ++i) {
3609
3610 /* if this token is not a word, skip it */
3611 {
3612 size_t k;
3613 for (k = 0; yytname[i][k] != '\0'; ++k) {
3614 if (yytname[i][k] != '_' && !gv_isalnum(yytname[i][k])) {
3615 break;
3616 }
3617 }
3618 if (yytname[i][k] != '\0') {
3619 continue;
3620 }
3621 }
3622
3623 if (j == index + minid) {
3624 return yytname[i];
3625 }
3626 ++j;
3627 }
3628 }
3629
3630 /* failed to find the requested token */
3631 return NULL;
3632}
3633
3634void ex_error(const char *message) {
3635 exerror("%s", message);
3636}
3637
3638#include <expr/exgram.h>
CDT_API Dtmethod_t * Dtset
set with unique elements
Definition dthash.c:277
CDT_API Dt_t * dtview(Dt_t *, Dt_t *)
Definition dtview.c:91
CDT_API int dtclose(Dt_t *)
Definition dtclose.c:8
CDT_API Dtmethod_t * Dtoset
ordered set (self-adjusting tree)
Definition dttree.c:304
CDT_API Dt_t * dtopen(Dtdisc_t *, Dtmethod_t *)
Definition dtopen.c:9
static int binary(Exnode_t *l, Exnode_t *ex, Exnode_t *r, int arg)
Definition compile.c:1852
void exwarn(const char *format,...)
Definition exerror.c:79
void exerror(const char *format,...)
Definition exerror.c:62
Extype_t exeval(Expr_t *ex, Exnode_t *exnode, void *env)
Definition exeval.c:1987
Exstate_t expr
#define exunlex(p, c)
Definition exlib.h:125
char * exnospace(void)
Definition exnospace.c:25
#define UNSIGNED
Definition exparse.c:237
#define ELSE
Definition exparse.c:252
#define LABEL
Definition exparse.c:261
static const yytype_uint8 yyr1[]
Definition exparse.c:1160
#define STRING
Definition exparse.c:240
#define CHARACTER
Definition exparse.c:238
#define DYNAMIC
Definition exparse.c:251
#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Definition exparse.c:504
const char * exop(size_t index)
Definition exparse.c:3590
#define YYMAXDEPTH
Definition exparse.c:1380
#define SCANF
Definition exparse.c:273
#define YYSTACK_FREE
Definition exparse.c:566
#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
Definition exparse.c:1361
static const yytype_int8 yytranslate[]
Definition exparse.c:679
#define F2S
Definition exparse.c:285
#define YY_ASSERT(E)
Definition exparse.c:524
#define YY_(Msgid)
Definition exparse.c:465
#define SSCANF
Definition exparse.c:277
#define RSH
Definition exparse.c:306
#define ADDRESS
Definition exparse.c:242
#define YY_IGNORE_MAYBE_UNINITIALIZED_END
Definition exparse.c:505
#define YYNSTATES
Definition exparse.c:666
#define YYSTYPE
Definition exparse.c:66
#define YY_IGNORE_USELESS_CAST_END
Definition exparse.c:520
short yytype_int16
Definition exparse.c:389
#define OR
Definition exparse.c:299
#define YYUSE(E)
Definition exparse.c:487
#define PRE
Definition exparse.c:266
#define yychar
Definition exparse.c:74
#define GE
Definition exparse.c:304
#define YYEOF
Definition exparse.c:1203
#define YYABORT
Definition exparse.c:1206
#define MINTOKEN
Definition exparse.c:235
#define DEFAULT
Definition exparse.c:250
#define YYSTACK_BYTES(N)
Definition exparse.c:610
yytype_int16 yy_state_t
Definition exparse.c:452
#define NAME
Definition exparse.c:263
static const yytype_int16 yydefgoto[]
Definition exparse.c:878
#define YY_REDUCE_PRINT(Rule)
Definition exparse.c:1363
#define X2F
Definition exparse.c:294
#define YY_CAST(Type, Val)
Definition exparse.c:105
#define S2X
Definition exparse.c:293
#define WHILE
Definition exparse.c:283
static const yytype_int16 yypact[]
Definition exparse.c:798
#define yylex
Definition exparse.c:69
#define ITERATE
Definition exparse.c:257
#define MAXTOKEN
Definition exparse.c:312
#define YY_NULLPTR
Definition exparse.c:117
#define NE
Definition exparse.c:302
#define SRAND
Definition exparse.c:276
#define S2I
Definition exparse.c:290
#define SUB
Definition exparse.c:278
#define POS
Definition exparse.c:264
#define YYFINAL
Definition exparse.c:655
#define LSH
Definition exparse.c:305
#define FLOATING
Definition exparse.c:239
#define FOR
Definition exparse.c:254
#define RETURN
Definition exparse.c:272
#define I2X
Definition exparse.c:292
#define IN_OP
Definition exparse.c:307
static const yytype_int16 yypgoto[]
Definition exparse.c:868
#define SUBSTR
Definition exparse.c:279
static void yydestruct(const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Definition exparse.c:1621
#define TOKENS
Definition exparse.c:281
#define yyparse
Definition exparse.c:1650
#define yylval
Definition exparse.c:73
#define ITERATOR
Definition exparse.c:258
#define VOIDTYPE
Definition exparse.c:241
#define YYNTOKENS
Definition exparse.c:660
#define ID
Definition exparse.c:259
unsigned char yytype_uint8
Definition exparse.c:398
#define YY_STACK_PRINT(Bottom, Top)
Definition exparse.c:1362
#define YYSIZE_T
Definition exparse.c:439
#define YYSTACK_ALLOC_MAXIMUM
Definition exparse.c:568
#define yydebug
Definition exparse.c:71
#define YY_IGNORE_USELESS_CAST_BEGIN
Definition exparse.c:519
#define RAND
Definition exparse.c:271
static const yytype_int8 yyr2[]
Definition exparse.c:1180
int ex_parse(void)
#define PRINT
Definition exparse.c:267
#define CAST
Definition exparse.c:311
void * malloc(YYSIZE_T)
#define I2F
Definition exparse.c:286
#define INTEGER
Definition exparse.c:236
#define YYPTRDIFF_T
Definition exparse.c:425
#define SPRINTF
Definition exparse.c:275
#define yynerrs
Definition exparse.c:72
#define I2S
Definition exparse.c:287
EX_STYPE ex_lval
ex_tokentype
Definition exparse.c:153
#define CONSTANT
Definition exparse.c:247
static const yytype_int16 yytable[]
Definition exparse.c:890
#define LE
Definition exparse.c:303
#define MEMBER
Definition exparse.c:262
#define YYACCEPT
Definition exparse.c:1205
#define yytable_value_is_error(Yyn)
Definition exparse.c:793
#define S2B
Definition exparse.c:288
#define CALL
Definition exparse.c:245
#define GSUB
Definition exparse.c:256
#define PRAGMA
Definition exparse.c:265
#define YYTRANSLATE(YYX)
Definition exparse.c:674
#define UNARY
Definition exparse.c:308
#define UNSET
Definition exparse.c:282
#define CONTINUE
Definition exparse.c:248
#define XPRINT
Definition exparse.c:298
static const char *const yytname[]
Definition exparse.c:742
#define F2I
Definition exparse.c:284
#define X2S
Definition exparse.c:296
#define SPLIT
Definition exparse.c:274
#define EQ
Definition exparse.c:301
static const yytype_uint8 yystos[]
Definition exparse.c:1126
#define BREAK
Definition exparse.c:244
#define S2F
Definition exparse.c:289
#define IF
Definition exparse.c:260
#define PROCEDURE
Definition exparse.c:269
#define SWITCH
Definition exparse.c:280
#define AND
Definition exparse.c:300
#define DECLARE
Definition exparse.c:249
#define X2X
Definition exparse.c:297
#define EXIT
Definition exparse.c:253
#define F2X
Definition exparse.c:291
#define YYTERROR
Definition exparse.c:1230
#define YYPOPSTACK(N)
int yy_state_fast_t
Definition exparse.c:455
#define X2I
Definition exparse.c:295
unsigned short yytype_uint16
Definition exparse.c:409
#define PRINTF
Definition exparse.c:268
#define YYEMPTY
Definition exparse.c:1202
#define QUERY
Definition exparse.c:270
#define YYLAST
Definition exparse.c:657
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
Definition exparse.c:621
#define yypact_value_is_default(Yyn)
Definition exparse.c:788
#define YYINITDEPTH
Definition exparse.c:1369
void ex_error(const char *message)
Definition exparse.c:3634
signed char yytype_int8
Definition exparse.c:381
#define FUNCTION
Definition exparse.c:255
void free(void *)
#define YYERROR
Definition exparse.c:1207
#define CASE
Definition exparse.c:246
#define YYSIZEOF(X)
Definition exparse.c:449
static const yytype_int16 yycheck[]
Definition exparse.c:1007
#define YYSTACK_ALLOC
Definition exparse.c:565
#define ARRAY
Definition exparse.c:243
#define YYDPRINTF(Args)
Definition exparse.c:1360
#define INC
Definition exparse.c:309
static const yytype_uint8 yydefact[]
Definition exparse.c:834
#define yyerror
Definition exparse.c:70
#define DEC
Definition exparse.c:310
$1 lex
Definition exparse.y:204
static Dtdisc_t disc
Definition exparse.y:207
expr procedure type
Definition exparse.y:206
struct Exref_s Exref_t
Definition expr.h:87
int exisAssign(Exnode_t *)
#define exalloc(p, n)
Definition expr.h:79
EX_STYPE Extype_t
Definition expr.h:81
Exnode_t * excast(Expr_t *, Exnode_t *, long, Exnode_t *, int)
#define BUILTIN(t)
Definition expr.h:58
Exnode_t * exnewnode(Expr_t *, long, bool, long, Exnode_t *, Exnode_t *)
void exfreenode(Expr_t *, Exnode_t *)
char * extypename(Expr_t *p, long)
#define EX_UNDECLARED
Definition expr.h:45
#define INTEGRAL(t)
Definition expr.h:57
Extype_t exzero(long int)
Definition exzero.c:24
#define YYSTYPE
Definition gmlparse.c:66
short yytype_int16
Definition gmlparse.c:443
unsigned char yytype_uint8
Definition gmlparse.c:452
int yy_state_fast_t
Definition gmlparse.c:509
signed char yytype_int8
Definition gmlparse.c:435
yytype_int8 yy_state_t
Definition gmlparse.c:506
node NULL
Definition grammar.y:163
replacements for ctype.h functions
static bool gv_isalnum(int c)
Definition gv_ctype.h:43
char * pre
Definition maze.c:32
static bool streq(const char *a, const char *b)
are a and b equal?
Definition streq.h:11
Definition expr.h:93
long type
Definition expr.h:97
long lex
Definition expr.h:95
char name[EX_NAMELEN]
Definition expr.h:101
long op
operator
Definition expr.h:150
long type
value type
Definition expr.h:149
Exdata_t data
Definition expr.h:158
Dt_t * symbols
Definition expr.h:222
Vmalloc_t * vm
Definition expr.h:224
Exid_t * symbol
Definition expr.h:107
Exref_t * next
Definition expr.h:106
Exnode_t * index
Definition expr.h:108
int assigned
Definition exlib.h:159
Expr_t * program
Definition exlib.h:156
Switch_t * swstate
Definition exlib.h:160
Exid_t * id
Definition exlib.h:152
Exref_t * refs
Definition exlib.h:158
long declare
current declaration type
Definition exlib.h:153
int nolabel
Definition exlib.h:154
Exnode_t * procedure
Definition exlib.h:157
size_t cap
Definition exlib.h:137
int def
Definition exlib.h:138
Exnode_t * defcase
Definition exlib.h:134
struct Switch_s * prev
Definition exlib.h:131
long type
switch test type
Definition exlib.h:139
Exnode_t * lastcase
Definition exlib.h:133
size_t cur
Definition exlib.h:136
Extype_t ** base
Definition exlib.h:135
Exnode_t * firstcase
Definition exlib.h:132
Definition legal.c:50
int key
Definition cdt.h:85
static mytime_t T
Definition timing.c:41
struct Exref_s * reference
Definition exparse.c:322
struct Exid_s * id
Definition exparse.c:323
char * string
Definition exparse.c:326
long long integer
Definition exparse.c:324
double floating
Definition exparse.c:321
struct Exnode_s * expr
Definition exparse.c:320
int op
Definition exparse.c:325
Exnode_t * left
Definition expr.h:122
Exnode_t * right
Definition expr.h:123
struct Exdata_u::@87 select
Exid_t * reference
Definition expr.h:117
Exnode_t * next
Definition expr.h:129
Exid_t * symbol
Definition expr.h:135
struct Exdata_u::@88 variable
struct Exdata_u::@86 operand
Exnode_t * dyna
Definition expr.h:138
Exnode_t * index
Definition expr.h:137
char * vmstrdup(Vmalloc_t *, const char *)
Definition vmstrdup.c:19