1 /* A Bison parser, made by GNU Bison 2.7. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
35
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
42
43 /* Identify Bison output. */
44 #define YYBISON 1
45
46 /* Bison version. */
47 #define YYBISON_VERSION "2.7"
48
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers. */
53 #define YYPURE 0
54
55 /* Push parsers. */
56 #define YYPUSH 0
57
58 /* Pull parsers. */
59 #define YYPULL 1
60
61
62 /* Substitute the variable and function names. */
63 #define yyparse so_evalparse
64 #define yylex so_evallex
65 #define yyerror so_evalerror
66 #define yylval so_evallval
67 #define yychar so_evalchar
68 #define yydebug so_evaldebug
69 #define yynerrs so_evalnerrs
70
71 /* Copy the first part of user declarations. */
72
73
74 /**************************************************************************\
75 * Copyright (c) Kongsberg Oil & Gas Technologies AS
76 * All rights reserved.
77 *
78 * Redistribution and use in source and binary forms, with or without
79 * modification, are permitted provided that the following conditions are
80 * met:
81 *
82 * Redistributions of source code must retain the above copyright notice,
83 * this list of conditions and the following disclaimer.
84 *
85 * Redistributions in binary form must reproduce the above copyright
86 * notice, this list of conditions and the following disclaimer in the
87 * documentation and/or other materials provided with the distribution.
88 *
89 * Neither the name of the copyright holder nor the names of its
90 * contributors may be used to endorse or promote products derived from
91 * this software without specific prior written permission.
92 *
93 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
94 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
95 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
96 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
97 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
98 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
99 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
100 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
101 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
102 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
103 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
104 \**************************************************************************/
105
106 /*
107 * Syntax analyzer for SoCalculator expressions.
108 *
109 * Compile with
110 *
111 * bison -p so_eval -o evaluator_tab.c -l evaluator.y
112 *
113 * ..with GNU bison version 1.27 (which is what we have on nfs.sim.no)
114 * then patch the resulting evaluator_tab.c file with
115 *
116 * patch -p0 < evaluator_tab.diff
117 *
118 * The patch is explained at the top of the diff file.
119 */
120
121 #ifdef HAVE_CONFIG_H
122 #include <config.h>
123 #endif /* HAVE_CONFIG_H */
124 #include <assert.h>
125 #include <stdlib.h>
126 #include <string.h>
127 #ifdef HAVE_IO_H
128 /* isatty() on windows */
129 #include <io.h>
130 #endif /* HAVE_IO_H */
131 #include <Inventor/C/basic.h>
132 #include "engines/evaluator.h"
133
134
135
136 # ifndef YY_NULL
137 # if defined __cplusplus && 201103L <= __cplusplus
138 # define YY_NULL nullptr
139 # else
140 # define YY_NULL 0
141 # endif
142 # endif
143
144 /* Enabling verbose error messages. */
145 #ifdef YYERROR_VERBOSE
146 # undef YYERROR_VERBOSE
147 # define YYERROR_VERBOSE 1
148 #else
149 # define YYERROR_VERBOSE 0
150 #endif
151
152
153 /* Enabling traces. */
154 #ifndef YYDEBUG
155 # define YYDEBUG 0
156 #endif
157 #if YYDEBUG
158 extern int so_evaldebug;
159 #endif
160
161 /* Tokens. */
162 #ifndef YYTOKENTYPE
163 # define YYTOKENTYPE
164 /* Put the tokens into the symbol table, so that GDB and other debuggers
165 know about them. */
166 enum yytokentype {
167 LEX_VALUE = 258,
168 LEX_TMP_FLT_REG = 259,
169 LEX_IN_FLT_REG = 260,
170 LEX_OUT_FLT_REG = 261,
171 LEX_TMP_VEC_REG = 262,
172 LEX_IN_VEC_REG = 263,
173 LEX_OUT_VEC_REG = 264,
174 LEX_COMPARE = 265,
175 LEX_FLTFUNC = 266,
176 LEX_ATAN2 = 267,
177 LEX_POW = 268,
178 LEX_FMOD = 269,
179 LEX_LEN = 270,
180 LEX_CROSS = 271,
181 LEX_DOT = 272,
182 LEX_NORMALIZE = 273,
183 LEX_VEC3F = 274,
184 LEX_ERROR = 275,
185 LEX_OR = 276,
186 LEX_AND = 277,
187 LEX_NEQ = 278,
188 LEX_EQ = 279,
189 UNARY = 280
190 };
191 #endif
192
193
194 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
195 typedef union YYSTYPE
196 {
197
198
199 int id;
200 float value;
201 char reg;
202 so_eval_node *node;
203
204
205
206 } YYSTYPE;
207 # define YYSTYPE_IS_TRIVIAL 1
208 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
209 # define YYSTYPE_IS_DECLARED 1
210 #endif
211
212 extern YYSTYPE so_evallval;
213
214 #ifdef YYPARSE_PARAM
215 #if defined __STDC__ || defined __cplusplus
216 int so_evalparse (void *YYPARSE_PARAM);
217 #else
218 int so_evalparse ();
219 #endif
220 #else /* ! YYPARSE_PARAM */
221 #if defined __STDC__ || defined __cplusplus
222 int so_evalparse (void);
223 #else
224 int so_evalparse ();
225 #endif
226 #endif /* ! YYPARSE_PARAM */
227
228
229
230 /* Copy the second part of user declarations. */
231
232
233 static char * get_regname(char reg, int regtype);
234 enum { REGTYPE_IN, REGTYPE_OUT, REGTYPE_TMP };
235 static so_eval_node *root_node;
236 static int so_evalerror(const char *);
237 static int so_evallex(void);
238
239
240
241 #ifdef short
242 # undef short
243 #endif
244
245 #ifdef YYTYPE_UINT8
246 typedef YYTYPE_UINT8 yytype_uint8;
247 #else
248 typedef unsigned char yytype_uint8;
249 #endif
250
251 #ifdef YYTYPE_INT8
252 typedef YYTYPE_INT8 yytype_int8;
253 #elif (defined __STDC__ || defined __C99__FUNC__ \
254 || defined __cplusplus || defined _MSC_VER)
255 typedef signed char yytype_int8;
256 #else
257 typedef short int yytype_int8;
258 #endif
259
260 #ifdef YYTYPE_UINT16
261 typedef YYTYPE_UINT16 yytype_uint16;
262 #else
263 typedef unsigned short int yytype_uint16;
264 #endif
265
266 #ifdef YYTYPE_INT16
267 typedef YYTYPE_INT16 yytype_int16;
268 #else
269 typedef short int yytype_int16;
270 #endif
271
272 #ifndef YYSIZE_T
273 # ifdef __SIZE_TYPE__
274 # define YYSIZE_T __SIZE_TYPE__
275 # elif defined size_t
276 # define YYSIZE_T size_t
277 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
278 || defined __cplusplus || defined _MSC_VER)
279 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
280 # define YYSIZE_T size_t
281 # else
282 # define YYSIZE_T unsigned int
283 # endif
284 #endif
285
286 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
287
288 #ifndef YY_
289 # if defined YYENABLE_NLS && YYENABLE_NLS
290 # if ENABLE_NLS
291 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
292 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
293 # endif
294 # endif
295 # ifndef YY_
296 # define YY_(Msgid) Msgid
297 # endif
298 #endif
299
300 /* Suppress unused-variable warnings by "using" E. */
301 #if ! defined lint || defined __GNUC__
302 # define YYUSE(E) ((void) (E))
303 #else
304 # define YYUSE(E) /* empty */
305 #endif
306
307 /* Identity function, used to suppress warnings about constant conditions. */
308 #ifndef lint
309 # define YYID(N) (N)
310 #else
311 #if (defined __STDC__ || defined __C99__FUNC__ \
312 || defined __cplusplus || defined _MSC_VER)
313 static int
YYID(int yyi)314 YYID (int yyi)
315 #else
316 static int
317 YYID (yyi)
318 int yyi;
319 #endif
320 {
321 return yyi;
322 }
323 #endif
324
325 #if ! defined yyoverflow || YYERROR_VERBOSE
326
327 /* The parser invokes alloca or malloc; define the necessary symbols. */
328
329 # ifdef YYSTACK_USE_ALLOCA
330 # if YYSTACK_USE_ALLOCA
331 # ifdef __GNUC__
332 # define YYSTACK_ALLOC __builtin_alloca
333 # elif defined __BUILTIN_VA_ARG_INCR
334 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
335 # elif defined _AIX
336 # define YYSTACK_ALLOC __alloca
337 # elif defined _MSC_VER
338 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
339 # define alloca _alloca
340 # else
341 # define YYSTACK_ALLOC alloca
342 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
343 || defined __cplusplus || defined _MSC_VER)
344 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
345 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
346 # ifndef EXIT_SUCCESS
347 # define EXIT_SUCCESS 0
348 # endif
349 # endif
350 # endif
351 # endif
352 # endif
353
354 # ifdef YYSTACK_ALLOC
355 /* Pacify GCC's `empty if-body' warning. */
356 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
357 # ifndef YYSTACK_ALLOC_MAXIMUM
358 /* The OS might guarantee only one guard page at the bottom of the stack,
359 and a page size can be as small as 4096 bytes. So we cannot safely
360 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
361 to allow for a few compiler-allocated temporary stack slots. */
362 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
363 # endif
364 # else
365 # define YYSTACK_ALLOC YYMALLOC
366 # define YYSTACK_FREE YYFREE
367 # ifndef YYSTACK_ALLOC_MAXIMUM
368 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
369 # endif
370 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
371 && ! ((defined YYMALLOC || defined malloc) \
372 && (defined YYFREE || defined free)))
373 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
374 # ifndef EXIT_SUCCESS
375 # define EXIT_SUCCESS 0
376 # endif
377 # endif
378 # ifndef YYMALLOC
379 # define YYMALLOC malloc
380 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
381 || defined __cplusplus || defined _MSC_VER)
382 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
383 # endif
384 # endif
385 # ifndef YYFREE
386 # define YYFREE free
387 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
388 || defined __cplusplus || defined _MSC_VER)
389 void free (void *); /* INFRINGES ON USER NAME SPACE */
390 # endif
391 # endif
392 # endif
393 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
394
395
396 #if (! defined yyoverflow \
397 && (! defined __cplusplus \
398 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
399
400 /* A type that is properly aligned for any stack member. */
401 union yyalloc
402 {
403 yytype_int16 yyss_alloc;
404 YYSTYPE yyvs_alloc;
405 };
406
407 /* The size of the maximum gap between one aligned stack and the next. */
408 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
409
410 /* The size of an array large to enough to hold all stacks, each with
411 N elements. */
412 # define YYSTACK_BYTES(N) \
413 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
414 + YYSTACK_GAP_MAXIMUM)
415
416 # define YYCOPY_NEEDED 1
417
418 /* Relocate STACK from its old location to the new one. The
419 local variables YYSIZE and YYSTACKSIZE give the old and new number of
420 elements in the stack, and YYPTR gives the new location of the
421 stack. Advance YYPTR to a properly aligned location for the next
422 stack. */
423 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
424 do \
425 { \
426 YYSIZE_T yynewbytes; \
427 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
428 Stack = &yyptr->Stack_alloc; \
429 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
430 yyptr += yynewbytes / sizeof (*yyptr); \
431 } \
432 while (YYID (0))
433
434 #endif
435
436 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
437 /* Copy COUNT objects from SRC to DST. The source and destination do
438 not overlap. */
439 # ifndef YYCOPY
440 # if defined __GNUC__ && 1 < __GNUC__
441 # define YYCOPY(Dst, Src, Count) \
442 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
443 # else
444 # define YYCOPY(Dst, Src, Count) \
445 do \
446 { \
447 YYSIZE_T yyi; \
448 for (yyi = 0; yyi < (Count); yyi++) \
449 (Dst)[yyi] = (Src)[yyi]; \
450 } \
451 while (YYID (0))
452 # endif
453 # endif
454 #endif /* !YYCOPY_NEEDED */
455
456 /* YYFINAL -- State number of the termination state. */
457 #define YYFINAL 11
458 /* YYLAST -- Last index in YYTABLE. */
459 #define YYLAST 500
460
461 /* YYNTOKENS -- Number of terminals. */
462 #define YYNTOKENS 41
463 /* YYNNTS -- Number of nonterminals. */
464 #define YYNNTS 8
465 /* YYNRULES -- Number of rules. */
466 #define YYNRULES 60
467 /* YYNRULES -- Number of states. */
468 #define YYNSTATES 157
469
470 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
471 #define YYUNDEFTOK 2
472 #define YYMAXUTOK 280
473
474 #define YYTRANSLATE(YYX) \
475 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
476
477 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
478 static const yytype_uint8 yytranslate[] =
479 {
480 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
481 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
482 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
483 2, 2, 2, 39, 2, 2, 2, 38, 2, 2,
484 23, 24, 36, 34, 20, 35, 2, 37, 2, 2,
485 2, 2, 2, 2, 2, 2, 2, 2, 29, 25,
486 2, 27, 2, 28, 2, 2, 2, 2, 2, 2,
487 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
488 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
489 2, 21, 2, 22, 2, 2, 2, 2, 2, 2,
490 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
491 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
492 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
493 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
494 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
495 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
496 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
497 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
498 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
499 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
500 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
501 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
505 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
506 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
507 15, 16, 17, 18, 19, 26, 30, 31, 32, 33,
508 40
509 };
510
511 #if YYDEBUG
512 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
513 YYRHS. */
514 static const yytype_uint8 yyprhs[] =
515 {
516 0, 0, 3, 7, 9, 10, 14, 18, 20, 22,
517 27, 32, 34, 36, 42, 48, 54, 58, 62, 66,
518 70, 74, 81, 88, 95, 98, 102, 107, 112, 119,
519 121, 123, 125, 130, 135, 140, 142, 148, 154, 160,
520 164, 168, 172, 176, 180, 187, 190, 194, 199, 201,
521 203, 205, 214, 218, 222, 226, 230, 234, 238, 242,
522 245
523 };
524
525 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
526 static const yytype_int8 yyrhs[] =
527 {
528 42, 0, -1, 42, 25, 43, -1, 43, -1, -1,
529 44, 27, 46, -1, 45, 27, 47, -1, 4, -1,
530 6, -1, 7, 21, 3, 22, -1, 9, 21, 3,
531 22, -1, 7, -1, 9, -1, 48, 28, 46, 29,
532 46, -1, 46, 28, 46, 29, 46, -1, 47, 28,
533 46, 29, 46, -1, 46, 34, 46, -1, 46, 35,
534 46, -1, 46, 37, 46, -1, 46, 36, 46, -1,
535 46, 38, 46, -1, 12, 23, 46, 20, 46, 24,
536 -1, 13, 23, 46, 20, 46, 24, -1, 14, 23,
537 46, 20, 46, 24, -1, 35, 46, -1, 23, 46,
538 24, -1, 11, 23, 46, 24, -1, 15, 23, 47,
539 24, -1, 17, 23, 47, 20, 47, 24, -1, 4,
540 -1, 6, -1, 5, -1, 7, 21, 3, 22, -1,
541 8, 21, 3, 22, -1, 9, 21, 3, 22, -1,
542 3, -1, 48, 28, 47, 29, 47, -1, 46, 28,
543 47, 29, 47, -1, 47, 28, 47, 29, 47, -1,
544 47, 34, 47, -1, 47, 35, 47, -1, 47, 36,
545 46, -1, 47, 37, 46, -1, 46, 36, 47, -1,
546 16, 23, 47, 20, 47, 24, -1, 35, 47, -1,
547 23, 47, 24, -1, 18, 23, 47, 24, -1, 7,
548 -1, 9, -1, 8, -1, 19, 23, 46, 20, 46,
549 20, 46, 24, -1, 46, 33, 46, -1, 46, 32,
550 46, -1, 47, 33, 47, -1, 47, 32, 47, -1,
551 46, 10, 46, -1, 48, 31, 48, -1, 48, 30,
552 48, -1, 39, 48, -1, 23, 48, 24, -1
553 };
554
555 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
556 static const yytype_uint8 yyrline[] =
557 {
558 0, 114, 114, 116, 119, 120, 121, 124, 125, 126,
559 128, 132, 133, 136, 138, 140, 143, 144, 145, 146,
560 147, 148, 150, 152, 155, 156, 157, 158, 159, 161,
561 162, 163, 164, 166, 168, 170, 174, 176, 178, 181,
562 182, 183, 184, 185, 186, 189, 190, 191, 194, 195,
563 196, 197, 201, 202, 203, 204, 205, 206, 207, 208,
564 209
565 };
566 #endif
567
568 #if YYDEBUG || YYERROR_VERBOSE || 0
569 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
570 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
571 static const char *const yytname[] =
572 {
573 "$end", "error", "$undefined", "LEX_VALUE", "LEX_TMP_FLT_REG",
574 "LEX_IN_FLT_REG", "LEX_OUT_FLT_REG", "LEX_TMP_VEC_REG", "LEX_IN_VEC_REG",
575 "LEX_OUT_VEC_REG", "LEX_COMPARE", "LEX_FLTFUNC", "LEX_ATAN2", "LEX_POW",
576 "LEX_FMOD", "LEX_LEN", "LEX_CROSS", "LEX_DOT", "LEX_NORMALIZE",
577 "LEX_VEC3F", "','", "'['", "']'", "'('", "')'", "';'", "LEX_ERROR",
578 "'='", "'?'", "':'", "LEX_OR", "LEX_AND", "LEX_NEQ", "LEX_EQ", "'+'",
579 "'-'", "'*'", "'/'", "'%'", "'!'", "UNARY", "$accept", "expression",
580 "subexpression", "fltlhs", "veclhs", "fltstatement", "vecstatement",
581 "boolstatement", YY_NULL
582 };
583 #endif
584
585 # ifdef YYPRINT
586 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
587 token YYLEX-NUM. */
588 static const yytype_uint16 yytoknum[] =
589 {
590 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
591 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
592 44, 91, 93, 40, 41, 59, 275, 61, 63, 58,
593 276, 277, 278, 279, 43, 45, 42, 47, 37, 33,
594 280
595 };
596 # endif
597
598 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
599 static const yytype_uint8 yyr1[] =
600 {
601 0, 41, 42, 42, 43, 43, 43, 44, 44, 44,
602 44, 45, 45, 46, 46, 46, 46, 46, 46, 46,
603 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
604 46, 46, 46, 46, 46, 46, 47, 47, 47, 47,
605 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
606 47, 47, 48, 48, 48, 48, 48, 48, 48, 48,
607 48
608 };
609
610 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
611 static const yytype_uint8 yyr2[] =
612 {
613 0, 2, 3, 1, 0, 3, 3, 1, 1, 4,
614 4, 1, 1, 5, 5, 5, 3, 3, 3, 3,
615 3, 6, 6, 6, 2, 3, 4, 4, 6, 1,
616 1, 1, 4, 4, 4, 1, 5, 5, 5, 3,
617 3, 3, 3, 3, 6, 2, 3, 4, 1, 1,
618 1, 8, 3, 3, 3, 3, 3, 3, 3, 2,
619 3
620 };
621
622 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
623 Performed when YYTABLE doesn't specify something else to do. Zero
624 means the default is an error. */
625 static const yytype_uint8 yydefact[] =
626 {
627 4, 7, 8, 11, 12, 0, 3, 0, 0, 0,
628 0, 1, 4, 0, 0, 0, 0, 2, 35, 29,
629 31, 30, 48, 50, 49, 0, 0, 0, 0, 0,
630 0, 0, 0, 0, 0, 0, 0, 5, 0, 0,
631 0, 6, 9, 10, 0, 0, 0, 0, 0, 0,
632 0, 0, 0, 0, 0, 0, 0, 0, 0, 24,
633 45, 59, 0, 0, 0, 0, 0, 0, 0, 0,
634 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
635 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
636 0, 0, 0, 25, 46, 60, 56, 0, 0, 53,
637 52, 16, 17, 19, 43, 18, 20, 0, 0, 55,
638 54, 39, 40, 41, 42, 0, 0, 58, 57, 32,
639 33, 34, 26, 0, 0, 0, 27, 0, 0, 47,
640 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
641 0, 0, 0, 14, 37, 15, 38, 13, 36, 21,
642 22, 23, 44, 28, 0, 0, 51
643 };
644
645 /* YYDEFGOTO[NTERM-NUM]. */
646 static const yytype_int8 yydefgoto[] =
647 {
648 -1, 5, 6, 7, 8, 40, 38, 39
649 };
650
651 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
652 STATE-NUM. */
653 #define YYPACT_NINF -34
654 static const yytype_int16 yypact[] =
655 {
656 85, -34, -34, 2, 12, 6, -34, -12, 16, 42,
657 45, -34, 85, 121, 121, 39, 51, -34, -34, -34,
658 -34, -34, 53, 54, 60, 59, 62, 67, 78, 79,
659 90, 91, 92, 93, 121, 121, 121, 34, -23, 10,
660 34, -23, -34, -34, 80, 116, 118, 121, 121, 121,
661 121, 121, 121, 121, 121, 121, -8, 377, 56, -34,
662 -34, -34, 121, 121, 121, 121, 121, 121, 121, 121,
663 121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
664 121, 73, 101, 109, 138, 157, 168, 187, 391, 353,
665 363, 405, 198, -34, -34, -34, 342, 217, 443, 342,
666 342, -19, -19, -34, -34, -34, -34, 228, 453, 72,
667 72, -29, -29, -6, -6, 248, 463, 111, -34, -34,
668 -34, -34, -34, 121, 121, 121, -34, 121, 121, -34,
669 121, 121, 121, 121, 121, 121, 121, 263, 278, 293,
670 419, 433, 312, 34, -23, 34, -23, 34, -23, -34,
671 -34, -34, -34, -34, 121, 327, -34
672 };
673
674 /* YYPGOTO[NTERM-NUM]. */
675 static const yytype_int16 yypgoto[] =
676 {
677 -34, -34, 131, -34, -34, -13, 25, -33
678 };
679
680 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
681 positive, shift that token. If negative, reduce the rule which
682 number is the opposite. If YYTABLE_NINF, syntax error. */
683 #define YYTABLE_NINF -1
684 static const yytype_uint8 yytable[] =
685 {
686 37, 58, 62, 61, 62, 71, 11, 76, 77, 72,
687 73, 74, 75, 76, 77, 13, 93, 68, 69, 70,
688 63, 56, 59, 9, 64, 65, 66, 67, 68, 69,
689 70, 12, 70, 10, 84, 85, 86, 87, 78, 41,
690 79, 80, 92, 14, 62, 15, 117, 118, 16, 96,
691 97, 99, 100, 101, 102, 103, 105, 106, 107, 57,
692 60, 42, 63, 113, 114, 115, 64, 65, 66, 67,
693 68, 69, 70, 43, 44, 45, 88, 89, 90, 91,
694 95, 46, 47, 81, 78, 48, 79, 80, 98, 1,
695 49, 2, 3, 104, 4, 119, 108, 109, 110, 111,
696 112, 50, 51, 116, 72, 73, 74, 75, 76, 77,
697 137, 138, 139, 52, 53, 54, 55, 142, 143, 82,
698 145, 83, 147, 120, 18, 19, 20, 21, 22, 23,
699 24, 121, 25, 26, 27, 28, 29, 30, 31, 32,
700 33, 155, 80, 17, 34, 0, 0, 0, 62, 0,
701 0, 0, 140, 141, 0, 0, 35, 144, 0, 146,
702 36, 148, 122, 0, 0, 0, 63, 62, 0, 0,
703 64, 65, 66, 67, 68, 69, 70, 123, 62, 0,
704 0, 0, 0, 0, 0, 63, 0, 0, 124, 64,
705 65, 66, 67, 68, 69, 70, 63, 62, 0, 0,
706 64, 65, 66, 67, 68, 69, 70, 125, 62, 0,
707 0, 0, 0, 0, 0, 63, 0, 0, 130, 64,
708 65, 66, 67, 68, 69, 70, 63, 62, 0, 0,
709 64, 65, 66, 67, 68, 69, 70, 0, 62, 0,
710 0, 0, 0, 0, 0, 63, 131, 0, 0, 64,
711 65, 66, 67, 68, 69, 70, 63, 133, 62, 0,
712 64, 65, 66, 67, 68, 69, 70, 0, 0, 0,
713 0, 0, 0, 62, 0, 0, 63, 135, 0, 0,
714 64, 65, 66, 67, 68, 69, 70, 149, 62, 0,
715 0, 63, 0, 0, 0, 64, 65, 66, 67, 68,
716 69, 70, 150, 62, 0, 0, 63, 0, 0, 0,
717 64, 65, 66, 67, 68, 69, 70, 151, 0, 0,
718 0, 63, 62, 0, 0, 64, 65, 66, 67, 68,
719 69, 70, 154, 0, 0, 0, 0, 62, 0, 0,
720 63, 0, 0, 0, 64, 65, 66, 67, 68, 69,
721 70, 156, 62, 0, 0, 63, 0, 0, 0, 64,
722 65, 66, 67, 68, 69, 70, 0, 0, 0, 0,
723 0, 0, 0, 127, 64, 65, 66, 67, 68, 69,
724 70, 71, 0, 128, 0, 72, 73, 74, 75, 76,
725 77, 71, 0, 0, 0, 72, 73, 74, 75, 76,
726 77, 94, 0, 0, 0, 71, 0, 0, 0, 72,
727 73, 74, 75, 76, 77, 126, 0, 0, 0, 71,
728 0, 0, 0, 72, 73, 74, 75, 76, 77, 129,
729 0, 0, 0, 71, 0, 0, 0, 72, 73, 74,
730 75, 76, 77, 152, 0, 0, 0, 71, 0, 0,
731 0, 72, 73, 74, 75, 76, 77, 153, 0, 0,
732 0, 71, 0, 0, 0, 72, 73, 74, 75, 76,
733 77, 71, 132, 0, 0, 72, 73, 74, 75, 76,
734 77, 71, 134, 0, 0, 72, 73, 74, 75, 76,
735 77, 71, 136, 0, 0, 72, 73, 74, 75, 76,
736 77
737 };
738
739 #define yypact_value_is_default(Yystate) \
740 (!!((Yystate) == (-34)))
741
742 #define yytable_value_is_error(Yytable_value) \
743 YYID (0)
744
745 static const yytype_int16 yycheck[] =
746 {
747 13, 34, 10, 36, 10, 28, 0, 36, 37, 32,
748 33, 34, 35, 36, 37, 27, 24, 36, 37, 38,
749 28, 34, 35, 21, 32, 33, 34, 35, 36, 37,
750 38, 25, 38, 21, 47, 48, 49, 50, 28, 14,
751 30, 31, 55, 27, 10, 3, 79, 80, 3, 62,
752 63, 64, 65, 66, 67, 68, 69, 70, 71, 34,
753 35, 22, 28, 76, 77, 78, 32, 33, 34, 35,
754 36, 37, 38, 22, 21, 21, 51, 52, 53, 54,
755 24, 21, 23, 3, 28, 23, 30, 31, 63, 4,
756 23, 6, 7, 68, 9, 22, 71, 72, 73, 74,
757 75, 23, 23, 78, 32, 33, 34, 35, 36, 37,
758 123, 124, 125, 23, 23, 23, 23, 130, 131, 3,
759 133, 3, 135, 22, 3, 4, 5, 6, 7, 8,
760 9, 22, 11, 12, 13, 14, 15, 16, 17, 18,
761 19, 154, 31, 12, 23, -1, -1, -1, 10, -1,
762 -1, -1, 127, 128, -1, -1, 35, 132, -1, 134,
763 39, 136, 24, -1, -1, -1, 28, 10, -1, -1,
764 32, 33, 34, 35, 36, 37, 38, 20, 10, -1,
765 -1, -1, -1, -1, -1, 28, -1, -1, 20, 32,
766 33, 34, 35, 36, 37, 38, 28, 10, -1, -1,
767 32, 33, 34, 35, 36, 37, 38, 20, 10, -1,
768 -1, -1, -1, -1, -1, 28, -1, -1, 20, 32,
769 33, 34, 35, 36, 37, 38, 28, 10, -1, -1,
770 32, 33, 34, 35, 36, 37, 38, -1, 10, -1,
771 -1, -1, -1, -1, -1, 28, 29, -1, -1, 32,
772 33, 34, 35, 36, 37, 38, 28, 29, 10, -1,
773 32, 33, 34, 35, 36, 37, 38, -1, -1, -1,
774 -1, -1, -1, 10, -1, -1, 28, 29, -1, -1,
775 32, 33, 34, 35, 36, 37, 38, 24, 10, -1,
776 -1, 28, -1, -1, -1, 32, 33, 34, 35, 36,
777 37, 38, 24, 10, -1, -1, 28, -1, -1, -1,
778 32, 33, 34, 35, 36, 37, 38, 24, -1, -1,
779 -1, 28, 10, -1, -1, 32, 33, 34, 35, 36,
780 37, 38, 20, -1, -1, -1, -1, 10, -1, -1,
781 28, -1, -1, -1, 32, 33, 34, 35, 36, 37,
782 38, 24, 10, -1, -1, 28, -1, -1, -1, 32,
783 33, 34, 35, 36, 37, 38, -1, -1, -1, -1,
784 -1, -1, -1, 20, 32, 33, 34, 35, 36, 37,
785 38, 28, -1, 20, -1, 32, 33, 34, 35, 36,
786 37, 28, -1, -1, -1, 32, 33, 34, 35, 36,
787 37, 24, -1, -1, -1, 28, -1, -1, -1, 32,
788 33, 34, 35, 36, 37, 24, -1, -1, -1, 28,
789 -1, -1, -1, 32, 33, 34, 35, 36, 37, 24,
790 -1, -1, -1, 28, -1, -1, -1, 32, 33, 34,
791 35, 36, 37, 24, -1, -1, -1, 28, -1, -1,
792 -1, 32, 33, 34, 35, 36, 37, 24, -1, -1,
793 -1, 28, -1, -1, -1, 32, 33, 34, 35, 36,
794 37, 28, 29, -1, -1, 32, 33, 34, 35, 36,
795 37, 28, 29, -1, -1, 32, 33, 34, 35, 36,
796 37, 28, 29, -1, -1, 32, 33, 34, 35, 36,
797 37
798 };
799
800 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
801 symbol of state STATE-NUM. */
802 static const yytype_uint8 yystos[] =
803 {
804 0, 4, 6, 7, 9, 42, 43, 44, 45, 21,
805 21, 0, 25, 27, 27, 3, 3, 43, 3, 4,
806 5, 6, 7, 8, 9, 11, 12, 13, 14, 15,
807 16, 17, 18, 19, 23, 35, 39, 46, 47, 48,
808 46, 47, 22, 22, 21, 21, 21, 23, 23, 23,
809 23, 23, 23, 23, 23, 23, 46, 47, 48, 46,
810 47, 48, 10, 28, 32, 33, 34, 35, 36, 37,
811 38, 28, 32, 33, 34, 35, 36, 37, 28, 30,
812 31, 3, 3, 3, 46, 46, 46, 46, 47, 47,
813 47, 47, 46, 24, 24, 24, 46, 46, 47, 46,
814 46, 46, 46, 46, 47, 46, 46, 46, 47, 47,
815 47, 47, 47, 46, 46, 46, 47, 48, 48, 22,
816 22, 22, 24, 20, 20, 20, 24, 20, 20, 24,
817 20, 29, 29, 29, 29, 29, 29, 46, 46, 46,
818 47, 47, 46, 46, 47, 46, 47, 46, 47, 24,
819 24, 24, 24, 24, 20, 46, 24
820 };
821
822 #define yyerrok (yyerrstatus = 0)
823 #define yyclearin (yychar = YYEMPTY)
824 #define YYEMPTY (-2)
825 #define YYEOF 0
826
827 #define YYACCEPT goto yyacceptlab
828 #define YYABORT goto yyabortlab
829 #define YYERROR goto yyerrorlab
830
831
832 /* Like YYERROR except do call yyerror. This remains here temporarily
833 to ease the transition to the new meaning of YYERROR, for GCC.
834 Once GCC version 2 has supplanted version 1, this can go. However,
835 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
836 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
837 discussed. */
838
839 #define YYFAIL goto yyerrlab
840 #if defined YYFAIL
841 /* This is here to suppress warnings from the GCC cpp's
842 -Wunused-macros. Normally we don't worry about that warning, but
843 some users do, and we want to make it easy for users to remove
844 YYFAIL uses, which will produce warnings from Bison 2.5. */
845 #endif
846
847 #define YYRECOVERING() (!!yyerrstatus)
848
849 #define YYBACKUP(Token, Value) \
850 do \
851 if (yychar == YYEMPTY) \
852 { \
853 yychar = (Token); \
854 yylval = (Value); \
855 YYPOPSTACK (yylen); \
856 yystate = *yyssp; \
857 goto yybackup; \
858 } \
859 else \
860 { \
861 yyerror (YY_("syntax error: cannot back up")); \
862 YYERROR; \
863 } \
864 while (YYID (0))
865
866 /* Error token number */
867 #define YYTERROR 1
868 #define YYERRCODE 256
869
870
871 /* This macro is provided for backward compatibility. */
872 #ifndef YY_LOCATION_PRINT
873 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
874 #endif
875
876
877 /* YYLEX -- calling `yylex' with the right arguments. */
878 #ifdef YYLEX_PARAM
879 # define YYLEX yylex (YYLEX_PARAM)
880 #else
881 # define YYLEX yylex ()
882 #endif
883
884 /* Enable debugging if requested. */
885 #if YYDEBUG
886
887 # ifndef YYFPRINTF
888 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
889 # define YYFPRINTF fprintf
890 # endif
891
892 # define YYDPRINTF(Args) \
893 do { \
894 if (yydebug) \
895 YYFPRINTF Args; \
896 } while (YYID (0))
897
898 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
899 do { \
900 if (yydebug) \
901 { \
902 YYFPRINTF (stderr, "%s ", Title); \
903 yy_symbol_print (stderr, \
904 Type, Value); \
905 YYFPRINTF (stderr, "\n"); \
906 } \
907 } while (YYID (0))
908
909
910 /*--------------------------------.
911 | Print this symbol on YYOUTPUT. |
912 `--------------------------------*/
913
914 /*ARGSUSED*/
915 #if (defined __STDC__ || defined __C99__FUNC__ \
916 || defined __cplusplus || defined _MSC_VER)
917 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)918 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
919 #else
920 static void
921 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
922 FILE *yyoutput;
923 int yytype;
924 YYSTYPE const * const yyvaluep;
925 #endif
926 {
927 FILE *yyo = yyoutput;
928 YYUSE (yyo);
929 if (!yyvaluep)
930 return;
931 # ifdef YYPRINT
932 if (yytype < YYNTOKENS)
933 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
934 # else
935 YYUSE (yyoutput);
936 # endif
937 switch (yytype)
938 {
939 default:
940 break;
941 }
942 }
943
944
945 /*--------------------------------.
946 | Print this symbol on YYOUTPUT. |
947 `--------------------------------*/
948
949 #if (defined __STDC__ || defined __C99__FUNC__ \
950 || defined __cplusplus || defined _MSC_VER)
951 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)952 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
953 #else
954 static void
955 yy_symbol_print (yyoutput, yytype, yyvaluep)
956 FILE *yyoutput;
957 int yytype;
958 YYSTYPE const * const yyvaluep;
959 #endif
960 {
961 if (yytype < YYNTOKENS)
962 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
963 else
964 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
965
966 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
967 YYFPRINTF (yyoutput, ")");
968 }
969
970 /*------------------------------------------------------------------.
971 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
972 | TOP (included). |
973 `------------------------------------------------------------------*/
974
975 #if (defined __STDC__ || defined __C99__FUNC__ \
976 || defined __cplusplus || defined _MSC_VER)
977 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)978 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
979 #else
980 static void
981 yy_stack_print (yybottom, yytop)
982 yytype_int16 *yybottom;
983 yytype_int16 *yytop;
984 #endif
985 {
986 YYFPRINTF (stderr, "Stack now");
987 for (; yybottom <= yytop; yybottom++)
988 {
989 int yybot = *yybottom;
990 YYFPRINTF (stderr, " %d", yybot);
991 }
992 YYFPRINTF (stderr, "\n");
993 }
994
995 # define YY_STACK_PRINT(Bottom, Top) \
996 do { \
997 if (yydebug) \
998 yy_stack_print ((Bottom), (Top)); \
999 } while (YYID (0))
1000
1001
1002 /*------------------------------------------------.
1003 | Report that the YYRULE is going to be reduced. |
1004 `------------------------------------------------*/
1005
1006 #if (defined __STDC__ || defined __C99__FUNC__ \
1007 || defined __cplusplus || defined _MSC_VER)
1008 static void
yy_reduce_print(YYSTYPE * yyvsp,int yyrule)1009 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1010 #else
1011 static void
1012 yy_reduce_print (yyvsp, yyrule)
1013 YYSTYPE *yyvsp;
1014 int yyrule;
1015 #endif
1016 {
1017 int yynrhs = yyr2[yyrule];
1018 int yyi;
1019 unsigned long int yylno = yyrline[yyrule];
1020 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1021 yyrule - 1, yylno);
1022 /* The symbols being reduced. */
1023 for (yyi = 0; yyi < yynrhs; yyi++)
1024 {
1025 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1026 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1027 &(yyvsp[(yyi + 1) - (yynrhs)])
1028 );
1029 YYFPRINTF (stderr, "\n");
1030 }
1031 }
1032
1033 # define YY_REDUCE_PRINT(Rule) \
1034 do { \
1035 if (yydebug) \
1036 yy_reduce_print (yyvsp, Rule); \
1037 } while (YYID (0))
1038
1039 /* Nonzero means print parse trace. It is left uninitialized so that
1040 multiple parsers can coexist. */
1041 int yydebug;
1042 #else /* !YYDEBUG */
1043 # define YYDPRINTF(Args)
1044 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1045 # define YY_STACK_PRINT(Bottom, Top)
1046 # define YY_REDUCE_PRINT(Rule)
1047 #endif /* !YYDEBUG */
1048
1049
1050 /* YYINITDEPTH -- initial size of the parser's stacks. */
1051 #ifndef YYINITDEPTH
1052 # define YYINITDEPTH 200
1053 #endif
1054
1055 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1056 if the built-in stack extension method is used).
1057
1058 Do not make this value too large; the results are undefined if
1059 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1060 evaluated with infinite-precision integer arithmetic. */
1061
1062 #ifndef YYMAXDEPTH
1063 # define YYMAXDEPTH 10000
1064 #endif
1065
1066
1067 #if YYERROR_VERBOSE
1068
1069 # ifndef yystrlen
1070 # if defined __GLIBC__ && defined _STRING_H
1071 # define yystrlen strlen
1072 # else
1073 /* Return the length of YYSTR. */
1074 #if (defined __STDC__ || defined __C99__FUNC__ \
1075 || defined __cplusplus || defined _MSC_VER)
1076 static YYSIZE_T
yystrlen(const char * yystr)1077 yystrlen (const char *yystr)
1078 #else
1079 static YYSIZE_T
1080 yystrlen (yystr)
1081 const char *yystr;
1082 #endif
1083 {
1084 YYSIZE_T yylen;
1085 for (yylen = 0; yystr[yylen]; yylen++)
1086 continue;
1087 return yylen;
1088 }
1089 # endif
1090 # endif
1091
1092 # ifndef yystpcpy
1093 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1094 # define yystpcpy stpcpy
1095 # else
1096 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1097 YYDEST. */
1098 #if (defined __STDC__ || defined __C99__FUNC__ \
1099 || defined __cplusplus || defined _MSC_VER)
1100 static char *
yystpcpy(char * yydest,const char * yysrc)1101 yystpcpy (char *yydest, const char *yysrc)
1102 #else
1103 static char *
1104 yystpcpy (yydest, yysrc)
1105 char *yydest;
1106 const char *yysrc;
1107 #endif
1108 {
1109 char *yyd = yydest;
1110 const char *yys = yysrc;
1111
1112 while ((*yyd++ = *yys++) != '\0')
1113 continue;
1114
1115 return yyd - 1;
1116 }
1117 # endif
1118 # endif
1119
1120 # ifndef yytnamerr
1121 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1122 quotes and backslashes, so that it's suitable for yyerror. The
1123 heuristic is that double-quoting is unnecessary unless the string
1124 contains an apostrophe, a comma, or backslash (other than
1125 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1126 null, do not copy; instead, return the length of what the result
1127 would have been. */
1128 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1129 yytnamerr (char *yyres, const char *yystr)
1130 {
1131 if (*yystr == '"')
1132 {
1133 YYSIZE_T yyn = 0;
1134 char const *yyp = yystr;
1135
1136 for (;;)
1137 switch (*++yyp)
1138 {
1139 case '\'':
1140 case ',':
1141 goto do_not_strip_quotes;
1142
1143 case '\\':
1144 if (*++yyp != '\\')
1145 goto do_not_strip_quotes;
1146 /* Fall through. */
1147 default:
1148 if (yyres)
1149 yyres[yyn] = *yyp;
1150 yyn++;
1151 break;
1152
1153 case '"':
1154 if (yyres)
1155 yyres[yyn] = '\0';
1156 return yyn;
1157 }
1158 do_not_strip_quotes: ;
1159 }
1160
1161 if (! yyres)
1162 return yystrlen (yystr);
1163
1164 return yystpcpy (yyres, yystr) - yyres;
1165 }
1166 # endif
1167
1168 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1169 about the unexpected token YYTOKEN for the state stack whose top is
1170 YYSSP.
1171
1172 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1173 not large enough to hold the message. In that case, also set
1174 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1175 required number of bytes is too large to store. */
1176 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)1177 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1178 yytype_int16 *yyssp, int yytoken)
1179 {
1180 YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1181 YYSIZE_T yysize = yysize0;
1182 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1183 /* Internationalized format string. */
1184 const char *yyformat = YY_NULL;
1185 /* Arguments of yyformat. */
1186 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1187 /* Number of reported tokens (one for the "unexpected", one per
1188 "expected"). */
1189 int yycount = 0;
1190
1191 /* There are many possibilities here to consider:
1192 - Assume YYFAIL is not used. It's too flawed to consider. See
1193 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1194 for details. YYERROR is fine as it does not invoke this
1195 function.
1196 - If this state is a consistent state with a default action, then
1197 the only way this function was invoked is if the default action
1198 is an error action. In that case, don't check for expected
1199 tokens because there are none.
1200 - The only way there can be no lookahead present (in yychar) is if
1201 this state is a consistent state with a default action. Thus,
1202 detecting the absence of a lookahead is sufficient to determine
1203 that there is no unexpected or expected token to report. In that
1204 case, just report a simple "syntax error".
1205 - Don't assume there isn't a lookahead just because this state is a
1206 consistent state with a default action. There might have been a
1207 previous inconsistent state, consistent state with a non-default
1208 action, or user semantic action that manipulated yychar.
1209 - Of course, the expected token list depends on states to have
1210 correct lookahead information, and it depends on the parser not
1211 to perform extra reductions after fetching a lookahead from the
1212 scanner and before detecting a syntax error. Thus, state merging
1213 (from LALR or IELR) and default reductions corrupt the expected
1214 token list. However, the list is correct for canonical LR with
1215 one exception: it will still contain any token that will not be
1216 accepted due to an error action in a later state.
1217 */
1218 if (yytoken != YYEMPTY)
1219 {
1220 int yyn = yypact[*yyssp];
1221 yyarg[yycount++] = yytname[yytoken];
1222 if (!yypact_value_is_default (yyn))
1223 {
1224 /* Start YYX at -YYN if negative to avoid negative indexes in
1225 YYCHECK. In other words, skip the first -YYN actions for
1226 this state because they are default actions. */
1227 int yyxbegin = yyn < 0 ? -yyn : 0;
1228 /* Stay within bounds of both yycheck and yytname. */
1229 int yychecklim = YYLAST - yyn + 1;
1230 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1231 int yyx;
1232
1233 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1234 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1235 && !yytable_value_is_error (yytable[yyx + yyn]))
1236 {
1237 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1238 {
1239 yycount = 1;
1240 yysize = yysize0;
1241 break;
1242 }
1243 yyarg[yycount++] = yytname[yyx];
1244 {
1245 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1246 if (! (yysize <= yysize1
1247 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1248 return 2;
1249 yysize = yysize1;
1250 }
1251 }
1252 }
1253 }
1254
1255 switch (yycount)
1256 {
1257 # define YYCASE_(N, S) \
1258 case N: \
1259 yyformat = S; \
1260 break
1261 YYCASE_(0, YY_("syntax error"));
1262 YYCASE_(1, YY_("syntax error, unexpected %s"));
1263 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1264 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1265 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1266 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1267 # undef YYCASE_
1268 }
1269
1270 {
1271 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1272 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1273 return 2;
1274 yysize = yysize1;
1275 }
1276
1277 if (*yymsg_alloc < yysize)
1278 {
1279 *yymsg_alloc = 2 * yysize;
1280 if (! (yysize <= *yymsg_alloc
1281 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1282 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1283 return 1;
1284 }
1285
1286 /* Avoid sprintf, as that infringes on the user's name space.
1287 Don't have undefined behavior even if the translation
1288 produced a string with the wrong number of "%s"s. */
1289 {
1290 char *yyp = *yymsg;
1291 int yyi = 0;
1292 while ((*yyp = *yyformat) != '\0')
1293 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1294 {
1295 yyp += yytnamerr (yyp, yyarg[yyi++]);
1296 yyformat += 2;
1297 }
1298 else
1299 {
1300 yyp++;
1301 yyformat++;
1302 }
1303 }
1304 return 0;
1305 }
1306 #endif /* YYERROR_VERBOSE */
1307
1308 /*-----------------------------------------------.
1309 | Release the memory associated to this symbol. |
1310 `-----------------------------------------------*/
1311
1312 /*ARGSUSED*/
1313 #if (defined __STDC__ || defined __C99__FUNC__ \
1314 || defined __cplusplus || defined _MSC_VER)
1315 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)1316 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1317 #else
1318 static void
1319 yydestruct (yymsg, yytype, yyvaluep)
1320 const char *yymsg;
1321 int yytype;
1322 YYSTYPE *yyvaluep;
1323 #endif
1324 {
1325 YYUSE (yyvaluep);
1326
1327 if (!yymsg)
1328 yymsg = "Deleting";
1329 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1330
1331 switch (yytype)
1332 {
1333
1334 default:
1335 break;
1336 }
1337 }
1338
1339
1340
1341
1342 /* The lookahead symbol. */
1343 int yychar;
1344
1345
1346 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1347 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1348 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1349 #endif
1350 #ifndef YY_INITIAL_VALUE
1351 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1352 #endif
1353
1354 /* The semantic value of the lookahead symbol. */
1355 YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1356
1357 /* Number of syntax errors so far. */
1358 int yynerrs;
1359
1360
1361 /*----------.
1362 | yyparse. |
1363 `----------*/
1364
1365 #ifdef YYPARSE_PARAM
1366 #if (defined __STDC__ || defined __C99__FUNC__ \
1367 || defined __cplusplus || defined _MSC_VER)
1368 int
yyparse(void * YYPARSE_PARAM)1369 yyparse (void *YYPARSE_PARAM)
1370 #else
1371 int
1372 yyparse (YYPARSE_PARAM)
1373 void *YYPARSE_PARAM;
1374 #endif
1375 #else /* ! YYPARSE_PARAM */
1376 #if (defined __STDC__ || defined __C99__FUNC__ \
1377 || defined __cplusplus || defined _MSC_VER)
1378 int
1379 yyparse (void)
1380 #else
1381 int
1382 yyparse ()
1383
1384 #endif
1385 #endif
1386 {
1387 int yystate;
1388 /* Number of tokens to shift before error messages enabled. */
1389 int yyerrstatus;
1390
1391 /* The stacks and their tools:
1392 `yyss': related to states.
1393 `yyvs': related to semantic values.
1394
1395 Refer to the stacks through separate pointers, to allow yyoverflow
1396 to reallocate them elsewhere. */
1397
1398 /* The state stack. */
1399 yytype_int16 yyssa[YYINITDEPTH];
1400 yytype_int16 *yyss;
1401 yytype_int16 *yyssp;
1402
1403 /* The semantic value stack. */
1404 YYSTYPE yyvsa[YYINITDEPTH];
1405 YYSTYPE *yyvs;
1406 YYSTYPE *yyvsp;
1407
1408 YYSIZE_T yystacksize;
1409
1410 int yyn;
1411 int yyresult;
1412 /* Lookahead token as an internal (translated) token number. */
1413 int yytoken = 0;
1414 /* The variables used to return semantic value and location from the
1415 action routines. */
1416 YYSTYPE yyval;
1417
1418 #if YYERROR_VERBOSE
1419 /* Buffer for error messages, and its allocated size. */
1420 char yymsgbuf[128];
1421 char *yymsg = yymsgbuf;
1422 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1423 #endif
1424
1425 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1426
1427 /* The number of symbols on the RHS of the reduced rule.
1428 Keep to zero when no symbol should be popped. */
1429 int yylen = 0;
1430
1431 yyssp = yyss = yyssa;
1432 yyvsp = yyvs = yyvsa;
1433 yystacksize = YYINITDEPTH;
1434
1435 YYDPRINTF ((stderr, "Starting parse\n"));
1436
1437 yystate = 0;
1438 yyerrstatus = 0;
1439 yynerrs = 0;
1440 yychar = YYEMPTY; /* Cause a token to be read. */
1441 goto yysetstate;
1442
1443 /*------------------------------------------------------------.
1444 | yynewstate -- Push a new state, which is found in yystate. |
1445 `------------------------------------------------------------*/
1446 yynewstate:
1447 /* In all cases, when you get here, the value and location stacks
1448 have just been pushed. So pushing a state here evens the stacks. */
1449 yyssp++;
1450
1451 yysetstate:
1452 *yyssp = yystate;
1453
1454 if (yyss + yystacksize - 1 <= yyssp)
1455 {
1456 /* Get the current used size of the three stacks, in elements. */
1457 YYSIZE_T yysize = yyssp - yyss + 1;
1458
1459 #ifdef yyoverflow
1460 {
1461 /* Give user a chance to reallocate the stack. Use copies of
1462 these so that the &'s don't force the real ones into
1463 memory. */
1464 YYSTYPE *yyvs1 = yyvs;
1465 yytype_int16 *yyss1 = yyss;
1466
1467 /* Each stack pointer address is followed by the size of the
1468 data in use in that stack, in bytes. This used to be a
1469 conditional around just the two extra args, but that might
1470 be undefined if yyoverflow is a macro. */
1471 yyoverflow (YY_("memory exhausted"),
1472 &yyss1, yysize * sizeof (*yyssp),
1473 &yyvs1, yysize * sizeof (*yyvsp),
1474 &yystacksize);
1475
1476 yyss = yyss1;
1477 yyvs = yyvs1;
1478 }
1479 #else /* no yyoverflow */
1480 # ifndef YYSTACK_RELOCATE
1481 goto yyexhaustedlab;
1482 # else
1483 /* Extend the stack our own way. */
1484 if (YYMAXDEPTH <= yystacksize)
1485 goto yyexhaustedlab;
1486 yystacksize *= 2;
1487 if (YYMAXDEPTH < yystacksize)
1488 yystacksize = YYMAXDEPTH;
1489
1490 {
1491 yytype_int16 *yyss1 = yyss;
1492 union yyalloc *yyptr =
1493 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1494 if (! yyptr)
1495 goto yyexhaustedlab;
1496 YYSTACK_RELOCATE (yyss_alloc, yyss);
1497 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1498 # undef YYSTACK_RELOCATE
1499 if (yyss1 != yyssa)
1500 YYSTACK_FREE (yyss1);
1501 }
1502 # endif
1503 #endif /* no yyoverflow */
1504
1505 yyssp = yyss + yysize - 1;
1506 yyvsp = yyvs + yysize - 1;
1507
1508 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1509 (unsigned long int) yystacksize));
1510
1511 if (yyss + yystacksize - 1 <= yyssp)
1512 YYABORT;
1513 }
1514
1515 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1516
1517 if (yystate == YYFINAL)
1518 YYACCEPT;
1519
1520 goto yybackup;
1521
1522 /*-----------.
1523 | yybackup. |
1524 `-----------*/
1525 yybackup:
1526
1527 /* Do appropriate processing given the current state. Read a
1528 lookahead token if we need one and don't already have one. */
1529
1530 /* First try to decide what to do without reference to lookahead token. */
1531 yyn = yypact[yystate];
1532 if (yypact_value_is_default (yyn))
1533 goto yydefault;
1534
1535 /* Not known => get a lookahead token if don't already have one. */
1536
1537 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1538 if (yychar == YYEMPTY)
1539 {
1540 YYDPRINTF ((stderr, "Reading a token: "));
1541 yychar = YYLEX;
1542 }
1543
1544 if (yychar <= YYEOF)
1545 {
1546 yychar = yytoken = YYEOF;
1547 YYDPRINTF ((stderr, "Now at end of input.\n"));
1548 }
1549 else
1550 {
1551 yytoken = YYTRANSLATE (yychar);
1552 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1553 }
1554
1555 /* If the proper action on seeing token YYTOKEN is to reduce or to
1556 detect an error, take that action. */
1557 yyn += yytoken;
1558 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1559 goto yydefault;
1560 yyn = yytable[yyn];
1561 if (yyn <= 0)
1562 {
1563 if (yytable_value_is_error (yyn))
1564 goto yyerrlab;
1565 yyn = -yyn;
1566 goto yyreduce;
1567 }
1568
1569 /* Count tokens shifted since error; after three, turn off error
1570 status. */
1571 if (yyerrstatus)
1572 yyerrstatus--;
1573
1574 /* Shift the lookahead token. */
1575 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1576
1577 /* Discard the shifted token. */
1578 yychar = YYEMPTY;
1579
1580 yystate = yyn;
1581 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1582 *++yyvsp = yylval;
1583 YY_IGNORE_MAYBE_UNINITIALIZED_END
1584
1585 goto yynewstate;
1586
1587
1588 /*-----------------------------------------------------------.
1589 | yydefault -- do the default action for the current state. |
1590 `-----------------------------------------------------------*/
1591 yydefault:
1592 yyn = yydefact[yystate];
1593 if (yyn == 0)
1594 goto yyerrlab;
1595 goto yyreduce;
1596
1597
1598 /*-----------------------------.
1599 | yyreduce -- Do a reduction. |
1600 `-----------------------------*/
1601 yyreduce:
1602 /* yyn is the number of a rule to reduce with. */
1603 yylen = yyr2[yyn];
1604
1605 /* If YYLEN is nonzero, implement the default value of the action:
1606 `$$ = $1'.
1607
1608 Otherwise, the following line sets YYVAL to garbage.
1609 This behavior is undocumented and Bison
1610 users should not rely upon it. Assigning to YYVAL
1611 unconditionally makes the parser a bit smaller, and it avoids a
1612 GCC warning that YYVAL may be used uninitialized. */
1613 yyval = yyvsp[1-yylen];
1614
1615
1616 YY_REDUCE_PRINT (yyn);
1617 switch (yyn)
1618 {
1619 case 2:
1620
1621 { root_node = so_eval_create_binary(ID_SEPARATOR, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); (yyval.node) = root_node; }
1622 break;
1623
1624 case 3:
1625
1626 { root_node = (yyvsp[(1) - (1)].node); (yyval.node) = (yyvsp[(1) - (1)].node); }
1627 break;
1628
1629 case 4:
1630
1631 { (yyval.node) = NULL; }
1632 break;
1633
1634 case 5:
1635
1636 { (yyval.node) = so_eval_create_binary(ID_ASSIGN_FLT, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1637 break;
1638
1639 case 6:
1640
1641 { (yyval.node) = so_eval_create_binary(ID_ASSIGN_VEC, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1642 break;
1643
1644 case 7:
1645
1646 { (yyval.node) = so_eval_create_reg(get_regname((yyvsp[(1) - (1)].reg), REGTYPE_TMP)); }
1647 break;
1648
1649 case 8:
1650
1651 { (yyval.node) = so_eval_create_reg(get_regname((yyvsp[(1) - (1)].reg), REGTYPE_OUT)); }
1652 break;
1653
1654 case 9:
1655
1656 { (yyval.node) = so_eval_create_reg_comp(get_regname((yyvsp[(1) - (4)].reg), REGTYPE_TMP), (int) (yyvsp[(3) - (4)].value)); }
1657 break;
1658
1659 case 10:
1660
1661 { (yyval.node) = so_eval_create_reg_comp(get_regname((yyvsp[(1) - (4)].reg), REGTYPE_OUT), (int) (yyvsp[(3) - (4)].value)); }
1662 break;
1663
1664 case 11:
1665
1666 { (yyval.node) = so_eval_create_reg(get_regname((yyvsp[(1) - (1)].reg), REGTYPE_TMP));}
1667 break;
1668
1669 case 12:
1670
1671 { (yyval.node) = so_eval_create_reg(get_regname((yyvsp[(1) - (1)].reg), REGTYPE_OUT));}
1672 break;
1673
1674 case 13:
1675
1676 { (yyval.node) = so_eval_create_ternary(ID_FLT_COND, (yyvsp[(1) - (5)].node), (yyvsp[(3) - (5)].node), (yyvsp[(5) - (5)].node)); }
1677 break;
1678
1679 case 14:
1680
1681 { (yyval.node) = so_eval_create_ternary(ID_FLT_COND, so_eval_create_unary(ID_TEST_FLT, (yyvsp[(1) - (5)].node)), (yyvsp[(3) - (5)].node), (yyvsp[(5) - (5)].node)); }
1682 break;
1683
1684 case 15:
1685
1686 { (yyval.node) = so_eval_create_ternary(ID_FLT_COND, so_eval_create_unary(ID_TEST_VEC, (yyvsp[(1) - (5)].node)), (yyvsp[(3) - (5)].node), (yyvsp[(5) - (5)].node)); }
1687 break;
1688
1689 case 16:
1690
1691 { (yyval.node) = so_eval_create_binary(ID_ADD, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1692 break;
1693
1694 case 17:
1695
1696 { (yyval.node) = so_eval_create_binary(ID_SUB, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1697 break;
1698
1699 case 18:
1700
1701 { (yyval.node) = so_eval_create_binary(ID_DIV, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1702 break;
1703
1704 case 19:
1705
1706 { (yyval.node) = so_eval_create_binary(ID_MUL, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1707 break;
1708
1709 case 20:
1710
1711 { (yyval.node) = so_eval_create_binary(ID_FMOD, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1712 break;
1713
1714 case 21:
1715
1716 { (yyval.node) = so_eval_create_binary(ID_ATAN2, (yyvsp[(3) - (6)].node), (yyvsp[(5) - (6)].node)); }
1717 break;
1718
1719 case 22:
1720
1721 { (yyval.node) = so_eval_create_binary(ID_POW, (yyvsp[(3) - (6)].node), (yyvsp[(5) - (6)].node)); }
1722 break;
1723
1724 case 23:
1725
1726 { (yyval.node) = so_eval_create_binary(ID_FMOD, (yyvsp[(3) - (6)].node), (yyvsp[(5) - (6)].node)); }
1727 break;
1728
1729 case 24:
1730
1731 { (yyval.node) = so_eval_create_unary(ID_NEG, (yyvsp[(2) - (2)].node)); }
1732 break;
1733
1734 case 25:
1735
1736 { (yyval.node) = (yyvsp[(2) - (3)].node); }
1737 break;
1738
1739 case 26:
1740
1741 { (yyval.node) = so_eval_create_unary((yyvsp[(1) - (4)].id), (yyvsp[(3) - (4)].node));}
1742 break;
1743
1744 case 27:
1745
1746 { (yyval.node) = so_eval_create_unary(ID_LEN, (yyvsp[(3) - (4)].node));}
1747 break;
1748
1749 case 28:
1750
1751 { (yyval.node) = so_eval_create_binary(ID_DOT, (yyvsp[(3) - (6)].node), (yyvsp[(5) - (6)].node)); }
1752 break;
1753
1754 case 29:
1755
1756 { (yyval.node) = so_eval_create_reg(get_regname((yyvsp[(1) - (1)].reg), REGTYPE_TMP));}
1757 break;
1758
1759 case 30:
1760
1761 { (yyval.node) = so_eval_create_reg(get_regname((yyvsp[(1) - (1)].reg), REGTYPE_OUT));}
1762 break;
1763
1764 case 31:
1765
1766 { (yyval.node) = so_eval_create_reg(get_regname((yyvsp[(1) - (1)].reg), REGTYPE_IN));}
1767 break;
1768
1769 case 32:
1770
1771 { (yyval.node) = so_eval_create_reg_comp(get_regname((yyvsp[(1) - (4)].reg), REGTYPE_TMP), (int) (yyvsp[(3) - (4)].value));}
1772 break;
1773
1774 case 33:
1775
1776 { (yyval.node) = so_eval_create_reg_comp(get_regname((yyvsp[(1) - (4)].reg), REGTYPE_IN), (int) (yyvsp[(3) - (4)].value));}
1777 break;
1778
1779 case 34:
1780
1781 { (yyval.node) = so_eval_create_reg_comp(get_regname((yyvsp[(1) - (4)].reg), REGTYPE_OUT), (int) (yyvsp[(3) - (4)].value));}
1782 break;
1783
1784 case 35:
1785
1786 { (yyval.node) = so_eval_create_flt_val((yyvsp[(1) - (1)].value)); }
1787 break;
1788
1789 case 36:
1790
1791 { (yyval.node) = so_eval_create_ternary(ID_VEC_COND, (yyvsp[(1) - (5)].node), (yyvsp[(3) - (5)].node), (yyvsp[(5) - (5)].node)); }
1792 break;
1793
1794 case 37:
1795
1796 { (yyval.node) = so_eval_create_ternary(ID_VEC_COND, so_eval_create_unary(ID_TEST_FLT, (yyvsp[(1) - (5)].node)), (yyvsp[(3) - (5)].node), (yyvsp[(5) - (5)].node)); }
1797 break;
1798
1799 case 38:
1800
1801 { (yyval.node) = so_eval_create_ternary(ID_VEC_COND, so_eval_create_unary(ID_TEST_VEC, (yyvsp[(1) - (5)].node)), (yyvsp[(3) - (5)].node), (yyvsp[(5) - (5)].node)); }
1802 break;
1803
1804 case 39:
1805
1806 { (yyval.node) = so_eval_create_binary(ID_ADD_VEC, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1807 break;
1808
1809 case 40:
1810
1811 { (yyval.node) = so_eval_create_binary(ID_SUB_VEC, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1812 break;
1813
1814 case 41:
1815
1816 { (yyval.node) = so_eval_create_binary(ID_MUL_VEC_FLT, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1817 break;
1818
1819 case 42:
1820
1821 { (yyval.node) = so_eval_create_binary(ID_DIV_VEC_FLT, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1822 break;
1823
1824 case 43:
1825
1826 { (yyval.node) = so_eval_create_binary(ID_MUL_VEC_FLT, (yyvsp[(3) - (3)].node), (yyvsp[(1) - (3)].node)); }
1827 break;
1828
1829 case 44:
1830
1831 { (yyval.node) = so_eval_create_binary(ID_CROSS, (yyvsp[(3) - (6)].node), (yyvsp[(5) - (6)].node)); }
1832 break;
1833
1834 case 45:
1835
1836 { (yyval.node) = so_eval_create_unary(ID_NEG_VEC, (yyvsp[(2) - (2)].node)); }
1837 break;
1838
1839 case 46:
1840
1841 { (yyval.node) = (yyvsp[(2) - (3)].node); }
1842 break;
1843
1844 case 47:
1845
1846 { (yyval.node) = so_eval_create_unary(ID_NORMALIZE, (yyvsp[(3) - (4)].node)); }
1847 break;
1848
1849 case 48:
1850
1851 { (yyval.node) = so_eval_create_reg(get_regname((yyvsp[(1) - (1)].reg), REGTYPE_TMP));}
1852 break;
1853
1854 case 49:
1855
1856 { (yyval.node) = so_eval_create_reg(get_regname((yyvsp[(1) - (1)].reg), REGTYPE_OUT));}
1857 break;
1858
1859 case 50:
1860
1861 { (yyval.node) = so_eval_create_reg(get_regname((yyvsp[(1) - (1)].reg), REGTYPE_IN));}
1862 break;
1863
1864 case 51:
1865
1866 { (yyval.node) = so_eval_create_ternary(ID_VEC3F, (yyvsp[(3) - (8)].node), (yyvsp[(5) - (8)].node), (yyvsp[(7) - (8)].node)); }
1867 break;
1868
1869 case 52:
1870
1871 { (yyval.node) = so_eval_create_binary(ID_EQ, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1872 break;
1873
1874 case 53:
1875
1876 { (yyval.node) = so_eval_create_binary(ID_NEQ, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1877 break;
1878
1879 case 54:
1880
1881 { (yyval.node) = so_eval_create_binary(ID_EQ, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1882 break;
1883
1884 case 55:
1885
1886 { (yyval.node) = so_eval_create_binary(ID_NEQ, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1887 break;
1888
1889 case 56:
1890
1891 { (yyval.node) = so_eval_create_binary((yyvsp[(2) - (3)].id), (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1892 break;
1893
1894 case 57:
1895
1896 { (yyval.node) = so_eval_create_binary(ID_AND, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1897 break;
1898
1899 case 58:
1900
1901 { (yyval.node) = so_eval_create_binary(ID_OR, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); }
1902 break;
1903
1904 case 59:
1905
1906 { (yyval.node) = so_eval_create_unary(ID_NOT, (yyvsp[(2) - (2)].node)); }
1907 break;
1908
1909 case 60:
1910
1911 { (yyval.node) = (yyvsp[(2) - (3)].node); }
1912 break;
1913
1914
1915
1916 default: break;
1917 }
1918 /* User semantic actions sometimes alter yychar, and that requires
1919 that yytoken be updated with the new translation. We take the
1920 approach of translating immediately before every use of yytoken.
1921 One alternative is translating here after every semantic action,
1922 but that translation would be missed if the semantic action invokes
1923 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1924 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1925 incorrect destructor might then be invoked immediately. In the
1926 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1927 to an incorrect destructor call or verbose syntax error message
1928 before the lookahead is translated. */
1929 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1930
1931 YYPOPSTACK (yylen);
1932 yylen = 0;
1933 YY_STACK_PRINT (yyss, yyssp);
1934
1935 *++yyvsp = yyval;
1936
1937 /* Now `shift' the result of the reduction. Determine what state
1938 that goes to, based on the state we popped back to and the rule
1939 number reduced by. */
1940
1941 yyn = yyr1[yyn];
1942
1943 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1944 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1945 yystate = yytable[yystate];
1946 else
1947 yystate = yydefgoto[yyn - YYNTOKENS];
1948
1949 goto yynewstate;
1950
1951
1952 /*------------------------------------.
1953 | yyerrlab -- here on detecting error |
1954 `------------------------------------*/
1955 yyerrlab:
1956 /* Make sure we have latest lookahead translation. See comments at
1957 user semantic actions for why this is necessary. */
1958 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1959
1960 /* If not already recovering from an error, report this error. */
1961 if (!yyerrstatus)
1962 {
1963 ++yynerrs;
1964 #if ! YYERROR_VERBOSE
1965 yyerror (YY_("syntax error"));
1966 #else
1967 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1968 yyssp, yytoken)
1969 {
1970 char const *yymsgp = YY_("syntax error");
1971 int yysyntax_error_status;
1972 yysyntax_error_status = YYSYNTAX_ERROR;
1973 if (yysyntax_error_status == 0)
1974 yymsgp = yymsg;
1975 else if (yysyntax_error_status == 1)
1976 {
1977 if (yymsg != yymsgbuf)
1978 YYSTACK_FREE (yymsg);
1979 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1980 if (!yymsg)
1981 {
1982 yymsg = yymsgbuf;
1983 yymsg_alloc = sizeof yymsgbuf;
1984 yysyntax_error_status = 2;
1985 }
1986 else
1987 {
1988 yysyntax_error_status = YYSYNTAX_ERROR;
1989 yymsgp = yymsg;
1990 }
1991 }
1992 yyerror (yymsgp);
1993 if (yysyntax_error_status == 2)
1994 goto yyexhaustedlab;
1995 }
1996 # undef YYSYNTAX_ERROR
1997 #endif
1998 }
1999
2000
2001
2002 if (yyerrstatus == 3)
2003 {
2004 /* If just tried and failed to reuse lookahead token after an
2005 error, discard it. */
2006
2007 if (yychar <= YYEOF)
2008 {
2009 /* Return failure if at end of input. */
2010 if (yychar == YYEOF)
2011 YYABORT;
2012 }
2013 else
2014 {
2015 yydestruct ("Error: discarding",
2016 yytoken, &yylval);
2017 yychar = YYEMPTY;
2018 }
2019 }
2020
2021 /* Else will try to reuse lookahead token after shifting the error
2022 token. */
2023 goto yyerrlab1;
2024
2025
2026 /*---------------------------------------------------.
2027 | yyerrorlab -- error raised explicitly by YYERROR. |
2028 `---------------------------------------------------*/
2029 yyerrorlab:
2030
2031 /* Pacify compilers like GCC when the user code never invokes
2032 YYERROR and the label yyerrorlab therefore never appears in user
2033 code. */
2034 if (/*CONSTCOND*/ 0)
2035 goto yyerrorlab;
2036
2037 /* Do not reclaim the symbols of the rule which action triggered
2038 this YYERROR. */
2039 YYPOPSTACK (yylen);
2040 yylen = 0;
2041 YY_STACK_PRINT (yyss, yyssp);
2042 yystate = *yyssp;
2043 goto yyerrlab1;
2044
2045
2046 /*-------------------------------------------------------------.
2047 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2048 `-------------------------------------------------------------*/
2049 yyerrlab1:
2050 yyerrstatus = 3; /* Each real token shifted decrements this. */
2051
2052 for (;;)
2053 {
2054 yyn = yypact[yystate];
2055 if (!yypact_value_is_default (yyn))
2056 {
2057 yyn += YYTERROR;
2058 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2059 {
2060 yyn = yytable[yyn];
2061 if (0 < yyn)
2062 break;
2063 }
2064 }
2065
2066 /* Pop the current state because it cannot handle the error token. */
2067 if (yyssp == yyss)
2068 YYABORT;
2069
2070
2071 yydestruct ("Error: popping",
2072 yystos[yystate], yyvsp);
2073 YYPOPSTACK (1);
2074 yystate = *yyssp;
2075 YY_STACK_PRINT (yyss, yyssp);
2076 }
2077
2078 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2079 *++yyvsp = yylval;
2080 YY_IGNORE_MAYBE_UNINITIALIZED_END
2081
2082
2083 /* Shift the error token. */
2084 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2085
2086 yystate = yyn;
2087 goto yynewstate;
2088
2089
2090 /*-------------------------------------.
2091 | yyacceptlab -- YYACCEPT comes here. |
2092 `-------------------------------------*/
2093 yyacceptlab:
2094 yyresult = 0;
2095 goto yyreturn;
2096
2097 /*-----------------------------------.
2098 | yyabortlab -- YYABORT comes here. |
2099 `-----------------------------------*/
2100 yyabortlab:
2101 yyresult = 1;
2102 goto yyreturn;
2103
2104 #if !defined yyoverflow || YYERROR_VERBOSE
2105 /*-------------------------------------------------.
2106 | yyexhaustedlab -- memory exhaustion comes here. |
2107 `-------------------------------------------------*/
2108 yyexhaustedlab:
2109 yyerror (YY_("memory exhausted"));
2110 yyresult = 2;
2111 /* Fall through. */
2112 #endif
2113
2114 yyreturn:
2115 if (yychar != YYEMPTY)
2116 {
2117 /* Make sure we have latest lookahead translation. See comments at
2118 user semantic actions for why this is necessary. */
2119 yytoken = YYTRANSLATE (yychar);
2120 yydestruct ("Cleanup: discarding lookahead",
2121 yytoken, &yylval);
2122 }
2123 /* Do not reclaim the symbols of the rule which action triggered
2124 this YYABORT or YYACCEPT. */
2125 YYPOPSTACK (yylen);
2126 YY_STACK_PRINT (yyss, yyssp);
2127 while (yyssp != yyss)
2128 {
2129 yydestruct ("Cleanup: popping",
2130 yystos[*yyssp], yyvsp);
2131 YYPOPSTACK (1);
2132 }
2133 #ifndef yyoverflow
2134 if (yyss != yyssa)
2135 YYSTACK_FREE (yyss);
2136 #endif
2137 #if YYERROR_VERBOSE
2138 if (yymsg != yymsgbuf)
2139 YYSTACK_FREE (yymsg);
2140 #endif
2141 /* Make sure YYID is used. */
2142 return YYID (yyresult);
2143 }
2144
2145
2146
2147
2148
2149 /*
2150 * Creates a register name from the register type and register char.
2151 *
2152 * Note: don't "const" the return type, as that will trigger a bug in
2153 * Microsoft Visual C++ v6.0. 20000606 mortene.
2154 */
2155 static char *
get_regname(char reg,int regtype)2156 get_regname(char reg, int regtype)
2157 {
2158 static char buf[3];
2159 buf[2] = 0;
2160
2161 if (regtype != REGTYPE_IN) {
2162 if (regtype == REGTYPE_TMP) buf[0] = 't';
2163 else if (regtype == REGTYPE_OUT) buf[0] = 'o';
2164 buf[1] = reg;
2165 buf[2] = 0;
2166 }
2167 else {
2168 buf[0] = reg;
2169 buf[1] = 0;
2170 }
2171 return buf;
2172 }
2173
2174
2175
2176 #include "so_eval.ic" /* our lexical scanner */
2177
2178 /* some very simple error handling for now :) */
2179 static char *myerrorptr;
2180 static char myerrorbuf[512];
2181
2182 /*
2183 * parse the text string into a tree structure.
2184 */
2185 so_eval_node *
so_eval_parse(const char * buffer)2186 so_eval_parse(const char *buffer)
2187 {
2188 /* FIXME: better error handling is obviously needed */
2189 YY_BUFFER_STATE state;
2190 myerrorptr = NULL;
2191 root_node = NULL;
2192 state = so_eval_scan_string(buffer); /* flex routine */
2193 so_evalparse(); /* start parsing */
2194 so_eval_delete_buffer(state); /* flex routine */
2195 if (myerrorptr) return NULL;
2196 return root_node;
2197 }
2198
2199 /*
2200 * Returns current error message or NULL if none.
2201 *
2202 * Note: don't "const" the return type, as that will trigger a bug in
2203 * Microsoft Visual C++ v6.0. 20000606 mortene.
2204 */
2205 char *
so_eval_error(void)2206 so_eval_error(void)
2207 {
2208 return myerrorptr;
2209 }
2210
2211 /*
2212 * Called by bison parser upon lexical/syntax error.
2213 */
2214 int
so_evalerror(const char * myerr)2215 so_evalerror(const char *myerr)
2216 {
2217 strncpy(myerrorbuf, myerr, 512);
2218 myerrorbuf[511] = 0; /* just in case string was too long */
2219 myerrorptr = myerrorbuf; /* signal error */
2220 so_eval_delete(root_node); /* free memory used */
2221 root_node = NULL;
2222 return 0;
2223 }
2224