996
|
1 /* A Bison parser, made by GNU Bison 2.3. */
|
|
2
|
|
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
|
|
4
|
|
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
|
6 Free Software Foundation, 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 2, or (at your option)
|
|
11 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, write to the Free Software
|
|
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
21 Boston, MA 02110-1301, USA. */
|
|
22
|
|
23 /* As a special exception, you may create a larger work that contains
|
|
24 part or all of the Bison parser skeleton and distribute that work
|
|
25 under terms of your choice, so long as that work isn't itself a
|
|
26 parser generator using the skeleton or a modified version thereof
|
|
27 as a parser skeleton. Alternatively, if you modify or redistribute
|
|
28 the parser skeleton itself, you may (at your option) remove this
|
|
29 special exception, which will cause the skeleton and the resulting
|
|
30 Bison output files to be licensed under the GNU General Public
|
|
31 License without this special exception.
|
|
32
|
|
33 This special exception was added by the Free Software Foundation in
|
|
34 version 2.2 of Bison. */
|
|
35
|
|
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
|
|
37 simplifying the original so-called "semantic" parser. */
|
|
38
|
|
39 /* All symbols defined below should begin with yy or YY, to avoid
|
|
40 infringing on user name space. This should be done even for local
|
|
41 variables, as they might otherwise be expanded by user macros.
|
|
42 There are some unavoidable exceptions within include files to
|
|
43 define necessary library symbols; they are noted "INFRINGES ON
|
|
44 USER NAME SPACE" below. */
|
|
45
|
|
46 /* Identify Bison output. */
|
|
47 #define YYBISON 1
|
|
48
|
|
49 /* Bison version. */
|
|
50 #define YYBISON_VERSION "2.3"
|
|
51
|
|
52 /* Skeleton name. */
|
|
53 #define YYSKELETON_NAME "yacc.c"
|
|
54
|
|
55 /* Pure parsers. */
|
|
56 #define YYPURE 0
|
|
57
|
|
58 /* Using locations. */
|
|
59 #define YYLSP_NEEDED 0
|
|
60
|
|
61
|
|
62
|
|
63 /* Tokens. */
|
|
64 #ifndef YYTOKENTYPE
|
|
65 # define YYTOKENTYPE
|
|
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
|
|
67 know about them. */
|
|
68 enum yytokentype {
|
|
69 LEXERLEAF = 258
|
|
70 };
|
|
71 #endif
|
|
72 /* Tokens. */
|
|
73 #define LEXERLEAF 258
|
|
74
|
|
75
|
|
76
|
|
77
|
|
78 /* Copy the first part of user declarations. */
|
|
79 #line 25 "oil.y"
|
|
80
|
|
81
|
|
82 #include "bconfig.h"
|
|
83 #include <stdio.h>
|
|
84 #include <stdlib.h>
|
|
85 #include <string.h>
|
|
86 #include <ctype.h>
|
|
87
|
|
88 /* Autoconf lets us know if we have _Bool available, usually. On DJGPP there's
|
|
89 an occasional bug that I haven't managed to reproduce that leaves
|
|
90 SIZEOF_BOOL as the null string, so detect that ick_first. */
|
|
91 #if 100 - SIZEOF__BOOL - 1 == 101
|
|
92 /* The bug happened, so play safe. */
|
|
93 typedef int mybool;
|
|
94 #else
|
|
95 # if SIZEOF__BOOL > 0
|
|
96 typedef _Bool mybool;
|
|
97 # else
|
|
98 typedef int mybool;
|
|
99 # endif
|
|
100 #endif
|
|
101
|
|
102 /* Define strdup if it isn't available */
|
|
103 #ifndef HAVE_STRDUP
|
|
104 char* strdup(const char* s)
|
|
105 {
|
|
106 char* t=malloc(strlen(s)+1);
|
|
107 if(t) strcpy(t,s);
|
|
108 return t;
|
|
109 }
|
|
110 #endif
|
|
111
|
|
112 /*
|
|
113 #define YYDEBUG 1
|
|
114 int yydebug=1;
|
|
115 */
|
|
116
|
|
117 /* Each semantic value represents either a constraint on a node that needs to
|
|
118 be true for the optimization template to match, or part of the replacement
|
|
119 for the optimization template. */
|
|
120 struct ickstype
|
|
121 {
|
|
122 unsigned depth; /* The number of child nodes this is from the root */
|
|
123 unsigned long path; /* Bits from the end of this number represent the
|
|
124 sequence of lvals (=0) or rvals (=1) this is from the
|
|
125 root; depth bits from the end are relevant, and the
|
|
126 bit nearest the root is least significant */
|
|
127 const char* condition; /* Points to a constant string; the condition to generate
|
|
128 on that node. Could also point to something the lexer
|
|
129 mallocs, but then the lexer has to keep track of being
|
|
130 able to free it again. If this is NULL, it means that
|
|
131 there isn't a condition other than maybe mustbemesh */
|
|
132 const char* nodetypename; /* The name of the type of node this condition matches,
|
|
133 or NULL for a LEXERLEAF */
|
|
134 mybool usec; /* Whether to append the value of c to the condition */
|
|
135 mybool mustbemesh; /* Must this node be a mesh or mesh32? */
|
|
136 mybool cxneeded; /* True means calculate c and x for the node and the
|
|
137 condition is on those; false means append 'condition'
|
|
138 to the node itself to form the condition and c and x
|
|
139 aren't needed */
|
|
140 mybool width32; /* Generate a 32-bit node? */
|
|
141 mybool ublo; /* Is this a UBLO (if set, generate conditions
|
|
142 to check width)? */
|
|
143 unsigned long c; /* The value to append to the condition */
|
|
144 int replnum; /* Number of this group for replacements */
|
|
145 struct ickstype *n1;/* n1 and n2 are pointers to other conditions that */
|
|
146 struct ickstype *n2;/* also have to be satisified */
|
|
147 };
|
|
148
|
|
149 #define YYSTYPE YYSTYPE
|
|
150
|
|
151 #define MAXOPTNAMELEN 64
|
|
152 char optname[MAXOPTNAMELEN]="undefined";
|
|
153
|
|
154 typedef struct ickstype *YYSTYPE;
|
|
155
|
|
156 void splitend(void);
|
|
157 void splitstart(void);
|
|
158
|
|
159 void treedepthup(YYSTYPE, mybool);
|
|
160 void treefree(YYSTYPE);
|
|
161 void gennodepath(unsigned, unsigned long);
|
|
162 mybool treeshapecond(YYSTYPE, mybool);
|
|
163 YYSTYPE treenscheck(YYSTYPE, YYSTYPE, int);
|
|
164 void treecxcond(YYSTYPE);
|
|
165 void treerepcount(YYSTYPE, int*);
|
|
166 void treerepgen(YYSTYPE, YYSTYPE*, int*);
|
|
167
|
|
168 int countgetchar(void);
|
|
169 int countungetc(int, FILE*);
|
|
170 int cgccol;
|
|
171 int cgcrow;
|
|
172
|
|
173 /* #defines for chaining together template expressions; here, s is the type
|
|
174 of expression (e.g. select, bitwise and, unary and) that's chaining the
|
|
175 expressions together and n is the nonterminal that's the rval */
|
|
176 #define BINARYEXPR(s,m,l,r,w) do{ \
|
|
177 m=malloc(sizeof(struct ickstype)); \
|
|
178 m->n1=l; \
|
|
179 m->n2=r; \
|
|
180 m->usec=0; \
|
|
181 m->condition="->opcode==" s; \
|
|
182 m->nodetypename=s; \
|
|
183 m->mustbemesh=0; \
|
|
184 m->cxneeded=0; \
|
|
185 m->depth=0; \
|
|
186 m->path=0; \
|
|
187 m->replnum=0; \
|
|
188 m->width32=w; \
|
|
189 m->ublo=0; \
|
|
190 treedepthup(m->n1,0); \
|
|
191 treedepthup(m->n2,1); \
|
|
192 } while(0)
|
|
193
|
|
194 #define UNARYEXPR(s,m,r,w,u) do{ \
|
|
195 m=malloc(sizeof(struct ickstype)); \
|
|
196 m->n1=0; \
|
|
197 m->n2=r; \
|
|
198 m->usec=0; \
|
|
199 m->condition="->opcode==" s; \
|
|
200 m->nodetypename=s; \
|
|
201 m->mustbemesh=0; \
|
|
202 m->cxneeded=0; \
|
|
203 m->depth=0; \
|
|
204 m->path=0; \
|
|
205 m->replnum=0; \
|
|
206 m->width32=w; \
|
|
207 m->ublo=u; \
|
|
208 treedepthup(m->n2,1); \
|
|
209 } while(0)
|
|
210
|
|
211 /* Error handling and lexing */
|
|
212 int yylex(void);
|
|
213 int yyerror(char const *);
|
|
214
|
|
215 /* Split the output file */
|
|
216 #define SPLITMAX 20
|
|
217 int splitcount=SPLITMAX;
|
|
218 int filenumber=0;
|
|
219 mybool inloop=0;
|
|
220
|
|
221
|
|
222 /* Enabling traces. */
|
|
223 #ifndef YYDEBUG
|
|
224 # define YYDEBUG 0
|
|
225 #endif
|
|
226
|
|
227 /* Enabling verbose error messages. */
|
|
228 #ifdef YYERROR_VERBOSE
|
|
229 # undef YYERROR_VERBOSE
|
|
230 # define YYERROR_VERBOSE 1
|
|
231 #else
|
|
232 # define YYERROR_VERBOSE 0
|
|
233 #endif
|
|
234
|
|
235 /* Enabling the token table. */
|
|
236 #ifndef YYTOKEN_TABLE
|
|
237 # define YYTOKEN_TABLE 0
|
|
238 #endif
|
|
239
|
|
240 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
|
241 typedef int YYSTYPE;
|
|
242 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
|
243 # define YYSTYPE_IS_DECLARED 1
|
|
244 # define YYSTYPE_IS_TRIVIAL 1
|
|
245 #endif
|
|
246
|
|
247
|
|
248
|
|
249 /* Copy the second part of user declarations. */
|
|
250
|
|
251
|
|
252 /* Line 216 of yacc.c. */
|
|
253 #line 254 "oil-oil.c"
|
|
254
|
|
255 #ifdef short
|
|
256 # undef short
|
|
257 #endif
|
|
258
|
|
259 #ifdef YYTYPE_UINT8
|
|
260 typedef YYTYPE_UINT8 yytype_uint8;
|
|
261 #else
|
|
262 typedef unsigned char yytype_uint8;
|
|
263 #endif
|
|
264
|
|
265 #ifdef YYTYPE_INT8
|
|
266 typedef YYTYPE_INT8 yytype_int8;
|
|
267 #elif (defined __STDC__ || defined __C99__FUNC__ \
|
|
268 || defined __cplusplus || defined _MSC_VER)
|
|
269 typedef signed char yytype_int8;
|
|
270 #else
|
|
271 typedef short int yytype_int8;
|
|
272 #endif
|
|
273
|
|
274 #ifdef YYTYPE_UINT16
|
|
275 typedef YYTYPE_UINT16 yytype_uint16;
|
|
276 #else
|
|
277 typedef unsigned short int yytype_uint16;
|
|
278 #endif
|
|
279
|
|
280 #ifdef YYTYPE_INT16
|
|
281 typedef YYTYPE_INT16 yytype_int16;
|
|
282 #else
|
|
283 typedef short int yytype_int16;
|
|
284 #endif
|
|
285
|
|
286 #ifndef YYSIZE_T
|
|
287 # ifdef __SIZE_TYPE__
|
|
288 # define YYSIZE_T __SIZE_TYPE__
|
|
289 # elif defined size_t
|
|
290 # define YYSIZE_T size_t
|
|
291 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
|
|
292 || defined __cplusplus || defined _MSC_VER)
|
|
293 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
|
294 # define YYSIZE_T size_t
|
|
295 # else
|
|
296 # define YYSIZE_T unsigned int
|
|
297 # endif
|
|
298 #endif
|
|
299
|
|
300 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
|
|
301
|
|
302 #ifndef YY_
|
|
303 # if YYENABLE_NLS
|
|
304 # if ENABLE_NLS
|
|
305 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
|
|
306 # define YY_(msgid) dgettext ("bison-runtime", msgid)
|
|
307 # endif
|
|
308 # endif
|
|
309 # ifndef YY_
|
|
310 # define YY_(msgid) msgid
|
|
311 # endif
|
|
312 #endif
|
|
313
|
|
314 /* Suppress unused-variable warnings by "using" E. */
|
|
315 #if ! defined lint || defined __GNUC__
|
|
316 # define YYUSE(e) ((void) (e))
|
|
317 #else
|
|
318 # define YYUSE(e) /* empty */
|
|
319 #endif
|
|
320
|
|
321 /* Identity function, used to suppress warnings about constant conditions. */
|
|
322 #ifndef lint
|
|
323 # define YYID(n) (n)
|
|
324 #else
|
|
325 #if (defined __STDC__ || defined __C99__FUNC__ \
|
|
326 || defined __cplusplus || defined _MSC_VER)
|
|
327 static int
|
|
328 YYID (int i)
|
|
329 #else
|
|
330 static int
|
|
331 YYID (i)
|
|
332 int i;
|
|
333 #endif
|
|
334 {
|
|
335 return i;
|
|
336 }
|
|
337 #endif
|
|
338
|
|
339 #if ! defined yyoverflow || YYERROR_VERBOSE
|
|
340
|
|
341 /* The parser invokes alloca or malloc; define the necessary symbols. */
|
|
342
|
|
343 # ifdef YYSTACK_USE_ALLOCA
|
|
344 # if YYSTACK_USE_ALLOCA
|
|
345 # ifdef __GNUC__
|
|
346 # define YYSTACK_ALLOC __builtin_alloca
|
|
347 # elif defined __BUILTIN_VA_ARG_INCR
|
|
348 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
|
|
349 # elif defined _AIX
|
|
350 # define YYSTACK_ALLOC __alloca
|
|
351 # elif defined _MSC_VER
|
|
352 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
|
|
353 # define alloca _alloca
|
|
354 # else
|
|
355 # define YYSTACK_ALLOC alloca
|
|
356 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|
|
357 || defined __cplusplus || defined _MSC_VER)
|
|
358 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
|
359 # ifndef _STDLIB_H
|
|
360 # define _STDLIB_H 1
|
|
361 # endif
|
|
362 # endif
|
|
363 # endif
|
|
364 # endif
|
|
365 # endif
|
|
366
|
|
367 # ifdef YYSTACK_ALLOC
|
|
368 /* Pacify GCC's `empty if-body' warning. */
|
|
369 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
|
|
370 # ifndef YYSTACK_ALLOC_MAXIMUM
|
|
371 /* The OS might guarantee only one guard page at the bottom of the stack,
|
|
372 and a page size can be as small as 4096 bytes. So we cannot safely
|
|
373 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
|
|
374 to allow for a few compiler-allocated temporary stack slots. */
|
|
375 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
|
|
376 # endif
|
|
377 # else
|
|
378 # define YYSTACK_ALLOC YYMALLOC
|
|
379 # define YYSTACK_FREE YYFREE
|
|
380 # ifndef YYSTACK_ALLOC_MAXIMUM
|
|
381 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
|
|
382 # endif
|
|
383 # if (defined __cplusplus && ! defined _STDLIB_H \
|
|
384 && ! ((defined YYMALLOC || defined malloc) \
|
|
385 && (defined YYFREE || defined free)))
|
|
386 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
|
387 # ifndef _STDLIB_H
|
|
388 # define _STDLIB_H 1
|
|
389 # endif
|
|
390 # endif
|
|
391 # ifndef YYMALLOC
|
|
392 # define YYMALLOC malloc
|
|
393 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|
|
394 || defined __cplusplus || defined _MSC_VER)
|
|
395 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
|
|
396 # endif
|
|
397 # endif
|
|
398 # ifndef YYFREE
|
|
399 # define YYFREE free
|
|
400 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|
|
401 || defined __cplusplus || defined _MSC_VER)
|
|
402 void free (void *); /* INFRINGES ON USER NAME SPACE */
|
|
403 # endif
|
|
404 # endif
|
|
405 # endif
|
|
406 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
|
|
407
|
|
408
|
|
409 #if (! defined yyoverflow \
|
|
410 && (! defined __cplusplus \
|
|
411 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|
|
412
|
|
413 /* A type that is properly aligned for any stack member. */
|
|
414 union yyalloc
|
|
415 {
|
|
416 yytype_int16 yyss;
|
|
417 YYSTYPE yyvs;
|
|
418 };
|
|
419
|
|
420 /* The size of the maximum gap between one aligned stack and the next. */
|
|
421 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
|
|
422
|
|
423 /* The size of an array large to enough to hold all stacks, each with
|
|
424 N elements. */
|
|
425 # define YYSTACK_BYTES(N) \
|
|
426 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
|
|
427 + YYSTACK_GAP_MAXIMUM)
|
|
428
|
|
429 /* Copy COUNT objects from FROM to TO. The source and destination do
|
|
430 not overlap. */
|
|
431 # ifndef YYCOPY
|
|
432 # if defined __GNUC__ && 1 < __GNUC__
|
|
433 # define YYCOPY(To, From, Count) \
|
|
434 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
|
|
435 # else
|
|
436 # define YYCOPY(To, From, Count) \
|
|
437 do \
|
|
438 { \
|
|
439 YYSIZE_T yyi; \
|
|
440 for (yyi = 0; yyi < (Count); yyi++) \
|
|
441 (To)[yyi] = (From)[yyi]; \
|
|
442 } \
|
|
443 while (YYID (0))
|
|
444 # endif
|
|
445 # endif
|
|
446
|
|
447 /* Relocate STACK from its old location to the new one. The
|
|
448 local variables YYSIZE and YYSTACKSIZE give the old and new number of
|
|
449 elements in the stack, and YYPTR gives the new location of the
|
|
450 stack. Advance YYPTR to a properly aligned location for the next
|
|
451 stack. */
|
|
452 # define YYSTACK_RELOCATE(Stack) \
|
|
453 do \
|
|
454 { \
|
|
455 YYSIZE_T yynewbytes; \
|
|
456 YYCOPY (&yyptr->Stack, Stack, yysize); \
|
|
457 Stack = &yyptr->Stack; \
|
|
458 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
|
459 yyptr += yynewbytes / sizeof (*yyptr); \
|
|
460 } \
|
|
461 while (YYID (0))
|
|
462
|
|
463 #endif
|
|
464
|
|
465 /* YYFINAL -- State number of the termination state. */
|
|
466 #define YYFINAL 2
|
|
467 /* YYLAST -- Last index in YYTABLE. */
|
|
468 #define YYLAST 345
|
|
469
|
|
470 /* YYNTOKENS -- Number of terminals. */
|
|
471 #define YYNTOKENS 31
|
|
472 /* YYNNTS -- Number of nonterminals. */
|
|
473 #define YYNNTS 8
|
|
474 /* YYNRULES -- Number of rules. */
|
|
475 #define YYNRULES 89
|
|
476 /* YYNRULES -- Number of states. */
|
|
477 #define YYNSTATES 244
|
|
478
|
|
479 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
|
480 #define YYUNDEFTOK 2
|
|
481 #define YYMAXUTOK 258
|
|
482
|
|
483 #define YYTRANSLATE(YYX) \
|
|
484 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
|
485
|
|
486 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
|
|
487 static const yytype_uint8 yytranslate[] =
|
|
488 {
|
|
489 0, 2, 2, 2, 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, 29, 9, 2, 11, 28, 17, 10,
|
|
493 7, 8, 26, 25, 2, 4, 2, 27, 2, 13,
|
|
494 16, 15, 22, 23, 14, 2, 2, 2, 2, 2,
|
|
495 6, 30, 5, 19, 21, 2, 2, 2, 2, 2,
|
|
496 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
497 2, 2, 2, 2, 2, 2, 18, 2, 2, 2,
|
|
498 2, 2, 2, 2, 20, 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, 24, 2, 12, 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, 2, 2, 2, 2,
|
|
506 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
507 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
511 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
512 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
514 2, 2, 2, 2, 2, 2, 1, 2, 3
|
|
515 };
|
|
516
|
|
517 #if YYDEBUG
|
|
518 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
|
519 YYRHS. */
|
|
520 static const yytype_uint16 yyprhs[] =
|
|
521 {
|
|
522 0, 0, 3, 4, 7, 12, 17, 19, 21, 25,
|
|
523 29, 33, 35, 37, 41, 45, 51, 57, 62, 67,
|
|
524 72, 77, 82, 87, 92, 97, 102, 108, 114, 120,
|
|
525 126, 131, 137, 143, 149, 155, 159, 165, 171, 175,
|
|
526 181, 187, 191, 197, 203, 207, 213, 219, 223, 229,
|
|
527 235, 239, 245, 251, 255, 261, 267, 271, 277, 283,
|
|
528 287, 293, 299, 303, 309, 315, 320, 325, 330, 337,
|
|
529 344, 349, 356, 363, 368, 375, 382, 387, 394, 401,
|
|
530 406, 413, 420, 425, 432, 439, 442, 447, 452, 454
|
|
531 };
|
|
532
|
|
533 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
|
534 static const yytype_int8 yyrhs[] =
|
|
535 {
|
|
536 32, 0, -1, -1, 32, 33, -1, 34, 4, 5,
|
|
537 38, -1, 6, 3, 4, 3, -1, 5, -1, 35,
|
|
538 -1, 7, 37, 8, -1, 9, 37, 9, -1, 10,
|
|
539 37, 10, -1, 35, -1, 3, -1, 36, 11, 36,
|
|
540 -1, 36, 12, 36, -1, 36, 12, 13, 14, 36,
|
|
541 -1, 36, 12, 15, 16, 36, -1, 17, 13, 14,
|
|
542 36, -1, 17, 15, 16, 36, -1, 18, 13, 14,
|
|
543 36, -1, 18, 15, 16, 36, -1, 19, 13, 14,
|
|
544 36, -1, 19, 15, 16, 36, -1, 20, 13, 14,
|
|
545 36, -1, 20, 15, 16, 36, -1, 21, 13, 14,
|
|
546 36, -1, 21, 16, 13, 14, 36, -1, 21, 15,
|
|
547 13, 14, 36, -1, 21, 22, 13, 14, 36, -1,
|
|
548 21, 23, 13, 14, 36, -1, 21, 15, 16, 36,
|
|
549 -1, 21, 16, 15, 16, 36, -1, 21, 15, 15,
|
|
550 16, 36, -1, 21, 22, 15, 16, 36, -1, 21,
|
|
551 23, 15, 16, 36, -1, 36, 17, 36, -1, 36,
|
|
552 17, 13, 14, 36, -1, 36, 17, 15, 16, 36,
|
|
553 -1, 36, 24, 36, -1, 36, 24, 13, 14, 36,
|
|
554 -1, 36, 24, 15, 16, 36, -1, 36, 20, 36,
|
|
555 -1, 36, 20, 13, 14, 36, -1, 36, 20, 15,
|
|
556 16, 36, -1, 36, 25, 36, -1, 36, 25, 13,
|
|
557 14, 36, -1, 36, 25, 15, 16, 36, -1, 36,
|
|
558 4, 36, -1, 36, 4, 13, 14, 36, -1, 36,
|
|
559 4, 15, 16, 36, -1, 36, 26, 36, -1, 36,
|
|
560 26, 13, 14, 36, -1, 36, 26, 15, 16, 36,
|
|
561 -1, 36, 27, 36, -1, 36, 27, 13, 14, 36,
|
|
562 -1, 36, 27, 15, 16, 36, -1, 36, 28, 36,
|
|
563 -1, 36, 28, 13, 14, 36, -1, 36, 28, 15,
|
|
564 16, 36, -1, 36, 5, 36, -1, 36, 5, 13,
|
|
565 14, 36, -1, 36, 5, 15, 16, 36, -1, 36,
|
|
566 6, 36, -1, 36, 6, 13, 14, 36, -1, 36,
|
|
567 6, 15, 16, 36, -1, 12, 13, 14, 36, -1,
|
|
568 12, 15, 16, 36, -1, 36, 29, 30, 36, -1,
|
|
569 36, 29, 30, 13, 14, 36, -1, 36, 29, 30,
|
|
570 15, 16, 36, -1, 36, 30, 30, 36, -1, 36,
|
|
571 30, 30, 13, 14, 36, -1, 36, 30, 30, 15,
|
|
572 16, 36, -1, 36, 17, 17, 36, -1, 36, 17,
|
|
573 17, 13, 14, 36, -1, 36, 17, 17, 15, 16,
|
|
574 36, -1, 36, 24, 24, 36, -1, 36, 24, 24,
|
|
575 13, 14, 36, -1, 36, 24, 24, 15, 16, 36,
|
|
576 -1, 36, 5, 5, 36, -1, 36, 5, 5, 13,
|
|
577 14, 36, -1, 36, 5, 5, 15, 16, 36, -1,
|
|
578 36, 6, 6, 36, -1, 36, 6, 6, 13, 14,
|
|
579 36, -1, 36, 6, 6, 15, 16, 36, -1, 29,
|
|
580 36, -1, 29, 13, 14, 36, -1, 29, 15, 16,
|
|
581 36, -1, 36, -1, 35, -1
|
|
582 };
|
|
583
|
|
584 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
|
585 static const yytype_uint16 yyrline[] =
|
|
586 {
|
|
587 0, 198, 198, 198, 200, 258, 270, 272, 274, 275,
|
|
588 276, 278, 279, 281, 282, 283, 284, 285, 286, 287,
|
|
589 288, 289, 290, 291, 292, 293, 294, 295, 296, 297,
|
|
590 298, 299, 300, 301, 302, 303, 304, 305, 306, 307,
|
|
591 308, 309, 310, 311, 312, 313, 314, 315, 316, 317,
|
|
592 318, 319, 320, 321, 322, 323, 324, 325, 326, 327,
|
|
593 328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
|
|
594 338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
|
|
595 348, 349, 350, 351, 352, 353, 354, 355, 356, 358
|
|
596 };
|
|
597 #endif
|
|
598
|
|
599 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
|
600 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
|
601 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
|
602 static const char *const yytname[] =
|
|
603 {
|
|
604 "$end", "error", "$undefined", "LEXERLEAF", "'-'", "'>'", "'<'", "'('",
|
|
605 "')'", "'\"'", "'''", "'$'", "'~'", "'1'", "'6'", "'3'", "'2'", "'&'",
|
|
606 "'V'", "'?'", "'^'", "'@'", "'4'", "'5'", "'|'", "'+'", "'*'", "'/'",
|
|
607 "'%'", "'!'", "'='", "$accept", "input", "optimization", "template",
|
|
608 "expr3", "expr", "expr2", "replacement", 0
|
|
609 };
|
|
610 #endif
|
|
611
|
|
612 # ifdef YYPRINT
|
|
613 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
|
|
614 token YYLEX-NUM. */
|
|
615 static const yytype_uint16 yytoknum[] =
|
|
616 {
|
|
617 0, 256, 257, 258, 45, 62, 60, 40, 41, 34,
|
|
618 39, 36, 126, 49, 54, 51, 50, 38, 86, 63,
|
|
619 94, 64, 52, 53, 124, 43, 42, 47, 37, 33,
|
|
620 61
|
|
621 };
|
|
622 # endif
|
|
623
|
|
624 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
|
625 static const yytype_uint8 yyr1[] =
|
|
626 {
|
|
627 0, 31, 32, 32, 33, 33, 33, 34, 35, 35,
|
|
628 35, 36, 36, 37, 37, 37, 37, 37, 37, 37,
|
|
629 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
|
|
630 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
|
|
631 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
|
|
632 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
|
|
633 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
|
|
634 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
|
|
635 37, 37, 37, 37, 37, 37, 37, 37, 37, 38
|
|
636 };
|
|
637
|
|
638 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
|
639 static const yytype_uint8 yyr2[] =
|
|
640 {
|
|
641 0, 2, 0, 2, 4, 4, 1, 1, 3, 3,
|
|
642 3, 1, 1, 3, 3, 5, 5, 4, 4, 4,
|
|
643 4, 4, 4, 4, 4, 4, 5, 5, 5, 5,
|
|
644 4, 5, 5, 5, 5, 3, 5, 5, 3, 5,
|
|
645 5, 3, 5, 5, 3, 5, 5, 3, 5, 5,
|
|
646 3, 5, 5, 3, 5, 5, 3, 5, 5, 3,
|
|
647 5, 5, 3, 5, 5, 4, 4, 4, 6, 6,
|
|
648 4, 6, 6, 4, 6, 6, 4, 6, 6, 4,
|
|
649 6, 6, 4, 6, 6, 2, 4, 4, 1, 1
|
|
650 };
|
|
651
|
|
652 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
|
|
653 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
|
|
654 means the default is an error. */
|
|
655 static const yytype_uint8 yydefact[] =
|
|
656 {
|
|
657 2, 0, 1, 6, 0, 0, 0, 0, 3, 0,
|
|
658 7, 0, 12, 0, 0, 0, 0, 0, 0, 0,
|
|
659 11, 88, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
660 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
661 0, 0, 0, 0, 85, 0, 0, 0, 0, 0,
|
|
662 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,
|
|
663 9, 10, 0, 5, 0, 0, 0, 0, 0, 0,
|
|
664 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
665 0, 0, 0, 0, 0, 0, 0, 0, 47, 0,
|
|
666 0, 0, 59, 0, 0, 0, 62, 13, 0, 0,
|
|
667 14, 0, 0, 0, 35, 0, 0, 41, 0, 0,
|
|
668 0, 38, 0, 0, 44, 0, 0, 50, 0, 0,
|
|
669 53, 0, 0, 56, 0, 0, 89, 4, 65, 66,
|
|
670 17, 18, 19, 20, 21, 22, 23, 24, 25, 0,
|
|
671 0, 30, 0, 0, 0, 0, 0, 0, 86, 87,
|
|
672 0, 0, 0, 0, 79, 0, 0, 0, 0, 82,
|
|
673 0, 0, 0, 0, 0, 0, 0, 0, 73, 0,
|
|
674 0, 0, 0, 0, 0, 76, 0, 0, 0, 0,
|
|
675 0, 0, 0, 0, 0, 0, 67, 0, 0, 70,
|
|
676 27, 32, 26, 31, 28, 33, 29, 34, 48, 49,
|
|
677 0, 0, 60, 61, 0, 0, 63, 64, 15, 16,
|
|
678 36, 37, 0, 0, 42, 43, 39, 40, 0, 0,
|
|
679 45, 46, 51, 52, 54, 55, 57, 58, 0, 0,
|
|
680 0, 0, 80, 81, 83, 84, 74, 75, 77, 78,
|
|
681 68, 69, 71, 72
|
|
682 };
|
|
683
|
|
684 /* YYDEFGOTO[NTERM-NUM]. */
|
|
685 static const yytype_int8 yydefgoto[] =
|
|
686 {
|
|
687 -1, 1, 8, 9, 20, 21, 22, 127
|
|
688 };
|
|
689
|
|
690 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
|
691 STATE-NUM. */
|
|
692 #define YYPACT_NINF -20
|
|
693 static const yytype_int16 yypact[] =
|
|
694 {
|
|
695 -20, 10, -20, -20, 1, 210, 210, 210, -20, 3,
|
|
696 -20, 17, -20, -10, -2, 29, 63, 120, 192, 89,
|
|
697 -20, 83, 31, 34, 46, 67, 65, 68, 74, 72,
|
|
698 77, 87, 81, 101, 102, 105, 106, 115, 25, 125,
|
|
699 134, 141, 116, 118, -20, 188, 70, 162, 15, 231,
|
|
700 54, 240, -1, 249, 258, 267, 276, 51, 109, -20,
|
|
701 -20, -20, 107, -20, 15, 15, 15, 15, 15, 15,
|
|
702 15, 15, 15, 15, 15, 152, 132, 15, 153, 139,
|
|
703 156, 157, 160, 163, 15, 15, 164, 167, -20, 285,
|
|
704 166, 168, -20, 294, 173, 172, -20, -20, 175, 174,
|
|
705 -20, 178, 180, 303, -20, 190, 186, -20, 202, 205,
|
|
706 312, -20, 204, 207, -20, 211, 208, -20, 212, 216,
|
|
707 -20, 219, 220, -20, 321, 330, -20, -20, -20, -20,
|
|
708 -20, -20, -20, -20, -20, -20, -20, -20, -20, 15,
|
|
709 15, -20, 15, 15, 15, 15, 15, 15, -20, -20,
|
|
710 15, 15, 221, 226, -20, 15, 15, 223, 229, -20,
|
|
711 15, 15, 15, 15, 15, 15, 234, 235, -20, 15,
|
|
712 15, 15, 15, 243, 238, -20, 15, 15, 15, 15,
|
|
713 15, 15, 15, 15, 246, 247, -20, 252, 253, -20,
|
|
714 -20, -20, -20, -20, -20, -20, -20, -20, -20, -20,
|
|
715 15, 15, -20, -20, 15, 15, -20, -20, -20, -20,
|
|
716 -20, -20, 15, 15, -20, -20, -20, -20, 15, 15,
|
|
717 -20, -20, -20, -20, -20, -20, -20, -20, 15, 15,
|
|
718 15, 15, -20, -20, -20, -20, -20, -20, -20, -20,
|
|
719 -20, -20, -20, -20
|
|
720 };
|
|
721
|
|
722 /* YYPGOTO[NTERM-NUM]. */
|
|
723 static const yytype_int8 yypgoto[] =
|
|
724 {
|
|
725 -20, -20, -20, -20, 0, -19, 53, -20
|
|
726 };
|
|
727
|
|
728 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
|
729 positive, shift that token. If negative, reduce the rule which
|
|
730 number is the opposite. If zero, do what YYDEFACT says.
|
|
731 If YYTABLE_NINF, syntax error. */
|
|
732 #define YYTABLE_NINF -1
|
|
733 static const yytype_uint8 yytable[] =
|
|
734 {
|
|
735 44, 10, 12, 27, 11, 28, 5, 25, 6, 7,
|
|
736 2, 29, 108, 30, 109, 3, 4, 5, 12, 6,
|
|
737 7, 26, 5, 110, 6, 7, 88, 92, 96, 97,
|
|
738 100, 104, 107, 111, 114, 117, 120, 123, 75, 59,
|
|
739 76, 77, 31, 60, 32, 128, 129, 130, 131, 132,
|
|
740 133, 134, 135, 136, 137, 138, 61, 12, 141, 23,
|
|
741 24, 5, 126, 6, 7, 148, 149, 101, 63, 102,
|
|
742 154, 103, 62, 12, 159, 89, 33, 5, 34, 6,
|
|
743 7, 124, 64, 90, 168, 91, 66, 45, 46, 47,
|
|
744 65, 175, 12, 67, 48, 49, 5, 69, 6, 7,
|
|
745 50, 68, 42, 51, 43, 186, 189, 52, 53, 54,
|
|
746 55, 56, 57, 58, 5, 70, 6, 7, 71, 72,
|
|
747 190, 191, 73, 192, 193, 194, 195, 196, 197, 74,
|
|
748 84, 198, 199, 35, 85, 36, 202, 203, 78, 125,
|
|
749 79, 206, 207, 208, 209, 210, 211, 80, 140, 81,
|
|
750 214, 215, 216, 217, 82, 143, 83, 220, 221, 222,
|
|
751 223, 224, 225, 226, 227, 12, 139, 142, 93, 5,
|
|
752 144, 6, 7, 145, 146, 94, 0, 95, 150, 147,
|
|
753 155, 232, 233, 151, 156, 234, 235, 160, 161, 162,
|
|
754 163, 12, 164, 236, 237, 5, 165, 6, 7, 238,
|
|
755 239, 86, 170, 87, 169, 37, 0, 38, 39, 240,
|
|
756 241, 242, 243, 12, 40, 41, 171, 5, 176, 6,
|
|
757 7, 172, 13, 177, 179, 178, 180, 14, 15, 16,
|
|
758 17, 18, 181, 182, 12, 200, 183, 204, 5, 19,
|
|
759 6, 7, 201, 12, 98, 205, 99, 5, 212, 6,
|
|
760 7, 213, 12, 105, 219, 106, 5, 218, 6, 7,
|
|
761 228, 12, 112, 229, 113, 5, 230, 6, 7, 231,
|
|
762 12, 115, 0, 116, 5, 0, 6, 7, 0, 12,
|
|
763 118, 0, 119, 5, 0, 6, 7, 0, 12, 121,
|
|
764 0, 122, 5, 0, 6, 7, 0, 12, 152, 0,
|
|
765 153, 5, 0, 6, 7, 0, 12, 157, 0, 158,
|
|
766 5, 0, 6, 7, 0, 12, 166, 0, 167, 5,
|
|
767 0, 6, 7, 0, 12, 173, 0, 174, 5, 0,
|
|
768 6, 7, 0, 12, 184, 0, 185, 5, 0, 6,
|
|
769 7, 0, 0, 187, 0, 188
|
|
770 };
|
|
771
|
|
772 static const yytype_int16 yycheck[] =
|
|
773 {
|
|
774 19, 1, 3, 13, 3, 15, 7, 4, 9, 10,
|
|
775 0, 13, 13, 15, 15, 5, 6, 7, 3, 9,
|
|
776 10, 4, 7, 24, 9, 10, 45, 46, 47, 48,
|
|
777 49, 50, 51, 52, 53, 54, 55, 56, 13, 8,
|
|
778 15, 16, 13, 9, 15, 64, 65, 66, 67, 68,
|
|
779 69, 70, 71, 72, 73, 74, 10, 3, 77, 6,
|
|
780 7, 7, 62, 9, 10, 84, 85, 13, 3, 15,
|
|
781 89, 17, 5, 3, 93, 5, 13, 7, 15, 9,
|
|
782 10, 30, 14, 13, 103, 15, 14, 4, 5, 6,
|
|
783 16, 110, 3, 16, 11, 12, 7, 16, 9, 10,
|
|
784 17, 14, 13, 20, 15, 124, 125, 24, 25, 26,
|
|
785 27, 28, 29, 30, 7, 14, 9, 10, 16, 14,
|
|
786 139, 140, 16, 142, 143, 144, 145, 146, 147, 14,
|
|
787 14, 150, 151, 13, 16, 15, 155, 156, 13, 30,
|
|
788 15, 160, 161, 162, 163, 164, 165, 13, 16, 15,
|
|
789 169, 170, 171, 172, 13, 16, 15, 176, 177, 178,
|
|
790 179, 180, 181, 182, 183, 3, 14, 14, 6, 7,
|
|
791 14, 9, 10, 16, 14, 13, -1, 15, 14, 16,
|
|
792 14, 200, 201, 16, 16, 204, 205, 14, 16, 14,
|
|
793 16, 3, 14, 212, 213, 7, 16, 9, 10, 218,
|
|
794 219, 13, 16, 15, 14, 13, -1, 15, 16, 228,
|
|
795 229, 230, 231, 3, 22, 23, 14, 7, 14, 9,
|
|
796 10, 16, 12, 16, 16, 14, 14, 17, 18, 19,
|
|
797 20, 21, 16, 14, 3, 14, 16, 14, 7, 29,
|
|
798 9, 10, 16, 3, 13, 16, 15, 7, 14, 9,
|
|
799 10, 16, 3, 13, 16, 15, 7, 14, 9, 10,
|
|
800 14, 3, 13, 16, 15, 7, 14, 9, 10, 16,
|
|
801 3, 13, -1, 15, 7, -1, 9, 10, -1, 3,
|
|
802 13, -1, 15, 7, -1, 9, 10, -1, 3, 13,
|
|
803 -1, 15, 7, -1, 9, 10, -1, 3, 13, -1,
|
|
804 15, 7, -1, 9, 10, -1, 3, 13, -1, 15,
|
|
805 7, -1, 9, 10, -1, 3, 13, -1, 15, 7,
|
|
806 -1, 9, 10, -1, 3, 13, -1, 15, 7, -1,
|
|
807 9, 10, -1, 3, 13, -1, 15, 7, -1, 9,
|
|
808 10, -1, -1, 13, -1, 15
|
|
809 };
|
|
810
|
|
811 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
|
|
812 symbol of state STATE-NUM. */
|
|
813 static const yytype_uint8 yystos[] =
|
|
814 {
|
|
815 0, 32, 0, 5, 6, 7, 9, 10, 33, 34,
|
|
816 35, 3, 3, 12, 17, 18, 19, 20, 21, 29,
|
|
817 35, 36, 37, 37, 37, 4, 4, 13, 15, 13,
|
|
818 15, 13, 15, 13, 15, 13, 15, 13, 15, 16,
|
|
819 22, 23, 13, 15, 36, 4, 5, 6, 11, 12,
|
|
820 17, 20, 24, 25, 26, 27, 28, 29, 30, 8,
|
|
821 9, 10, 5, 3, 14, 16, 14, 16, 14, 16,
|
|
822 14, 16, 14, 16, 14, 13, 15, 16, 13, 15,
|
|
823 13, 15, 13, 15, 14, 16, 13, 15, 36, 5,
|
|
824 13, 15, 36, 6, 13, 15, 36, 36, 13, 15,
|
|
825 36, 13, 15, 17, 36, 13, 15, 36, 13, 15,
|
|
826 24, 36, 13, 15, 36, 13, 15, 36, 13, 15,
|
|
827 36, 13, 15, 36, 30, 30, 35, 38, 36, 36,
|
|
828 36, 36, 36, 36, 36, 36, 36, 36, 36, 14,
|
|
829 16, 36, 14, 16, 14, 16, 14, 16, 36, 36,
|
|
830 14, 16, 13, 15, 36, 14, 16, 13, 15, 36,
|
|
831 14, 16, 14, 16, 14, 16, 13, 15, 36, 14,
|
|
832 16, 14, 16, 13, 15, 36, 14, 16, 14, 16,
|
|
833 14, 16, 14, 16, 13, 15, 36, 13, 15, 36,
|
|
834 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
|
|
835 14, 16, 36, 36, 14, 16, 36, 36, 36, 36,
|
|
836 36, 36, 14, 16, 36, 36, 36, 36, 14, 16,
|
|
837 36, 36, 36, 36, 36, 36, 36, 36, 14, 16,
|
|
838 14, 16, 36, 36, 36, 36, 36, 36, 36, 36,
|
|
839 36, 36, 36, 36
|
|
840 };
|
|
841
|
|
842 #define yyerrok (yyerrstatus = 0)
|
|
843 #define yyclearin (yychar = YYEMPTY)
|
|
844 #define YYEMPTY (-2)
|
|
845 #define YYEOF 0
|
|
846
|
|
847 #define YYACCEPT goto yyacceptlab
|
|
848 #define YYABORT goto yyabortlab
|
|
849 #define YYERROR goto yyerrorlab
|
|
850
|
|
851
|
|
852 /* Like YYERROR except do call yyerror. This remains here temporarily
|
|
853 to ease the transition to the new meaning of YYERROR, for GCC.
|
|
854 Once GCC version 2 has supplanted version 1, this can go. */
|
|
855
|
|
856 #define YYFAIL goto yyerrlab
|
|
857
|
|
858 #define YYRECOVERING() (!!yyerrstatus)
|
|
859
|
|
860 #define YYBACKUP(Token, Value) \
|
|
861 do \
|
|
862 if (yychar == YYEMPTY && yylen == 1) \
|
|
863 { \
|
|
864 yychar = (Token); \
|
|
865 yylval = (Value); \
|
|
866 yytoken = YYTRANSLATE (yychar); \
|
|
867 YYPOPSTACK (1); \
|
|
868 goto yybackup; \
|
|
869 } \
|
|
870 else \
|
|
871 { \
|
|
872 yyerror (YY_("syntax error: cannot back up")); \
|
|
873 YYERROR; \
|
|
874 } \
|
|
875 while (YYID (0))
|
|
876
|
|
877
|
|
878 #define YYTERROR 1
|
|
879 #define YYERRCODE 256
|
|
880
|
|
881
|
|
882 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
|
883 If N is 0, then set CURRENT to the empty location which ends
|
|
884 the previous symbol: RHS[0] (always defined). */
|
|
885
|
|
886 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
|
887 #ifndef YYLLOC_DEFAULT
|
|
888 # define YYLLOC_DEFAULT(Current, Rhs, N) \
|
|
889 do \
|
|
890 if (YYID (N)) \
|
|
891 { \
|
|
892 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
|
893 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
|
894 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
|
895 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
|
896 } \
|
|
897 else \
|
|
898 { \
|
|
899 (Current).first_line = (Current).last_line = \
|
|
900 YYRHSLOC (Rhs, 0).last_line; \
|
|
901 (Current).first_column = (Current).last_column = \
|
|
902 YYRHSLOC (Rhs, 0).last_column; \
|
|
903 } \
|
|
904 while (YYID (0))
|
|
905 #endif
|
|
906
|
|
907
|
|
908 /* YY_LOCATION_PRINT -- Print the location on the stream.
|
|
909 This macro was not mandated originally: define only if we know
|
|
910 we won't break user code: when these are the locations we know. */
|
|
911
|
|
912 #ifndef YY_LOCATION_PRINT
|
|
913 # if YYLTYPE_IS_TRIVIAL
|
|
914 # define YY_LOCATION_PRINT(File, Loc) \
|
|
915 fprintf (File, "%d.%d-%d.%d", \
|
|
916 (Loc).first_line, (Loc).first_column, \
|
|
917 (Loc).last_line, (Loc).last_column)
|
|
918 # else
|
|
919 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
|
920 # endif
|
|
921 #endif
|
|
922
|
|
923
|
|
924 /* YYLEX -- calling `yylex' with the right arguments. */
|
|
925
|
|
926 #ifdef YYLEX_PARAM
|
|
927 # define YYLEX yylex (YYLEX_PARAM)
|
|
928 #else
|
|
929 # define YYLEX yylex ()
|
|
930 #endif
|
|
931
|
|
932 /* Enable debugging if requested. */
|
|
933 #if YYDEBUG
|
|
934
|
|
935 # ifndef YYFPRINTF
|
|
936 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
|
|
937 # define YYFPRINTF fprintf
|
|
938 # endif
|
|
939
|
|
940 # define YYDPRINTF(Args) \
|
|
941 do { \
|
|
942 if (yydebug) \
|
|
943 YYFPRINTF Args; \
|
|
944 } while (YYID (0))
|
|
945
|
|
946 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
|
947 do { \
|
|
948 if (yydebug) \
|
|
949 { \
|
|
950 YYFPRINTF (stderr, "%s ", Title); \
|
|
951 yy_symbol_print (stderr, \
|
|
952 Type, Value); \
|
|
953 YYFPRINTF (stderr, "\n"); \
|
|
954 } \
|
|
955 } while (YYID (0))
|
|
956
|
|
957
|
|
958 /*--------------------------------.
|
|
959 | Print this symbol on YYOUTPUT. |
|
|
960 `--------------------------------*/
|
|
961
|
|
962 /*ARGSUSED*/
|
|
963 #if (defined __STDC__ || defined __C99__FUNC__ \
|
|
964 || defined __cplusplus || defined _MSC_VER)
|
|
965 static void
|
|
966 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
|
|
967 #else
|
|
968 static void
|
|
969 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
|
|
970 FILE *yyoutput;
|
|
971 int yytype;
|
|
972 YYSTYPE const * const yyvaluep;
|
|
973 #endif
|
|
974 {
|
|
975 if (!yyvaluep)
|
|
976 return;
|
|
977 # ifdef YYPRINT
|
|
978 if (yytype < YYNTOKENS)
|
|
979 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
|
|
980 # else
|
|
981 YYUSE (yyoutput);
|
|
982 # endif
|
|
983 switch (yytype)
|
|
984 {
|
|
985 default:
|
|
986 break;
|
|
987 }
|
|
988 }
|
|
989
|
|
990
|
|
991 /*--------------------------------.
|
|
992 | Print this symbol on YYOUTPUT. |
|
|
993 `--------------------------------*/
|
|
994
|
|
995 #if (defined __STDC__ || defined __C99__FUNC__ \
|
|
996 || defined __cplusplus || defined _MSC_VER)
|
|
997 static void
|
|
998 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
|
|
999 #else
|
|
1000 static void
|
|
1001 yy_symbol_print (yyoutput, yytype, yyvaluep)
|
|
1002 FILE *yyoutput;
|
|
1003 int yytype;
|
|
1004 YYSTYPE const * const yyvaluep;
|
|
1005 #endif
|
|
1006 {
|
|
1007 if (yytype < YYNTOKENS)
|
|
1008 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
|
|
1009 else
|
|
1010 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
|
|
1011
|
|
1012 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
|
|
1013 YYFPRINTF (yyoutput, ")");
|
|
1014 }
|
|
1015
|
|
1016 /*------------------------------------------------------------------.
|
|
1017 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
|
|
1018 | TOP (included). |
|
|
1019 `------------------------------------------------------------------*/
|
|
1020
|
|
1021 #if (defined __STDC__ || defined __C99__FUNC__ \
|
|
1022 || defined __cplusplus || defined _MSC_VER)
|
|
1023 static void
|
|
1024 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
|
|
1025 #else
|
|
1026 static void
|
|
1027 yy_stack_print (bottom, top)
|
|
1028 yytype_int16 *bottom;
|
|
1029 yytype_int16 *top;
|
|
1030 #endif
|
|
1031 {
|
|
1032 YYFPRINTF (stderr, "Stack now");
|
|
1033 for (; bottom <= top; ++bottom)
|
|
1034 YYFPRINTF (stderr, " %d", *bottom);
|
|
1035 YYFPRINTF (stderr, "\n");
|
|
1036 }
|
|
1037
|
|
1038 # define YY_STACK_PRINT(Bottom, Top) \
|
|
1039 do { \
|
|
1040 if (yydebug) \
|
|
1041 yy_stack_print ((Bottom), (Top)); \
|
|
1042 } while (YYID (0))
|
|
1043
|
|
1044
|
|
1045 /*------------------------------------------------.
|
|
1046 | Report that the YYRULE is going to be reduced. |
|
|
1047 `------------------------------------------------*/
|
|
1048
|
|
1049 #if (defined __STDC__ || defined __C99__FUNC__ \
|
|
1050 || defined __cplusplus || defined _MSC_VER)
|
|
1051 static void
|
|
1052 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
|
|
1053 #else
|
|
1054 static void
|
|
1055 yy_reduce_print (yyvsp, yyrule)
|
|
1056 YYSTYPE *yyvsp;
|
|
1057 int yyrule;
|
|
1058 #endif
|
|
1059 {
|
|
1060 int yynrhs = yyr2[yyrule];
|
|
1061 int yyi;
|
|
1062 unsigned long int yylno = yyrline[yyrule];
|
|
1063 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
|
1064 yyrule - 1, yylno);
|
|
1065 /* The symbols being reduced. */
|
|
1066 for (yyi = 0; yyi < yynrhs; yyi++)
|
|
1067 {
|
|
1068 fprintf (stderr, " $%d = ", yyi + 1);
|
|
1069 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
|
|
1070 &(yyvsp[(yyi + 1) - (yynrhs)])
|
|
1071 );
|
|
1072 fprintf (stderr, "\n");
|
|
1073 }
|
|
1074 }
|
|
1075
|
|
1076 # define YY_REDUCE_PRINT(Rule) \
|
|
1077 do { \
|
|
1078 if (yydebug) \
|
|
1079 yy_reduce_print (yyvsp, Rule); \
|
|
1080 } while (YYID (0))
|
|
1081
|
|
1082 /* Nonzero means print parse trace. It is left uninitialized so that
|
|
1083 multiple parsers can coexist. */
|
|
1084 int yydebug;
|
|
1085 #else /* !YYDEBUG */
|
|
1086 # define YYDPRINTF(Args)
|
|
1087 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
|
1088 # define YY_STACK_PRINT(Bottom, Top)
|
|
1089 # define YY_REDUCE_PRINT(Rule)
|
|
1090 #endif /* !YYDEBUG */
|
|
1091
|
|
1092
|
|
1093 /* YYINITDEPTH -- initial size of the parser's stacks. */
|
|
1094 #ifndef YYINITDEPTH
|
|
1095 # define YYINITDEPTH 200
|
|
1096 #endif
|
|
1097
|
|
1098 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
|
|
1099 if the built-in stack extension method is used).
|
|
1100
|
|
1101 Do not make this value too large; the results are undefined if
|
|
1102 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
|
|
1103 evaluated with infinite-precision integer arithmetic. */
|
|
1104
|
|
1105 #ifndef YYMAXDEPTH
|
|
1106 # define YYMAXDEPTH 10000
|
|
1107 #endif
|
|
1108
|
|
1109
|
|
1110
|
|
1111 #if YYERROR_VERBOSE
|
|
1112
|
|
1113 # ifndef yystrlen
|
|
1114 # if defined __GLIBC__ && defined _STRING_H
|
|
1115 # define yystrlen strlen
|
|
1116 # else
|
|
1117 /* Return the length of YYSTR. */
|
|
1118 #if (defined __STDC__ || defined __C99__FUNC__ \
|
|
1119 || defined __cplusplus || defined _MSC_VER)
|
|
1120 static YYSIZE_T
|
|
1121 yystrlen (const char *yystr)
|
|
1122 #else
|
|
1123 static YYSIZE_T
|
|
1124 yystrlen (yystr)
|
|
1125 const char *yystr;
|
|
1126 #endif
|
|
1127 {
|
|
1128 YYSIZE_T yylen;
|
|
1129 for (yylen = 0; yystr[yylen]; yylen++)
|
|
1130 continue;
|
|
1131 return yylen;
|
|
1132 }
|
|
1133 # endif
|
|
1134 # endif
|
|
1135
|
|
1136 # ifndef yystpcpy
|
|
1137 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
|
|
1138 # define yystpcpy stpcpy
|
|
1139 # else
|
|
1140 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
|
|
1141 YYDEST. */
|
|
1142 #if (defined __STDC__ || defined __C99__FUNC__ \
|
|
1143 || defined __cplusplus || defined _MSC_VER)
|
|
1144 static char *
|
|
1145 yystpcpy (char *yydest, const char *yysrc)
|
|
1146 #else
|
|
1147 static char *
|
|
1148 yystpcpy (yydest, yysrc)
|
|
1149 char *yydest;
|
|
1150 const char *yysrc;
|
|
1151 #endif
|
|
1152 {
|
|
1153 char *yyd = yydest;
|
|
1154 const char *yys = yysrc;
|
|
1155
|
|
1156 while ((*yyd++ = *yys++) != '\0')
|
|
1157 continue;
|
|
1158
|
|
1159 return yyd - 1;
|
|
1160 }
|
|
1161 # endif
|
|
1162 # endif
|
|
1163
|
|
1164 # ifndef yytnamerr
|
|
1165 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
|
|
1166 quotes and backslashes, so that it's suitable for yyerror. The
|
|
1167 heuristic is that double-quoting is unnecessary unless the string
|
|
1168 contains an apostrophe, a comma, or backslash (other than
|
|
1169 backslash-backslash). YYSTR is taken from yytname. If YYRES is
|
|
1170 null, do not copy; instead, return the length of what the result
|
|
1171 would have been. */
|
|
1172 static YYSIZE_T
|
|
1173 yytnamerr (char *yyres, const char *yystr)
|
|
1174 {
|
|
1175 if (*yystr == '"')
|
|
1176 {
|
|
1177 YYSIZE_T yyn = 0;
|
|
1178 char const *yyp = yystr;
|
|
1179
|
|
1180 for (;;)
|
|
1181 switch (*++yyp)
|
|
1182 {
|
|
1183 case '\'':
|
|
1184 case ',':
|
|
1185 goto do_not_strip_quotes;
|
|
1186
|
|
1187 case '\\':
|
|
1188 if (*++yyp != '\\')
|
|
1189 goto do_not_strip_quotes;
|
|
1190 /* Fall through. */
|
|
1191 default:
|
|
1192 if (yyres)
|
|
1193 yyres[yyn] = *yyp;
|
|
1194 yyn++;
|
|
1195 break;
|
|
1196
|
|
1197 case '"':
|
|
1198 if (yyres)
|
|
1199 yyres[yyn] = '\0';
|
|
1200 return yyn;
|
|
1201 }
|
|
1202 do_not_strip_quotes: ;
|
|
1203 }
|
|
1204
|
|
1205 if (! yyres)
|
|
1206 return yystrlen (yystr);
|
|
1207
|
|
1208 return yystpcpy (yyres, yystr) - yyres;
|
|
1209 }
|
|
1210 # endif
|
|
1211
|
|
1212 /* Copy into YYRESULT an error message about the unexpected token
|
|
1213 YYCHAR while in state YYSTATE. Return the number of bytes copied,
|
|
1214 including the terminating null byte. If YYRESULT is null, do not
|
|
1215 copy anything; just return the number of bytes that would be
|
|
1216 copied. As a special case, return 0 if an ordinary "syntax error"
|
|
1217 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
|
|
1218 size calculation. */
|
|
1219 static YYSIZE_T
|
|
1220 yysyntax_error (char *yyresult, int yystate, int yychar)
|
|
1221 {
|
|
1222 int yyn = yypact[yystate];
|
|
1223
|
|
1224 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
|
|
1225 return 0;
|
|
1226 else
|
|
1227 {
|
|
1228 int yytype = YYTRANSLATE (yychar);
|
|
1229 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
|
|
1230 YYSIZE_T yysize = yysize0;
|
|
1231 YYSIZE_T yysize1;
|
|
1232 int yysize_overflow = 0;
|
|
1233 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
|
1234 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
|
|
1235 int yyx;
|
|
1236
|
|
1237 # if 0
|
|
1238 /* This is so xgettext sees the translatable formats that are
|
|
1239 constructed on the fly. */
|
|
1240 YY_("syntax error, unexpected %s");
|
|
1241 YY_("syntax error, unexpected %s, expecting %s");
|
|
1242 YY_("syntax error, unexpected %s, expecting %s or %s");
|
|
1243 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
|
|
1244 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
|
|
1245 # endif
|
|
1246 char *yyfmt;
|
|
1247 char const *yyf;
|
|
1248 static char const yyunexpected[] = "syntax error, unexpected %s";
|
|
1249 static char const yyexpecting[] = ", expecting %s";
|
|
1250 static char const yyor[] = " or %s";
|
|
1251 char yyformat[sizeof yyunexpected
|
|
1252 + sizeof yyexpecting - 1
|
|
1253 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
|
|
1254 * (sizeof yyor - 1))];
|
|
1255 char const *yyprefix = yyexpecting;
|
|
1256
|
|
1257 /* Start YYX at -YYN if negative to avoid negative indexes in
|
|
1258 YYCHECK. */
|
|
1259 int yyxbegin = yyn < 0 ? -yyn : 0;
|
|
1260
|
|
1261 /* Stay within bounds of both yycheck and yytname. */
|
|
1262 int yychecklim = YYLAST - yyn + 1;
|
|
1263 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
|
1264 int yycount = 1;
|
|
1265
|
|
1266 yyarg[0] = yytname[yytype];
|
|
1267 yyfmt = yystpcpy (yyformat, yyunexpected);
|
|
1268
|
|
1269 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
|
1270 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
|
1271 {
|
|
1272 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
|
|
1273 {
|
|
1274 yycount = 1;
|
|
1275 yysize = yysize0;
|
|
1276 yyformat[sizeof yyunexpected - 1] = '\0';
|
|
1277 break;
|
|
1278 }
|
|
1279 yyarg[yycount++] = yytname[yyx];
|
|
1280 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
|
|
1281 yysize_overflow |= (yysize1 < yysize);
|
|
1282 yysize = yysize1;
|
|
1283 yyfmt = yystpcpy (yyfmt, yyprefix);
|
|
1284 yyprefix = yyor;
|
|
1285 }
|
|
1286
|
|
1287 yyf = YY_(yyformat);
|
|
1288 yysize1 = yysize + yystrlen (yyf);
|
|
1289 yysize_overflow |= (yysize1 < yysize);
|
|
1290 yysize = yysize1;
|
|
1291
|
|
1292 if (yysize_overflow)
|
|
1293 return YYSIZE_MAXIMUM;
|
|
1294
|
|
1295 if (yyresult)
|
|
1296 {
|
|
1297 /* Avoid sprintf, as that infringes on the user's name space.
|
|
1298 Don't have undefined behavior even if the translation
|
|
1299 produced a string with the wrong number of "%s"s. */
|
|
1300 char *yyp = yyresult;
|
|
1301 int yyi = 0;
|
|
1302 while ((*yyp = *yyf) != '\0')
|
|
1303 {
|
|
1304 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
|
|
1305 {
|
|
1306 yyp += yytnamerr (yyp, yyarg[yyi++]);
|
|
1307 yyf += 2;
|
|
1308 }
|
|
1309 else
|
|
1310 {
|
|
1311 yyp++;
|
|
1312 yyf++;
|
|
1313 }
|
|
1314 }
|
|
1315 }
|
|
1316 return yysize;
|
|
1317 }
|
|
1318 }
|
|
1319 #endif /* YYERROR_VERBOSE */
|
|
1320
|
|
1321
|
|
1322 /*-----------------------------------------------.
|
|
1323 | Release the memory associated to this symbol. |
|
|
1324 `-----------------------------------------------*/
|
|
1325
|
|
1326 /*ARGSUSED*/
|
|
1327 #if (defined __STDC__ || defined __C99__FUNC__ \
|
|
1328 || defined __cplusplus || defined _MSC_VER)
|
|
1329 static void
|
|
1330 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
|
|
1331 #else
|
|
1332 static void
|
|
1333 yydestruct (yymsg, yytype, yyvaluep)
|
|
1334 const char *yymsg;
|
|
1335 int yytype;
|
|
1336 YYSTYPE *yyvaluep;
|
|
1337 #endif
|
|
1338 {
|
|
1339 YYUSE (yyvaluep);
|
|
1340
|
|
1341 if (!yymsg)
|
|
1342 yymsg = "Deleting";
|
|
1343 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
|
1344
|
|
1345 switch (yytype)
|
|
1346 {
|
|
1347
|
|
1348 default:
|
|
1349 break;
|
|
1350 }
|
|
1351 }
|
|
1352
|
|
1353
|
|
1354 /* Prevent warnings from -Wmissing-prototypes. */
|
|
1355
|
|
1356 #ifdef YYPARSE_PARAM
|
|
1357 #if defined __STDC__ || defined __cplusplus
|
|
1358 int yyparse (void *YYPARSE_PARAM);
|
|
1359 #else
|
|
1360 int yyparse ();
|
|
1361 #endif
|
|
1362 #else /* ! YYPARSE_PARAM */
|
|
1363 #if defined __STDC__ || defined __cplusplus
|
|
1364 int yyparse (void);
|
|
1365 #else
|
|
1366 int yyparse ();
|
|
1367 #endif
|
|
1368 #endif /* ! YYPARSE_PARAM */
|
|
1369
|
|
1370
|
|
1371
|
|
1372 /* The look-ahead symbol. */
|
|
1373 int yychar;
|
|
1374
|
|
1375 /* The semantic value of the look-ahead symbol. */
|
|
1376 YYSTYPE yylval;
|
|
1377
|
|
1378 /* Number of syntax errors so far. */
|
|
1379 int yynerrs;
|
|
1380
|
|
1381
|
|
1382
|
|
1383 /*----------.
|
|
1384 | yyparse. |
|
|
1385 `----------*/
|
|
1386
|
|
1387 #ifdef YYPARSE_PARAM
|
|
1388 #if (defined __STDC__ || defined __C99__FUNC__ \
|
|
1389 || defined __cplusplus || defined _MSC_VER)
|
|
1390 int
|
|
1391 yyparse (void *YYPARSE_PARAM)
|
|
1392 #else
|
|
1393 int
|
|
1394 yyparse (YYPARSE_PARAM)
|
|
1395 void *YYPARSE_PARAM;
|
|
1396 #endif
|
|
1397 #else /* ! YYPARSE_PARAM */
|
|
1398 #if (defined __STDC__ || defined __C99__FUNC__ \
|
|
1399 || defined __cplusplus || defined _MSC_VER)
|
|
1400 int
|
|
1401 yyparse (void)
|
|
1402 #else
|
|
1403 int
|
|
1404 yyparse ()
|
|
1405
|
|
1406 #endif
|
|
1407 #endif
|
|
1408 {
|
|
1409
|
|
1410 int yystate;
|
|
1411 int yyn;
|
|
1412 int yyresult;
|
|
1413 /* Number of tokens to shift before error messages enabled. */
|
|
1414 int yyerrstatus;
|
|
1415 /* Look-ahead token as an internal (translated) token number. */
|
|
1416 int yytoken = 0;
|
|
1417 #if YYERROR_VERBOSE
|
|
1418 /* Buffer for error messages, and its allocated size. */
|
|
1419 char yymsgbuf[128];
|
|
1420 char *yymsg = yymsgbuf;
|
|
1421 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
|
|
1422 #endif
|
|
1423
|
|
1424 /* Three stacks and their tools:
|
|
1425 `yyss': related to states,
|
|
1426 `yyvs': related to semantic values,
|
|
1427 `yyls': related to locations.
|
|
1428
|
|
1429 Refer to the stacks thru separate pointers, to allow yyoverflow
|
|
1430 to reallocate them elsewhere. */
|
|
1431
|
|
1432 /* The state stack. */
|
|
1433 yytype_int16 yyssa[YYINITDEPTH];
|
|
1434 yytype_int16 *yyss = yyssa;
|
|
1435 yytype_int16 *yyssp;
|
|
1436
|
|
1437 /* The semantic value stack. */
|
|
1438 YYSTYPE yyvsa[YYINITDEPTH];
|
|
1439 YYSTYPE *yyvs = yyvsa;
|
|
1440 YYSTYPE *yyvsp;
|
|
1441
|
|
1442
|
|
1443
|
|
1444 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
|
|
1445
|
|
1446 YYSIZE_T yystacksize = YYINITDEPTH;
|
|
1447
|
|
1448 /* The variables used to return semantic value and location from the
|
|
1449 action routines. */
|
|
1450 YYSTYPE yyval;
|
|
1451
|
|
1452
|
|
1453 /* The number of symbols on the RHS of the reduced rule.
|
|
1454 Keep to zero when no symbol should be popped. */
|
|
1455 int yylen = 0;
|
|
1456
|
|
1457 YYDPRINTF ((stderr, "Starting parse\n"));
|
|
1458
|
|
1459 yystate = 0;
|
|
1460 yyerrstatus = 0;
|
|
1461 yynerrs = 0;
|
|
1462 yychar = YYEMPTY; /* Cause a token to be read. */
|
|
1463
|
|
1464 /* Initialize stack pointers.
|
|
1465 Waste one element of value and location stack
|
|
1466 so that they stay on the same level as the state stack.
|
|
1467 The wasted elements are never initialized. */
|
|
1468
|
|
1469 yyssp = yyss;
|
|
1470 yyvsp = yyvs;
|
|
1471
|
|
1472 goto yysetstate;
|
|
1473
|
|
1474 /*------------------------------------------------------------.
|
|
1475 | yynewstate -- Push a new state, which is found in yystate. |
|
|
1476 `------------------------------------------------------------*/
|
|
1477 yynewstate:
|
|
1478 /* In all cases, when you get here, the value and location stacks
|
|
1479 have just been pushed. So pushing a state here evens the stacks. */
|
|
1480 yyssp++;
|
|
1481
|
|
1482 yysetstate:
|
|
1483 *yyssp = yystate;
|
|
1484
|
|
1485 if (yyss + yystacksize - 1 <= yyssp)
|
|
1486 {
|
|
1487 /* Get the current used size of the three stacks, in elements. */
|
|
1488 YYSIZE_T yysize = yyssp - yyss + 1;
|
|
1489
|
|
1490 #ifdef yyoverflow
|
|
1491 {
|
|
1492 /* Give user a chance to reallocate the stack. Use copies of
|
|
1493 these so that the &'s don't force the real ones into
|
|
1494 memory. */
|
|
1495 YYSTYPE *yyvs1 = yyvs;
|
|
1496 yytype_int16 *yyss1 = yyss;
|
|
1497
|
|
1498
|
|
1499 /* Each stack pointer address is followed by the size of the
|
|
1500 data in use in that stack, in bytes. This used to be a
|
|
1501 conditional around just the two extra args, but that might
|
|
1502 be undefined if yyoverflow is a macro. */
|
|
1503 yyoverflow (YY_("memory exhausted"),
|
|
1504 &yyss1, yysize * sizeof (*yyssp),
|
|
1505 &yyvs1, yysize * sizeof (*yyvsp),
|
|
1506
|
|
1507 &yystacksize);
|
|
1508
|
|
1509 yyss = yyss1;
|
|
1510 yyvs = yyvs1;
|
|
1511 }
|
|
1512 #else /* no yyoverflow */
|
|
1513 # ifndef YYSTACK_RELOCATE
|
|
1514 goto yyexhaustedlab;
|
|
1515 # else
|
|
1516 /* Extend the stack our own way. */
|
|
1517 if (YYMAXDEPTH <= yystacksize)
|
|
1518 goto yyexhaustedlab;
|
|
1519 yystacksize *= 2;
|
|
1520 if (YYMAXDEPTH < yystacksize)
|
|
1521 yystacksize = YYMAXDEPTH;
|
|
1522
|
|
1523 {
|
|
1524 yytype_int16 *yyss1 = yyss;
|
|
1525 union yyalloc *yyptr =
|
|
1526 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
|
|
1527 if (! yyptr)
|
|
1528 goto yyexhaustedlab;
|
|
1529 YYSTACK_RELOCATE (yyss);
|
|
1530 YYSTACK_RELOCATE (yyvs);
|
|
1531
|
|
1532 # undef YYSTACK_RELOCATE
|
|
1533 if (yyss1 != yyssa)
|
|
1534 YYSTACK_FREE (yyss1);
|
|
1535 }
|
|
1536 # endif
|
|
1537 #endif /* no yyoverflow */
|
|
1538
|
|
1539 yyssp = yyss + yysize - 1;
|
|
1540 yyvsp = yyvs + yysize - 1;
|
|
1541
|
|
1542
|
|
1543 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
|
1544 (unsigned long int) yystacksize));
|
|
1545
|
|
1546 if (yyss + yystacksize - 1 <= yyssp)
|
|
1547 YYABORT;
|
|
1548 }
|
|
1549
|
|
1550 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
|
1551
|
|
1552 goto yybackup;
|
|
1553
|
|
1554 /*-----------.
|
|
1555 | yybackup. |
|
|
1556 `-----------*/
|
|
1557 yybackup:
|
|
1558
|
|
1559 /* Do appropriate processing given the current state. Read a
|
|
1560 look-ahead token if we need one and don't already have one. */
|
|
1561
|
|
1562 /* First try to decide what to do without reference to look-ahead token. */
|
|
1563 yyn = yypact[yystate];
|
|
1564 if (yyn == YYPACT_NINF)
|
|
1565 goto yydefault;
|
|
1566
|
|
1567 /* Not known => get a look-ahead token if don't already have one. */
|
|
1568
|
|
1569 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
|
|
1570 if (yychar == YYEMPTY)
|
|
1571 {
|
|
1572 YYDPRINTF ((stderr, "Reading a token: "));
|
|
1573 yychar = YYLEX;
|
|
1574 }
|
|
1575
|
|
1576 if (yychar <= YYEOF)
|
|
1577 {
|
|
1578 yychar = yytoken = YYEOF;
|
|
1579 YYDPRINTF ((stderr, "Now at end of input.\n"));
|
|
1580 }
|
|
1581 else
|
|
1582 {
|
|
1583 yytoken = YYTRANSLATE (yychar);
|
|
1584 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
|
|
1585 }
|
|
1586
|
|
1587 /* If the proper action on seeing token YYTOKEN is to reduce or to
|
|
1588 detect an error, take that action. */
|
|
1589 yyn += yytoken;
|
|
1590 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
|
|
1591 goto yydefault;
|
|
1592 yyn = yytable[yyn];
|
|
1593 if (yyn <= 0)
|
|
1594 {
|
|
1595 if (yyn == 0 || yyn == YYTABLE_NINF)
|
|
1596 goto yyerrlab;
|
|
1597 yyn = -yyn;
|
|
1598 goto yyreduce;
|
|
1599 }
|
|
1600
|
|
1601 if (yyn == YYFINAL)
|
|
1602 YYACCEPT;
|
|
1603
|
|
1604 /* Count tokens shifted since error; after three, turn off error
|
|
1605 status. */
|
|
1606 if (yyerrstatus)
|
|
1607 yyerrstatus--;
|
|
1608
|
|
1609 /* Shift the look-ahead token. */
|
|
1610 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
|
|
1611
|
|
1612 /* Discard the shifted token unless it is eof. */
|
|
1613 if (yychar != YYEOF)
|
|
1614 yychar = YYEMPTY;
|
|
1615
|
|
1616 yystate = yyn;
|
|
1617 *++yyvsp = yylval;
|
|
1618
|
|
1619 goto yynewstate;
|
|
1620
|
|
1621
|
|
1622 /*-----------------------------------------------------------.
|
|
1623 | yydefault -- do the default action for the current state. |
|
|
1624 `-----------------------------------------------------------*/
|
|
1625 yydefault:
|
|
1626 yyn = yydefact[yystate];
|
|
1627 if (yyn == 0)
|
|
1628 goto yyerrlab;
|
|
1629 goto yyreduce;
|
|
1630
|
|
1631
|
|
1632 /*-----------------------------.
|
|
1633 | yyreduce -- Do a reduction. |
|
|
1634 `-----------------------------*/
|
|
1635 yyreduce:
|
|
1636 /* yyn is the number of a rule to reduce with. */
|
|
1637 yylen = yyr2[yyn];
|
|
1638
|
|
1639 /* If YYLEN is nonzero, implement the default value of the action:
|
|
1640 `$$ = $1'.
|
|
1641
|
|
1642 Otherwise, the following line sets YYVAL to garbage.
|
|
1643 This behavior is undocumented and Bison
|
|
1644 users should not rely upon it. Assigning to YYVAL
|
|
1645 unconditionally makes the parser a bit smaller, and it avoids a
|
|
1646 GCC warning that YYVAL may be used uninitialized. */
|
|
1647 yyval = yyvsp[1-yylen];
|
|
1648
|
|
1649
|
|
1650 YY_REDUCE_PRINT (yyn);
|
|
1651 switch (yyn)
|
|
1652 {
|
|
1653 case 4:
|
|
1654 #line 201 "oil.y"
|
|
1655 {
|
|
1656 static YYSTYPE tempmem[10];
|
|
1657 static int replcount[10];
|
|
1658 /* Handle splitting the file. */
|
|
1659 if(splitcount) splitcount--;
|
|
1660 if(!splitcount && !inloop)
|
|
1661 {
|
|
1662 splitcount=SPLITMAX;
|
|
1663 splitend();
|
|
1664 ++filenumber;
|
|
1665 splitstart();
|
|
1666 }
|
|
1667 /* This is where we actually generate the optimizer code. */
|
|
1668 /* Tree-shape and is-constant conditions */
|
|
1669 printf(" checknodeactbits(np);\n");
|
|
1670 if(treeshapecond((yyvsp[(1) - (4)]),1)) printf(" if(1"); printf(")\n do\n {\n");
|
|
1671 /* Nodesame and cxdata conditions */
|
|
1672 {
|
|
1673 int i=10;
|
|
1674 YYSTYPE temp;
|
|
1675 while(--i)
|
|
1676 {
|
|
1677 temp=treenscheck((yyvsp[(1) - (4)]),0,i);
|
|
1678 if(temp)
|
|
1679 {
|
|
1680 printf(" x%d=np",i);
|
|
1681 gennodepath(temp->depth,temp->path);
|
|
1682 printf("->constant; c%d=np",i);
|
|
1683 gennodepath(temp->depth,temp->path);
|
|
1684 printf("->optdata;\n");
|
|
1685 }
|
|
1686 tempmem[i]=temp;
|
|
1687 replcount[i]=0; /* we need to zero this somewhere, may as well be here */
|
|
1688 }
|
|
1689 treecxcond((yyvsp[(1) - (4)]));
|
|
1690 }
|
|
1691 /* If we reach this point in the generated code, we have an optimizer
|
|
1692 template match. */
|
|
1693 printf(" OPTING(%s);\n",optname);
|
|
1694
|
|
1695 /* We now need to replace np with its replacement. This is done by creating
|
|
1696 a new nodetree, copying across tempmem'd nodes where necessary, and then
|
|
1697 substituting one for the other. (This is an inefficient but general way
|
|
1698 to do this.) One special case is needed; because pointers into the root
|
|
1699 node need to continue pointing there, the temporary node tp is copied
|
|
1700 member-for-member and then freed again. To make coding optimizations
|
|
1701 easier, the root stays as the same width no matter what. */
|
|
1702 printf(" tp=newnode();\n");
|
|
1703 treerepcount((yyvsp[(4) - (4)]),replcount);
|
|
1704 treerepgen((yyvsp[(4) - (4)]),tempmem,replcount);
|
|
1705 printf(" nodefree(np->lval); nodefree(np->rval);\n");
|
|
1706 printf(" tempw=np->width; *np=*tp; np->width=tempw; free(tp);\n");
|
|
1707 printf(" } while(0);\n\n");
|
|
1708 /* Free the template and replacement now they're finished being used. */
|
|
1709 treefree((yyvsp[(1) - (4)]));
|
|
1710 treefree((yyvsp[(4) - (4)]));
|
|
1711 }
|
|
1712 break;
|
|
1713
|
|
1714 case 5:
|
|
1715 #line 259 "oil.y"
|
|
1716 {
|
|
1717 if(!(yyvsp[(2) - (4)])->mustbemesh||!(yyvsp[(4) - (4)])->mustbemesh)
|
|
1718 {
|
|
1719 yyerror("syntax error in <#..#()->()> construct");
|
|
1720 free((yyvsp[(2) - (4)])); free((yyvsp[(4) - (4)]));
|
|
1721 YYERROR;
|
|
1722 }
|
|
1723 printf(" r=%luLU; while(r<=%luLU) {\n",(yyvsp[(2) - (4)])->c,(yyvsp[(4) - (4)])->c);
|
|
1724 free((yyvsp[(2) - (4)])); free((yyvsp[(4) - (4)]));
|
|
1725 inloop=1;
|
|
1726 }
|
|
1727 break;
|
|
1728
|
|
1729 case 6:
|
|
1730 #line 270 "oil.y"
|
|
1731 {printf(" r++;\n }\n"); inloop=0;}
|
|
1732 break;
|
|
1733
|
|
1734 case 8:
|
|
1735 #line 274 "oil.y"
|
|
1736 {(yyval)=(yyvsp[(2) - (3)]);}
|
|
1737 break;
|
|
1738
|
|
1739 case 9:
|
|
1740 #line 275 "oil.y"
|
|
1741 {(yyval)=(yyvsp[(2) - (3)]);}
|
|
1742 break;
|
|
1743
|
|
1744 case 10:
|
|
1745 #line 276 "oil.y"
|
|
1746 {(yyval)=(yyvsp[(2) - (3)]);}
|
|
1747 break;
|
|
1748
|
|
1749 case 13:
|
|
1750 #line 281 "oil.y"
|
|
1751 {BINARYEXPR("MINGLE",(yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),1);}
|
|
1752 break;
|
|
1753
|
|
1754 case 14:
|
|
1755 #line 282 "oil.y"
|
|
1756 {BINARYEXPR("SELECT",(yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),1);}
|
|
1757 break;
|
|
1758
|
|
1759 case 15:
|
|
1760 #line 283 "oil.y"
|
|
1761 {BINARYEXPR("SELECT",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),0);}
|
|
1762 break;
|
|
1763
|
|
1764 case 16:
|
|
1765 #line 284 "oil.y"
|
|
1766 {BINARYEXPR("SELECT",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),1);}
|
|
1767 break;
|
|
1768
|
|
1769 case 17:
|
|
1770 #line 285 "oil.y"
|
|
1771 {UNARYEXPR("AND",(yyval),(yyvsp[(4) - (4)]),0,1);}
|
|
1772 break;
|
|
1773
|
|
1774 case 18:
|
|
1775 #line 286 "oil.y"
|
|
1776 {UNARYEXPR("AND",(yyval),(yyvsp[(4) - (4)]),1,1);}
|
|
1777 break;
|
|
1778
|
|
1779 case 19:
|
|
1780 #line 287 "oil.y"
|
|
1781 {UNARYEXPR("OR",(yyval),(yyvsp[(4) - (4)]),0,1);}
|
|
1782 break;
|
|
1783
|
|
1784 case 20:
|
|
1785 #line 288 "oil.y"
|
|
1786 {UNARYEXPR("OR",(yyval),(yyvsp[(4) - (4)]),1,1);}
|
|
1787 break;
|
|
1788
|
|
1789 case 21:
|
|
1790 #line 289 "oil.y"
|
|
1791 {UNARYEXPR("XOR",(yyval),(yyvsp[(4) - (4)]),0,1);}
|
|
1792 break;
|
|
1793
|
|
1794 case 22:
|
|
1795 #line 290 "oil.y"
|
|
1796 {UNARYEXPR("XOR",(yyval),(yyvsp[(4) - (4)]),1,1);}
|
|
1797 break;
|
|
1798
|
|
1799 case 23:
|
|
1800 #line 291 "oil.y"
|
|
1801 {UNARYEXPR("FIN",(yyval),(yyvsp[(4) - (4)]),0,1);}
|
|
1802 break;
|
|
1803
|
|
1804 case 24:
|
|
1805 #line 292 "oil.y"
|
|
1806 {UNARYEXPR("FIN",(yyval),(yyvsp[(4) - (4)]),1,1);}
|
|
1807 break;
|
|
1808
|
|
1809 case 25:
|
|
1810 #line 293 "oil.y"
|
|
1811 {UNARYEXPR("WHIRL",(yyval),(yyvsp[(4) - (4)]),0,1);}
|
|
1812 break;
|
|
1813
|
|
1814 case 26:
|
|
1815 #line 294 "oil.y"
|
|
1816 {UNARYEXPR("WHIRL2",(yyval),(yyvsp[(5) - (5)]),0,1);}
|
|
1817 break;
|
|
1818
|
|
1819 case 27:
|
|
1820 #line 295 "oil.y"
|
|
1821 {UNARYEXPR("WHIRL3",(yyval),(yyvsp[(5) - (5)]),0,1);}
|
|
1822 break;
|
|
1823
|
|
1824 case 28:
|
|
1825 #line 296 "oil.y"
|
|
1826 {UNARYEXPR("WHIRL4",(yyval),(yyvsp[(5) - (5)]),0,1);}
|
|
1827 break;
|
|
1828
|
|
1829 case 29:
|
|
1830 #line 297 "oil.y"
|
|
1831 {UNARYEXPR("WHIRL5",(yyval),(yyvsp[(5) - (5)]),0,1);}
|
|
1832 break;
|
|
1833
|
|
1834 case 30:
|
|
1835 #line 298 "oil.y"
|
|
1836 {UNARYEXPR("WHIRL",(yyval),(yyvsp[(4) - (4)]),1,1);}
|
|
1837 break;
|
|
1838
|
|
1839 case 31:
|
|
1840 #line 299 "oil.y"
|
|
1841 {UNARYEXPR("WHIRL2",(yyval),(yyvsp[(5) - (5)]),1,1);}
|
|
1842 break;
|
|
1843
|
|
1844 case 32:
|
|
1845 #line 300 "oil.y"
|
|
1846 {UNARYEXPR("WHIRL3",(yyval),(yyvsp[(5) - (5)]),1,1);}
|
|
1847 break;
|
|
1848
|
|
1849 case 33:
|
|
1850 #line 301 "oil.y"
|
|
1851 {UNARYEXPR("WHIRL4",(yyval),(yyvsp[(5) - (5)]),1,1);}
|
|
1852 break;
|
|
1853
|
|
1854 case 34:
|
|
1855 #line 302 "oil.y"
|
|
1856 {UNARYEXPR("WHIRL5",(yyval),(yyvsp[(5) - (5)]),1,1);}
|
|
1857 break;
|
|
1858
|
|
1859 case 35:
|
|
1860 #line 303 "oil.y"
|
|
1861 {BINARYEXPR("C_AND",(yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),1);}
|
|
1862 break;
|
|
1863
|
|
1864 case 36:
|
|
1865 #line 304 "oil.y"
|
|
1866 {BINARYEXPR("C_AND",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),0);}
|
|
1867 break;
|
|
1868
|
|
1869 case 37:
|
|
1870 #line 305 "oil.y"
|
|
1871 {BINARYEXPR("C_AND",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),1);}
|
|
1872 break;
|
|
1873
|
|
1874 case 38:
|
|
1875 #line 306 "oil.y"
|
|
1876 {BINARYEXPR("C_OR",(yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),1);}
|
|
1877 break;
|
|
1878
|
|
1879 case 39:
|
|
1880 #line 307 "oil.y"
|
|
1881 {BINARYEXPR("C_OR",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),0);}
|
|
1882 break;
|
|
1883
|
|
1884 case 40:
|
|
1885 #line 308 "oil.y"
|
|
1886 {BINARYEXPR("C_OR",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),1);}
|
|
1887 break;
|
|
1888
|
|
1889 case 41:
|
|
1890 #line 309 "oil.y"
|
|
1891 {BINARYEXPR("C_XOR",(yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),1);}
|
|
1892 break;
|
|
1893
|
|
1894 case 42:
|
|
1895 #line 310 "oil.y"
|
|
1896 {BINARYEXPR("C_XOR",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),0);}
|
|
1897 break;
|
|
1898
|
|
1899 case 43:
|
|
1900 #line 311 "oil.y"
|
|
1901 {BINARYEXPR("C_XOR",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),1);}
|
|
1902 break;
|
|
1903
|
|
1904 case 44:
|
|
1905 #line 312 "oil.y"
|
|
1906 {BINARYEXPR("C_PLUS",(yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),1);}
|
|
1907 break;
|
|
1908
|
|
1909 case 45:
|
|
1910 #line 313 "oil.y"
|
|
1911 {BINARYEXPR("C_PLUS",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),0);}
|
|
1912 break;
|
|
1913
|
|
1914 case 46:
|
|
1915 #line 314 "oil.y"
|
|
1916 {BINARYEXPR("C_PLUS",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),1);}
|
|
1917 break;
|
|
1918
|
|
1919 case 47:
|
|
1920 #line 315 "oil.y"
|
|
1921 {BINARYEXPR("C_MINUS",(yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),1);}
|
|
1922 break;
|
|
1923
|
|
1924 case 48:
|
|
1925 #line 316 "oil.y"
|
|
1926 {BINARYEXPR("C_MINUS",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),0);}
|
|
1927 break;
|
|
1928
|
|
1929 case 49:
|
|
1930 #line 317 "oil.y"
|
|
1931 {BINARYEXPR("C_MINUS",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),1);}
|
|
1932 break;
|
|
1933
|
|
1934 case 50:
|
|
1935 #line 318 "oil.y"
|
|
1936 {BINARYEXPR("C_TIMES",(yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),1);}
|
|
1937 break;
|
|
1938
|
|
1939 case 51:
|
|
1940 #line 319 "oil.y"
|
|
1941 {BINARYEXPR("C_TIMES",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),0);}
|
|
1942 break;
|
|
1943
|
|
1944 case 52:
|
|
1945 #line 320 "oil.y"
|
|
1946 {BINARYEXPR("C_TIMES",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),1);}
|
|
1947 break;
|
|
1948
|
|
1949 case 53:
|
|
1950 #line 321 "oil.y"
|
|
1951 {BINARYEXPR("C_DIVIDEBY",(yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),1);}
|
|
1952 break;
|
|
1953
|
|
1954 case 54:
|
|
1955 #line 322 "oil.y"
|
|
1956 {BINARYEXPR("C_DIVIDEBY",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),0);}
|
|
1957 break;
|
|
1958
|
|
1959 case 55:
|
|
1960 #line 323 "oil.y"
|
|
1961 {BINARYEXPR("C_DIVIDEBY",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),1);}
|
|
1962 break;
|
|
1963
|
|
1964 case 56:
|
|
1965 #line 324 "oil.y"
|
|
1966 {BINARYEXPR("C_MODULUS",(yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),1);}
|
|
1967 break;
|
|
1968
|
|
1969 case 57:
|
|
1970 #line 325 "oil.y"
|
|
1971 {BINARYEXPR("C_MODULUS",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),0);}
|
|
1972 break;
|
|
1973
|
|
1974 case 58:
|
|
1975 #line 326 "oil.y"
|
|
1976 {BINARYEXPR("C_MODULUS",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),1);}
|
|
1977 break;
|
|
1978
|
|
1979 case 59:
|
|
1980 #line 327 "oil.y"
|
|
1981 {BINARYEXPR("C_GREATER",(yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),1);}
|
|
1982 break;
|
|
1983
|
|
1984 case 60:
|
|
1985 #line 328 "oil.y"
|
|
1986 {BINARYEXPR("C_GREATER",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),0);}
|
|
1987 break;
|
|
1988
|
|
1989 case 61:
|
|
1990 #line 329 "oil.y"
|
|
1991 {BINARYEXPR("C_GREATER",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),1);}
|
|
1992 break;
|
|
1993
|
|
1994 case 62:
|
|
1995 #line 330 "oil.y"
|
|
1996 {BINARYEXPR("C_LESS",(yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),1);}
|
|
1997 break;
|
|
1998
|
|
1999 case 63:
|
|
2000 #line 331 "oil.y"
|
|
2001 {BINARYEXPR("C_LESS",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),0);}
|
|
2002 break;
|
|
2003
|
|
2004 case 64:
|
|
2005 #line 332 "oil.y"
|
|
2006 {BINARYEXPR("C_LESS",(yyval),(yyvsp[(1) - (5)]),(yyvsp[(5) - (5)]),1);}
|
|
2007 break;
|
|
2008
|
|
2009 case 65:
|
|
2010 #line 333 "oil.y"
|
|
2011 {UNARYEXPR("C_NOT",(yyval),(yyvsp[(4) - (4)]),0,1);}
|
|
2012 break;
|
|
2013
|
|
2014 case 66:
|
|
2015 #line 334 "oil.y"
|
|
2016 {UNARYEXPR("C_NOT",(yyval),(yyvsp[(4) - (4)]),1,1);}
|
|
2017 break;
|
|
2018
|
|
2019 case 67:
|
|
2020 #line 335 "oil.y"
|
|
2021 {BINARYEXPR("C_NOTEQUAL",(yyval),(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),0);}
|
|
2022 break;
|
|
2023
|
|
2024 case 68:
|
|
2025 #line 336 "oil.y"
|
|
2026 {BINARYEXPR("C_NOTEQUAL",(yyval),(yyvsp[(1) - (6)]),(yyvsp[(6) - (6)]),0);}
|
|
2027 break;
|
|
2028
|
|
2029 case 69:
|
|
2030 #line 337 "oil.y"
|
|
2031 {BINARYEXPR("C_NOTEQUAL",(yyval),(yyvsp[(1) - (6)]),(yyvsp[(6) - (6)]),1);}
|
|
2032 break;
|
|
2033
|
|
2034 case 70:
|
|
2035 #line 338 "oil.y"
|
|
2036 {BINARYEXPR("C_ISEQUAL",(yyval),(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),0);}
|
|
2037 break;
|
|
2038
|
|
2039 case 71:
|
|
2040 #line 339 "oil.y"
|
|
2041 {BINARYEXPR("C_ISEQUAL",(yyval),(yyvsp[(1) - (6)]),(yyvsp[(6) - (6)]),0);}
|
|
2042 break;
|
|
2043
|
|
2044 case 72:
|
|
2045 #line 340 "oil.y"
|
|
2046 {BINARYEXPR("C_ISEQUAL",(yyval),(yyvsp[(1) - (6)]),(yyvsp[(6) - (6)]),1);}
|
|
2047 break;
|
|
2048
|
|
2049 case 73:
|
|
2050 #line 341 "oil.y"
|
|
2051 {BINARYEXPR("C_LOGICALAND",(yyval),(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),0);}
|
|
2052 break;
|
|
2053
|
|
2054 case 74:
|
|
2055 #line 342 "oil.y"
|
|
2056 {BINARYEXPR("C_LOGICALAND",(yyval),(yyvsp[(1) - (6)]),(yyvsp[(6) - (6)]),0);}
|
|
2057 break;
|
|
2058
|
|
2059 case 75:
|
|
2060 #line 343 "oil.y"
|
|
2061 {BINARYEXPR("C_LOGICALAND",(yyval),(yyvsp[(1) - (6)]),(yyvsp[(6) - (6)]),1);}
|
|
2062 break;
|
|
2063
|
|
2064 case 76:
|
|
2065 #line 344 "oil.y"
|
|
2066 {BINARYEXPR("C_LOGICALOR",(yyval),(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),0);}
|
|
2067 break;
|
|
2068
|
|
2069 case 77:
|
|
2070 #line 345 "oil.y"
|
|
2071 {BINARYEXPR("C_LOGICALOR",(yyval),(yyvsp[(1) - (6)]),(yyvsp[(6) - (6)]),0);}
|
|
2072 break;
|
|
2073
|
|
2074 case 78:
|
|
2075 #line 346 "oil.y"
|
|
2076 {BINARYEXPR("C_LOGICALOR",(yyval),(yyvsp[(1) - (6)]),(yyvsp[(6) - (6)]),1);}
|
|
2077 break;
|
|
2078
|
|
2079 case 79:
|
|
2080 #line 347 "oil.y"
|
|
2081 {BINARYEXPR("C_RSHIFTBY",(yyval),(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),1);}
|
|
2082 break;
|
|
2083
|
|
2084 case 80:
|
|
2085 #line 348 "oil.y"
|
|
2086 {BINARYEXPR("C_RSHIFTBY",(yyval),(yyvsp[(1) - (6)]),(yyvsp[(6) - (6)]),0);}
|
|
2087 break;
|
|
2088
|
|
2089 case 81:
|
|
2090 #line 349 "oil.y"
|
|
2091 {BINARYEXPR("C_RSHIFTBY",(yyval),(yyvsp[(1) - (6)]),(yyvsp[(6) - (6)]),1);}
|
|
2092 break;
|
|
2093
|
|
2094 case 82:
|
|
2095 #line 350 "oil.y"
|
|
2096 {BINARYEXPR("C_LSHIFTBY",(yyval),(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),1);}
|
|
2097 break;
|
|
2098
|
|
2099 case 83:
|
|
2100 #line 351 "oil.y"
|
|
2101 {BINARYEXPR("C_LSHIFTBY",(yyval),(yyvsp[(1) - (6)]),(yyvsp[(6) - (6)]),0);}
|
|
2102 break;
|
|
2103
|
|
2104 case 84:
|
|
2105 #line 352 "oil.y"
|
|
2106 {BINARYEXPR("C_LSHIFTBY",(yyval),(yyvsp[(1) - (6)]),(yyvsp[(6) - (6)]),1);}
|
|
2107 break;
|
|
2108
|
|
2109 case 85:
|
|
2110 #line 353 "oil.y"
|
|
2111 {UNARYEXPR("C_LOGICALNOT",(yyval),(yyvsp[(2) - (2)]),0,0);}
|
|
2112 break;
|
|
2113
|
|
2114 case 86:
|
|
2115 #line 354 "oil.y"
|
|
2116 {UNARYEXPR("C_LOGICALNOT",(yyval),(yyvsp[(4) - (4)]),0,0);}
|
|
2117 break;
|
|
2118
|
|
2119 case 87:
|
|
2120 #line 355 "oil.y"
|
|
2121 {UNARYEXPR("C_LOGICALNOT",(yyval),(yyvsp[(4) - (4)]),1,0);}
|
|
2122 break;
|
|
2123
|
|
2124
|
|
2125 /* Line 1267 of yacc.c. */
|
|
2126 #line 2127 "oil-oil.c"
|
|
2127 default: break;
|
|
2128 }
|
|
2129 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
|
|
2130
|
|
2131 YYPOPSTACK (yylen);
|
|
2132 yylen = 0;
|
|
2133 YY_STACK_PRINT (yyss, yyssp);
|
|
2134
|
|
2135 *++yyvsp = yyval;
|
|
2136
|
|
2137
|
|
2138 /* Now `shift' the result of the reduction. Determine what state
|
|
2139 that goes to, based on the state we popped back to and the rule
|
|
2140 number reduced by. */
|
|
2141
|
|
2142 yyn = yyr1[yyn];
|
|
2143
|
|
2144 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
|
|
2145 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
|
|
2146 yystate = yytable[yystate];
|
|
2147 else
|
|
2148 yystate = yydefgoto[yyn - YYNTOKENS];
|
|
2149
|
|
2150 goto yynewstate;
|
|
2151
|
|
2152
|
|
2153 /*------------------------------------.
|
|
2154 | yyerrlab -- here on detecting error |
|
|
2155 `------------------------------------*/
|
|
2156 yyerrlab:
|
|
2157 /* If not already recovering from an error, report this error. */
|
|
2158 if (!yyerrstatus)
|
|
2159 {
|
|
2160 ++yynerrs;
|
|
2161 #if ! YYERROR_VERBOSE
|
|
2162 yyerror (YY_("syntax error"));
|
|
2163 #else
|
|
2164 {
|
|
2165 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
|
|
2166 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
|
|
2167 {
|
|
2168 YYSIZE_T yyalloc = 2 * yysize;
|
|
2169 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
|
|
2170 yyalloc = YYSTACK_ALLOC_MAXIMUM;
|
|
2171 if (yymsg != yymsgbuf)
|
|
2172 YYSTACK_FREE (yymsg);
|
|
2173 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
|
|
2174 if (yymsg)
|
|
2175 yymsg_alloc = yyalloc;
|
|
2176 else
|
|
2177 {
|
|
2178 yymsg = yymsgbuf;
|
|
2179 yymsg_alloc = sizeof yymsgbuf;
|
|
2180 }
|
|
2181 }
|
|
2182
|
|
2183 if (0 < yysize && yysize <= yymsg_alloc)
|
|
2184 {
|
|
2185 (void) yysyntax_error (yymsg, yystate, yychar);
|
|
2186 yyerror (yymsg);
|
|
2187 }
|
|
2188 else
|
|
2189 {
|
|
2190 yyerror (YY_("syntax error"));
|
|
2191 if (yysize != 0)
|
|
2192 goto yyexhaustedlab;
|
|
2193 }
|
|
2194 }
|
|
2195 #endif
|
|
2196 }
|
|
2197
|
|
2198
|
|
2199
|
|
2200 if (yyerrstatus == 3)
|
|
2201 {
|
|
2202 /* If just tried and failed to reuse look-ahead token after an
|
|
2203 error, discard it. */
|
|
2204
|
|
2205 if (yychar <= YYEOF)
|
|
2206 {
|
|
2207 /* Return failure if at end of input. */
|
|
2208 if (yychar == YYEOF)
|
|
2209 YYABORT;
|
|
2210 }
|
|
2211 else
|
|
2212 {
|
|
2213 yydestruct ("Error: discarding",
|
|
2214 yytoken, &yylval);
|
|
2215 yychar = YYEMPTY;
|
|
2216 }
|
|
2217 }
|
|
2218
|
|
2219 /* Else will try to reuse look-ahead token after shifting the error
|
|
2220 token. */
|
|
2221 goto yyerrlab1;
|
|
2222
|
|
2223
|
|
2224 /*---------------------------------------------------.
|
|
2225 | yyerrorlab -- error raised explicitly by YYERROR. |
|
|
2226 `---------------------------------------------------*/
|
|
2227 yyerrorlab:
|
|
2228
|
|
2229 /* Pacify compilers like GCC when the user code never invokes
|
|
2230 YYERROR and the label yyerrorlab therefore never appears in user
|
|
2231 code. */
|
|
2232 if (/*CONSTCOND*/ 0)
|
|
2233 goto yyerrorlab;
|
|
2234
|
|
2235 /* Do not reclaim the symbols of the rule which action triggered
|
|
2236 this YYERROR. */
|
|
2237 YYPOPSTACK (yylen);
|
|
2238 yylen = 0;
|
|
2239 YY_STACK_PRINT (yyss, yyssp);
|
|
2240 yystate = *yyssp;
|
|
2241 goto yyerrlab1;
|
|
2242
|
|
2243
|
|
2244 /*-------------------------------------------------------------.
|
|
2245 | yyerrlab1 -- common code for both syntax error and YYERROR. |
|
|
2246 `-------------------------------------------------------------*/
|
|
2247 yyerrlab1:
|
|
2248 yyerrstatus = 3; /* Each real token shifted decrements this. */
|
|
2249
|
|
2250 for (;;)
|
|
2251 {
|
|
2252 yyn = yypact[yystate];
|
|
2253 if (yyn != YYPACT_NINF)
|
|
2254 {
|
|
2255 yyn += YYTERROR;
|
|
2256 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
|
|
2257 {
|
|
2258 yyn = yytable[yyn];
|
|
2259 if (0 < yyn)
|
|
2260 break;
|
|
2261 }
|
|
2262 }
|
|
2263
|
|
2264 /* Pop the current state because it cannot handle the error token. */
|
|
2265 if (yyssp == yyss)
|
|
2266 YYABORT;
|
|
2267
|
|
2268
|
|
2269 yydestruct ("Error: popping",
|
|
2270 yystos[yystate], yyvsp);
|
|
2271 YYPOPSTACK (1);
|
|
2272 yystate = *yyssp;
|
|
2273 YY_STACK_PRINT (yyss, yyssp);
|
|
2274 }
|
|
2275
|
|
2276 if (yyn == YYFINAL)
|
|
2277 YYACCEPT;
|
|
2278
|
|
2279 *++yyvsp = yylval;
|
|
2280
|
|
2281
|
|
2282 /* Shift the error token. */
|
|
2283 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
|
|
2284
|
|
2285 yystate = yyn;
|
|
2286 goto yynewstate;
|
|
2287
|
|
2288
|
|
2289 /*-------------------------------------.
|
|
2290 | yyacceptlab -- YYACCEPT comes here. |
|
|
2291 `-------------------------------------*/
|
|
2292 yyacceptlab:
|
|
2293 yyresult = 0;
|
|
2294 goto yyreturn;
|
|
2295
|
|
2296 /*-----------------------------------.
|
|
2297 | yyabortlab -- YYABORT comes here. |
|
|
2298 `-----------------------------------*/
|
|
2299 yyabortlab:
|
|
2300 yyresult = 1;
|
|
2301 goto yyreturn;
|
|
2302
|
|
2303 #ifndef yyoverflow
|
|
2304 /*-------------------------------------------------.
|
|
2305 | yyexhaustedlab -- memory exhaustion comes here. |
|
|
2306 `-------------------------------------------------*/
|
|
2307 yyexhaustedlab:
|
|
2308 yyerror (YY_("memory exhausted"));
|
|
2309 yyresult = 2;
|
|
2310 /* Fall through. */
|
|
2311 #endif
|
|
2312
|
|
2313 yyreturn:
|
|
2314 if (yychar != YYEOF && yychar != YYEMPTY)
|
|
2315 yydestruct ("Cleanup: discarding lookahead",
|
|
2316 yytoken, &yylval);
|
|
2317 /* Do not reclaim the symbols of the rule which action triggered
|
|
2318 this YYABORT or YYACCEPT. */
|
|
2319 YYPOPSTACK (yylen);
|
|
2320 YY_STACK_PRINT (yyss, yyssp);
|
|
2321 while (yyssp != yyss)
|
|
2322 {
|
|
2323 yydestruct ("Cleanup: popping",
|
|
2324 yystos[*yyssp], yyvsp);
|
|
2325 YYPOPSTACK (1);
|
|
2326 }
|
|
2327 #ifndef yyoverflow
|
|
2328 if (yyss != yyssa)
|
|
2329 YYSTACK_FREE (yyss);
|
|
2330 #endif
|
|
2331 #if YYERROR_VERBOSE
|
|
2332 if (yymsg != yymsgbuf)
|
|
2333 YYSTACK_FREE (yymsg);
|
|
2334 #endif
|
|
2335 /* Make sure YYID is used. */
|
|
2336 return YYID (yyresult);
|
|
2337 }
|
|
2338
|
|
2339
|
|
2340 #line 360 "oil.y"
|
|
2341
|
|
2342
|
|
2343 #define MAXTOFREE 1000
|
|
2344
|
|
2345 char* tofree[MAXTOFREE]={0};
|
|
2346 int tfi=0;
|
|
2347
|
|
2348 int yylex(void)
|
|
2349 {
|
|
2350 int c;
|
|
2351 unsigned long acc;
|
|
2352
|
|
2353 /* Whitespace is completely insignificant here, even inside && and other
|
|
2354 two-character operators. Just to be different, though, it /is/ significant
|
|
2355 inside constructs like .1 and #{1}2; in such cases, it isn't allowed. */
|
|
2356 c=countgetchar();
|
|
2357 while(isspace(c)) c=countgetchar();
|
|
2358 while(c==';'||c=='[')
|
|
2359 {
|
|
2360 /* Comments go from a semicolon/hybrid to the end of the line. */
|
|
2361 if(c==';')
|
|
2362 {
|
|
2363 c=countgetchar();
|
|
2364 while(c!='\n') c=countgetchar();
|
|
2365 while(isspace(c)) c=countgetchar();
|
|
2366 }
|
|
2367 /* Square brackets set the name for optimizations. */
|
|
2368 if(c=='[')
|
|
2369 {
|
|
2370 int i=0;
|
|
2371 c=countgetchar();
|
|
2372 while(c!=']')
|
|
2373 {
|
|
2374 optname[i++]=c;
|
|
2375 c=countgetchar();
|
|
2376 if(i==MAXOPTNAMELEN-1) {i=0; yyerror("optimization name too long");}
|
|
2377 }
|
|
2378 optname[i]=0;
|
|
2379 c=countgetchar();
|
|
2380 while(isspace(c)) c=countgetchar();
|
|
2381 }
|
|
2382 }
|
|
2383 if(c==EOF) return 0;
|
|
2384 switch(c)
|
|
2385 {
|
|
2386 case '#':
|
|
2387 c=countgetchar();
|
|
2388 if(c!='{')
|
|
2389 {
|
|
2390 acc=0;
|
|
2391 while(isdigit(c))
|
|
2392 {
|
|
2393 acc*=10;
|
|
2394 acc+=(c-'0');
|
|
2395 c=countgetchar();
|
|
2396 }
|
|
2397 yylval=malloc(sizeof(struct ickstype));
|
|
2398 yylval->depth=0;
|
|
2399 yylval->path=0;
|
|
2400 yylval->condition="->constant==";
|
|
2401 yylval->nodetypename=0;
|
|
2402 yylval->usec=1;
|
|
2403 yylval->mustbemesh=1;
|
|
2404 yylval->cxneeded=0;
|
|
2405 yylval->c=acc;
|
|
2406 yylval->replnum=0;
|
|
2407 yylval->n1=0;
|
|
2408 yylval->n2=0;
|
|
2409 yylval->ublo=0;
|
|
2410 yylval->width32=1; /* generate MESH32 not MESH; we can still AND16 it,
|
|
2411 etc., if necessary */
|
|
2412 countungetc(c, stdin);
|
|
2413 return LEXERLEAF;
|
|
2414 }
|
|
2415 countungetc(c, stdin);
|
|
2416 c='#';
|
|
2417 /* fall through */
|
|
2418 case '_':
|
|
2419 case ':':
|
|
2420 case '.':
|
|
2421 yylval=malloc(sizeof(struct ickstype));
|
|
2422 yylval->depth=0;
|
|
2423 yylval->path=0;
|
|
2424 yylval->condition=0; /* _ or # */
|
|
2425 yylval->width32=1; /* should never matter, but you never
|
|
2426 know... */
|
|
2427 yylval->ublo=0;
|
|
2428 if(c==':') yylval->condition="->width==32";
|
|
2429 if(c=='.') {yylval->condition="->width==16"; yylval->width32=0;}
|
|
2430 yylval->nodetypename=0;
|
|
2431 yylval->usec=0;
|
|
2432 yylval->mustbemesh=c=='#';
|
|
2433 yylval->cxneeded=0;
|
|
2434 c=countgetchar();
|
|
2435 if(c=='{')
|
|
2436 {
|
|
2437 /* Create a new node to hold the c/x condition */
|
|
2438 yylval->n1=malloc(sizeof(struct ickstype));
|
|
2439 yylval->n1->depth=0;
|
|
2440 yylval->n1->path=0;
|
|
2441 {
|
|
2442 static char buf[512];
|
|
2443 int bi=0;
|
|
2444 c=countgetchar();
|
|
2445 while(c!='}')
|
|
2446 {
|
|
2447 buf[bi++]=c;
|
|
2448 if(bi==511) {yyerror("{quoted} string too long"); bi=0;}
|
|
2449 c=countgetchar();
|
|
2450 }
|
|
2451 buf[bi]=0;
|
|
2452 yylval->n1->condition=tofree[tfi++]=strdup(buf);
|
|
2453 if(tfi==MAXTOFREE) {yyerror("Too many {quoted} strings"); tfi--;}
|
|
2454 c=countgetchar();
|
|
2455 }
|
|
2456 yylval->n1->nodetypename=0;
|
|
2457 yylval->n1->usec=0;
|
|
2458 yylval->n1->mustbemesh=0;
|
|
2459 yylval->n1->cxneeded=1;
|
|
2460 yylval->n1->n1=0;
|
|
2461 yylval->n1->n2=0;
|
|
2462 yylval->n1->width32=yylval->width32;
|
|
2463 yylval->n1->ublo=0;
|
|
2464 }
|
|
2465 else yylval->n1=0;
|
|
2466 yylval->replnum=0;
|
|
2467 if(yylval->n1) yylval->n1->replnum=c-'0'; else yylval->replnum=c-'0';
|
|
2468 yylval->n2=0;
|
|
2469 return LEXERLEAF;
|
|
2470 default:
|
|
2471 return c;
|
|
2472 }
|
|
2473 }
|
|
2474
|
|
2475 void treedepthup(YYSTYPE v, mybool i)
|
|
2476 {
|
|
2477 if(!v) return;
|
|
2478 treedepthup(v->n1,i);
|
|
2479 treedepthup(v->n2,i);
|
|
2480 v->depth++;
|
|
2481 v->path<<=1;
|
|
2482 v->path|=i;
|
|
2483 if(v->depth>30) yyerror("Nesting too deep in template or replacement\n");
|
|
2484 }
|
|
2485
|
|
2486 void treefree(YYSTYPE v)
|
|
2487 {
|
|
2488 if(!v) return;
|
|
2489 treefree(v->n1);
|
|
2490 treefree(v->n2);
|
|
2491 free(v);
|
|
2492 }
|
|
2493
|
|
2494 void gennodepath(unsigned depth, unsigned long path)
|
|
2495 {
|
|
2496 while(depth--)
|
|
2497 {
|
|
2498 if(path&1) printf("->rval"); else printf("->lval");
|
|
2499 path>>=1;
|
|
2500 }
|
|
2501 }
|
|
2502
|
|
2503 mybool treeshapecond(YYSTYPE v, mybool firstopt)
|
|
2504 {
|
|
2505 if(!v) return firstopt;
|
|
2506 /* To prevent possibly dereferencing a null pointer, check the root ick_first */
|
|
2507 if(v->mustbemesh) /* it's a must-be-constant constraint */
|
|
2508 {
|
|
2509 printf(firstopt?" if((np":" &&\n (np");
|
|
2510 gennodepath(v->depth,v->path);
|
|
2511 printf("->opcode==MESH || np");
|
|
2512 gennodepath(v->depth,v->path);
|
|
2513 printf("->opcode==MESH32)");
|
|
2514 firstopt=0;
|
|
2515 }
|
|
2516 if(v->condition&&!v->cxneeded) /* it's a tree-shape constraint */
|
|
2517 {
|
|
2518 printf(firstopt?" if(np":" &&\n np");
|
|
2519 gennodepath(v->depth,v->path);
|
|
2520 printf("%s",v->condition);
|
|
2521 if(v->usec) printf("%luLU",v->c);
|
|
2522 firstopt=0;
|
|
2523 }
|
|
2524 if(v->ublo) /* generate a width check */
|
|
2525 {
|
|
2526 printf(firstopt?" if(np":" &&\n np");
|
|
2527 gennodepath(v->depth,v->path);
|
|
2528 printf("->width==%d",v->width32?32:16);
|
|
2529 firstopt=0;
|
|
2530 }
|
|
2531 firstopt=treeshapecond(v->n1,firstopt);
|
|
2532 return treeshapecond(v->n2,firstopt);
|
|
2533 }
|
|
2534
|
|
2535 YYSTYPE treenscheck(YYSTYPE v, YYSTYPE prev, int replnum)
|
|
2536 {
|
|
2537 if(!v) return prev;
|
|
2538 prev=treenscheck(v->n1,prev,replnum);
|
|
2539 prev=treenscheck(v->n2,prev,replnum);
|
|
2540 if(v->replnum!=replnum) return prev;
|
|
2541 if(prev)
|
|
2542 {
|
|
2543 printf(" if(!nodessame(np");
|
|
2544 gennodepath(prev->depth,prev->path);
|
|
2545 printf(",np");
|
|
2546 gennodepath(v->depth,v->path);
|
|
2547 printf(")) break;\n");
|
|
2548 }
|
|
2549 return v;
|
|
2550 }
|
|
2551
|
|
2552 void treecxcond(YYSTYPE v)
|
|
2553 {
|
|
2554 if(!v) return;
|
|
2555 if(v->cxneeded&&strcmp(v->condition,"1"))
|
|
2556 {
|
|
2557 if(v->replnum)
|
|
2558 printf(" x=x%d; c=c%d; ",v->replnum,v->replnum);
|
|
2559 else
|
|
2560 {
|
|
2561 printf(" x=np");
|
|
2562 gennodepath(v->depth,v->path);
|
|
2563 printf("->constant;\n c=np");
|
|
2564 gennodepath(v->depth,v->path);
|
|
2565 printf("->optdata;\n ");
|
|
2566 }
|
|
2567 printf("if(!(%s)) break;\n",v->condition);
|
|
2568 }
|
|
2569 treecxcond(v->n1);
|
|
2570 treecxcond(v->n2);
|
|
2571 }
|
|
2572
|
|
2573 void treerepcount(YYSTYPE v, int* rc)
|
|
2574 {
|
|
2575 if(!v) return;
|
|
2576 if(!(v->nodetypename)&&v->replnum&&!(v->cxneeded)) rc[v->replnum]++;
|
|
2577 treerepcount(v->n1, rc);
|
|
2578 treerepcount(v->n2, rc);
|
|
2579 }
|
|
2580
|
|
2581 void treerepgen(YYSTYPE v, YYSTYPE* refs, int* rc)
|
|
2582 {
|
|
2583 if(!v) return;
|
|
2584 /* We absolutely have to generate the root node ick_first here, because otherwise
|
|
2585 the nodes in question won't exist. */
|
|
2586 if(v->nodetypename) /* Generate an intermediate node */
|
|
2587 {
|
|
2588 printf(" MAYBENEWNODE(tp");
|
|
2589 gennodepath(v->depth,v->path);
|
|
2590 printf(");\n tp");
|
|
2591 gennodepath(v->depth,v->path);
|
|
2592 printf("->opcode=%s;\n tp",v->nodetypename);
|
|
2593 gennodepath(v->depth,v->path);
|
|
2594 printf("->width=%d;\n",v->width32?32:16);
|
|
2595 /* optdata will be filled in by checknodeactbits before the ick_next idiom is
|
|
2596 tested; constant is irrelevant, lval and rval are NULL at present and
|
|
2597 will be filled in by later recursions of this function, and I seriously
|
|
2598 hope that nextslat is never filled in by an optimizer idiom. */
|
|
2599 }
|
|
2600 else if(v->replnum&&!(v->cxneeded))
|
|
2601 {
|
|
2602 /* Copy a node from the template. The node ought not to be allocated at
|
|
2603 this point, so we can safely just ick_assign to it with a new malloced
|
|
2604 node. */
|
|
2605 if(refs[v->replnum])
|
|
2606 {
|
|
2607 if(rc[v->replnum]>1||!refs[v->replnum]->depth)
|
|
2608 {
|
|
2609 /* The node actually has to be copied, either because another copy is
|
|
2610 needed or because it's np itself that's being copied over. */
|
|
2611 rc[v->replnum]--;
|
|
2612 printf(" tp");
|
|
2613 gennodepath(v->depth,v->path);
|
|
2614 printf("=nodecopy(np");
|
|
2615 gennodepath(refs[v->replnum]->depth,refs[v->replnum]->path);
|
|
2616 printf(");\n");
|
|
2617 }
|
|
2618 else
|
|
2619 {
|
|
2620 /* This can be optimized slightly by moving rather than copying,
|
|
2621 zeroing backlinks so that the node won't be freed. */
|
|
2622 rc[v->replnum]--;
|
|
2623 printf(" tp");
|
|
2624 gennodepath(v->depth,v->path);
|
|
2625 printf("=np");
|
|
2626 gennodepath(refs[v->replnum]->depth,refs[v->replnum]->path);
|
|
2627 printf(";\n np");
|
|
2628 gennodepath(refs[v->replnum]->depth,refs[v->replnum]->path);
|
|
2629 printf("=0;\n");
|
|
2630 }
|
|
2631 }
|
|
2632 else yyerror("Replacement isn't in the template");
|
|
2633 }
|
|
2634 else if(v->cxneeded)
|
|
2635 {
|
|
2636 /* Generate a constant node based on an expression (#{expr}0). */
|
|
2637 printf(" MAYBENEWNODE(tp");
|
|
2638 gennodepath(v->depth,v->path);
|
|
2639 printf(");\n tp");
|
|
2640 gennodepath(v->depth,v->path);
|
|
2641 printf("->opcode=MESH32;\n tp");
|
|
2642 gennodepath(v->depth,v->path);
|
|
2643 printf("->width=32;\n tp");
|
|
2644 gennodepath(v->depth,v->path);
|
|
2645 printf("->constant=(%s);\n",v->condition);
|
|
2646 }
|
|
2647 else if(v->mustbemesh&&!v->n1)
|
|
2648 {
|
|
2649 /* Generate a constant node based on a constant (#65535). */
|
|
2650 printf(" MAYBENEWNODE(tp");
|
|
2651 gennodepath(v->depth,v->path);
|
|
2652 printf(");\n tp");
|
|
2653 gennodepath(v->depth,v->path);
|
|
2654 printf("->opcode=MESH32;\n tp");
|
|
2655 gennodepath(v->depth,v->path);
|
|
2656 printf("->width=32;\n tp");
|
|
2657 gennodepath(v->depth,v->path);
|
|
2658 printf("->constant=(%luLU);\n",v->c);
|
|
2659 }
|
|
2660 else if(v->mustbemesh&&v->n1)
|
|
2661 /* let this node's n1 handle it */ ;
|
|
2662 else
|
|
2663 yyerror("can't figure out how to generate a replacement node\n");
|
|
2664 treerepgen(v->n1,refs,rc);
|
|
2665 treerepgen(v->n2,refs,rc);
|
|
2666 }
|
|
2667
|
|
2668 int yyerror(char const *s)
|
|
2669 {
|
|
2670 fprintf(stderr,"Error at (%d:%d): \"%s\"\n",cgcrow,cgccol,s);
|
|
2671 return 0; /* this return value is ignored anyway */
|
|
2672 }
|
|
2673
|
|
2674 static int cgcpushback=0;
|
|
2675
|
|
2676 int countgetchar(void)
|
|
2677 {
|
|
2678 int c=getchar();
|
|
2679 if(cgcpushback) {cgcpushback=0; return c;}
|
|
2680 cgccol++;
|
|
2681 if(c=='\n') {cgccol=0; cgcrow++;}
|
|
2682 return c;
|
|
2683 }
|
|
2684
|
|
2685 int countungetc(int c, FILE* f)
|
|
2686 {
|
|
2687 ungetc(c,f);
|
|
2688 cgcpushback=1;
|
|
2689 return c;
|
|
2690 }
|
|
2691
|
|
2692 void splitstart(void)
|
|
2693 {
|
|
2694 static char fname[]="oilout00.c";
|
|
2695 if(filenumber>255)
|
|
2696 {
|
|
2697 filenumber=255;
|
|
2698 fprintf(stdout,"Input file too long.\n");
|
|
2699 }
|
|
2700 sprintf(fname,"oilout%02x.c",filenumber);
|
|
2701 freopen(fname,"w",stdout);
|
|
2702 puts("/* Automatically generated output, edit source and recompile to "
|
|
2703 "change */");
|
|
2704 printf("#include \"oil.h\"\n"
|
|
2705 "int optimize_pass1_%x(node *np)\n"
|
|
2706 "{"
|
|
2707 " int opted=0;\n"
|
|
2708 " unsigned long c,c1,c2,c3,c4,c5,c6,c7,c8,c9;\n"
|
|
2709 " unsigned long x,x1,x2,x3,x4,x5,x6,x7,x8,x9,r;\n"
|
|
2710 " int tempw;\n"
|
|
2711 " node *tp;\n", filenumber);
|
|
2712 }
|
|
2713
|
|
2714 void splitend(void)
|
|
2715 {
|
|
2716 /* Disabling warnings about unused variables. gcc will optimize this right
|
|
2717 out, and in any case the raise(SIGSEGV) will be unreachable (but will
|
|
2718 cause a pretty recognizable error because it'll be caught by the handler
|
|
2719 for SIGSEGV and output an internal error, with an obvious debug backtrace
|
|
2720 if -U is used). */
|
|
2721 printf(" c=c1=c2=c3=c4=c5=c6=c7=c8=c9=0;\n"
|
|
2722 " x=x1=x2=x3=x4=x5=x6=x7=x8=x9=r=0;\n"
|
|
2723 " if(c+c1+c2+c3+c4+c5+c6+c7+c8+c9+r+\n"
|
|
2724 " x+x1+x2+x3+x4+x5+x6+x7+x8+x9) raise(SIGSEGV);\n");
|
|
2725 printf(" return opted;\n}\n");
|
|
2726 fclose(stdout);
|
|
2727 }
|
|
2728
|
|
2729 int main(void)
|
|
2730 {
|
|
2731 int e,i;
|
|
2732 /*
|
|
2733 " if(!np) return 0;\n"
|
|
2734 " if(np->lval) opted|=optimize_pass1(np->lval);\n"
|
|
2735 " if(np->rval) opted|=optimize_pass1(np->rval);\n"
|
|
2736 */
|
|
2737 splitstart();
|
|
2738 cgccol=0;
|
|
2739 cgcrow=1;
|
|
2740 e=yyparse();
|
|
2741 while(tfi--) free(tofree[tfi]);
|
|
2742 splitend();
|
|
2743 freopen("oilout-m.c","w",stdout);
|
|
2744 puts("/* Automatically generated output, edit source and recompile to "
|
|
2745 "change */");
|
|
2746 puts("#include \"ick.h\"");
|
|
2747 i=filenumber+1;
|
|
2748 while(i--) printf("extern int optimize_pass1_%x(node*);\n",i);
|
|
2749 puts("int optimize_pass1(node* np)\n"
|
|
2750 "{\n"
|
|
2751 " int opted=0;\n"
|
|
2752 " if(!np) return 0;\n"
|
|
2753 " if(np->lval) opted|=optimize_pass1(np->lval);\n"
|
|
2754 " if(np->rval) opted|=optimize_pass1(np->rval);");
|
|
2755 i=filenumber+1;
|
|
2756 while(i--) printf(" opted|=optimize_pass1_%x(np);\n",i);
|
|
2757 puts(" return opted;\n"
|
|
2758 "}");
|
|
2759 return e;
|
|
2760 }
|
|
2761
|