1
2 /* A Bison parser, made by GNU Bison 2.4.1. */
3
4 /* Skeleton implementation for Bison's Yacc-like parsers in C
5
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
8
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22 /* As a special exception, you may create a larger work that contains
23 part or all of the Bison parser skeleton and distribute that work
24 under terms of your choice, so long as that work isn't itself a
25 parser generator using the skeleton or a modified version thereof
26 as a parser skeleton. Alternatively, if you modify or redistribute
27 the parser skeleton itself, you may (at your option) remove this
28 special exception, which will cause the skeleton and the resulting
29 Bison output files to be licensed under the GNU General Public
30 License without this special exception.
31
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
34
35 /* C LALR(1) parser skeleton written by Richard Stallman, by
36 simplifying the original so-called "semantic" parser. */
37
38 /* All symbols defined below should begin with yy or YY, to avoid
39 infringing on user name space. This should be done even for local
40 variables, as they might otherwise be expanded by user macros.
41 There are some unavoidable exceptions within include files to
42 define necessary library symbols; they are noted "INFRINGES ON
43 USER NAME SPACE" below. */
44
45 /* Identify Bison output. */
46 #define YYBISON 1
47
48 /* Bison version. */
49 #define YYBISON_VERSION "2.4.1"
50
51 /* Skeleton name. */
52 #define YYSKELETON_NAME "yacc.c"
53
54 /* Pure parsers. */
55 #define YYPURE 0
56
57 /* Push parsers. */
58 #define YYPUSH 0
59
60 /* Pull parsers. */
61 #define YYPULL 1
62
63 /* Using locations. */
64 #define YYLSP_NEEDED 0
65
66
67
68 /* Copy the first part of user declarations. */
69
70 /* Line 189 of yacc.c */
71 #line 1 "let.y"
72
73
74 #define YYSTYPE ngx_let_node_t*
75
76 #include "let.h"
77 #include "let.tab.h"
78
79 #include <ngx_http.h>
80
81 static ngx_conf_t *conf;
82 static unsigned inpos;
83 static ngx_let_node_t *result;
84
85 int yylex();
86
yyerror(char * s)87 void yyerror(char *s) {
88
89 ngx_str_t* token = conf->args->elts;
90
91 if (inpos < conf->args->nelts)
92 token += inpos;
93 else
94 token = 0;
95
96 ngx_log_debug(NGX_LOG_INFO, conf->log, 0,
97 "error parsing let expression: %s[%d]: %*s", s, inpos,
98 token ? token->len : 0, token ? (char*)token->data : "");
99
100 yylval = NULL;
101 }
102
ngx_let_binop_node_create(ngx_let_node_t * left,char op,ngx_let_node_t * right)103 ngx_let_node_t* ngx_let_binop_node_create(
104 ngx_let_node_t* left,
105 char op,
106 ngx_let_node_t* right)
107 {
108 ngx_let_node_t** args;
109 ngx_let_node_t* node;
110
111 node = ngx_pcalloc(conf->pool, sizeof(ngx_let_node_t));
112
113 node->type = NGX_LTYPE_OPERATION;
114
115 node->index = op;
116
117 ngx_array_init(&node->args, conf->pool, 2, sizeof(ngx_let_node_t*));
118
119 args = ngx_array_push_n(&node->args, 2);
120 args[0] = left;
121 args[1] = right;
122
123 /* yylval = node;*/
124
125 ngx_log_debug(NGX_LOG_INFO, conf->log, 0, "let operation reduce '%c'", op);
126
127 return node;
128 }
129
ngx_let_fun_arg(ngx_let_node_t * fun,ngx_let_node_t * arg)130 ngx_let_node_t* ngx_let_fun_arg(
131 ngx_let_node_t* fun,
132 ngx_let_node_t* arg)
133 {
134 ngx_let_node_t** args;
135
136 if (!fun->args.nalloc)
137 ngx_array_init(&fun->args, conf->pool, 1, sizeof(ngx_let_node_t*));
138
139 args = ngx_array_push(&fun->args);
140 *args = arg;
141
142 ngx_log_debug(NGX_LOG_INFO, conf->log, 0, "let function argument: %d : %d", fun->type, arg->type);
143
144 /* yylval = fun;*/
145
146 return fun;
147 }
148
149
150
151 /* Line 189 of yacc.c */
152 #line 153 "let.tab.c"
153
154 /* Enabling traces. */
155 #ifndef YYDEBUG
156 # define YYDEBUG 0
157 #endif
158
159 /* Enabling verbose error messages. */
160 #ifdef YYERROR_VERBOSE
161 # undef YYERROR_VERBOSE
162 # define YYERROR_VERBOSE 1
163 #else
164 # define YYERROR_VERBOSE 0
165 #endif
166
167 /* Enabling the token table. */
168 #ifndef YYTOKEN_TABLE
169 # define YYTOKEN_TABLE 0
170 #endif
171
172
173 /* Tokens. */
174 #ifndef YYTOKENTYPE
175 # define YYTOKENTYPE
176 /* Put the tokens into the symbol table, so that GDB and other debuggers
177 know about them. */
178 enum yytokentype {
179 NGXLEAF = 258,
180 NGXFUNC = 259,
181 NGXFUNC0 = 260,
182 NGXDONE = 261
183 };
184 #endif
185
186
187
188 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
189 typedef int YYSTYPE;
190 # define YYSTYPE_IS_TRIVIAL 1
191 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
192 # define YYSTYPE_IS_DECLARED 1
193 #endif
194
195
196 /* Copy the second part of user declarations. */
197
198
199 /* Line 264 of yacc.c */
200 #line 201 "let.tab.c"
201
202 #ifdef short
203 # undef short
204 #endif
205
206 #ifdef YYTYPE_UINT8
207 typedef YYTYPE_UINT8 yytype_uint8;
208 #else
209 typedef unsigned char yytype_uint8;
210 #endif
211
212 #ifdef YYTYPE_INT8
213 typedef YYTYPE_INT8 yytype_int8;
214 #elif (defined __STDC__ || defined __C99__FUNC__ \
215 || defined __cplusplus || defined _MSC_VER)
216 typedef signed char yytype_int8;
217 #else
218 typedef short int yytype_int8;
219 #endif
220
221 #ifdef YYTYPE_UINT16
222 typedef YYTYPE_UINT16 yytype_uint16;
223 #else
224 typedef unsigned short int yytype_uint16;
225 #endif
226
227 #ifdef YYTYPE_INT16
228 typedef YYTYPE_INT16 yytype_int16;
229 #else
230 typedef short int yytype_int16;
231 #endif
232
233 #ifndef YYSIZE_T
234 # ifdef __SIZE_TYPE__
235 # define YYSIZE_T __SIZE_TYPE__
236 # elif defined size_t
237 # define YYSIZE_T size_t
238 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
239 || defined __cplusplus || defined _MSC_VER)
240 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
241 # define YYSIZE_T size_t
242 # else
243 # define YYSIZE_T unsigned int
244 # endif
245 #endif
246
247 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
248
249 #ifndef YY_
250 # if YYENABLE_NLS
251 # if ENABLE_NLS
252 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
253 # define YY_(msgid) dgettext ("bison-runtime", msgid)
254 # endif
255 # endif
256 # ifndef YY_
257 # define YY_(msgid) msgid
258 # endif
259 #endif
260
261 /* Suppress unused-variable warnings by "using" E. */
262 #if ! defined lint || defined __GNUC__
263 # define YYUSE(e) ((void) (e))
264 #else
265 # define YYUSE(e) /* empty */
266 #endif
267
268 /* Identity function, used to suppress warnings about constant conditions. */
269 #ifndef lint
270 # define YYID(n) (n)
271 #else
272 #if (defined __STDC__ || defined __C99__FUNC__ \
273 || defined __cplusplus || defined _MSC_VER)
274 static int
YYID(int yyi)275 YYID (int yyi)
276 #else
277 static int
278 YYID (yyi)
279 int yyi;
280 #endif
281 {
282 return yyi;
283 }
284 #endif
285
286 #if ! defined yyoverflow || YYERROR_VERBOSE
287
288 /* The parser invokes alloca or malloc; define the necessary symbols. */
289
290 # ifdef YYSTACK_USE_ALLOCA
291 # if YYSTACK_USE_ALLOCA
292 # ifdef __GNUC__
293 # define YYSTACK_ALLOC __builtin_alloca
294 # elif defined __BUILTIN_VA_ARG_INCR
295 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
296 # elif defined _AIX
297 # define YYSTACK_ALLOC __alloca
298 # elif defined _MSC_VER
299 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
300 # define alloca _alloca
301 # else
302 # define YYSTACK_ALLOC alloca
303 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
304 || defined __cplusplus || defined _MSC_VER)
305 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
306 # ifndef _STDLIB_H
307 # define _STDLIB_H 1
308 # endif
309 # endif
310 # endif
311 # endif
312 # endif
313
314 # ifdef YYSTACK_ALLOC
315 /* Pacify GCC's `empty if-body' warning. */
316 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
317 # ifndef YYSTACK_ALLOC_MAXIMUM
318 /* The OS might guarantee only one guard page at the bottom of the stack,
319 and a page size can be as small as 4096 bytes. So we cannot safely
320 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
321 to allow for a few compiler-allocated temporary stack slots. */
322 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
323 # endif
324 # else
325 # define YYSTACK_ALLOC YYMALLOC
326 # define YYSTACK_FREE YYFREE
327 # ifndef YYSTACK_ALLOC_MAXIMUM
328 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
329 # endif
330 # if (defined __cplusplus && ! defined _STDLIB_H \
331 && ! ((defined YYMALLOC || defined malloc) \
332 && (defined YYFREE || defined free)))
333 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
334 # ifndef _STDLIB_H
335 # define _STDLIB_H 1
336 # endif
337 # endif
338 # ifndef YYMALLOC
339 # define YYMALLOC malloc
340 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
341 || defined __cplusplus || defined _MSC_VER)
342 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
343 # endif
344 # endif
345 # ifndef YYFREE
346 # define YYFREE free
347 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
348 || defined __cplusplus || defined _MSC_VER)
349 void free (void *); /* INFRINGES ON USER NAME SPACE */
350 # endif
351 # endif
352 # endif
353 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
354
355
356 #if (! defined yyoverflow \
357 && (! defined __cplusplus \
358 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
359
360 /* A type that is properly aligned for any stack member. */
361 union yyalloc
362 {
363 yytype_int16 yyss_alloc;
364 YYSTYPE yyvs_alloc;
365 };
366
367 /* The size of the maximum gap between one aligned stack and the next. */
368 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
369
370 /* The size of an array large to enough to hold all stacks, each with
371 N elements. */
372 # define YYSTACK_BYTES(N) \
373 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
374 + YYSTACK_GAP_MAXIMUM)
375
376 /* Copy COUNT objects from FROM to TO. The source and destination do
377 not overlap. */
378 # ifndef YYCOPY
379 # if defined __GNUC__ && 1 < __GNUC__
380 # define YYCOPY(To, From, Count) \
381 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
382 # else
383 # define YYCOPY(To, From, Count) \
384 do \
385 { \
386 YYSIZE_T yyi; \
387 for (yyi = 0; yyi < (Count); yyi++) \
388 (To)[yyi] = (From)[yyi]; \
389 } \
390 while (YYID (0))
391 # endif
392 # endif
393
394 /* Relocate STACK from its old location to the new one. The
395 local variables YYSIZE and YYSTACKSIZE give the old and new number of
396 elements in the stack, and YYPTR gives the new location of the
397 stack. Advance YYPTR to a properly aligned location for the next
398 stack. */
399 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
400 do \
401 { \
402 YYSIZE_T yynewbytes; \
403 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
404 Stack = &yyptr->Stack_alloc; \
405 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
406 yyptr += yynewbytes / sizeof (*yyptr); \
407 } \
408 while (YYID (0))
409
410 #endif
411
412 /* YYFINAL -- State number of the termination state. */
413 #define YYFINAL 9
414 /* YYLAST -- Last index in YYTABLE. */
415 #define YYLAST 55
416
417 /* YYNTOKENS -- Number of terminals. */
418 #define YYNTOKENS 17
419 /* YYNNTS -- Number of nonterminals. */
420 #define YYNNTS 4
421 /* YYNRULES -- Number of rules. */
422 #define YYNRULES 16
423 /* YYNRULES -- Number of states. */
424 #define YYNSTATES 30
425
426 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
427 #define YYUNDEFTOK 2
428 #define YYMAXUTOK 261
429
430 #define YYTRANSLATE(YYX) \
431 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
432
433 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
434 static const yytype_uint8 yytranslate[] =
435 {
436 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
437 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
438 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439 2, 2, 2, 2, 2, 2, 2, 11, 13, 2,
440 15, 16, 9, 7, 2, 8, 12, 10, 2, 2,
441 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
442 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
447 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
448 2, 2, 2, 2, 14, 2, 2, 2, 2, 2,
449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
455 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
456 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
457 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
458 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
459 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
460 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
461 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
462 5, 6
463 };
464
465 #if YYDEBUG
466 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
467 YYRHS. */
468 static const yytype_uint8 yyprhs[] =
469 {
470 0, 0, 3, 6, 10, 12, 14, 17, 21, 25,
471 29, 33, 37, 41, 45, 49, 51
472 };
473
474 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
475 static const yytype_int8 yyrhs[] =
476 {
477 18, 0, -1, 19, 6, -1, 15, 19, 16, -1,
478 3, -1, 5, -1, 20, 16, -1, 19, 9, 19,
479 -1, 19, 10, 19, -1, 19, 11, 19, -1, 19,
480 7, 19, -1, 19, 8, 19, -1, 19, 13, 19,
481 -1, 19, 14, 19, -1, 19, 12, 19, -1, 4,
482 -1, 20, 19, -1
483 };
484
485 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
486 static const yytype_uint8 yyrline[] =
487 {
488 0, 91, 91, 93, 95, 97, 99, 101, 103, 105,
489 107, 109, 111, 113, 115, 119, 121
490 };
491 #endif
492
493 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
494 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
495 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
496 static const char *const yytname[] =
497 {
498 "$end", "error", "$undefined", "NGXLEAF", "NGXFUNC", "NGXFUNC0",
499 "NGXDONE", "'+'", "'-'", "'*'", "'/'", "'%'", "'.'", "'&'", "'|'", "'('",
500 "')'", "$accept", "letexpr", "expr", "funopen", 0
501 };
502 #endif
503
504 # ifdef YYPRINT
505 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
506 token YYLEX-NUM. */
507 static const yytype_uint16 yytoknum[] =
508 {
509 0, 256, 257, 258, 259, 260, 261, 43, 45, 42,
510 47, 37, 46, 38, 124, 40, 41
511 };
512 # endif
513
514 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
515 static const yytype_uint8 yyr1[] =
516 {
517 0, 17, 18, 19, 19, 19, 19, 19, 19, 19,
518 19, 19, 19, 19, 19, 20, 20
519 };
520
521 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
522 static const yytype_uint8 yyr2[] =
523 {
524 0, 2, 2, 3, 1, 1, 2, 3, 3, 3,
525 3, 3, 3, 3, 3, 1, 2
526 };
527
528 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
529 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
530 means the default is an error. */
531 static const yytype_uint8 yydefact[] =
532 {
533 0, 4, 15, 5, 0, 0, 0, 0, 0, 1,
534 2, 0, 0, 0, 0, 0, 0, 0, 0, 6,
535 16, 3, 10, 11, 7, 8, 9, 14, 12, 13
536 };
537
538 /* YYDEFGOTO[NTERM-NUM]. */
539 static const yytype_int8 yydefgoto[] =
540 {
541 -1, 5, 6, 7
542 };
543
544 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
545 STATE-NUM. */
546 #define YYPACT_NINF -13
547 static const yytype_int8 yypact[] =
548 {
549 15, -13, -13, -13, 15, 29, 35, 1, 24, -13,
550 -13, 15, 15, 15, 15, 15, 15, 15, 15, -13,
551 14, -13, 41, 41, -12, -12, -12, -12, -13, -13
552 };
553
554 /* YYPGOTO[NTERM-NUM]. */
555 static const yytype_int8 yypgoto[] =
556 {
557 -13, -13, -4, -13
558 };
559
560 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
561 positive, shift that token. If negative, reduce the rule which
562 number is the opposite. If zero, do what YYDEFACT says.
563 If YYTABLE_NINF, syntax error. */
564 #define YYTABLE_NINF -1
565 static const yytype_uint8 yytable[] =
566 {
567 8, 17, 18, 20, 1, 2, 3, 22, 23, 24,
568 25, 26, 27, 28, 29, 0, 4, 19, 1, 2,
569 3, 11, 12, 13, 14, 15, 16, 17, 18, 9,
570 4, 11, 12, 13, 14, 15, 16, 17, 18, 0,
571 21, 10, 11, 12, 13, 14, 15, 16, 17, 18,
572 13, 14, 15, 16, 17, 18
573 };
574
575 static const yytype_int8 yycheck[] =
576 {
577 4, 13, 14, 7, 3, 4, 5, 11, 12, 13,
578 14, 15, 16, 17, 18, -1, 15, 16, 3, 4,
579 5, 7, 8, 9, 10, 11, 12, 13, 14, 0,
580 15, 7, 8, 9, 10, 11, 12, 13, 14, -1,
581 16, 6, 7, 8, 9, 10, 11, 12, 13, 14,
582 9, 10, 11, 12, 13, 14
583 };
584
585 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
586 symbol of state STATE-NUM. */
587 static const yytype_uint8 yystos[] =
588 {
589 0, 3, 4, 5, 15, 18, 19, 20, 19, 0,
590 6, 7, 8, 9, 10, 11, 12, 13, 14, 16,
591 19, 16, 19, 19, 19, 19, 19, 19, 19, 19
592 };
593
594 #define yyerrok (yyerrstatus = 0)
595 #define yyclearin (yychar = YYEMPTY)
596 #define YYEMPTY (-2)
597 #define YYEOF 0
598
599 #define YYACCEPT goto yyacceptlab
600 #define YYABORT goto yyabortlab
601 #define YYERROR goto yyerrorlab
602
603
604 /* Like YYERROR except do call yyerror. This remains here temporarily
605 to ease the transition to the new meaning of YYERROR, for GCC.
606 Once GCC version 2 has supplanted version 1, this can go. */
607
608 #define YYFAIL goto yyerrlab
609
610 #define YYRECOVERING() (!!yyerrstatus)
611
612 #define YYBACKUP(Token, Value) \
613 do \
614 if (yychar == YYEMPTY && yylen == 1) \
615 { \
616 yychar = (Token); \
617 yylval = (Value); \
618 yytoken = YYTRANSLATE (yychar); \
619 YYPOPSTACK (1); \
620 goto yybackup; \
621 } \
622 else \
623 { \
624 yyerror (YY_("syntax error: cannot back up")); \
625 YYERROR; \
626 } \
627 while (YYID (0))
628
629
630 #define YYTERROR 1
631 #define YYERRCODE 256
632
633
634 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
635 If N is 0, then set CURRENT to the empty location which ends
636 the previous symbol: RHS[0] (always defined). */
637
638 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
639 #ifndef YYLLOC_DEFAULT
640 # define YYLLOC_DEFAULT(Current, Rhs, N) \
641 do \
642 if (YYID (N)) \
643 { \
644 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
645 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
646 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
647 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
648 } \
649 else \
650 { \
651 (Current).first_line = (Current).last_line = \
652 YYRHSLOC (Rhs, 0).last_line; \
653 (Current).first_column = (Current).last_column = \
654 YYRHSLOC (Rhs, 0).last_column; \
655 } \
656 while (YYID (0))
657 #endif
658
659
660 /* YY_LOCATION_PRINT -- Print the location on the stream.
661 This macro was not mandated originally: define only if we know
662 we won't break user code: when these are the locations we know. */
663
664 #ifndef YY_LOCATION_PRINT
665 # if YYLTYPE_IS_TRIVIAL
666 # define YY_LOCATION_PRINT(File, Loc) \
667 fprintf (File, "%d.%d-%d.%d", \
668 (Loc).first_line, (Loc).first_column, \
669 (Loc).last_line, (Loc).last_column)
670 # else
671 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
672 # endif
673 #endif
674
675
676 /* YYLEX -- calling `yylex' with the right arguments. */
677
678 #ifdef YYLEX_PARAM
679 # define YYLEX yylex (YYLEX_PARAM)
680 #else
681 # define YYLEX yylex ()
682 #endif
683
684 /* Enable debugging if requested. */
685 #if YYDEBUG
686
687 # ifndef YYFPRINTF
688 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
689 # define YYFPRINTF fprintf
690 # endif
691
692 # define YYDPRINTF(Args) \
693 do { \
694 if (yydebug) \
695 YYFPRINTF Args; \
696 } while (YYID (0))
697
698 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
699 do { \
700 if (yydebug) \
701 { \
702 YYFPRINTF (stderr, "%s ", Title); \
703 yy_symbol_print (stderr, \
704 Type, Value); \
705 YYFPRINTF (stderr, "\n"); \
706 } \
707 } while (YYID (0))
708
709
710 /*--------------------------------.
711 | Print this symbol on YYOUTPUT. |
712 `--------------------------------*/
713
714 /*ARGSUSED*/
715 #if (defined __STDC__ || defined __C99__FUNC__ \
716 || defined __cplusplus || defined _MSC_VER)
717 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)718 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
719 #else
720 static void
721 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
722 FILE *yyoutput;
723 int yytype;
724 YYSTYPE const * const yyvaluep;
725 #endif
726 {
727 if (!yyvaluep)
728 return;
729 # ifdef YYPRINT
730 if (yytype < YYNTOKENS)
731 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
732 # else
733 YYUSE (yyoutput);
734 # endif
735 switch (yytype)
736 {
737 default:
738 break;
739 }
740 }
741
742
743 /*--------------------------------.
744 | Print this symbol on YYOUTPUT. |
745 `--------------------------------*/
746
747 #if (defined __STDC__ || defined __C99__FUNC__ \
748 || defined __cplusplus || defined _MSC_VER)
749 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)750 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
751 #else
752 static void
753 yy_symbol_print (yyoutput, yytype, yyvaluep)
754 FILE *yyoutput;
755 int yytype;
756 YYSTYPE const * const yyvaluep;
757 #endif
758 {
759 if (yytype < YYNTOKENS)
760 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
761 else
762 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
763
764 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
765 YYFPRINTF (yyoutput, ")");
766 }
767
768 /*------------------------------------------------------------------.
769 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
770 | TOP (included). |
771 `------------------------------------------------------------------*/
772
773 #if (defined __STDC__ || defined __C99__FUNC__ \
774 || defined __cplusplus || defined _MSC_VER)
775 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)776 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
777 #else
778 static void
779 yy_stack_print (yybottom, yytop)
780 yytype_int16 *yybottom;
781 yytype_int16 *yytop;
782 #endif
783 {
784 YYFPRINTF (stderr, "Stack now");
785 for (; yybottom <= yytop; yybottom++)
786 {
787 int yybot = *yybottom;
788 YYFPRINTF (stderr, " %d", yybot);
789 }
790 YYFPRINTF (stderr, "\n");
791 }
792
793 # define YY_STACK_PRINT(Bottom, Top) \
794 do { \
795 if (yydebug) \
796 yy_stack_print ((Bottom), (Top)); \
797 } while (YYID (0))
798
799
800 /*------------------------------------------------.
801 | Report that the YYRULE is going to be reduced. |
802 `------------------------------------------------*/
803
804 #if (defined __STDC__ || defined __C99__FUNC__ \
805 || defined __cplusplus || defined _MSC_VER)
806 static void
yy_reduce_print(YYSTYPE * yyvsp,int yyrule)807 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
808 #else
809 static void
810 yy_reduce_print (yyvsp, yyrule)
811 YYSTYPE *yyvsp;
812 int yyrule;
813 #endif
814 {
815 int yynrhs = yyr2[yyrule];
816 int yyi;
817 unsigned long int yylno = yyrline[yyrule];
818 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
819 yyrule - 1, yylno);
820 /* The symbols being reduced. */
821 for (yyi = 0; yyi < yynrhs; yyi++)
822 {
823 YYFPRINTF (stderr, " $%d = ", yyi + 1);
824 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
825 &(yyvsp[(yyi + 1) - (yynrhs)])
826 );
827 YYFPRINTF (stderr, "\n");
828 }
829 }
830
831 # define YY_REDUCE_PRINT(Rule) \
832 do { \
833 if (yydebug) \
834 yy_reduce_print (yyvsp, Rule); \
835 } while (YYID (0))
836
837 /* Nonzero means print parse trace. It is left uninitialized so that
838 multiple parsers can coexist. */
839 int yydebug;
840 #else /* !YYDEBUG */
841 # define YYDPRINTF(Args)
842 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
843 # define YY_STACK_PRINT(Bottom, Top)
844 # define YY_REDUCE_PRINT(Rule)
845 #endif /* !YYDEBUG */
846
847
848 /* YYINITDEPTH -- initial size of the parser's stacks. */
849 #ifndef YYINITDEPTH
850 # define YYINITDEPTH 200
851 #endif
852
853 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
854 if the built-in stack extension method is used).
855
856 Do not make this value too large; the results are undefined if
857 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
858 evaluated with infinite-precision integer arithmetic. */
859
860 #ifndef YYMAXDEPTH
861 # define YYMAXDEPTH 10000
862 #endif
863
864
865
866 #if YYERROR_VERBOSE
867
868 # ifndef yystrlen
869 # if defined __GLIBC__ && defined _STRING_H
870 # define yystrlen strlen
871 # else
872 /* Return the length of YYSTR. */
873 #if (defined __STDC__ || defined __C99__FUNC__ \
874 || defined __cplusplus || defined _MSC_VER)
875 static YYSIZE_T
yystrlen(const char * yystr)876 yystrlen (const char *yystr)
877 #else
878 static YYSIZE_T
879 yystrlen (yystr)
880 const char *yystr;
881 #endif
882 {
883 YYSIZE_T yylen;
884 for (yylen = 0; yystr[yylen]; yylen++)
885 continue;
886 return yylen;
887 }
888 # endif
889 # endif
890
891 # ifndef yystpcpy
892 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
893 # define yystpcpy stpcpy
894 # else
895 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
896 YYDEST. */
897 #if (defined __STDC__ || defined __C99__FUNC__ \
898 || defined __cplusplus || defined _MSC_VER)
899 static char *
yystpcpy(char * yydest,const char * yysrc)900 yystpcpy (char *yydest, const char *yysrc)
901 #else
902 static char *
903 yystpcpy (yydest, yysrc)
904 char *yydest;
905 const char *yysrc;
906 #endif
907 {
908 char *yyd = yydest;
909 const char *yys = yysrc;
910
911 while ((*yyd++ = *yys++) != '\0')
912 continue;
913
914 return yyd - 1;
915 }
916 # endif
917 # endif
918
919 # ifndef yytnamerr
920 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
921 quotes and backslashes, so that it's suitable for yyerror. The
922 heuristic is that double-quoting is unnecessary unless the string
923 contains an apostrophe, a comma, or backslash (other than
924 backslash-backslash). YYSTR is taken from yytname. If YYRES is
925 null, do not copy; instead, return the length of what the result
926 would have been. */
927 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)928 yytnamerr (char *yyres, const char *yystr)
929 {
930 if (*yystr == '"')
931 {
932 YYSIZE_T yyn = 0;
933 char const *yyp = yystr;
934
935 for (;;)
936 switch (*++yyp)
937 {
938 case '\'':
939 case ',':
940 goto do_not_strip_quotes;
941
942 case '\\':
943 if (*++yyp != '\\')
944 goto do_not_strip_quotes;
945 /* Fall through. */
946 default:
947 if (yyres)
948 yyres[yyn] = *yyp;
949 yyn++;
950 break;
951
952 case '"':
953 if (yyres)
954 yyres[yyn] = '\0';
955 return yyn;
956 }
957 do_not_strip_quotes: ;
958 }
959
960 if (! yyres)
961 return yystrlen (yystr);
962
963 return yystpcpy (yyres, yystr) - yyres;
964 }
965 # endif
966
967 /* Copy into YYRESULT an error message about the unexpected token
968 YYCHAR while in state YYSTATE. Return the number of bytes copied,
969 including the terminating null byte. If YYRESULT is null, do not
970 copy anything; just return the number of bytes that would be
971 copied. As a special case, return 0 if an ordinary "syntax error"
972 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
973 size calculation. */
974 static YYSIZE_T
yysyntax_error(char * yyresult,int yystate,int yychar)975 yysyntax_error (char *yyresult, int yystate, int yychar)
976 {
977 int yyn = yypact[yystate];
978
979 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
980 return 0;
981 else
982 {
983 int yytype = YYTRANSLATE (yychar);
984 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
985 YYSIZE_T yysize = yysize0;
986 YYSIZE_T yysize1;
987 int yysize_overflow = 0;
988 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
989 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
990 int yyx;
991
992 # if 0
993 /* This is so xgettext sees the translatable formats that are
994 constructed on the fly. */
995 YY_("syntax error, unexpected %s");
996 YY_("syntax error, unexpected %s, expecting %s");
997 YY_("syntax error, unexpected %s, expecting %s or %s");
998 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
999 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1000 # endif
1001 char *yyfmt;
1002 char const *yyf;
1003 static char const yyunexpected[] = "syntax error, unexpected %s";
1004 static char const yyexpecting[] = ", expecting %s";
1005 static char const yyor[] = " or %s";
1006 char yyformat[sizeof yyunexpected
1007 + sizeof yyexpecting - 1
1008 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1009 * (sizeof yyor - 1))];
1010 char const *yyprefix = yyexpecting;
1011
1012 /* Start YYX at -YYN if negative to avoid negative indexes in
1013 YYCHECK. */
1014 int yyxbegin = yyn < 0 ? -yyn : 0;
1015
1016 /* Stay within bounds of both yycheck and yytname. */
1017 int yychecklim = YYLAST - yyn + 1;
1018 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1019 int yycount = 1;
1020
1021 yyarg[0] = yytname[yytype];
1022 yyfmt = yystpcpy (yyformat, yyunexpected);
1023
1024 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1025 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1026 {
1027 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1028 {
1029 yycount = 1;
1030 yysize = yysize0;
1031 yyformat[sizeof yyunexpected - 1] = '\0';
1032 break;
1033 }
1034 yyarg[yycount++] = yytname[yyx];
1035 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1036 yysize_overflow |= (yysize1 < yysize);
1037 yysize = yysize1;
1038 yyfmt = yystpcpy (yyfmt, yyprefix);
1039 yyprefix = yyor;
1040 }
1041
1042 yyf = YY_(yyformat);
1043 yysize1 = yysize + yystrlen (yyf);
1044 yysize_overflow |= (yysize1 < yysize);
1045 yysize = yysize1;
1046
1047 if (yysize_overflow)
1048 return YYSIZE_MAXIMUM;
1049
1050 if (yyresult)
1051 {
1052 /* Avoid sprintf, as that infringes on the user's name space.
1053 Don't have undefined behavior even if the translation
1054 produced a string with the wrong number of "%s"s. */
1055 char *yyp = yyresult;
1056 int yyi = 0;
1057 while ((*yyp = *yyf) != '\0')
1058 {
1059 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1060 {
1061 yyp += yytnamerr (yyp, yyarg[yyi++]);
1062 yyf += 2;
1063 }
1064 else
1065 {
1066 yyp++;
1067 yyf++;
1068 }
1069 }
1070 }
1071 return yysize;
1072 }
1073 }
1074 #endif /* YYERROR_VERBOSE */
1075
1076
1077 /*-----------------------------------------------.
1078 | Release the memory associated to this symbol. |
1079 `-----------------------------------------------*/
1080
1081 /*ARGSUSED*/
1082 #if (defined __STDC__ || defined __C99__FUNC__ \
1083 || defined __cplusplus || defined _MSC_VER)
1084 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)1085 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1086 #else
1087 static void
1088 yydestruct (yymsg, yytype, yyvaluep)
1089 const char *yymsg;
1090 int yytype;
1091 YYSTYPE *yyvaluep;
1092 #endif
1093 {
1094 YYUSE (yyvaluep);
1095
1096 if (!yymsg)
1097 yymsg = "Deleting";
1098 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1099
1100 switch (yytype)
1101 {
1102
1103 default:
1104 break;
1105 }
1106 }
1107
1108 /* Prevent warnings from -Wmissing-prototypes. */
1109 #ifdef YYPARSE_PARAM
1110 #if defined __STDC__ || defined __cplusplus
1111 int yyparse (void *YYPARSE_PARAM);
1112 #else
1113 int yyparse ();
1114 #endif
1115 #else /* ! YYPARSE_PARAM */
1116 #if defined __STDC__ || defined __cplusplus
1117 int yyparse (void);
1118 #else
1119 int yyparse ();
1120 #endif
1121 #endif /* ! YYPARSE_PARAM */
1122
1123
1124 /* The lookahead symbol. */
1125 int yychar;
1126
1127 /* The semantic value of the lookahead symbol. */
1128 YYSTYPE yylval;
1129
1130 /* Number of syntax errors so far. */
1131 int yynerrs;
1132
1133
1134
1135 /*-------------------------.
1136 | yyparse or yypush_parse. |
1137 `-------------------------*/
1138
1139 #ifdef YYPARSE_PARAM
1140 #if (defined __STDC__ || defined __C99__FUNC__ \
1141 || defined __cplusplus || defined _MSC_VER)
1142 int
yyparse(void * YYPARSE_PARAM)1143 yyparse (void *YYPARSE_PARAM)
1144 #else
1145 int
1146 yyparse (YYPARSE_PARAM)
1147 void *YYPARSE_PARAM;
1148 #endif
1149 #else /* ! YYPARSE_PARAM */
1150 #if (defined __STDC__ || defined __C99__FUNC__ \
1151 || defined __cplusplus || defined _MSC_VER)
1152 int
1153 yyparse (void)
1154 #else
1155 int
1156 yyparse ()
1157
1158 #endif
1159 #endif
1160 {
1161
1162
1163 int yystate;
1164 /* Number of tokens to shift before error messages enabled. */
1165 int yyerrstatus;
1166
1167 /* The stacks and their tools:
1168 `yyss': related to states.
1169 `yyvs': related to semantic values.
1170
1171 Refer to the stacks thru separate pointers, to allow yyoverflow
1172 to reallocate them elsewhere. */
1173
1174 /* The state stack. */
1175 yytype_int16 yyssa[YYINITDEPTH];
1176 yytype_int16 *yyss;
1177 yytype_int16 *yyssp;
1178
1179 /* The semantic value stack. */
1180 YYSTYPE yyvsa[YYINITDEPTH];
1181 YYSTYPE *yyvs;
1182 YYSTYPE *yyvsp;
1183
1184 YYSIZE_T yystacksize;
1185
1186 int yyn;
1187 int yyresult;
1188 /* Lookahead token as an internal (translated) token number. */
1189 int yytoken;
1190 /* The variables used to return semantic value and location from the
1191 action routines. */
1192 YYSTYPE yyval;
1193
1194 #if YYERROR_VERBOSE
1195 /* Buffer for error messages, and its allocated size. */
1196 char yymsgbuf[128];
1197 char *yymsg = yymsgbuf;
1198 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1199 #endif
1200
1201 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1202
1203 /* The number of symbols on the RHS of the reduced rule.
1204 Keep to zero when no symbol should be popped. */
1205 int yylen = 0;
1206
1207 yytoken = 0;
1208 yyss = yyssa;
1209 yyvs = yyvsa;
1210 yystacksize = YYINITDEPTH;
1211
1212 YYDPRINTF ((stderr, "Starting parse\n"));
1213
1214 yystate = 0;
1215 yyerrstatus = 0;
1216 yynerrs = 0;
1217 yychar = YYEMPTY; /* Cause a token to be read. */
1218
1219 /* Initialize stack pointers.
1220 Waste one element of value and location stack
1221 so that they stay on the same level as the state stack.
1222 The wasted elements are never initialized. */
1223 yyssp = yyss;
1224 yyvsp = yyvs;
1225
1226 goto yysetstate;
1227
1228 /*------------------------------------------------------------.
1229 | yynewstate -- Push a new state, which is found in yystate. |
1230 `------------------------------------------------------------*/
1231 yynewstate:
1232 /* In all cases, when you get here, the value and location stacks
1233 have just been pushed. So pushing a state here evens the stacks. */
1234 yyssp++;
1235
1236 yysetstate:
1237 *yyssp = yystate;
1238
1239 if (yyss + yystacksize - 1 <= yyssp)
1240 {
1241 /* Get the current used size of the three stacks, in elements. */
1242 YYSIZE_T yysize = yyssp - yyss + 1;
1243
1244 #ifdef yyoverflow
1245 {
1246 /* Give user a chance to reallocate the stack. Use copies of
1247 these so that the &'s don't force the real ones into
1248 memory. */
1249 YYSTYPE *yyvs1 = yyvs;
1250 yytype_int16 *yyss1 = yyss;
1251
1252 /* Each stack pointer address is followed by the size of the
1253 data in use in that stack, in bytes. This used to be a
1254 conditional around just the two extra args, but that might
1255 be undefined if yyoverflow is a macro. */
1256 yyoverflow (YY_("memory exhausted"),
1257 &yyss1, yysize * sizeof (*yyssp),
1258 &yyvs1, yysize * sizeof (*yyvsp),
1259 &yystacksize);
1260
1261 yyss = yyss1;
1262 yyvs = yyvs1;
1263 }
1264 #else /* no yyoverflow */
1265 # ifndef YYSTACK_RELOCATE
1266 goto yyexhaustedlab;
1267 # else
1268 /* Extend the stack our own way. */
1269 if (YYMAXDEPTH <= yystacksize)
1270 goto yyexhaustedlab;
1271 yystacksize *= 2;
1272 if (YYMAXDEPTH < yystacksize)
1273 yystacksize = YYMAXDEPTH;
1274
1275 {
1276 yytype_int16 *yyss1 = yyss;
1277 union yyalloc *yyptr =
1278 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1279 if (! yyptr)
1280 goto yyexhaustedlab;
1281 YYSTACK_RELOCATE (yyss_alloc, yyss);
1282 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1283 # undef YYSTACK_RELOCATE
1284 if (yyss1 != yyssa)
1285 YYSTACK_FREE (yyss1);
1286 }
1287 # endif
1288 #endif /* no yyoverflow */
1289
1290 yyssp = yyss + yysize - 1;
1291 yyvsp = yyvs + yysize - 1;
1292
1293 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1294 (unsigned long int) yystacksize));
1295
1296 if (yyss + yystacksize - 1 <= yyssp)
1297 YYABORT;
1298 }
1299
1300 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1301
1302 if (yystate == YYFINAL)
1303 YYACCEPT;
1304
1305 goto yybackup;
1306
1307 /*-----------.
1308 | yybackup. |
1309 `-----------*/
1310 yybackup:
1311
1312 /* Do appropriate processing given the current state. Read a
1313 lookahead token if we need one and don't already have one. */
1314
1315 /* First try to decide what to do without reference to lookahead token. */
1316 yyn = yypact[yystate];
1317 if (yyn == YYPACT_NINF)
1318 goto yydefault;
1319
1320 /* Not known => get a lookahead token if don't already have one. */
1321
1322 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1323 if (yychar == YYEMPTY)
1324 {
1325 YYDPRINTF ((stderr, "Reading a token: "));
1326 yychar = YYLEX;
1327 }
1328
1329 if (yychar <= YYEOF)
1330 {
1331 yychar = yytoken = YYEOF;
1332 YYDPRINTF ((stderr, "Now at end of input.\n"));
1333 }
1334 else
1335 {
1336 yytoken = YYTRANSLATE (yychar);
1337 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1338 }
1339
1340 /* If the proper action on seeing token YYTOKEN is to reduce or to
1341 detect an error, take that action. */
1342 yyn += yytoken;
1343 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1344 goto yydefault;
1345 yyn = yytable[yyn];
1346 if (yyn <= 0)
1347 {
1348 if (yyn == 0 || yyn == YYTABLE_NINF)
1349 goto yyerrlab;
1350 yyn = -yyn;
1351 goto yyreduce;
1352 }
1353
1354 /* Count tokens shifted since error; after three, turn off error
1355 status. */
1356 if (yyerrstatus)
1357 yyerrstatus--;
1358
1359 /* Shift the lookahead token. */
1360 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1361
1362 /* Discard the shifted token. */
1363 yychar = YYEMPTY;
1364
1365 yystate = yyn;
1366 *++yyvsp = yylval;
1367
1368 goto yynewstate;
1369
1370
1371 /*-----------------------------------------------------------.
1372 | yydefault -- do the default action for the current state. |
1373 `-----------------------------------------------------------*/
1374 yydefault:
1375 yyn = yydefact[yystate];
1376 if (yyn == 0)
1377 goto yyerrlab;
1378 goto yyreduce;
1379
1380
1381 /*-----------------------------.
1382 | yyreduce -- Do a reduction. |
1383 `-----------------------------*/
1384 yyreduce:
1385 /* yyn is the number of a rule to reduce with. */
1386 yylen = yyr2[yyn];
1387
1388 /* If YYLEN is nonzero, implement the default value of the action:
1389 `$$ = $1'.
1390
1391 Otherwise, the following line sets YYVAL to garbage.
1392 This behavior is undocumented and Bison
1393 users should not rely upon it. Assigning to YYVAL
1394 unconditionally makes the parser a bit smaller, and it avoids a
1395 GCC warning that YYVAL may be used uninitialized. */
1396 yyval = yyvsp[1-yylen];
1397
1398
1399 YY_REDUCE_PRINT (yyn);
1400 switch (yyn)
1401 {
1402 case 2:
1403
1404 /* Line 1455 of yacc.c */
1405 #line 91 "let.y"
1406 { result = (yyvsp[(1) - (2)]); YYACCEPT; ;}
1407 break;
1408
1409 case 3:
1410
1411 /* Line 1455 of yacc.c */
1412 #line 93 "let.y"
1413 { (yyval) = (yyvsp[(2) - (3)]); ;}
1414 break;
1415
1416 case 7:
1417
1418 /* Line 1455 of yacc.c */
1419 #line 101 "let.y"
1420 { (yyval) = ngx_let_binop_node_create((yyvsp[(1) - (3)]), '*', (yyvsp[(3) - (3)])); ;}
1421 break;
1422
1423 case 8:
1424
1425 /* Line 1455 of yacc.c */
1426 #line 103 "let.y"
1427 { (yyval) = ngx_let_binop_node_create((yyvsp[(1) - (3)]), '/', (yyvsp[(3) - (3)])); ;}
1428 break;
1429
1430 case 9:
1431
1432 /* Line 1455 of yacc.c */
1433 #line 105 "let.y"
1434 { (yyval) = ngx_let_binop_node_create((yyvsp[(1) - (3)]), '%', (yyvsp[(3) - (3)])); ;}
1435 break;
1436
1437 case 10:
1438
1439 /* Line 1455 of yacc.c */
1440 #line 107 "let.y"
1441 { (yyval) = ngx_let_binop_node_create((yyvsp[(1) - (3)]), '+', (yyvsp[(3) - (3)])); ;}
1442 break;
1443
1444 case 11:
1445
1446 /* Line 1455 of yacc.c */
1447 #line 109 "let.y"
1448 { (yyval) = ngx_let_binop_node_create((yyvsp[(1) - (3)]), '-', (yyvsp[(3) - (3)])); ;}
1449 break;
1450
1451 case 12:
1452
1453 /* Line 1455 of yacc.c */
1454 #line 111 "let.y"
1455 { (yyval) = ngx_let_binop_node_create((yyvsp[(1) - (3)]), '&', (yyvsp[(3) - (3)])); ;}
1456 break;
1457
1458 case 13:
1459
1460 /* Line 1455 of yacc.c */
1461 #line 113 "let.y"
1462 { (yyval) = ngx_let_binop_node_create((yyvsp[(1) - (3)]), '|', (yyvsp[(3) - (3)])); ;}
1463 break;
1464
1465 case 14:
1466
1467 /* Line 1455 of yacc.c */
1468 #line 115 "let.y"
1469 { (yyval) = ngx_let_binop_node_create((yyvsp[(1) - (3)]), '.', (yyvsp[(3) - (3)])); ;}
1470 break;
1471
1472 case 16:
1473
1474 /* Line 1455 of yacc.c */
1475 #line 121 "let.y"
1476 { (yyval) = ngx_let_fun_arg((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); ;}
1477 break;
1478
1479
1480
1481 /* Line 1455 of yacc.c */
1482 #line 1483 "let.tab.c"
1483 default: break;
1484 }
1485 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1486
1487 YYPOPSTACK (yylen);
1488 yylen = 0;
1489 YY_STACK_PRINT (yyss, yyssp);
1490
1491 *++yyvsp = yyval;
1492
1493 /* Now `shift' the result of the reduction. Determine what state
1494 that goes to, based on the state we popped back to and the rule
1495 number reduced by. */
1496
1497 yyn = yyr1[yyn];
1498
1499 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1500 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1501 yystate = yytable[yystate];
1502 else
1503 yystate = yydefgoto[yyn - YYNTOKENS];
1504
1505 goto yynewstate;
1506
1507
1508 /*------------------------------------.
1509 | yyerrlab -- here on detecting error |
1510 `------------------------------------*/
1511 yyerrlab:
1512 /* If not already recovering from an error, report this error. */
1513 if (!yyerrstatus)
1514 {
1515 ++yynerrs;
1516 #if ! YYERROR_VERBOSE
1517 yyerror (YY_("syntax error"));
1518 #else
1519 {
1520 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1521 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1522 {
1523 YYSIZE_T yyalloc = 2 * yysize;
1524 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1525 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1526 if (yymsg != yymsgbuf)
1527 YYSTACK_FREE (yymsg);
1528 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1529 if (yymsg)
1530 yymsg_alloc = yyalloc;
1531 else
1532 {
1533 yymsg = yymsgbuf;
1534 yymsg_alloc = sizeof yymsgbuf;
1535 }
1536 }
1537
1538 if (0 < yysize && yysize <= yymsg_alloc)
1539 {
1540 (void) yysyntax_error (yymsg, yystate, yychar);
1541 yyerror (yymsg);
1542 }
1543 else
1544 {
1545 yyerror (YY_("syntax error"));
1546 if (yysize != 0)
1547 goto yyexhaustedlab;
1548 }
1549 }
1550 #endif
1551 }
1552
1553
1554
1555 if (yyerrstatus == 3)
1556 {
1557 /* If just tried and failed to reuse lookahead token after an
1558 error, discard it. */
1559
1560 if (yychar <= YYEOF)
1561 {
1562 /* Return failure if at end of input. */
1563 if (yychar == YYEOF)
1564 YYABORT;
1565 }
1566 else
1567 {
1568 yydestruct ("Error: discarding",
1569 yytoken, &yylval);
1570 yychar = YYEMPTY;
1571 }
1572 }
1573
1574 /* Else will try to reuse lookahead token after shifting the error
1575 token. */
1576 goto yyerrlab1;
1577
1578
1579 /*---------------------------------------------------.
1580 | yyerrorlab -- error raised explicitly by YYERROR. |
1581 `---------------------------------------------------*/
1582 yyerrorlab:
1583
1584 /* Pacify compilers like GCC when the user code never invokes
1585 YYERROR and the label yyerrorlab therefore never appears in user
1586 code. */
1587 if (/*CONSTCOND*/ 0)
1588 goto yyerrorlab;
1589
1590 /* Do not reclaim the symbols of the rule which action triggered
1591 this YYERROR. */
1592 YYPOPSTACK (yylen);
1593 yylen = 0;
1594 YY_STACK_PRINT (yyss, yyssp);
1595 yystate = *yyssp;
1596 goto yyerrlab1;
1597
1598
1599 /*-------------------------------------------------------------.
1600 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1601 `-------------------------------------------------------------*/
1602 yyerrlab1:
1603 yyerrstatus = 3; /* Each real token shifted decrements this. */
1604
1605 for (;;)
1606 {
1607 yyn = yypact[yystate];
1608 if (yyn != YYPACT_NINF)
1609 {
1610 yyn += YYTERROR;
1611 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1612 {
1613 yyn = yytable[yyn];
1614 if (0 < yyn)
1615 break;
1616 }
1617 }
1618
1619 /* Pop the current state because it cannot handle the error token. */
1620 if (yyssp == yyss)
1621 YYABORT;
1622
1623
1624 yydestruct ("Error: popping",
1625 yystos[yystate], yyvsp);
1626 YYPOPSTACK (1);
1627 yystate = *yyssp;
1628 YY_STACK_PRINT (yyss, yyssp);
1629 }
1630
1631 *++yyvsp = yylval;
1632
1633
1634 /* Shift the error token. */
1635 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1636
1637 yystate = yyn;
1638 goto yynewstate;
1639
1640
1641 /*-------------------------------------.
1642 | yyacceptlab -- YYACCEPT comes here. |
1643 `-------------------------------------*/
1644 yyacceptlab:
1645 yyresult = 0;
1646 goto yyreturn;
1647
1648 /*-----------------------------------.
1649 | yyabortlab -- YYABORT comes here. |
1650 `-----------------------------------*/
1651 yyabortlab:
1652 yyresult = 1;
1653 goto yyreturn;
1654
1655 #if !defined(yyoverflow) || YYERROR_VERBOSE
1656 /*-------------------------------------------------.
1657 | yyexhaustedlab -- memory exhaustion comes here. |
1658 `-------------------------------------------------*/
1659 yyexhaustedlab:
1660 yyerror (YY_("memory exhausted"));
1661 yyresult = 2;
1662 /* Fall through. */
1663 #endif
1664
1665 yyreturn:
1666 if (yychar != YYEMPTY)
1667 yydestruct ("Cleanup: discarding lookahead",
1668 yytoken, &yylval);
1669 /* Do not reclaim the symbols of the rule which action triggered
1670 this YYABORT or YYACCEPT. */
1671 YYPOPSTACK (yylen);
1672 YY_STACK_PRINT (yyss, yyssp);
1673 while (yyssp != yyss)
1674 {
1675 yydestruct ("Cleanup: popping",
1676 yystos[*yyssp], yyvsp);
1677 YYPOPSTACK (1);
1678 }
1679 #ifndef yyoverflow
1680 if (yyss != yyssa)
1681 YYSTACK_FREE (yyss);
1682 #endif
1683 #if YYERROR_VERBOSE
1684 if (yymsg != yymsgbuf)
1685 YYSTACK_FREE (yymsg);
1686 #endif
1687 /* Make sure YYID is used. */
1688 return YYID (yyresult);
1689 }
1690
1691
1692
1693 /* Line 1675 of yacc.c */
1694 #line 125 "let.y"
1695
1696
yylex()1697 int yylex() {
1698
1699 ngx_str_t* str;
1700 ngx_let_node_t* node;
1701
1702 ++inpos;
1703
1704 if (conf == NULL
1705 || conf->args == NULL
1706 || conf->args->nelts <= inpos)
1707 {
1708 return NGXDONE;
1709 }
1710
1711 str = ((ngx_str_t*)conf->args->elts + inpos);
1712
1713 if (str->len == 1 && strchr("+-*/%&|.()", str->data[0])) {
1714
1715 /* terminal */
1716
1717 yylval = 0;
1718
1719 ngx_log_debug(NGX_LOG_INFO, conf->log, 0, "let terminal '%c'", str->data[0]);
1720
1721 return str->data[0];
1722 }
1723
1724 node = ngx_pcalloc(conf->pool, sizeof(ngx_let_node_t));
1725 yylval = node;
1726
1727 if (str->len > 1 && str->data[0] == '$') {
1728
1729 /* variable */
1730
1731 ngx_log_debug(NGX_LOG_INFO, conf->log, 0, "let variable %*s", str->len, str->data);
1732
1733 str->data++;
1734 str->len--;
1735
1736 if (str->data[0] >= '1' && str->data[0] <= '9') {
1737
1738 node->type = NGX_LTYPE_CAPTURE;
1739 node->index = str->data[0] - '0';
1740
1741 } else {
1742
1743 node->type = NGX_LTYPE_VARIABLE;
1744 node->index = ngx_http_get_variable_index(conf, str);
1745
1746 }
1747
1748 return NGXLEAF;
1749
1750 } else if (str->len > 2 && str->data[str->len - 2] == '('
1751 && str->data[str->len - 1] == ')') {
1752
1753 /* function w/o arguments*/
1754
1755 ngx_log_debug(NGX_LOG_INFO, conf->log, 0, "let function0 %*s", str->len - 1, str->data);
1756
1757 node->type = NGX_LTYPE_FUNCTION;
1758 node->name = *str;
1759 node->name.len -= 2;
1760
1761 return NGXFUNC0;
1762
1763 } else if (str->len > 1 && str->data[str->len - 1] == '(' ) {
1764
1765 /* function */
1766
1767 ngx_log_debug(NGX_LOG_INFO, conf->log, 0, "let function %*s", str->len - 1, str->data);
1768
1769 node->type = NGX_LTYPE_FUNCTION;
1770 node->name = *str;
1771 node->name.len--;
1772
1773 return NGXFUNC;
1774
1775 } else {
1776
1777 /* literal */
1778
1779 ngx_log_debug(NGX_LOG_INFO, conf->log, 0, "let literal %*s", str->len, str->data);
1780
1781 node->type = NGX_LTYPE_LITERAL;
1782 node->name = *str;
1783
1784 return NGXLEAF;
1785 }
1786 }
1787
ngx_parse_let_expr(ngx_conf_t * cf)1788 ngx_let_node_t* ngx_parse_let_expr(ngx_conf_t* cf) {
1789 conf = cf;
1790 inpos = 1; /* #1 is dest variable */
1791 result = 0;
1792 yyparse();
1793 return result;
1794 }
1795
1796
1797