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 1
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 7 "expr.y"
72
73 #include <math.h> /* For math functions, cos(), sin(), etc. */
74 #include <stdio.h> /* for printf */
75 #include <stdlib.h> /* for malloc */
76 #include <ctype.h> /* for yylex alnum */
77 #include "calc.h" /* Contains definition of `symrec'. */
78 #include "tmpllog.h"
79 #include "pabstract.h"
80 #include "prostate.h"
81 #include "provalue.h"
82 #include "pparam.h"
83 #include "pmiscdef.h"
84 /* for expr-specific only */
85 #include "exprtool.h"
86 #include "exprpstr.h"
87 #include "parse_expr.h"
88 /* Remember unsigned char assert on win32
89 Debug Assertion Failed! f:\dd\vctools\crt_bld\self_x86\crt\src \isctype.c Expression:(unsigned)(c + 1) <= 256
90 */
91
92
93 /* Line 189 of yacc.c */
94 #line 95 "y.tab.c"
95
96 /* Enabling traces. */
97 #ifndef YYDEBUG
98 # define YYDEBUG 0
99 #endif
100
101 /* Enabling verbose error messages. */
102 #ifdef YYERROR_VERBOSE
103 # undef YYERROR_VERBOSE
104 # define YYERROR_VERBOSE 1
105 #else
106 # define YYERROR_VERBOSE 0
107 #endif
108
109 /* Enabling the token table. */
110 #ifndef YYTOKEN_TABLE
111 # define YYTOKEN_TABLE 0
112 #endif
113
114
115 /* Tokens. */
116 #ifndef YYTOKENTYPE
117 # define YYTOKENTYPE
118 /* Put the tokens into the symbol table, so that GDB and other debuggers
119 know about them. */
120 enum yytokentype {
121 NUM = 258,
122 EXTFUNC = 259,
123 BUILTIN_VAR = 260,
124 BUILTIN_FNC_DD = 261,
125 BUILTIN_FNC_DDD = 262,
126 BUILTIN_FNC_EE = 263,
127 VAR = 264,
128 OR = 265,
129 AND = 266,
130 strCMP = 267,
131 strNE = 268,
132 strEQ = 269,
133 strLE = 270,
134 strLT = 271,
135 strGE = 272,
136 strGT = 273,
137 numNE = 274,
138 numEQ = 275,
139 numLE = 276,
140 numLT = 277,
141 numGE = 278,
142 numGT = 279,
143 reNOTLIKE = 280,
144 reLIKE = 281,
145 NEG = 282,
146 NOT = 283
147 };
148 #endif
149 /* Tokens. */
150 #define NUM 258
151 #define EXTFUNC 259
152 #define BUILTIN_VAR 260
153 #define BUILTIN_FNC_DD 261
154 #define BUILTIN_FNC_DDD 262
155 #define BUILTIN_FNC_EE 263
156 #define VAR 264
157 #define OR 265
158 #define AND 266
159 #define strCMP 267
160 #define strNE 268
161 #define strEQ 269
162 #define strLE 270
163 #define strLT 271
164 #define strGE 272
165 #define strGT 273
166 #define numNE 274
167 #define numEQ 275
168 #define numLE 276
169 #define numLT 277
170 #define numGE 278
171 #define numGT 279
172 #define reNOTLIKE 280
173 #define reLIKE 281
174 #define NEG 282
175 #define NOT 283
176
177
178
179
180 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
181 typedef union YYSTYPE
182 {
183
184 /* Line 214 of yacc.c */
185 #line 27 "expr.y"
186
187 struct exprval numval; /* For returning numbers. */
188 const symrec_const *tptr; /* For returning symbol-table pointers. */
189 struct user_func_call extfunc; /* for user-defined function name */
190 PSTRING uservar;
191
192
193
194 /* Line 214 of yacc.c */
195 #line 196 "y.tab.c"
196 } YYSTYPE;
197 # define YYSTYPE_IS_TRIVIAL 1
198 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
199 # define YYSTYPE_IS_DECLARED 1
200 #endif
201
202
203 /* Copy the second part of user declarations. */
204
205 /* Line 264 of yacc.c */
206 #line 33 "expr.y"
207
208 /* the second section is required as we use YYSTYPE here */
209 static void yyerror (struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr, char const *);
210 static int yylex (YYSTYPE *lvalp, struct tmplpro_state* state, struct expr_parser* exprobj);
211
212
213 /* Line 264 of yacc.c */
214 #line 215 "y.tab.c"
215
216 #ifdef short
217 # undef short
218 #endif
219
220 #ifdef YYTYPE_UINT8
221 typedef YYTYPE_UINT8 yytype_uint8;
222 #else
223 typedef unsigned char yytype_uint8;
224 #endif
225
226 #ifdef YYTYPE_INT8
227 typedef YYTYPE_INT8 yytype_int8;
228 #elif (defined __STDC__ || defined __C99__FUNC__ \
229 || defined __cplusplus || defined _MSC_VER)
230 typedef signed char yytype_int8;
231 #else
232 typedef short int yytype_int8;
233 #endif
234
235 #ifdef YYTYPE_UINT16
236 typedef YYTYPE_UINT16 yytype_uint16;
237 #else
238 typedef unsigned short int yytype_uint16;
239 #endif
240
241 #ifdef YYTYPE_INT16
242 typedef YYTYPE_INT16 yytype_int16;
243 #else
244 typedef short int yytype_int16;
245 #endif
246
247 #ifndef YYSIZE_T
248 # ifdef __SIZE_TYPE__
249 # define YYSIZE_T __SIZE_TYPE__
250 # elif defined size_t
251 # define YYSIZE_T size_t
252 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
253 || defined __cplusplus || defined _MSC_VER)
254 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
255 # define YYSIZE_T size_t
256 # else
257 # define YYSIZE_T unsigned int
258 # endif
259 #endif
260
261 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
262
263 #ifndef YY_
264 # if YYENABLE_NLS
265 # if ENABLE_NLS
266 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
267 # define YY_(msgid) dgettext ("bison-runtime", msgid)
268 # endif
269 # endif
270 # ifndef YY_
271 # define YY_(msgid) msgid
272 # endif
273 #endif
274
275 /* Suppress unused-variable warnings by "using" E. */
276 #if ! defined lint || defined __GNUC__
277 # define YYUSE(e) ((void) (e))
278 #else
279 # define YYUSE(e) /* empty */
280 #endif
281
282 /* Identity function, used to suppress warnings about constant conditions. */
283 #ifndef lint
284 # define YYID(n) (n)
285 #else
286 #if (defined __STDC__ || defined __C99__FUNC__ \
287 || defined __cplusplus || defined _MSC_VER)
288 static int
YYID(int yyi)289 YYID (int yyi)
290 #else
291 static int
292 YYID (yyi)
293 int yyi;
294 #endif
295 {
296 return yyi;
297 }
298 #endif
299
300 #if ! defined yyoverflow || YYERROR_VERBOSE
301
302 /* The parser invokes alloca or malloc; define the necessary symbols. */
303
304 # ifdef YYSTACK_USE_ALLOCA
305 # if YYSTACK_USE_ALLOCA
306 # ifdef __GNUC__
307 # define YYSTACK_ALLOC __builtin_alloca
308 # elif defined __BUILTIN_VA_ARG_INCR
309 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
310 # elif defined _AIX
311 # define YYSTACK_ALLOC __alloca
312 # elif defined _MSC_VER
313 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
314 # define alloca _alloca
315 # else
316 # define YYSTACK_ALLOC alloca
317 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
318 || defined __cplusplus || defined _MSC_VER)
319 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
320 # ifndef _STDLIB_H
321 # define _STDLIB_H 1
322 # endif
323 # endif
324 # endif
325 # endif
326 # endif
327
328 # ifdef YYSTACK_ALLOC
329 /* Pacify GCC's `empty if-body' warning. */
330 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
331 # ifndef YYSTACK_ALLOC_MAXIMUM
332 /* The OS might guarantee only one guard page at the bottom of the stack,
333 and a page size can be as small as 4096 bytes. So we cannot safely
334 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
335 to allow for a few compiler-allocated temporary stack slots. */
336 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
337 # endif
338 # else
339 # define YYSTACK_ALLOC YYMALLOC
340 # define YYSTACK_FREE YYFREE
341 # ifndef YYSTACK_ALLOC_MAXIMUM
342 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
343 # endif
344 # if (defined __cplusplus && ! defined _STDLIB_H \
345 && ! ((defined YYMALLOC || defined malloc) \
346 && (defined YYFREE || defined free)))
347 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
348 # ifndef _STDLIB_H
349 # define _STDLIB_H 1
350 # endif
351 # endif
352 # ifndef YYMALLOC
353 # define YYMALLOC malloc
354 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
355 || defined __cplusplus || defined _MSC_VER)
356 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
357 # endif
358 # endif
359 # ifndef YYFREE
360 # define YYFREE free
361 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
362 || defined __cplusplus || defined _MSC_VER)
363 void free (void *); /* INFRINGES ON USER NAME SPACE */
364 # endif
365 # endif
366 # endif
367 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
368
369
370 #if (! defined yyoverflow \
371 && (! defined __cplusplus \
372 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
373
374 /* A type that is properly aligned for any stack member. */
375 union yyalloc
376 {
377 yytype_int16 yyss_alloc;
378 YYSTYPE yyvs_alloc;
379 };
380
381 /* The size of the maximum gap between one aligned stack and the next. */
382 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
383
384 /* The size of an array large to enough to hold all stacks, each with
385 N elements. */
386 # define YYSTACK_BYTES(N) \
387 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
388 + YYSTACK_GAP_MAXIMUM)
389
390 /* Copy COUNT objects from FROM to TO. The source and destination do
391 not overlap. */
392 # ifndef YYCOPY
393 # if defined __GNUC__ && 1 < __GNUC__
394 # define YYCOPY(To, From, Count) \
395 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
396 # else
397 # define YYCOPY(To, From, Count) \
398 do \
399 { \
400 YYSIZE_T yyi; \
401 for (yyi = 0; yyi < (Count); yyi++) \
402 (To)[yyi] = (From)[yyi]; \
403 } \
404 while (YYID (0))
405 # endif
406 # endif
407
408 /* Relocate STACK from its old location to the new one. The
409 local variables YYSIZE and YYSTACKSIZE give the old and new number of
410 elements in the stack, and YYPTR gives the new location of the
411 stack. Advance YYPTR to a properly aligned location for the next
412 stack. */
413 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
414 do \
415 { \
416 YYSIZE_T yynewbytes; \
417 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
418 Stack = &yyptr->Stack_alloc; \
419 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
420 yyptr += yynewbytes / sizeof (*yyptr); \
421 } \
422 while (YYID (0))
423
424 #endif
425
426 /* YYFINAL -- State number of the termination state. */
427 #define YYFINAL 23
428 /* YYLAST -- Last index in YYTABLE. */
429 #define YYLAST 377
430
431 /* YYNTOKENS -- Number of terminals. */
432 #define YYNTOKENS 41
433 /* YYNNTS -- Number of nonterminals. */
434 #define YYNNTS 4
435 /* YYNRULES -- Number of rules. */
436 #define YYNRULES 40
437 /* YYNRULES -- Number of states. */
438 #define YYNSTATES 85
439
440 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
441 #define YYUNDEFTOK 2
442 #define YYMAXUTOK 283
443
444 #define YYTRANSLATE(YYX) \
445 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
446
447 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
448 static const yytype_uint8 yytranslate[] =
449 {
450 0, 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, 34, 2, 2, 2, 33, 2, 2,
454 39, 38, 31, 30, 40, 29, 2, 32, 2, 2,
455 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
456 19, 2, 20, 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, 37, 2, 2, 2, 2, 2,
460 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
461 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
462 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
463 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
464 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
465 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
466 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
467 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
468 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
469 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
470 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
471 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
472 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
473 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
474 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
475 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
476 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
477 15, 16, 17, 18, 21, 22, 23, 24, 25, 26,
478 27, 28, 35, 36
479 };
480
481 #if YYDEBUG
482 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
483 YYRHS. */
484 static const yytype_uint8 yyprhs[] =
485 {
486 0, 0, 3, 5, 7, 9, 11, 14, 18, 22,
487 27, 34, 39, 43, 47, 51, 55, 59, 62, 66,
488 70, 74, 78, 82, 86, 90, 94, 98, 101, 104,
489 108, 112, 116, 120, 124, 128, 132, 136, 140, 144,
490 148
491 };
492
493 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
494 static const yytype_int8 yyrhs[] =
495 {
496 42, 0, -1, 43, -1, 3, -1, 5, -1, 9,
497 -1, 44, 38, -1, 4, 39, 38, -1, 8, 39,
498 38, -1, 6, 39, 43, 38, -1, 7, 39, 43,
499 40, 43, 38, -1, 8, 39, 43, 38, -1, 43,
500 30, 43, -1, 43, 29, 43, -1, 43, 31, 43,
501 -1, 43, 33, 43, -1, 43, 32, 43, -1, 29,
502 43, -1, 43, 37, 43, -1, 43, 10, 43, -1,
503 43, 11, 43, -1, 43, 25, 43, -1, 43, 23,
504 43, -1, 43, 21, 43, -1, 43, 22, 43, -1,
505 43, 20, 43, -1, 43, 19, 43, -1, 34, 43,
506 -1, 36, 43, -1, 39, 43, 38, -1, 43, 12,
507 43, -1, 43, 17, 43, -1, 43, 15, 43, -1,
508 43, 13, 43, -1, 43, 14, 43, -1, 43, 18,
509 43, -1, 43, 16, 43, -1, 43, 28, 43, -1,
510 43, 27, 43, -1, 4, 39, 43, -1, 44, 40,
511 43, -1
512 };
513
514 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
515 static const yytype_uint8 yyrline[] =
516 {
517 0, 61, 61, 69, 70, 72, 81, 85, 90, 97,
518 103, 109, 113, 114, 115, 116, 147, 159, 170, 176,
519 188, 200, 201, 202, 203, 204, 205, 206, 207, 208,
520 209, 213, 214, 215, 216, 217, 218, 219, 220, 223,
521 228
522 };
523 #endif
524
525 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
526 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
527 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
528 static const char *const yytname[] =
529 {
530 "$end", "error", "$undefined", "NUM", "EXTFUNC", "BUILTIN_VAR",
531 "BUILTIN_FNC_DD", "BUILTIN_FNC_DDD", "BUILTIN_FNC_EE", "VAR", "OR",
532 "AND", "strCMP", "strNE", "strEQ", "strLE", "strLT", "strGE", "strGT",
533 "'<'", "'>'", "numNE", "numEQ", "numLE", "numLT", "numGE", "numGT",
534 "reNOTLIKE", "reLIKE", "'-'", "'+'", "'*'", "'/'", "'%'", "'!'", "NEG",
535 "NOT", "'^'", "')'", "'('", "','", "$accept", "line", "numEXP",
536 "arglist", 0
537 };
538 #endif
539
540 # ifdef YYPRINT
541 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
542 token YYLEX-NUM. */
543 static const yytype_uint16 yytoknum[] =
544 {
545 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
546 265, 266, 267, 268, 269, 270, 271, 272, 273, 60,
547 62, 274, 275, 276, 277, 278, 279, 280, 281, 45,
548 43, 42, 47, 37, 33, 282, 283, 94, 41, 40,
549 44
550 };
551 # endif
552
553 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
554 static const yytype_uint8 yyr1[] =
555 {
556 0, 41, 42, 43, 43, 43, 43, 43, 43, 43,
557 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
558 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
559 43, 43, 43, 43, 43, 43, 43, 43, 43, 44,
560 44
561 };
562
563 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
564 static const yytype_uint8 yyr2[] =
565 {
566 0, 2, 1, 1, 1, 1, 2, 3, 3, 4,
567 6, 4, 3, 3, 3, 3, 3, 2, 3, 3,
568 3, 3, 3, 3, 3, 3, 3, 2, 2, 3,
569 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
570 3
571 };
572
573 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
574 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
575 means the default is an error. */
576 static const yytype_uint8 yydefact[] =
577 {
578 0, 3, 0, 4, 0, 0, 0, 5, 0, 0,
579 0, 0, 0, 2, 0, 0, 0, 0, 0, 17,
580 27, 28, 0, 1, 0, 0, 0, 0, 0, 0,
581 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
582 0, 0, 0, 0, 0, 0, 0, 6, 0, 7,
583 39, 0, 0, 8, 0, 29, 19, 20, 30, 33,
584 34, 32, 36, 31, 35, 26, 25, 23, 24, 22,
585 21, 38, 37, 13, 12, 14, 16, 15, 18, 40,
586 9, 0, 11, 0, 10
587 };
588
589 /* YYDEFGOTO[NTERM-NUM]. */
590 static const yytype_int8 yydefgoto[] =
591 {
592 -1, 12, 13, 14
593 };
594
595 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
596 STATE-NUM. */
597 #define YYPACT_NINF -35
598 static const yytype_int16 yypact[] =
599 {
600 54, -35, -28, -35, -27, -26, -25, -35, 54, 54,
601 54, 54, 5, 231, -34, 38, 54, 54, 46, -22,
602 -22, -22, 115, -35, 54, 54, 54, 54, 54, 54,
603 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
604 54, 54, 54, 54, 54, 54, 54, -35, 54, -35,
605 231, 144, 84, -35, 173, -35, 258, 284, 310, 310,
606 310, 310, 310, 310, 310, 329, 329, 329, 329, 329,
607 329, 340, 340, 33, 33, -22, -22, -22, -22, 231,
608 -35, 54, -35, 202, -35
609 };
610
611 /* YYPGOTO[NTERM-NUM]. */
612 static const yytype_int8 yypgoto[] =
613 {
614 -35, -35, -8, -35
615 };
616
617 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
618 positive, shift that token. If negative, reduce the rule which
619 number is the opposite. If zero, do what YYDEFACT says.
620 If YYTABLE_NINF, syntax error. */
621 #define YYTABLE_NINF -1
622 static const yytype_int8 yytable[] =
623 {
624 19, 20, 21, 22, 47, 23, 48, 50, 51, 52,
625 54, 15, 16, 17, 18, 46, 56, 57, 58, 59,
626 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
627 70, 71, 72, 73, 74, 75, 76, 77, 78, 0,
628 79, 1, 2, 3, 4, 5, 6, 7, 0, 1,
629 2, 3, 4, 5, 6, 7, 0, 1, 2, 3,
630 4, 5, 6, 7, 43, 44, 45, 8, 0, 0,
631 46, 0, 9, 83, 10, 8, 49, 11, 0, 0,
632 9, 0, 10, 8, 53, 11, 0, 0, 9, 0,
633 10, 0, 0, 11, 24, 25, 26, 27, 28, 29,
634 30, 31, 32, 33, 34, 35, 36, 37, 0, 38,
635 0, 39, 40, 41, 42, 43, 44, 45, 0, 0,
636 0, 46, 0, 0, 81, 24, 25, 26, 27, 28,
637 29, 30, 31, 32, 33, 34, 35, 36, 37, 0,
638 38, 0, 39, 40, 41, 42, 43, 44, 45, 0,
639 0, 0, 46, 55, 24, 25, 26, 27, 28, 29,
640 30, 31, 32, 33, 34, 35, 36, 37, 0, 38,
641 0, 39, 40, 41, 42, 43, 44, 45, 0, 0,
642 0, 46, 80, 24, 25, 26, 27, 28, 29, 30,
643 31, 32, 33, 34, 35, 36, 37, 0, 38, 0,
644 39, 40, 41, 42, 43, 44, 45, 0, 0, 0,
645 46, 82, 24, 25, 26, 27, 28, 29, 30, 31,
646 32, 33, 34, 35, 36, 37, 0, 38, 0, 39,
647 40, 41, 42, 43, 44, 45, 0, 0, 0, 46,
648 84, 24, 25, 26, 27, 28, 29, 30, 31, 32,
649 33, 34, 35, 36, 37, 0, 38, 0, 39, 40,
650 41, 42, 43, 44, 45, 0, 0, 0, 46, 25,
651 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
652 36, 37, 0, 38, 0, 39, 40, 41, 42, 43,
653 44, 45, 0, 0, 0, 46, 26, 27, 28, 29,
654 30, 31, 32, 33, 34, 35, 36, 37, 0, 38,
655 0, 39, 40, 41, 42, 43, 44, 45, 0, 0,
656 0, 46, -1, -1, -1, -1, -1, -1, -1, 33,
657 34, 35, 36, 37, 0, 38, 0, 39, 40, 41,
658 42, 43, 44, 45, 0, 0, 0, 46, -1, -1,
659 -1, -1, -1, 0, -1, 0, 39, 40, 41, 42,
660 43, 44, 45, 0, 0, 0, 46, -1, -1, 41,
661 42, 43, 44, 45, 0, 0, 0, 46
662 };
663
664 static const yytype_int8 yycheck[] =
665 {
666 8, 9, 10, 11, 38, 0, 40, 15, 16, 17,
667 18, 39, 39, 39, 39, 37, 24, 25, 26, 27,
668 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
669 38, 39, 40, 41, 42, 43, 44, 45, 46, -1,
670 48, 3, 4, 5, 6, 7, 8, 9, -1, 3,
671 4, 5, 6, 7, 8, 9, -1, 3, 4, 5,
672 6, 7, 8, 9, 31, 32, 33, 29, -1, -1,
673 37, -1, 34, 81, 36, 29, 38, 39, -1, -1,
674 34, -1, 36, 29, 38, 39, -1, -1, 34, -1,
675 36, -1, -1, 39, 10, 11, 12, 13, 14, 15,
676 16, 17, 18, 19, 20, 21, 22, 23, -1, 25,
677 -1, 27, 28, 29, 30, 31, 32, 33, -1, -1,
678 -1, 37, -1, -1, 40, 10, 11, 12, 13, 14,
679 15, 16, 17, 18, 19, 20, 21, 22, 23, -1,
680 25, -1, 27, 28, 29, 30, 31, 32, 33, -1,
681 -1, -1, 37, 38, 10, 11, 12, 13, 14, 15,
682 16, 17, 18, 19, 20, 21, 22, 23, -1, 25,
683 -1, 27, 28, 29, 30, 31, 32, 33, -1, -1,
684 -1, 37, 38, 10, 11, 12, 13, 14, 15, 16,
685 17, 18, 19, 20, 21, 22, 23, -1, 25, -1,
686 27, 28, 29, 30, 31, 32, 33, -1, -1, -1,
687 37, 38, 10, 11, 12, 13, 14, 15, 16, 17,
688 18, 19, 20, 21, 22, 23, -1, 25, -1, 27,
689 28, 29, 30, 31, 32, 33, -1, -1, -1, 37,
690 38, 10, 11, 12, 13, 14, 15, 16, 17, 18,
691 19, 20, 21, 22, 23, -1, 25, -1, 27, 28,
692 29, 30, 31, 32, 33, -1, -1, -1, 37, 11,
693 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
694 22, 23, -1, 25, -1, 27, 28, 29, 30, 31,
695 32, 33, -1, -1, -1, 37, 12, 13, 14, 15,
696 16, 17, 18, 19, 20, 21, 22, 23, -1, 25,
697 -1, 27, 28, 29, 30, 31, 32, 33, -1, -1,
698 -1, 37, 12, 13, 14, 15, 16, 17, 18, 19,
699 20, 21, 22, 23, -1, 25, -1, 27, 28, 29,
700 30, 31, 32, 33, -1, -1, -1, 37, 19, 20,
701 21, 22, 23, -1, 25, -1, 27, 28, 29, 30,
702 31, 32, 33, -1, -1, -1, 37, 27, 28, 29,
703 30, 31, 32, 33, -1, -1, -1, 37
704 };
705
706 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
707 symbol of state STATE-NUM. */
708 static const yytype_uint8 yystos[] =
709 {
710 0, 3, 4, 5, 6, 7, 8, 9, 29, 34,
711 36, 39, 42, 43, 44, 39, 39, 39, 39, 43,
712 43, 43, 43, 0, 10, 11, 12, 13, 14, 15,
713 16, 17, 18, 19, 20, 21, 22, 23, 25, 27,
714 28, 29, 30, 31, 32, 33, 37, 38, 40, 38,
715 43, 43, 43, 38, 43, 38, 43, 43, 43, 43,
716 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
717 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
718 38, 40, 38, 43, 38
719 };
720
721 #define yyerrok (yyerrstatus = 0)
722 #define yyclearin (yychar = YYEMPTY)
723 #define YYEMPTY (-2)
724 #define YYEOF 0
725
726 #define YYACCEPT goto yyacceptlab
727 #define YYABORT goto yyabortlab
728 #define YYERROR goto yyerrorlab
729
730
731 /* Like YYERROR except do call yyerror. This remains here temporarily
732 to ease the transition to the new meaning of YYERROR, for GCC.
733 Once GCC version 2 has supplanted version 1, this can go. */
734
735 #define YYFAIL goto yyerrlab
736
737 #define YYRECOVERING() (!!yyerrstatus)
738
739 #define YYBACKUP(Token, Value) \
740 do \
741 if (yychar == YYEMPTY && yylen == 1) \
742 { \
743 yychar = (Token); \
744 yylval = (Value); \
745 yytoken = YYTRANSLATE (yychar); \
746 YYPOPSTACK (1); \
747 goto yybackup; \
748 } \
749 else \
750 { \
751 yyerror (state, exprobj, expr_retval_ptr, YY_("syntax error: cannot back up")); \
752 YYERROR; \
753 } \
754 while (YYID (0))
755
756
757 #define YYTERROR 1
758 #define YYERRCODE 256
759
760
761 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
762 If N is 0, then set CURRENT to the empty location which ends
763 the previous symbol: RHS[0] (always defined). */
764
765 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
766 #ifndef YYLLOC_DEFAULT
767 # define YYLLOC_DEFAULT(Current, Rhs, N) \
768 do \
769 if (YYID (N)) \
770 { \
771 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
772 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
773 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
774 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
775 } \
776 else \
777 { \
778 (Current).first_line = (Current).last_line = \
779 YYRHSLOC (Rhs, 0).last_line; \
780 (Current).first_column = (Current).last_column = \
781 YYRHSLOC (Rhs, 0).last_column; \
782 } \
783 while (YYID (0))
784 #endif
785
786
787 /* YY_LOCATION_PRINT -- Print the location on the stream.
788 This macro was not mandated originally: define only if we know
789 we won't break user code: when these are the locations we know. */
790
791 #ifndef YY_LOCATION_PRINT
792 # if YYLTYPE_IS_TRIVIAL
793 # define YY_LOCATION_PRINT(File, Loc) \
794 fprintf (File, "%d.%d-%d.%d", \
795 (Loc).first_line, (Loc).first_column, \
796 (Loc).last_line, (Loc).last_column)
797 # else
798 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
799 # endif
800 #endif
801
802
803 /* YYLEX -- calling `yylex' with the right arguments. */
804
805 #ifdef YYLEX_PARAM
806 # define YYLEX yylex (&yylval, YYLEX_PARAM)
807 #else
808 # define YYLEX yylex (&yylval, state, exprobj)
809 #endif
810
811 /* Enable debugging if requested. */
812 #if YYDEBUG
813
814 # ifndef YYFPRINTF
815 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
816 # define YYFPRINTF fprintf
817 # endif
818
819 # define YYDPRINTF(Args) \
820 do { \
821 if (yydebug) \
822 YYFPRINTF Args; \
823 } while (YYID (0))
824
825 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
826 do { \
827 if (yydebug) \
828 { \
829 YYFPRINTF (stderr, "%s ", Title); \
830 yy_symbol_print (stderr, \
831 Type, Value, state, exprobj, expr_retval_ptr); \
832 YYFPRINTF (stderr, "\n"); \
833 } \
834 } while (YYID (0))
835
836
837 /*--------------------------------.
838 | Print this symbol on YYOUTPUT. |
839 `--------------------------------*/
840
841 /*ARGSUSED*/
842 #if (defined __STDC__ || defined __C99__FUNC__ \
843 || defined __cplusplus || defined _MSC_VER)
844 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep,struct tmplpro_state * state,struct expr_parser * exprobj,PSTRING * expr_retval_ptr)845 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr)
846 #else
847 static void
848 yy_symbol_value_print (yyoutput, yytype, yyvaluep, state, exprobj, expr_retval_ptr)
849 FILE *yyoutput;
850 int yytype;
851 YYSTYPE const * const yyvaluep;
852 struct tmplpro_state* state;
853 struct expr_parser* exprobj;
854 PSTRING* expr_retval_ptr;
855 #endif
856 {
857 if (!yyvaluep)
858 return;
859 YYUSE (state);
860 YYUSE (exprobj);
861 YYUSE (expr_retval_ptr);
862 # ifdef YYPRINT
863 if (yytype < YYNTOKENS)
864 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
865 # else
866 YYUSE (yyoutput);
867 # endif
868 switch (yytype)
869 {
870 default:
871 break;
872 }
873 }
874
875
876 /*--------------------------------.
877 | Print this symbol on YYOUTPUT. |
878 `--------------------------------*/
879
880 #if (defined __STDC__ || defined __C99__FUNC__ \
881 || defined __cplusplus || defined _MSC_VER)
882 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep,struct tmplpro_state * state,struct expr_parser * exprobj,PSTRING * expr_retval_ptr)883 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr)
884 #else
885 static void
886 yy_symbol_print (yyoutput, yytype, yyvaluep, state, exprobj, expr_retval_ptr)
887 FILE *yyoutput;
888 int yytype;
889 YYSTYPE const * const yyvaluep;
890 struct tmplpro_state* state;
891 struct expr_parser* exprobj;
892 PSTRING* expr_retval_ptr;
893 #endif
894 {
895 if (yytype < YYNTOKENS)
896 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
897 else
898 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
899
900 yy_symbol_value_print (yyoutput, yytype, yyvaluep, state, exprobj, expr_retval_ptr);
901 YYFPRINTF (yyoutput, ")");
902 }
903
904 /*------------------------------------------------------------------.
905 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
906 | TOP (included). |
907 `------------------------------------------------------------------*/
908
909 #if (defined __STDC__ || defined __C99__FUNC__ \
910 || defined __cplusplus || defined _MSC_VER)
911 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)912 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
913 #else
914 static void
915 yy_stack_print (yybottom, yytop)
916 yytype_int16 *yybottom;
917 yytype_int16 *yytop;
918 #endif
919 {
920 YYFPRINTF (stderr, "Stack now");
921 for (; yybottom <= yytop; yybottom++)
922 {
923 int yybot = *yybottom;
924 YYFPRINTF (stderr, " %d", yybot);
925 }
926 YYFPRINTF (stderr, "\n");
927 }
928
929 # define YY_STACK_PRINT(Bottom, Top) \
930 do { \
931 if (yydebug) \
932 yy_stack_print ((Bottom), (Top)); \
933 } while (YYID (0))
934
935
936 /*------------------------------------------------.
937 | Report that the YYRULE is going to be reduced. |
938 `------------------------------------------------*/
939
940 #if (defined __STDC__ || defined __C99__FUNC__ \
941 || defined __cplusplus || defined _MSC_VER)
942 static void
yy_reduce_print(YYSTYPE * yyvsp,int yyrule,struct tmplpro_state * state,struct expr_parser * exprobj,PSTRING * expr_retval_ptr)943 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr)
944 #else
945 static void
946 yy_reduce_print (yyvsp, yyrule, state, exprobj, expr_retval_ptr)
947 YYSTYPE *yyvsp;
948 int yyrule;
949 struct tmplpro_state* state;
950 struct expr_parser* exprobj;
951 PSTRING* expr_retval_ptr;
952 #endif
953 {
954 int yynrhs = yyr2[yyrule];
955 int yyi;
956 unsigned long int yylno = yyrline[yyrule];
957 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
958 yyrule - 1, yylno);
959 /* The symbols being reduced. */
960 for (yyi = 0; yyi < yynrhs; yyi++)
961 {
962 YYFPRINTF (stderr, " $%d = ", yyi + 1);
963 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
964 &(yyvsp[(yyi + 1) - (yynrhs)])
965 , state, exprobj, expr_retval_ptr);
966 YYFPRINTF (stderr, "\n");
967 }
968 }
969
970 # define YY_REDUCE_PRINT(Rule) \
971 do { \
972 if (yydebug) \
973 yy_reduce_print (yyvsp, Rule, state, exprobj, expr_retval_ptr); \
974 } while (YYID (0))
975
976 /* Nonzero means print parse trace. It is left uninitialized so that
977 multiple parsers can coexist. */
978 int yydebug;
979 #else /* !YYDEBUG */
980 # define YYDPRINTF(Args)
981 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
982 # define YY_STACK_PRINT(Bottom, Top)
983 # define YY_REDUCE_PRINT(Rule)
984 #endif /* !YYDEBUG */
985
986
987 /* YYINITDEPTH -- initial size of the parser's stacks. */
988 #ifndef YYINITDEPTH
989 # define YYINITDEPTH 200
990 #endif
991
992 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
993 if the built-in stack extension method is used).
994
995 Do not make this value too large; the results are undefined if
996 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
997 evaluated with infinite-precision integer arithmetic. */
998
999 #ifndef YYMAXDEPTH
1000 # define YYMAXDEPTH 10000
1001 #endif
1002
1003
1004
1005 #if YYERROR_VERBOSE
1006
1007 # ifndef yystrlen
1008 # if defined __GLIBC__ && defined _STRING_H
1009 # define yystrlen strlen
1010 # else
1011 /* Return the length of YYSTR. */
1012 #if (defined __STDC__ || defined __C99__FUNC__ \
1013 || defined __cplusplus || defined _MSC_VER)
1014 static YYSIZE_T
yystrlen(const char * yystr)1015 yystrlen (const char *yystr)
1016 #else
1017 static YYSIZE_T
1018 yystrlen (yystr)
1019 const char *yystr;
1020 #endif
1021 {
1022 YYSIZE_T yylen;
1023 for (yylen = 0; yystr[yylen]; yylen++)
1024 continue;
1025 return yylen;
1026 }
1027 # endif
1028 # endif
1029
1030 # ifndef yystpcpy
1031 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1032 # define yystpcpy stpcpy
1033 # else
1034 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1035 YYDEST. */
1036 #if (defined __STDC__ || defined __C99__FUNC__ \
1037 || defined __cplusplus || defined _MSC_VER)
1038 static char *
yystpcpy(char * yydest,const char * yysrc)1039 yystpcpy (char *yydest, const char *yysrc)
1040 #else
1041 static char *
1042 yystpcpy (yydest, yysrc)
1043 char *yydest;
1044 const char *yysrc;
1045 #endif
1046 {
1047 char *yyd = yydest;
1048 const char *yys = yysrc;
1049
1050 while ((*yyd++ = *yys++) != '\0')
1051 continue;
1052
1053 return yyd - 1;
1054 }
1055 # endif
1056 # endif
1057
1058 # ifndef yytnamerr
1059 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1060 quotes and backslashes, so that it's suitable for yyerror. The
1061 heuristic is that double-quoting is unnecessary unless the string
1062 contains an apostrophe, a comma, or backslash (other than
1063 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1064 null, do not copy; instead, return the length of what the result
1065 would have been. */
1066 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1067 yytnamerr (char *yyres, const char *yystr)
1068 {
1069 if (*yystr == '"')
1070 {
1071 YYSIZE_T yyn = 0;
1072 char const *yyp = yystr;
1073
1074 for (;;)
1075 switch (*++yyp)
1076 {
1077 case '\'':
1078 case ',':
1079 goto do_not_strip_quotes;
1080
1081 case '\\':
1082 if (*++yyp != '\\')
1083 goto do_not_strip_quotes;
1084 /* Fall through. */
1085 default:
1086 if (yyres)
1087 yyres[yyn] = *yyp;
1088 yyn++;
1089 break;
1090
1091 case '"':
1092 if (yyres)
1093 yyres[yyn] = '\0';
1094 return yyn;
1095 }
1096 do_not_strip_quotes: ;
1097 }
1098
1099 if (! yyres)
1100 return yystrlen (yystr);
1101
1102 return yystpcpy (yyres, yystr) - yyres;
1103 }
1104 # endif
1105
1106 /* Copy into YYRESULT an error message about the unexpected token
1107 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1108 including the terminating null byte. If YYRESULT is null, do not
1109 copy anything; just return the number of bytes that would be
1110 copied. As a special case, return 0 if an ordinary "syntax error"
1111 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1112 size calculation. */
1113 static YYSIZE_T
yysyntax_error(char * yyresult,int yystate,int yychar)1114 yysyntax_error (char *yyresult, int yystate, int yychar)
1115 {
1116 int yyn = yypact[yystate];
1117
1118 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1119 return 0;
1120 else
1121 {
1122 int yytype = YYTRANSLATE (yychar);
1123 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1124 YYSIZE_T yysize = yysize0;
1125 YYSIZE_T yysize1;
1126 int yysize_overflow = 0;
1127 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1128 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1129 int yyx;
1130
1131 # if 0
1132 /* This is so xgettext sees the translatable formats that are
1133 constructed on the fly. */
1134 YY_("syntax error, unexpected %s");
1135 YY_("syntax error, unexpected %s, expecting %s");
1136 YY_("syntax error, unexpected %s, expecting %s or %s");
1137 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1138 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1139 # endif
1140 char *yyfmt;
1141 char const *yyf;
1142 static char const yyunexpected[] = "syntax error, unexpected %s";
1143 static char const yyexpecting[] = ", expecting %s";
1144 static char const yyor[] = " or %s";
1145 char yyformat[sizeof yyunexpected
1146 + sizeof yyexpecting - 1
1147 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1148 * (sizeof yyor - 1))];
1149 char const *yyprefix = yyexpecting;
1150
1151 /* Start YYX at -YYN if negative to avoid negative indexes in
1152 YYCHECK. */
1153 int yyxbegin = yyn < 0 ? -yyn : 0;
1154
1155 /* Stay within bounds of both yycheck and yytname. */
1156 int yychecklim = YYLAST - yyn + 1;
1157 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1158 int yycount = 1;
1159
1160 yyarg[0] = yytname[yytype];
1161 yyfmt = yystpcpy (yyformat, yyunexpected);
1162
1163 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1164 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1165 {
1166 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1167 {
1168 yycount = 1;
1169 yysize = yysize0;
1170 yyformat[sizeof yyunexpected - 1] = '\0';
1171 break;
1172 }
1173 yyarg[yycount++] = yytname[yyx];
1174 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1175 yysize_overflow |= (yysize1 < yysize);
1176 yysize = yysize1;
1177 yyfmt = yystpcpy (yyfmt, yyprefix);
1178 yyprefix = yyor;
1179 }
1180
1181 yyf = YY_(yyformat);
1182 yysize1 = yysize + yystrlen (yyf);
1183 yysize_overflow |= (yysize1 < yysize);
1184 yysize = yysize1;
1185
1186 if (yysize_overflow)
1187 return YYSIZE_MAXIMUM;
1188
1189 if (yyresult)
1190 {
1191 /* Avoid sprintf, as that infringes on the user's name space.
1192 Don't have undefined behavior even if the translation
1193 produced a string with the wrong number of "%s"s. */
1194 char *yyp = yyresult;
1195 int yyi = 0;
1196 while ((*yyp = *yyf) != '\0')
1197 {
1198 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1199 {
1200 yyp += yytnamerr (yyp, yyarg[yyi++]);
1201 yyf += 2;
1202 }
1203 else
1204 {
1205 yyp++;
1206 yyf++;
1207 }
1208 }
1209 }
1210 return yysize;
1211 }
1212 }
1213 #endif /* YYERROR_VERBOSE */
1214
1215
1216 /*-----------------------------------------------.
1217 | Release the memory associated to this symbol. |
1218 `-----------------------------------------------*/
1219
1220 /*ARGSUSED*/
1221 #if (defined __STDC__ || defined __C99__FUNC__ \
1222 || defined __cplusplus || defined _MSC_VER)
1223 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep,struct tmplpro_state * state,struct expr_parser * exprobj,PSTRING * expr_retval_ptr)1224 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr)
1225 #else
1226 static void
1227 yydestruct (yymsg, yytype, yyvaluep, state, exprobj, expr_retval_ptr)
1228 const char *yymsg;
1229 int yytype;
1230 YYSTYPE *yyvaluep;
1231 struct tmplpro_state* state;
1232 struct expr_parser* exprobj;
1233 PSTRING* expr_retval_ptr;
1234 #endif
1235 {
1236 YYUSE (yyvaluep);
1237 YYUSE (state);
1238 YYUSE (exprobj);
1239 YYUSE (expr_retval_ptr);
1240
1241 if (!yymsg)
1242 yymsg = "Deleting";
1243 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1244
1245 switch (yytype)
1246 {
1247
1248 default:
1249 break;
1250 }
1251 }
1252
1253 /* Prevent warnings from -Wmissing-prototypes. */
1254 #ifdef YYPARSE_PARAM
1255 #if defined __STDC__ || defined __cplusplus
1256 int yyparse (void *YYPARSE_PARAM);
1257 #else
1258 int yyparse ();
1259 #endif
1260 #else /* ! YYPARSE_PARAM */
1261 #if defined __STDC__ || defined __cplusplus
1262 int yyparse (struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr);
1263 #else
1264 int yyparse ();
1265 #endif
1266 #endif /* ! YYPARSE_PARAM */
1267
1268
1269
1270
1271
1272 /*-------------------------.
1273 | yyparse or yypush_parse. |
1274 `-------------------------*/
1275
1276 #ifdef YYPARSE_PARAM
1277 #if (defined __STDC__ || defined __C99__FUNC__ \
1278 || defined __cplusplus || defined _MSC_VER)
1279 int
yyparse(void * YYPARSE_PARAM)1280 yyparse (void *YYPARSE_PARAM)
1281 #else
1282 int
1283 yyparse (YYPARSE_PARAM)
1284 void *YYPARSE_PARAM;
1285 #endif
1286 #else /* ! YYPARSE_PARAM */
1287 #if (defined __STDC__ || defined __C99__FUNC__ \
1288 || defined __cplusplus || defined _MSC_VER)
1289 int
1290 yyparse (struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr)
1291 #else
1292 int
1293 yyparse (state, exprobj, expr_retval_ptr)
1294 struct tmplpro_state* state;
1295 struct expr_parser* exprobj;
1296 PSTRING* expr_retval_ptr;
1297 #endif
1298 #endif
1299 {
1300 /* The lookahead symbol. */
1301 int yychar;
1302
1303 /* The semantic value of the lookahead symbol. */
1304 YYSTYPE yylval;
1305
1306 /* Number of syntax errors so far. */
1307 int yynerrs;
1308
1309 int yystate;
1310 /* Number of tokens to shift before error messages enabled. */
1311 int yyerrstatus;
1312
1313 /* The stacks and their tools:
1314 `yyss': related to states.
1315 `yyvs': related to semantic values.
1316
1317 Refer to the stacks thru separate pointers, to allow yyoverflow
1318 to reallocate them elsewhere. */
1319
1320 /* The state stack. */
1321 yytype_int16 yyssa[YYINITDEPTH];
1322 yytype_int16 *yyss;
1323 yytype_int16 *yyssp;
1324
1325 /* The semantic value stack. */
1326 YYSTYPE yyvsa[YYINITDEPTH];
1327 YYSTYPE *yyvs;
1328 YYSTYPE *yyvsp;
1329
1330 YYSIZE_T yystacksize;
1331
1332 int yyn;
1333 int yyresult;
1334 /* Lookahead token as an internal (translated) token number. */
1335 int yytoken;
1336 /* The variables used to return semantic value and location from the
1337 action routines. */
1338 YYSTYPE yyval;
1339
1340 #if YYERROR_VERBOSE
1341 /* Buffer for error messages, and its allocated size. */
1342 char yymsgbuf[128];
1343 char *yymsg = yymsgbuf;
1344 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1345 #endif
1346
1347 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1348
1349 /* The number of symbols on the RHS of the reduced rule.
1350 Keep to zero when no symbol should be popped. */
1351 int yylen = 0;
1352
1353 yytoken = 0;
1354 yyss = yyssa;
1355 yyvs = yyvsa;
1356 yystacksize = YYINITDEPTH;
1357
1358 YYDPRINTF ((stderr, "Starting parse\n"));
1359
1360 yystate = 0;
1361 yyerrstatus = 0;
1362 yynerrs = 0;
1363 yychar = YYEMPTY; /* Cause a token to be read. */
1364
1365 /* Initialize stack pointers.
1366 Waste one element of value and location stack
1367 so that they stay on the same level as the state stack.
1368 The wasted elements are never initialized. */
1369 yyssp = yyss;
1370 yyvsp = yyvs;
1371
1372 goto yysetstate;
1373
1374 /*------------------------------------------------------------.
1375 | yynewstate -- Push a new state, which is found in yystate. |
1376 `------------------------------------------------------------*/
1377 yynewstate:
1378 /* In all cases, when you get here, the value and location stacks
1379 have just been pushed. So pushing a state here evens the stacks. */
1380 yyssp++;
1381
1382 yysetstate:
1383 *yyssp = yystate;
1384
1385 if (yyss + yystacksize - 1 <= yyssp)
1386 {
1387 /* Get the current used size of the three stacks, in elements. */
1388 YYSIZE_T yysize = yyssp - yyss + 1;
1389
1390 #ifdef yyoverflow
1391 {
1392 /* Give user a chance to reallocate the stack. Use copies of
1393 these so that the &'s don't force the real ones into
1394 memory. */
1395 YYSTYPE *yyvs1 = yyvs;
1396 yytype_int16 *yyss1 = yyss;
1397
1398 /* Each stack pointer address is followed by the size of the
1399 data in use in that stack, in bytes. This used to be a
1400 conditional around just the two extra args, but that might
1401 be undefined if yyoverflow is a macro. */
1402 yyoverflow (YY_("memory exhausted"),
1403 &yyss1, yysize * sizeof (*yyssp),
1404 &yyvs1, yysize * sizeof (*yyvsp),
1405 &yystacksize);
1406
1407 yyss = yyss1;
1408 yyvs = yyvs1;
1409 }
1410 #else /* no yyoverflow */
1411 # ifndef YYSTACK_RELOCATE
1412 goto yyexhaustedlab;
1413 # else
1414 /* Extend the stack our own way. */
1415 if (YYMAXDEPTH <= yystacksize)
1416 goto yyexhaustedlab;
1417 yystacksize *= 2;
1418 if (YYMAXDEPTH < yystacksize)
1419 yystacksize = YYMAXDEPTH;
1420
1421 {
1422 yytype_int16 *yyss1 = yyss;
1423 union yyalloc *yyptr =
1424 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1425 if (! yyptr)
1426 goto yyexhaustedlab;
1427 YYSTACK_RELOCATE (yyss_alloc, yyss);
1428 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1429 # undef YYSTACK_RELOCATE
1430 if (yyss1 != yyssa)
1431 YYSTACK_FREE (yyss1);
1432 }
1433 # endif
1434 #endif /* no yyoverflow */
1435
1436 yyssp = yyss + yysize - 1;
1437 yyvsp = yyvs + yysize - 1;
1438
1439 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1440 (unsigned long int) yystacksize));
1441
1442 if (yyss + yystacksize - 1 <= yyssp)
1443 YYABORT;
1444 }
1445
1446 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1447
1448 if (yystate == YYFINAL)
1449 YYACCEPT;
1450
1451 goto yybackup;
1452
1453 /*-----------.
1454 | yybackup. |
1455 `-----------*/
1456 yybackup:
1457
1458 /* Do appropriate processing given the current state. Read a
1459 lookahead token if we need one and don't already have one. */
1460
1461 /* First try to decide what to do without reference to lookahead token. */
1462 yyn = yypact[yystate];
1463 if (yyn == YYPACT_NINF)
1464 goto yydefault;
1465
1466 /* Not known => get a lookahead token if don't already have one. */
1467
1468 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1469 if (yychar == YYEMPTY)
1470 {
1471 YYDPRINTF ((stderr, "Reading a token: "));
1472 yychar = YYLEX;
1473 }
1474
1475 if (yychar <= YYEOF)
1476 {
1477 yychar = yytoken = YYEOF;
1478 YYDPRINTF ((stderr, "Now at end of input.\n"));
1479 }
1480 else
1481 {
1482 yytoken = YYTRANSLATE (yychar);
1483 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1484 }
1485
1486 /* If the proper action on seeing token YYTOKEN is to reduce or to
1487 detect an error, take that action. */
1488 yyn += yytoken;
1489 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1490 goto yydefault;
1491 yyn = yytable[yyn];
1492 if (yyn <= 0)
1493 {
1494 if (yyn == 0 || yyn == YYTABLE_NINF)
1495 goto yyerrlab;
1496 yyn = -yyn;
1497 goto yyreduce;
1498 }
1499
1500 /* Count tokens shifted since error; after three, turn off error
1501 status. */
1502 if (yyerrstatus)
1503 yyerrstatus--;
1504
1505 /* Shift the lookahead token. */
1506 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1507
1508 /* Discard the shifted token. */
1509 yychar = YYEMPTY;
1510
1511 yystate = yyn;
1512 *++yyvsp = yylval;
1513
1514 goto yynewstate;
1515
1516
1517 /*-----------------------------------------------------------.
1518 | yydefault -- do the default action for the current state. |
1519 `-----------------------------------------------------------*/
1520 yydefault:
1521 yyn = yydefact[yystate];
1522 if (yyn == 0)
1523 goto yyerrlab;
1524 goto yyreduce;
1525
1526
1527 /*-----------------------------.
1528 | yyreduce -- Do a reduction. |
1529 `-----------------------------*/
1530 yyreduce:
1531 /* yyn is the number of a rule to reduce with. */
1532 yylen = yyr2[yyn];
1533
1534 /* If YYLEN is nonzero, implement the default value of the action:
1535 `$$ = $1'.
1536
1537 Otherwise, the following line sets YYVAL to garbage.
1538 This behavior is undocumented and Bison
1539 users should not rely upon it. Assigning to YYVAL
1540 unconditionally makes the parser a bit smaller, and it avoids a
1541 GCC warning that YYVAL may be used uninitialized. */
1542 yyval = yyvsp[1-yylen];
1543
1544
1545 YY_REDUCE_PRINT (yyn);
1546 switch (yyn)
1547 {
1548 case 2:
1549
1550 /* Line 1455 of yacc.c */
1551 #line 62 "expr.y"
1552 {
1553 expr_to_str1(state, &(yyvsp[(1) - (1)].numval));
1554 *expr_retval_ptr=(yyvsp[(1) - (1)].numval).val.strval;
1555 }
1556 break;
1557
1558 case 3:
1559
1560 /* Line 1455 of yacc.c */
1561 #line 69 "expr.y"
1562 { (yyval.numval) = (yyvsp[(1) - (1)].numval); }
1563 break;
1564
1565 case 4:
1566
1567 /* Line 1455 of yacc.c */
1568 #line 70 "expr.y"
1569 { (yyval.numval).type=EXPR_TYPE_DBL; (yyval.numval).val.dblval = (yyvsp[(1) - (1)].tptr)->var; }
1570 break;
1571
1572 case 5:
1573
1574 /* Line 1455 of yacc.c */
1575 #line 72 "expr.y"
1576 {
1577 PSTRING varvalue=_get_variable_value(state->param, (yyvsp[(1) - (1)].uservar));
1578 if (varvalue.begin==NULL) {
1579 int loglevel = state->param->warn_unused ? TMPL_LOG_ERROR : TMPL_LOG_INFO;
1580 log_expr(exprobj,loglevel, "non-initialized variable %.*s\n",(int)((yyvsp[(1) - (1)].uservar).endnext-(yyvsp[(1) - (1)].uservar).begin),(yyvsp[(1) - (1)].uservar).begin);
1581 }
1582 (yyval.numval).type=EXPR_TYPE_PSTR;
1583 (yyval.numval).val.strval=varvalue;
1584 }
1585 break;
1586
1587 case 6:
1588
1589 /* Line 1455 of yacc.c */
1590 #line 82 "expr.y"
1591 {
1592 (yyval.numval) = call_expr_userfunc(exprobj, state->param, (yyvsp[(1) - (2)].extfunc));
1593 }
1594 break;
1595
1596 case 7:
1597
1598 /* Line 1455 of yacc.c */
1599 #line 86 "expr.y"
1600 {
1601 (yyvsp[(1) - (3)].extfunc).arglist=state->param->InitExprArglistFuncPtr(state->param->ext_calluserfunc_state);
1602 (yyval.numval) = call_expr_userfunc(exprobj, state->param, (yyvsp[(1) - (3)].extfunc));
1603 }
1604 break;
1605
1606 case 8:
1607
1608 /* Line 1455 of yacc.c */
1609 #line 91 "expr.y"
1610 {
1611 struct exprval e = NEW_EXPRVAL(EXPR_TYPE_PSTR);
1612 e.val.strval.begin = NULL;
1613 e.val.strval.endnext = NULL;
1614 (yyval.numval) = (*((func_t_ee)(yyvsp[(1) - (3)].tptr)->fnctptr))(exprobj, e);
1615 }
1616 break;
1617
1618 case 9:
1619
1620 /* Line 1455 of yacc.c */
1621 #line 98 "expr.y"
1622 {
1623 (yyval.numval).type=EXPR_TYPE_DBL;
1624 expr_to_dbl1(exprobj, &(yyvsp[(3) - (4)].numval));
1625 (yyval.numval).val.dblval = (*((func_t_dd)(yyvsp[(1) - (4)].tptr)->fnctptr))((yyvsp[(3) - (4)].numval).val.dblval);
1626 }
1627 break;
1628
1629 case 10:
1630
1631 /* Line 1455 of yacc.c */
1632 #line 104 "expr.y"
1633 {
1634 (yyval.numval).type=EXPR_TYPE_DBL;
1635 expr_to_dbl(exprobj, &(yyvsp[(3) - (6)].numval), &(yyvsp[(5) - (6)].numval));
1636 (yyval.numval).val.dblval = (*((func_t_ddd)(yyvsp[(1) - (6)].tptr)->fnctptr))((yyvsp[(3) - (6)].numval).val.dblval,(yyvsp[(5) - (6)].numval).val.dblval);
1637 }
1638 break;
1639
1640 case 11:
1641
1642 /* Line 1455 of yacc.c */
1643 #line 110 "expr.y"
1644 {
1645 (yyval.numval) = (*((func_t_ee)(yyvsp[(1) - (4)].tptr)->fnctptr))(exprobj,(yyvsp[(3) - (4)].numval));
1646 }
1647 break;
1648
1649 case 12:
1650
1651 /* Line 1455 of yacc.c */
1652 #line 113 "expr.y"
1653 { DO_MATHOP(exprobj, (yyval.numval),+,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1654 break;
1655
1656 case 13:
1657
1658 /* Line 1455 of yacc.c */
1659 #line 114 "expr.y"
1660 { DO_MATHOP(exprobj, (yyval.numval),-,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1661 break;
1662
1663 case 14:
1664
1665 /* Line 1455 of yacc.c */
1666 #line 115 "expr.y"
1667 { DO_MATHOP(exprobj, (yyval.numval),*,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1668 break;
1669
1670 case 15:
1671
1672 /* Line 1455 of yacc.c */
1673 #line 117 "expr.y"
1674 {
1675 (yyval.numval).type=EXPR_TYPE_INT;
1676 expr_to_int(exprobj, &(yyvsp[(1) - (3)].numval),&(yyvsp[(3) - (3)].numval));
1677 (yyval.numval).val.intval = (yyvsp[(1) - (3)].numval).val.intval % (yyvsp[(3) - (3)].numval).val.intval;
1678 }
1679 break;
1680
1681 case 16:
1682
1683 /* Line 1455 of yacc.c */
1684 #line 148 "expr.y"
1685 {
1686 (yyval.numval).type=EXPR_TYPE_DBL;
1687 expr_to_dbl(exprobj, &(yyvsp[(1) - (3)].numval),&(yyvsp[(3) - (3)].numval));
1688 if ((yyvsp[(3) - (3)].numval).val.dblval)
1689 (yyval.numval).val.dblval = (yyvsp[(1) - (3)].numval).val.dblval / (yyvsp[(3) - (3)].numval).val.dblval;
1690 else
1691 {
1692 (yyval.numval).val.dblval = 0;
1693 log_expr(exprobj, TMPL_LOG_ERROR, "%s\n", "division by zero");
1694 }
1695 }
1696 break;
1697
1698 case 17:
1699
1700 /* Line 1455 of yacc.c */
1701 #line 160 "expr.y"
1702 {
1703 switch ((yyval.numval).type=(yyvsp[(2) - (2)].numval).type) {
1704 case EXPR_TYPE_INT:
1705 (yyval.numval).val.intval = -(yyvsp[(2) - (2)].numval).val.intval;
1706 ;break;
1707 case EXPR_TYPE_DBL:
1708 (yyval.numval).val.dblval = -(yyvsp[(2) - (2)].numval).val.dblval;
1709 ;break;
1710 }
1711 }
1712 break;
1713
1714 case 18:
1715
1716 /* Line 1455 of yacc.c */
1717 #line 171 "expr.y"
1718 {
1719 (yyval.numval).type=EXPR_TYPE_DBL;
1720 expr_to_dbl(exprobj, &(yyvsp[(1) - (3)].numval),&(yyvsp[(3) - (3)].numval));
1721 (yyval.numval).val.dblval = pow ((yyvsp[(1) - (3)].numval).val.dblval, (yyvsp[(3) - (3)].numval).val.dblval);
1722 }
1723 break;
1724
1725 case 19:
1726
1727 /* Line 1455 of yacc.c */
1728 #line 177 "expr.y"
1729 {
1730 if (exprobj->is_tt_like_logical) {
1731 (yyval.numval)=(yyvsp[(1) - (3)].numval);
1732 switch (expr_to_int_or_dbl_logop1(exprobj, &(yyval.numval))) {
1733 case EXPR_TYPE_INT: (yyval.numval)= ((yyvsp[(1) - (3)].numval).val.intval ? (yyvsp[(1) - (3)].numval) : (yyvsp[(3) - (3)].numval)); break;
1734 case EXPR_TYPE_DBL: (yyval.numval)= ((yyvsp[(1) - (3)].numval).val.dblval ? (yyvsp[(1) - (3)].numval) : (yyvsp[(3) - (3)].numval)); break;
1735 }
1736 } else {
1737 DO_LOGOP(exprobj, (yyval.numval),||,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval));
1738 }
1739 }
1740 break;
1741
1742 case 20:
1743
1744 /* Line 1455 of yacc.c */
1745 #line 189 "expr.y"
1746 {
1747 if (exprobj->is_tt_like_logical) {
1748 (yyval.numval)=(yyvsp[(1) - (3)].numval);
1749 switch (expr_to_int_or_dbl_logop1(exprobj, &(yyval.numval))) {
1750 case EXPR_TYPE_INT: (yyval.numval)= ((yyvsp[(1) - (3)].numval).val.intval ? (yyvsp[(3) - (3)].numval) : (yyvsp[(1) - (3)].numval)); break;
1751 case EXPR_TYPE_DBL: (yyval.numval)= ((yyvsp[(1) - (3)].numval).val.dblval ? (yyvsp[(3) - (3)].numval) : (yyvsp[(1) - (3)].numval)); break;
1752 }
1753 } else {
1754 DO_LOGOP(exprobj, (yyval.numval),&&,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval));
1755 }
1756 }
1757 break;
1758
1759 case 21:
1760
1761 /* Line 1455 of yacc.c */
1762 #line 200 "expr.y"
1763 { DO_CMPOP(exprobj, (yyval.numval),>=,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1764 break;
1765
1766 case 22:
1767
1768 /* Line 1455 of yacc.c */
1769 #line 201 "expr.y"
1770 { DO_CMPOP(exprobj, (yyval.numval),<=,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1771 break;
1772
1773 case 23:
1774
1775 /* Line 1455 of yacc.c */
1776 #line 202 "expr.y"
1777 { DO_CMPOP(exprobj, (yyval.numval),!=,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1778 break;
1779
1780 case 24:
1781
1782 /* Line 1455 of yacc.c */
1783 #line 203 "expr.y"
1784 { DO_CMPOP(exprobj, (yyval.numval),==,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1785 break;
1786
1787 case 25:
1788
1789 /* Line 1455 of yacc.c */
1790 #line 204 "expr.y"
1791 { DO_CMPOP(exprobj, (yyval.numval),>,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1792 break;
1793
1794 case 26:
1795
1796 /* Line 1455 of yacc.c */
1797 #line 205 "expr.y"
1798 { DO_CMPOP(exprobj, (yyval.numval),<,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1799 break;
1800
1801 case 27:
1802
1803 /* Line 1455 of yacc.c */
1804 #line 206 "expr.y"
1805 { DO_LOGOP1(exprobj, (yyval.numval),!,(yyvsp[(2) - (2)].numval)); }
1806 break;
1807
1808 case 28:
1809
1810 /* Line 1455 of yacc.c */
1811 #line 207 "expr.y"
1812 { DO_LOGOP1(exprobj, (yyval.numval),!,(yyvsp[(2) - (2)].numval)); }
1813 break;
1814
1815 case 29:
1816
1817 /* Line 1455 of yacc.c */
1818 #line 208 "expr.y"
1819 { (yyval.numval) = (yyvsp[(2) - (3)].numval); }
1820 break;
1821
1822 case 30:
1823
1824 /* Line 1455 of yacc.c */
1825 #line 209 "expr.y"
1826 {
1827 expr_to_str(state, &(yyvsp[(1) - (3)].numval),&(yyvsp[(3) - (3)].numval));
1828 (yyval.numval).type=EXPR_TYPE_INT; (yyval.numval).val.intval = pstring_ge ((yyvsp[(1) - (3)].numval).val.strval,(yyvsp[(3) - (3)].numval).val.strval)-pstring_le ((yyvsp[(1) - (3)].numval).val.strval,(yyvsp[(3) - (3)].numval).val.strval);
1829 }
1830 break;
1831
1832 case 31:
1833
1834 /* Line 1455 of yacc.c */
1835 #line 213 "expr.y"
1836 { DO_TXTOP((yyval.numval),pstring_ge,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1837 break;
1838
1839 case 32:
1840
1841 /* Line 1455 of yacc.c */
1842 #line 214 "expr.y"
1843 { DO_TXTOP((yyval.numval),pstring_le,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1844 break;
1845
1846 case 33:
1847
1848 /* Line 1455 of yacc.c */
1849 #line 215 "expr.y"
1850 { DO_TXTOP((yyval.numval),pstring_ne,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1851 break;
1852
1853 case 34:
1854
1855 /* Line 1455 of yacc.c */
1856 #line 216 "expr.y"
1857 { DO_TXTOP((yyval.numval),pstring_eq,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1858 break;
1859
1860 case 35:
1861
1862 /* Line 1455 of yacc.c */
1863 #line 217 "expr.y"
1864 { DO_TXTOP((yyval.numval),pstring_gt,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1865 break;
1866
1867 case 36:
1868
1869 /* Line 1455 of yacc.c */
1870 #line 218 "expr.y"
1871 { DO_TXTOP((yyval.numval),pstring_lt,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1872 break;
1873
1874 case 37:
1875
1876 /* Line 1455 of yacc.c */
1877 #line 219 "expr.y"
1878 { DO_TXTOPLOG((yyval.numval),re_like,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),exprobj);}
1879 break;
1880
1881 case 38:
1882
1883 /* Line 1455 of yacc.c */
1884 #line 220 "expr.y"
1885 { DO_TXTOPLOG((yyval.numval),re_notlike,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),exprobj);}
1886 break;
1887
1888 case 39:
1889
1890 /* Line 1455 of yacc.c */
1891 #line 223 "expr.y"
1892 {
1893 (yyvsp[(1) - (3)].extfunc).arglist=state->param->InitExprArglistFuncPtr(state->param->expr_func_map);
1894 pusharg_expr_userfunc(exprobj,state->param,(yyvsp[(1) - (3)].extfunc),(yyvsp[(3) - (3)].numval));
1895 (yyval.extfunc) = (yyvsp[(1) - (3)].extfunc);
1896 }
1897 break;
1898
1899 case 40:
1900
1901 /* Line 1455 of yacc.c */
1902 #line 228 "expr.y"
1903 { pusharg_expr_userfunc(exprobj,state->param,(yyvsp[(1) - (3)].extfunc),(yyvsp[(3) - (3)].numval)); (yyval.extfunc) = (yyvsp[(1) - (3)].extfunc); }
1904 break;
1905
1906
1907
1908 /* Line 1455 of yacc.c */
1909 #line 1910 "y.tab.c"
1910 default: break;
1911 }
1912 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1913
1914 YYPOPSTACK (yylen);
1915 yylen = 0;
1916 YY_STACK_PRINT (yyss, yyssp);
1917
1918 *++yyvsp = yyval;
1919
1920 /* Now `shift' the result of the reduction. Determine what state
1921 that goes to, based on the state we popped back to and the rule
1922 number reduced by. */
1923
1924 yyn = yyr1[yyn];
1925
1926 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1927 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1928 yystate = yytable[yystate];
1929 else
1930 yystate = yydefgoto[yyn - YYNTOKENS];
1931
1932 goto yynewstate;
1933
1934
1935 /*------------------------------------.
1936 | yyerrlab -- here on detecting error |
1937 `------------------------------------*/
1938 yyerrlab:
1939 /* If not already recovering from an error, report this error. */
1940 if (!yyerrstatus)
1941 {
1942 ++yynerrs;
1943 #if ! YYERROR_VERBOSE
1944 yyerror (state, exprobj, expr_retval_ptr, YY_("syntax error"));
1945 #else
1946 {
1947 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1948 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1949 {
1950 YYSIZE_T yyalloc = 2 * yysize;
1951 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1952 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1953 if (yymsg != yymsgbuf)
1954 YYSTACK_FREE (yymsg);
1955 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1956 if (yymsg)
1957 yymsg_alloc = yyalloc;
1958 else
1959 {
1960 yymsg = yymsgbuf;
1961 yymsg_alloc = sizeof yymsgbuf;
1962 }
1963 }
1964
1965 if (0 < yysize && yysize <= yymsg_alloc)
1966 {
1967 (void) yysyntax_error (yymsg, yystate, yychar);
1968 yyerror (state, exprobj, expr_retval_ptr, yymsg);
1969 }
1970 else
1971 {
1972 yyerror (state, exprobj, expr_retval_ptr, YY_("syntax error"));
1973 if (yysize != 0)
1974 goto yyexhaustedlab;
1975 }
1976 }
1977 #endif
1978 }
1979
1980
1981
1982 if (yyerrstatus == 3)
1983 {
1984 /* If just tried and failed to reuse lookahead token after an
1985 error, discard it. */
1986
1987 if (yychar <= YYEOF)
1988 {
1989 /* Return failure if at end of input. */
1990 if (yychar == YYEOF)
1991 YYABORT;
1992 }
1993 else
1994 {
1995 yydestruct ("Error: discarding",
1996 yytoken, &yylval, state, exprobj, expr_retval_ptr);
1997 yychar = YYEMPTY;
1998 }
1999 }
2000
2001 /* Else will try to reuse lookahead token after shifting the error
2002 token. */
2003 goto yyerrlab1;
2004
2005
2006 /*---------------------------------------------------.
2007 | yyerrorlab -- error raised explicitly by YYERROR. |
2008 `---------------------------------------------------*/
2009 yyerrorlab:
2010
2011 /* Pacify compilers like GCC when the user code never invokes
2012 YYERROR and the label yyerrorlab therefore never appears in user
2013 code. */
2014 if (/*CONSTCOND*/ 0)
2015 goto yyerrorlab;
2016
2017 /* Do not reclaim the symbols of the rule which action triggered
2018 this YYERROR. */
2019 YYPOPSTACK (yylen);
2020 yylen = 0;
2021 YY_STACK_PRINT (yyss, yyssp);
2022 yystate = *yyssp;
2023 goto yyerrlab1;
2024
2025
2026 /*-------------------------------------------------------------.
2027 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2028 `-------------------------------------------------------------*/
2029 yyerrlab1:
2030 yyerrstatus = 3; /* Each real token shifted decrements this. */
2031
2032 for (;;)
2033 {
2034 yyn = yypact[yystate];
2035 if (yyn != YYPACT_NINF)
2036 {
2037 yyn += YYTERROR;
2038 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2039 {
2040 yyn = yytable[yyn];
2041 if (0 < yyn)
2042 break;
2043 }
2044 }
2045
2046 /* Pop the current state because it cannot handle the error token. */
2047 if (yyssp == yyss)
2048 YYABORT;
2049
2050
2051 yydestruct ("Error: popping",
2052 yystos[yystate], yyvsp, state, exprobj, expr_retval_ptr);
2053 YYPOPSTACK (1);
2054 yystate = *yyssp;
2055 YY_STACK_PRINT (yyss, yyssp);
2056 }
2057
2058 *++yyvsp = yylval;
2059
2060
2061 /* Shift the error token. */
2062 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2063
2064 yystate = yyn;
2065 goto yynewstate;
2066
2067
2068 /*-------------------------------------.
2069 | yyacceptlab -- YYACCEPT comes here. |
2070 `-------------------------------------*/
2071 yyacceptlab:
2072 yyresult = 0;
2073 goto yyreturn;
2074
2075 /*-----------------------------------.
2076 | yyabortlab -- YYABORT comes here. |
2077 `-----------------------------------*/
2078 yyabortlab:
2079 yyresult = 1;
2080 goto yyreturn;
2081
2082 #if !defined(yyoverflow) || YYERROR_VERBOSE
2083 /*-------------------------------------------------.
2084 | yyexhaustedlab -- memory exhaustion comes here. |
2085 `-------------------------------------------------*/
2086 yyexhaustedlab:
2087 yyerror (state, exprobj, expr_retval_ptr, YY_("memory exhausted"));
2088 yyresult = 2;
2089 /* Fall through. */
2090 #endif
2091
2092 yyreturn:
2093 if (yychar != YYEMPTY)
2094 yydestruct ("Cleanup: discarding lookahead",
2095 yytoken, &yylval, state, exprobj, expr_retval_ptr);
2096 /* Do not reclaim the symbols of the rule which action triggered
2097 this YYABORT or YYACCEPT. */
2098 YYPOPSTACK (yylen);
2099 YY_STACK_PRINT (yyss, yyssp);
2100 while (yyssp != yyss)
2101 {
2102 yydestruct ("Cleanup: popping",
2103 yystos[*yyssp], yyvsp, state, exprobj, expr_retval_ptr);
2104 YYPOPSTACK (1);
2105 }
2106 #ifndef yyoverflow
2107 if (yyss != yyssa)
2108 YYSTACK_FREE (yyss);
2109 #endif
2110 #if YYERROR_VERBOSE
2111 if (yymsg != yymsgbuf)
2112 YYSTACK_FREE (yymsg);
2113 #endif
2114 /* Make sure YYID is used. */
2115 return YYID (yyresult);
2116 }
2117
2118
2119
2120 /* Line 1675 of yacc.c */
2121 #line 232 "expr.y"
2122
2123
2124 /* Called by yyparse on error. */
2125 static void
yyerror(struct tmplpro_state * state,struct expr_parser * exprobj,PSTRING * expr_retval_ptr,char const * s)2126 yyerror (struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr, char const *s)
2127 {
2128 log_expr(exprobj, TMPL_LOG_ERROR, "not a valid expression: %s\n", s);
2129 }
2130
2131 #include "calc.inc"
2132
2133 static
2134 const symrec_const
2135 #ifndef __cplusplus
2136 const
2137 #endif
2138 builtin_funcs_symrec[] =
2139 {
2140 /* built-in funcs */
2141 {SYMREC("sin"), BUILTIN_FNC_DD, 0, sin},
2142 {SYMREC("cos"), BUILTIN_FNC_DD, 0, cos},
2143 {SYMREC("atan"), BUILTIN_FNC_DD, 0, atan},
2144 {SYMREC("log"), BUILTIN_FNC_DD, 0, log},
2145 {SYMREC("exp"), BUILTIN_FNC_DD, 0, exp},
2146 {SYMREC("sqrt"), BUILTIN_FNC_DD, 0, sqrt},
2147 {SYMREC("atan2"), BUILTIN_FNC_DDD, 0, atan2},
2148 {SYMREC("abs"), BUILTIN_FNC_EE, 0, builtin_abs},
2149 {SYMREC("defined"), BUILTIN_FNC_EE, 0, builtin_defined},
2150 {SYMREC("int"), BUILTIN_FNC_EE, 0, builtin_int},
2151 {SYMREC("hex"), BUILTIN_FNC_EE, 0, builtin_hex},
2152 {SYMREC("length"), BUILTIN_FNC_EE, 0, builtin_length},
2153 {SYMREC("oct"), BUILTIN_FNC_EE, 0, builtin_oct},
2154 {SYMREC("rand"), BUILTIN_FNC_EE, 0, builtin_rand},
2155 {SYMREC("srand"), BUILTIN_FNC_EE, 0, builtin_srand},
2156 {SYMREC("version"), BUILTIN_FNC_EE, 0, builtin_version},
2157 /* end mark */
2158 {0, 0, 0}
2159 };
2160
2161 static
2162 const symrec_const
2163 #ifndef __cplusplus
2164 const
2165 #endif
2166 builtin_ops_symrec[] =
2167 {
2168 /* built-in ops */
2169 {SYMREC("eq"), strEQ, 0, NULL},
2170 {SYMREC("ne"), strNE, 0, NULL},
2171 {SYMREC("gt"), strGT, 0, NULL},
2172 {SYMREC("ge"), strGE, 0, NULL},
2173 {SYMREC("lt"), strLT, 0, NULL},
2174 {SYMREC("le"), strLE, 0, NULL},
2175 {SYMREC("cmp"), strCMP, 0, NULL},
2176 {SYMREC("or"), OR, 0, NULL},
2177 {SYMREC("and"),AND, 0, NULL},
2178 {SYMREC("not"),NOT, 0, NULL},
2179 /* end mark */
2180 {0, 0, 0}
2181 };
2182
2183 TMPLPRO_LOCAL
2184 PSTRING
parse_expr(PSTRING expression,struct tmplpro_state * state)2185 parse_expr(PSTRING expression, struct tmplpro_state* state)
2186 {
2187 PSTRING expr_retval;
2188 struct expr_parser exprobj;
2189 expr_retval.begin=expression.begin;
2190 expr_retval.endnext=expression.begin;
2191 exprobj.expr_curpos=expression.begin;
2192 exprobj.exprarea=expression;
2193 exprobj.state = state;
2194 exprobj.is_expect_quote_like=1;
2195 // TODO!!
2196 exprobj.is_tt_like_logical=0;
2197 yyparse (state, &exprobj, &expr_retval);
2198 if (NULL!=expr_retval.begin && NULL==expr_retval.endnext) log_expr(&exprobj, TMPL_LOG_ERROR, "parse_expr internal warning: %s\n", "endnext is null pointer");
2199 return expr_retval;
2200 }
2201
2202 static
2203 void
log_expr(struct expr_parser * exprobj,int loglevel,const char * fmt,...)2204 log_expr(struct expr_parser* exprobj, int loglevel, const char* fmt, ...)
2205 {
2206 va_list vl;
2207 va_start(vl, fmt);
2208 log_state(exprobj->state, loglevel, "in EXPR:at pos " MOD_TD " [" MOD_TD "]: ",
2209 TO_PTRDIFF_T((exprobj->expr_curpos)-(exprobj->state->top)),
2210 TO_PTRDIFF_T((exprobj->expr_curpos)-(exprobj->exprarea).begin));
2211 tmpl_vlog(loglevel, fmt, vl);
2212 va_end(vl);
2213 }
2214
2215 static
2216 PSTRING
fill_symbuf(struct expr_parser * exprobj,int is_accepted (unsigned char))2217 fill_symbuf (struct expr_parser* exprobj, int is_accepted(unsigned char)) {
2218 /* skip first char, already tested */
2219 PSTRING retval = {exprobj->expr_curpos++};
2220 while (exprobj->expr_curpos < (exprobj->exprarea).endnext && is_accepted(*exprobj->expr_curpos)) exprobj->expr_curpos++;
2221 retval.endnext= exprobj->expr_curpos;
2222 return retval;
2223 }
2224
2225 static
2226 int
is_alnum_lex(unsigned char c)2227 is_alnum_lex (unsigned char c)
2228 {
2229 return (c == '_' || isalnum (c));
2230 }
2231
2232 static
2233 int
is_not_identifier_ext_end(unsigned char c)2234 is_not_identifier_ext_end (unsigned char c)
2235 {
2236 return (c != '}');
2237 }
2238
2239 #define TESTOP(c1,c2,z) if (c1 == c) { char d=*++(exprobj->expr_curpos); if (c2 != d) return c; else (exprobj->expr_curpos)++; return z; }
2240 #define TESTOP3(c1,c2,c3,num2,str3) if (c1 == c) { char d=*++(exprobj->expr_curpos); if (c2 == d) {(exprobj->expr_curpos)++; return num2;} else if (c3 == d) {(exprobj->expr_curpos)++; exprobj->is_expect_quote_like=1; return str3;} else return c; }
2241
2242 static
2243 int
yylex(YYSTYPE * lvalp,struct tmplpro_state * state,struct expr_parser * exprobj)2244 yylex (YYSTYPE *lvalp, struct tmplpro_state* state, struct expr_parser* exprobj)
2245 {
2246 register unsigned char c = 0;
2247 int is_identifier_ext;
2248 /* TODO: newline? */
2249 /* Ignore white space, get first nonwhite character. */
2250 while ((exprobj->expr_curpos)<(exprobj->exprarea).endnext && ((c = *(exprobj->expr_curpos)) == ' ' || c == '\t')) (exprobj->expr_curpos)++;
2251 if ((exprobj->expr_curpos)>=(exprobj->exprarea).endnext) return 0;
2252
2253 /* Char starts a quote => read a string */
2254 if ('\''==c || '"'==c || (exprobj->is_expect_quote_like && '/'==c) ) {
2255 PSTRING strvalue;
2256 unsigned char terminal_quote=c;
2257 int escape_flag = 0;
2258 c =* ++(exprobj->expr_curpos);
2259 strvalue.begin = exprobj->expr_curpos;
2260 strvalue.endnext = exprobj->expr_curpos;
2261
2262 while ((exprobj->expr_curpos)<(exprobj->exprarea).endnext && c != terminal_quote) {
2263 /* any escaped char with \ , incl. quote */
2264 if ('\\' == c) {
2265 escape_flag = 1;
2266 exprobj->expr_curpos+=2;
2267 c =*(exprobj->expr_curpos);
2268 } else {
2269 c = * ++(exprobj->expr_curpos);
2270 }
2271 }
2272
2273 strvalue.endnext = exprobj->expr_curpos;
2274 if ((exprobj->expr_curpos)<(exprobj->exprarea).endnext && ((c = *(exprobj->expr_curpos)) == terminal_quote)) (exprobj->expr_curpos)++;
2275 if (escape_flag) {
2276 (*lvalp).numval.type=EXPR_TYPE_UPSTR;
2277 } else {
2278 (*lvalp).numval.type=EXPR_TYPE_PSTR;
2279 }
2280 (*lvalp).numval.val.strval=strvalue;
2281 exprobj->is_expect_quote_like=0;
2282 return NUM;
2283 }
2284
2285 exprobj->is_expect_quote_like=0;
2286 /* Char starts a number => parse the number. */
2287 if (c == '.' || isdigit (c))
2288 {
2289 (*lvalp).numval=exp_read_number (exprobj, &(exprobj->expr_curpos), (exprobj->exprarea).endnext);
2290 return NUM;
2291 }
2292
2293 /*
2294 * Emiliano Bruni extension to Expr:
2295 * original HTML::Template allows almost arbitrary chars in parameter names,
2296 * but original HTML::Template::Expr (as to 0.04) allows only
2297 * var to be m![A-Za-z_][A-Za-z0-9_]*!.
2298 * with this extension, arbitrary chars can be used
2299 * if bracketed in ${}, as, for example, EXPR="${foo.bar} eq 'a'".
2300 * first it was bracketing in {}, but it is changed
2301 *
2302 * COMPATIBILITY WARNING.
2303 * Currently, this extension is not present in HTML::Template::Expr (as of 0.04).
2304 */
2305 /* Let's try to see if this is an identifier between two { } - Emiliano */
2306 is_identifier_ext = (int) (c == '{' || c == '$');
2307
2308 /* Char starts an identifier => read the name. */
2309 /* variables with _leading_underscore are allowed too */
2310 if (isalpha (c) || c=='_' || is_identifier_ext) {
2311 const symrec_const *s;
2312 PSTRING name;
2313 if (is_identifier_ext) {
2314 (exprobj->expr_curpos)++; /* jump over $ or { */
2315 if ('$' == c && '{' == *(exprobj->expr_curpos)) {
2316 (exprobj->expr_curpos)++; /* jump over { */
2317 #ifndef ALLOW_OLD_BRACKETING_IN_EXPR
2318 } else {
2319 log_expr(exprobj, TMPL_LOG_ERROR, "{} bracketing is deprecated. Use ${} bracketing.\n");
2320 #endif
2321 }
2322 name=fill_symbuf(exprobj, is_not_identifier_ext_end);
2323 if ((exprobj->expr_curpos)<(exprobj->exprarea).endnext) (exprobj->expr_curpos)++; /* Jump the last } - Emiliano */
2324 } else {
2325 name=fill_symbuf(exprobj, is_alnum_lex);
2326 }
2327 s = getsym (builtin_ops_symrec, name);
2328 if (s != 0) {
2329 (*lvalp).tptr = s;
2330 return s->type;
2331 }
2332
2333 {
2334 const char* next_char= exprobj->expr_curpos;
2335 /* optimization: funcs is always followed by ( */
2336 while ((next_char<(exprobj->exprarea).endnext) && isspace(*next_char)) next_char++;
2337 if ((*next_char)=='(') {
2338 /* user-defined functions have precedence over buit-in */
2339 if (((*lvalp).extfunc.func=(state->param->IsExprUserfncFuncPtr)(state->param->expr_func_map, name))) {
2340 return EXTFUNC;
2341 }
2342 s = getsym (builtin_funcs_symrec, name);
2343 if (s != 0) {
2344 (*lvalp).tptr = s;
2345 return s->type;
2346 }
2347 }
2348 (*lvalp).uservar=name;
2349 /*log_expr(exprobj,TMPL_LOG_DEBUG2, "yylex: returned variable name %.*s\n",(int)(name.endnext-name.begin),name.begin);*/
2350 return VAR;
2351 }
2352 }
2353
2354 TESTOP3('=','=','~',numEQ,reLIKE)
2355 TESTOP3('!','=','~',numNE,reNOTLIKE)
2356 TESTOP('>','=',numGE)
2357 TESTOP('<','=',numLE)
2358 TESTOP('&','&',AND)
2359 TESTOP('|','|',OR)
2360
2361 /* Any other character is a token by itself. */
2362 (exprobj->expr_curpos)++;
2363 return c;
2364 }
2365
2366 static
2367 struct exprval
call_expr_userfunc(struct expr_parser * exprobj,struct tmplpro_param * param,struct user_func_call USERFUNC)2368 call_expr_userfunc(struct expr_parser* exprobj, struct tmplpro_param* param, struct user_func_call USERFUNC) {
2369 struct exprval emptyval = {EXPR_TYPE_PSTR};
2370 emptyval.val.strval.begin=NULL;
2371 emptyval.val.strval.endnext=NULL;
2372 exprobj->userfunc_call = emptyval;
2373 param->CallExprUserfncFuncPtr(param->ext_calluserfunc_state, USERFUNC.arglist, USERFUNC.func, &(exprobj->userfunc_call));
2374 if (param->debug>6) _tmplpro_expnum_debug (exprobj->userfunc_call, "EXPR: function call: returned ");
2375 param->FreeExprArglistFuncPtr(USERFUNC.arglist);
2376 USERFUNC.arglist = NULL;
2377 /* never happen; tmplpro_set_expr_as_* never set EXPR_TYPE_NULL *
2378 * if (exprobj->userfunc_call.type == EXPR_TYPE_NULL) exprobj->userfunc_call.type = EXPR_TYPE_PSTR; */
2379 return exprobj->userfunc_call;
2380 }
2381
2382 static
2383 void
pusharg_expr_userfunc(struct expr_parser * exprobj,struct tmplpro_param * param,struct user_func_call USERFUNC,struct exprval arg)2384 pusharg_expr_userfunc(struct expr_parser* exprobj, struct tmplpro_param* param, struct user_func_call USERFUNC, struct exprval arg) {
2385 if (arg.type == EXPR_TYPE_UPSTR) {
2386 arg.val.strval=expr_unescape_pstring_val(&(exprobj->state->expr_left_pbuffer),arg.val.strval);
2387 arg.type=EXPR_TYPE_PSTR;
2388 }
2389 exprobj->userfunc_call = arg;
2390 param->PushExprArglistFuncPtr(USERFUNC.arglist,&(exprobj->userfunc_call));
2391 if (param->debug>6) _tmplpro_expnum_debug (arg, "EXPR: arglist: pushed ");
2392 }
2393
2394 #include "exprtool.inc"
2395 #include "exprpstr.inc"
2396
2397