Wed Jan 8 2020 09:49:42

Asterisk developer's documentation


ast_expr2.c
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 2.5. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 /* As a special exception, you may create a larger work that contains
21  part or all of the Bison parser skeleton and distribute that work
22  under terms of your choice, so long as that work isn't itself a
23  parser generator using the skeleton or a modified version thereof
24  as a parser skeleton. Alternatively, if you modify or redistribute
25  the parser skeleton itself, you may (at your option) remove this
26  special exception, which will cause the skeleton and the resulting
27  Bison output files to be licensed under the GNU General Public
28  License without this special exception.
29 
30  This special exception was added by the Free Software Foundation in
31  version 2.2 of Bison. */
32 
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34  simplifying the original so-called "semantic" parser. */
35 
36 /* All symbols defined below should begin with yy or YY, to avoid
37  infringing on user name space. This should be done even for local
38  variables, as they might otherwise be expanded by user macros.
39  There are some unavoidable exceptions within include files to
40  define necessary library symbols; they are noted "INFRINGES ON
41  USER NAME SPACE" below. */
42 
43 /* Identify Bison output. */
44 #define YYBISON 1
45 
46 /* Bison version. */
47 #define YYBISON_VERSION "2.5"
48 
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51 
52 /* Pure parsers. */
53 #define YYPURE 1
54 
55 /* Push parsers. */
56 #define YYPUSH 0
57 
58 /* Pull parsers. */
59 #define YYPULL 1
60 
61 /* Using locations. */
62 #define YYLSP_NEEDED 1
63 
64 /* Substitute the variable and function names. */
65 #define yyparse ast_yyparse
66 #define yylex ast_yylex
67 #define yyerror ast_yyerror
68 #define yylval ast_yylval
69 #define yychar ast_yychar
70 #define yydebug ast_yydebug
71 #define yynerrs ast_yynerrs
72 #define yylloc ast_yylloc
73 
74 /* Copy the first part of user declarations. */
75 
76 /* Line 268 of yacc.c */
77 #line 1 "ast_expr2.y"
78 
79 /* Written by Pace Willisson (pace@blitz.com)
80  * and placed in the public domain.
81  *
82  * Largely rewritten by J.T. Conklin (jtc@wimsey.com)
83  *
84  * And then overhauled twice by Steve Murphy (murf@digium.com)
85  * to add double-quoted strings, allow mult. spaces, improve
86  * error messages, and then to fold in a flex scanner for the
87  * yylex operation.
88  *
89  * $FreeBSD: src/bin/expr/expr.y,v 1.16 2000/07/22 10:59:36 se Exp $
90  */
91 
92 #include "asterisk.h"
93 
94 #include <sys/types.h>
95 #include <stdio.h>
96 
97 #if !defined(STANDALONE) && !defined(STANDALONE2) \
98 
99 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 360357 $")
100 #else
101 #ifndef __USE_ISOC99
102 #define __USE_ISOC99 1
103 #endif
104 #endif
105 
106 #ifdef __USE_ISOC99
107 #define FP___PRINTF "%.18Lg"
108 #define FP___TYPE long double
109 #else
110 #define FP___PRINTF "%.16g"
111 #define FP___TYPE double
112 #endif
113 
114 #ifdef HAVE_COSL
115 #define FUNC_COS cosl
116 #elif defined(HAVE_COS)
117 #define FUNC_COS (long double)cos
118 #endif
119 
120 #ifdef HAVE_SINL
121 #define FUNC_SIN sinl
122 #elif defined(HAVE_SIN)
123 #define FUNC_SIN (long double)sin
124 #endif
125 
126 #ifdef HAVE_TANL
127 #define FUNC_TAN tanl
128 #elif defined(HAVE_TAN)
129 #define FUNC_TAN (long double)tan
130 #endif
131 
132 #ifdef HAVE_ACOSL
133 #define FUNC_ACOS acosl
134 #elif defined(HAVE_ACOS)
135 #define FUNC_ACOS (long double)acos
136 #endif
137 
138 #ifdef HAVE_ASINL
139 #define FUNC_ASIN asinl
140 #elif defined(HAVE_ASIN)
141 #define FUNC_ASIN (long double)asin
142 #endif
143 
144 #ifdef HAVE_ATANL
145 #define FUNC_ATAN atanl
146 #elif defined(HAVE_ATAN)
147 #define FUNC_ATAN (long double)atan
148 #endif
149 
150 #ifdef HAVE_ATAN2L
151 #define FUNC_ATAN2 atan2l
152 #elif defined(HAVE_ATAN2)
153 #define FUNC_ATAN2 (long double)atan2
154 #endif
155 
156 #ifdef HAVE_POWL
157 #define FUNC_POW powl
158 #elif defined(HAVE_POW)
159 #define FUNC_POW (long double)pow
160 #endif
161 
162 #ifdef HAVE_SQRTL
163 #define FUNC_SQRT sqrtl
164 #elif defined(HAVE_SQRT)
165 #define FUNC_SQRT (long double)sqrt
166 #endif
167 
168 #ifdef HAVE_RINTL
169 #define FUNC_RINT rintl
170 #elif defined(HAVE_RINT)
171 #define FUNC_RINT (long double)rint
172 #endif
173 
174 #ifdef HAVE_EXPL
175 #define FUNC_EXP expl
176 #elif defined(HAVE_EXP)
177 #define FUNC_EXP (long double)exp
178 #endif
179 
180 #ifdef HAVE_LOGL
181 #define FUNC_LOG logl
182 #elif defined(HAVE_LOG)
183 #define FUNC_LOG (long double)log
184 #endif
185 
186 #ifdef HAVE_REMAINDERL
187 #define FUNC_REMAINDER remainderl
188 #elif defined(HAVE_REMAINDER)
189 #define FUNC_REMAINDER (long double)remainder
190 #endif
191 
192 #ifdef HAVE_FMODL
193 #define FUNC_FMOD fmodl
194 #elif defined(HAVE_FMOD)
195 #define FUNC_FMOD (long double)fmod
196 #endif
197 
198 #ifdef HAVE_STRTOLD
199 #define FUNC_STRTOD strtold
200 #elif defined(HAVE_STRTOD)
201 #define FUNC_STRTOD (long double)strtod
202 #endif
203 
204 #ifdef HAVE_FLOORL
205 #define FUNC_FLOOR floorl
206 #elif defined(HAVE_FLOOR)
207 #define FUNC_FLOOR (long double)floor
208 #endif
209 
210 #ifdef HAVE_CEILL
211 #define FUNC_CEIL ceill
212 #elif defined(HAVE_CEIL)
213 #define FUNC_CEIL (long double)ceil
214 #endif
215 
216 #ifdef HAVE_ROUNDL
217 #define FUNC_ROUND roundl
218 #elif defined(HAVE_ROUND)
219 #define FUNC_ROUND (long double)round
220 #endif
221 
222 #ifdef HAVE_TRUNCL
223 #define FUNC_TRUNC truncl
224 #elif defined(HAVE_TRUNC)
225 #define FUNC_TRUNC (long double)trunc
226 #endif
227 
228 /*! \note
229  * Oddly enough, some platforms have some ISO C99 functions, but not others, so
230  * we define the missing functions in terms of their mathematical identities.
231  */
232 #ifdef HAVE_EXP2L
233 #define FUNC_EXP2 exp2l
234 #elif (defined(HAVE_EXPL) && defined(HAVE_LOGL))
235 #define FUNC_EXP2(x) expl((x) * logl(2.0))
236 #elif (defined(HAVE_EXP) && defined(HAVE_LOG))
237 #define FUNC_EXP2(x) (long double)exp((x) * log(2.0))
238 #endif
239 
240 #ifdef HAVE_EXP10L
241 #define FUNC_EXP10 exp10l
242 #elif (defined(HAVE_EXPL) && defined(HAVE_LOGL))
243 #define FUNC_EXP10(x) expl((x) * logl(10.0))
244 #elif (defined(HAVE_EXP) && defined(HAVE_LOG))
245 #define FUNC_EXP10(x) (long double)exp((x) * log(10.0))
246 #endif
247 
248 #ifdef HAVE_LOG2L
249 #define FUNC_LOG2 log2l
250 #elif defined(HAVE_LOGL)
251 #define FUNC_LOG2(x) (logl(x) / logl(2.0))
252 #elif defined(HAVE_LOG10L)
253 #define FUNC_LOG2(x) (log10l(x) / log10l(2.0))
254 #elif defined(HAVE_LOG2)
255 #define FUNC_LOG2 (long double)log2
256 #elif defined(HAVE_LOG)
257 #define FUNC_LOG2(x) ((long double)log(x) / log(2.0))
258 #endif
259 
260 #ifdef HAVE_LOG10L
261 #define FUNC_LOG10 log10l
262 #elif defined(HAVE_LOGL)
263 #define FUNC_LOG10(x) (logl(x) / logl(10.0))
264 #elif defined(HAVE_LOG2L)
265 #define FUNC_LOG10(x) (log2l(x) / log2l(10.0))
266 #elif defined(HAVE_LOG10)
267 #define FUNC_LOG10(x) (long double)log10(x)
268 #elif defined(HAVE_LOG)
269 #define FUNC_LOG10(x) ((long double)log(x) / log(10.0))
270 #endif
271 
272 
273 #include <stdlib.h>
274 #ifndef _GNU_SOURCE
275 #define _GNU_SOURCE
276 #endif
277 #include <string.h>
278 #include <math.h>
279 #include <locale.h>
280 #include <unistd.h>
281 #include <ctype.h>
282 #if !defined(SOLARIS) && !defined(__CYGWIN__)
283  /* #include <err.h> */
284 #else
285 #define quad_t int64_t
286 #endif
287 #include <errno.h>
288 #include <regex.h>
289 #include <limits.h>
290 
291 #include "asterisk/ast_expr.h"
292 #include "asterisk/logger.h"
293 #if !defined(STANDALONE) && !defined(STANDALONE2)
294 #include "asterisk/pbx.h"
295 #endif
296 
297 #if defined(LONG_LONG_MIN) && !defined(QUAD_MIN)
298 #define QUAD_MIN LONG_LONG_MIN
299 #endif
300 #if defined(LONG_LONG_MAX) && !defined(QUAD_MAX)
301 #define QUAD_MAX LONG_LONG_MAX
302 #endif
303 
304 # if ! defined(QUAD_MIN)
305 # define QUAD_MIN (-0x7fffffffffffffffLL-1)
306 # endif
307 # if ! defined(QUAD_MAX)
308 # define QUAD_MAX (0x7fffffffffffffffLL)
309 # endif
310 #define YYENABLE_NLS 0
311 #define YYPARSE_PARAM parseio
312 #define YYLEX_PARAM ((struct parse_io *)parseio)->scanner
313 #define YYERROR_VERBOSE 1
314 extern char extra_error_message[4095];
316 
317 enum valtype {
319 } ;
320 
321 #if defined(STANDALONE) || defined(STANDALONE2)
322 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf,5,6)));
323 #endif
324 
325 struct val {
326  enum valtype type;
327  union {
328  char *s;
329  FP___TYPE i; /* either long double, or just double, on a bad day */
330  } u;
331 } ;
332 
333 enum node_type {
335 } ;
336 
337 struct expr_node
338 {
340  struct val *val;
341  struct expr_node *left;
342  struct expr_node *right;
343 };
344 
345 
346 typedef void *yyscan_t;
347 
348 struct parse_io
349 {
350  char *string;
351  struct val *val;
352  yyscan_t scanner;
353  struct ast_channel *chan;
354 };
355 
356 static int chk_div __P((FP___TYPE, FP___TYPE));
357 static int chk_minus __P((FP___TYPE, FP___TYPE, FP___TYPE));
358 static int chk_plus __P((FP___TYPE, FP___TYPE, FP___TYPE));
359 static int chk_times __P((FP___TYPE, FP___TYPE, FP___TYPE));
360 static void free_value __P((struct val *));
361 static int is_zero_or_null __P((struct val *));
362 static int isstring __P((struct val *));
363 static struct val *make_number __P((FP___TYPE));
364 static struct val *make_str __P((const char *));
365 static struct val *op_and __P((struct val *, struct val *));
366 static struct val *op_colon __P((struct val *, struct val *));
367 static struct val *op_eqtilde __P((struct val *, struct val *));
368 static struct val *op_tildetilde __P((struct val *, struct val *));
369 static struct val *op_div __P((struct val *, struct val *));
370 static struct val *op_eq __P((struct val *, struct val *));
371 static struct val *op_ge __P((struct val *, struct val *));
372 static struct val *op_gt __P((struct val *, struct val *));
373 static struct val *op_le __P((struct val *, struct val *));
374 static struct val *op_lt __P((struct val *, struct val *));
375 static struct val *op_cond __P((struct val *, struct val *, struct val *));
376 static struct val *op_minus __P((struct val *, struct val *));
377 static struct val *op_negate __P((struct val *));
378 static struct val *op_compl __P((struct val *));
379 static struct val *op_ne __P((struct val *, struct val *));
380 static struct val *op_or __P((struct val *, struct val *));
381 static struct val *op_plus __P((struct val *, struct val *));
382 static struct val *op_rem __P((struct val *, struct val *));
383 static struct val *op_times __P((struct val *, struct val *));
384 static struct val *op_func(struct val *funcname, struct expr_node *arglist, struct ast_channel *chan);
385 static int to_number __P((struct val *));
386 static void to_string __P((struct val *));
387 static struct expr_node *alloc_expr_node(enum node_type);
388 static void destroy_arglist(struct expr_node *arglist);
389 
390 /* uh, if I want to predeclare yylex with a YYLTYPE, I have to predeclare the yyltype... sigh */
391 typedef struct yyltype
392 {
395 
398 } yyltype;
399 
400 # define YYLTYPE yyltype
401 # define YYLTYPE_IS_TRIVIAL 1
402 
403 /* we will get warning about no prototype for yylex! But we can't
404  define it here, we have no definition yet for YYSTYPE. */
405 
406 int ast_yyerror(const char *,YYLTYPE *, struct parse_io *);
407 
408 /* I wanted to add args to the yyerror routine, so I could print out
409  some useful info about the error. Not as easy as it looks, but it
410  is possible. */
411 #define ast_yyerror(x) ast_yyerror(x,&yyloc,parseio)
412 #define DESTROY(x) {if((x)->type == AST_EXPR_numeric_string || (x)->type == AST_EXPR_string) free((x)->u.s); (x)->u.s = 0; free(x);}
413 
414 
415 /* Line 268 of yacc.c */
416 #line 417 "ast_expr2.c"
417 
418 /* Enabling traces. */
419 #ifndef YYDEBUG
420 # define YYDEBUG 0
421 #endif
422 
423 /* Enabling verbose error messages. */
424 #ifdef YYERROR_VERBOSE
425 # undef YYERROR_VERBOSE
426 # define YYERROR_VERBOSE 1
427 #else
428 # define YYERROR_VERBOSE 0
429 #endif
430 
431 /* Enabling the token table. */
432 #ifndef YYTOKEN_TABLE
433 # define YYTOKEN_TABLE 0
434 #endif
435 
436 
437 /* Tokens. */
438 #ifndef YYTOKENTYPE
439 # define YYTOKENTYPE
440  /* Put the tokens into the symbol table, so that GDB and other debuggers
441  know about them. */
442  enum yytokentype {
443  TOK_COMMA = 258,
445  TOK_COND = 260,
446  TOK_OR = 261,
447  TOK_AND = 262,
448  TOK_NE = 263,
449  TOK_LE = 264,
450  TOK_GE = 265,
451  TOK_LT = 266,
452  TOK_GT = 267,
453  TOK_EQ = 268,
454  TOK_MINUS = 269,
455  TOK_PLUS = 270,
456  TOK_MOD = 271,
457  TOK_DIV = 272,
458  TOK_MULT = 273,
459  TOK_COMPL = 274,
461  TOK_EQTILDE = 276,
462  TOK_COLON = 277,
463  TOK_LP = 278,
464  TOK_RP = 279,
465  TOKEN = 280
466  };
467 #endif
468 
469 
470 
471 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
472 typedef union YYSTYPE
473 {
474 
475 /* Line 293 of yacc.c */
476 #line 345 "ast_expr2.y"
477 
478  struct val *val;
480 
481 
482 
483 /* Line 293 of yacc.c */
484 #line 485 "ast_expr2.c"
485 } YYSTYPE;
486 # define YYSTYPE_IS_TRIVIAL 1
487 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
488 # define YYSTYPE_IS_DECLARED 1
489 #endif
490 
491 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
492 typedef struct YYLTYPE
493 {
494  int first_line;
495  int first_column;
496  int last_line;
497  int last_column;
498 } YYLTYPE;
499 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
500 # define YYLTYPE_IS_DECLARED 1
501 # define YYLTYPE_IS_TRIVIAL 1
502 #endif
503 
504 
505 /* Copy the second part of user declarations. */
506 
507 /* Line 343 of yacc.c */
508 #line 350 "ast_expr2.y"
509 
510 extern int ast_yylex __P((YYSTYPE *, YYLTYPE *, yyscan_t));
511 
512 
513 /* Line 343 of yacc.c */
514 #line 515 "ast_expr2.c"
515 
516 #ifdef short
517 # undef short
518 #endif
519 
520 #ifdef YYTYPE_UINT8
521 typedef YYTYPE_UINT8 yytype_uint8;
522 #else
523 typedef unsigned char yytype_uint8;
524 #endif
525 
526 #ifdef YYTYPE_INT8
527 typedef YYTYPE_INT8 yytype_int8;
528 #elif (defined __STDC__ || defined __C99__FUNC__ \
529  || defined __cplusplus || defined _MSC_VER)
530 typedef signed char yytype_int8;
531 #else
532 typedef short int yytype_int8;
533 #endif
534 
535 #ifdef YYTYPE_UINT16
536 typedef YYTYPE_UINT16 yytype_uint16;
537 #else
538 typedef unsigned short int yytype_uint16;
539 #endif
540 
541 #ifdef YYTYPE_INT16
542 typedef YYTYPE_INT16 yytype_int16;
543 #else
544 typedef short int yytype_int16;
545 #endif
546 
547 #ifndef YYSIZE_T
548 # ifdef __SIZE_TYPE__
549 # define YYSIZE_T __SIZE_TYPE__
550 # elif defined size_t
551 # define YYSIZE_T size_t
552 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
553  || defined __cplusplus || defined _MSC_VER)
554 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
555 # define YYSIZE_T size_t
556 # else
557 # define YYSIZE_T unsigned int
558 # endif
559 #endif
560 
561 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
562 
563 #ifndef YY_
564 # if defined YYENABLE_NLS && YYENABLE_NLS
565 # if ENABLE_NLS
566 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
567 # define YY_(msgid) dgettext ("bison-runtime", msgid)
568 # endif
569 # endif
570 # ifndef YY_
571 # define YY_(msgid) msgid
572 # endif
573 #endif
574 
575 /* Suppress unused-variable warnings by "using" E. */
576 #if ! defined lint || defined __GNUC__
577 # define YYUSE(e) ((void) (e))
578 #else
579 # define YYUSE(e) /* empty */
580 #endif
581 
582 /* Identity function, used to suppress warnings about constant conditions. */
583 #ifndef lint
584 # define YYID(n) (n)
585 #else
586 #if (defined __STDC__ || defined __C99__FUNC__ \
587  || defined __cplusplus || defined _MSC_VER)
588 static int
589 YYID (int yyi)
590 #else
591 static int
592 YYID (yyi)
593  int yyi;
594 #endif
595 {
596  return yyi;
597 }
598 #endif
599 
600 #if ! defined yyoverflow || YYERROR_VERBOSE
601 
602 /* The parser invokes alloca or malloc; define the necessary symbols. */
603 
604 # ifdef YYSTACK_USE_ALLOCA
605 # if YYSTACK_USE_ALLOCA
606 # ifdef __GNUC__
607 # define YYSTACK_ALLOC __builtin_alloca
608 # elif defined __BUILTIN_VA_ARG_INCR
609 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
610 # elif defined _AIX
611 # define YYSTACK_ALLOC __alloca
612 # elif defined _MSC_VER
613 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
614 # define alloca _alloca
615 # else
616 # define YYSTACK_ALLOC alloca
617 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
618  || defined __cplusplus || defined _MSC_VER)
619 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
620 # ifndef EXIT_SUCCESS
621 # define EXIT_SUCCESS 0
622 # endif
623 # endif
624 # endif
625 # endif
626 # endif
627 
628 # ifdef YYSTACK_ALLOC
629  /* Pacify GCC's `empty if-body' warning. */
630 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
631 # ifndef YYSTACK_ALLOC_MAXIMUM
632  /* The OS might guarantee only one guard page at the bottom of the stack,
633  and a page size can be as small as 4096 bytes. So we cannot safely
634  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
635  to allow for a few compiler-allocated temporary stack slots. */
636 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
637 # endif
638 # else
639 # define YYSTACK_ALLOC YYMALLOC
640 # define YYSTACK_FREE YYFREE
641 # ifndef YYSTACK_ALLOC_MAXIMUM
642 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
643 # endif
644 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
645  && ! ((defined YYMALLOC || defined malloc) \
646  && (defined YYFREE || defined free)))
647 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
648 # ifndef EXIT_SUCCESS
649 # define EXIT_SUCCESS 0
650 # endif
651 # endif
652 # ifndef YYMALLOC
653 # define YYMALLOC malloc
654 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
655  || defined __cplusplus || defined _MSC_VER)
656 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
657 # endif
658 # endif
659 # ifndef YYFREE
660 # define YYFREE free
661 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
662  || defined __cplusplus || defined _MSC_VER)
663 void free (void *); /* INFRINGES ON USER NAME SPACE */
664 # endif
665 # endif
666 # endif
667 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
668 
669 
670 #if (! defined yyoverflow \
671  && (! defined __cplusplus \
672  || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
673  && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
674 
675 /* A type that is properly aligned for any stack member. */
676 union yyalloc
677 {
678  yytype_int16 yyss_alloc;
681 };
682 
683 /* The size of the maximum gap between one aligned stack and the next. */
684 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
685 
686 /* The size of an array large to enough to hold all stacks, each with
687  N elements. */
688 # define YYSTACK_BYTES(N) \
689  ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
690  + 2 * YYSTACK_GAP_MAXIMUM)
691 
692 # define YYCOPY_NEEDED 1
693 
694 /* Relocate STACK from its old location to the new one. The
695  local variables YYSIZE and YYSTACKSIZE give the old and new number of
696  elements in the stack, and YYPTR gives the new location of the
697  stack. Advance YYPTR to a properly aligned location for the next
698  stack. */
699 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
700  do \
701  { \
702  YYSIZE_T yynewbytes; \
703  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
704  Stack = &yyptr->Stack_alloc; \
705  yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
706  yyptr += yynewbytes / sizeof (*yyptr); \
707  } \
708  while (YYID (0))
709 
710 #endif
711 
712 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
713 /* Copy COUNT objects from FROM to TO. The source and destination do
714  not overlap. */
715 # ifndef YYCOPY
716 # if defined __GNUC__ && 1 < __GNUC__
717 # define YYCOPY(To, From, Count) \
718  __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
719 # else
720 # define YYCOPY(To, From, Count) \
721  do \
722  { \
723  YYSIZE_T yyi; \
724  for (yyi = 0; yyi < (Count); yyi++) \
725  (To)[yyi] = (From)[yyi]; \
726  } \
727  while (YYID (0))
728 # endif
729 # endif
730 #endif /* !YYCOPY_NEEDED */
731 
732 /* YYFINAL -- State number of the termination state. */
733 #define YYFINAL 11
734 /* YYLAST -- Last index in YYTABLE. */
735 #define YYLAST 159
736 
737 /* YYNTOKENS -- Number of terminals. */
738 #define YYNTOKENS 26
739 /* YYNNTS -- Number of nonterminals. */
740 #define YYNNTS 4
741 /* YYNRULES -- Number of rules. */
742 #define YYNRULES 28
743 /* YYNRULES -- Number of states. */
744 #define YYNSTATES 54
745 
746 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
747 #define YYUNDEFTOK 2
748 #define YYMAXUTOK 280
749 
750 #define YYTRANSLATE(YYX) \
751  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
752 
753 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
754 static const yytype_uint8 yytranslate[] =
755 {
756  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
757  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
758  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
759  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
760  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
761  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
762  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
763  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
764  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
765  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
766  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
767  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
768  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
769  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
770  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
771  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
772  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
773  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
774  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
775  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
776  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
777  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
778  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
779  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
780  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
781  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
782  5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
783  15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
784  25
785 };
786 
787 #if YYDEBUG
788 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
789  YYRHS. */
790 static const yytype_uint8 yyprhs[] =
791 {
792  0, 0, 3, 5, 6, 8, 12, 15, 20, 22,
793  26, 30, 34, 38, 42, 46, 50, 54, 58, 62,
794  66, 69, 72, 76, 80, 84, 88, 92, 98
795 };
796 
797 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
798 static const yytype_int8 yyrhs[] =
799 {
800  27, 0, -1, 29, -1, -1, 29, -1, 28, 3,
801  29, -1, 28, 3, -1, 25, 23, 28, 24, -1,
802  25, -1, 23, 29, 24, -1, 29, 6, 29, -1,
803  29, 7, 29, -1, 29, 13, 29, -1, 29, 12,
804  29, -1, 29, 11, 29, -1, 29, 10, 29, -1,
805  29, 9, 29, -1, 29, 8, 29, -1, 29, 15,
806  29, -1, 29, 14, 29, -1, 14, 29, -1, 19,
807  29, -1, 29, 18, 29, -1, 29, 17, 29, -1,
808  29, 16, 29, -1, 29, 22, 29, -1, 29, 21,
809  29, -1, 29, 5, 29, 4, 29, -1, 29, 20,
810  29, -1
811 };
812 
813 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
814 static const yytype_uint16 yyrline[] =
815 {
816  0, 374, 374, 382, 389, 390, 396, 405, 411, 412,
817  416, 420, 424, 428, 432, 436, 440, 444, 448, 452,
818  456, 460, 464, 468, 472, 476, 480, 484, 489
819 };
820 #endif
821 
822 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
823 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
824  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
825 static const char *const yytname[] =
826 {
827  "$end", "error", "$undefined", "TOK_COMMA", "TOK_COLONCOLON",
828  "TOK_COND", "TOK_OR", "TOK_AND", "TOK_NE", "TOK_LE", "TOK_GE", "TOK_LT",
829  "TOK_GT", "TOK_EQ", "TOK_MINUS", "TOK_PLUS", "TOK_MOD", "TOK_DIV",
830  "TOK_MULT", "TOK_COMPL", "TOK_TILDETILDE", "TOK_EQTILDE", "TOK_COLON",
831  "TOK_LP", "TOK_RP", "TOKEN", "$accept", "start", "arglist", "expr", 0
832 };
833 #endif
834 
835 # ifdef YYPRINT
836 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
837  token YYLEX-NUM. */
838 static const yytype_uint16 yytoknum[] =
839 {
840  0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
841  265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
842  275, 276, 277, 278, 279, 280
843 };
844 # endif
845 
846 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
847 static const yytype_uint8 yyr1[] =
848 {
849  0, 26, 27, 27, 28, 28, 28, 29, 29, 29,
850  29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
851  29, 29, 29, 29, 29, 29, 29, 29, 29
852 };
853 
854 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
855 static const yytype_uint8 yyr2[] =
856 {
857  0, 2, 1, 0, 1, 3, 2, 4, 1, 3,
858  3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
859  2, 2, 3, 3, 3, 3, 3, 5, 3
860 };
861 
862 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
863  Performed when YYTABLE doesn't specify something else to do. Zero
864  means the default is an error. */
865 static const yytype_uint8 yydefact[] =
866 {
867  3, 0, 0, 0, 8, 0, 2, 20, 21, 0,
868  0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
869  0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
870  0, 4, 0, 10, 11, 17, 16, 15, 14, 13,
871  12, 19, 18, 24, 23, 22, 28, 26, 25, 6,
872  7, 0, 5, 27
873 };
874 
875 /* YYDEFGOTO[NTERM-NUM]. */
876 static const yytype_int8 yydefgoto[] =
877 {
878  -1, 5, 30, 6
879 };
880 
881 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
882  STATE-NUM. */
883 #define YYPACT_NINF -18
884 static const yytype_int16 yypact[] =
885 {
886  118, 118, 118, 118, -15, 6, 65, -17, -17, 25,
887  118, -18, 118, 118, 118, 118, 118, 118, 118, 118,
888  118, 118, 118, 118, 118, 118, 118, 118, 118, -18,
889  4, 65, 47, 98, 113, 130, 130, 130, 130, 130,
890  130, 137, 137, -17, -17, -17, -18, -18, -18, 118,
891  -18, 118, 65, 82
892 };
893 
894 /* YYPGOTO[NTERM-NUM]. */
895 static const yytype_int8 yypgoto[] =
896 {
897  -18, -18, -18, -1
898 };
899 
900 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
901  positive, shift that token. If negative, reduce the rule which
902  number is the opposite. If YYTABLE_NINF, syntax error. */
903 #define YYTABLE_NINF -1
904 static const yytype_uint8 yytable[] =
905 {
906  7, 8, 9, 26, 27, 28, 11, 49, 10, 31,
907  0, 32, 33, 34, 35, 36, 37, 38, 39, 40,
908  41, 42, 43, 44, 45, 46, 47, 48, 50, 0,
909  12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
910  22, 23, 24, 25, 0, 26, 27, 28, 52, 29,
911  53, 51, 12, 13, 14, 15, 16, 17, 18, 19,
912  20, 21, 22, 23, 24, 25, 0, 26, 27, 28,
913  12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
914  22, 23, 24, 25, 0, 26, 27, 28, 13, 14,
915  15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
916  25, 0, 26, 27, 28, 14, 15, 16, 17, 18,
917  19, 20, 21, 22, 23, 24, 25, 0, 26, 27,
918  28, 15, 16, 17, 18, 19, 20, 21, 22, 23,
919  24, 25, 1, 26, 27, 28, 0, 2, 0, 0,
920  0, 3, 0, 4, 21, 22, 23, 24, 25, 0,
921  26, 27, 28, 23, 24, 25, 0, 26, 27, 28
922 };
923 
924 #define yypact_value_is_default(yystate) \
925  ((yystate) == (-18))
926 
927 #define yytable_value_is_error(yytable_value) \
928  YYID (0)
929 
930 static const yytype_int8 yycheck[] =
931 {
932  1, 2, 3, 20, 21, 22, 0, 3, 23, 10,
933  -1, 12, 13, 14, 15, 16, 17, 18, 19, 20,
934  21, 22, 23, 24, 25, 26, 27, 28, 24, -1,
935  5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
936  15, 16, 17, 18, -1, 20, 21, 22, 49, 24,
937  51, 4, 5, 6, 7, 8, 9, 10, 11, 12,
938  13, 14, 15, 16, 17, 18, -1, 20, 21, 22,
939  5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
940  15, 16, 17, 18, -1, 20, 21, 22, 6, 7,
941  8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
942  18, -1, 20, 21, 22, 7, 8, 9, 10, 11,
943  12, 13, 14, 15, 16, 17, 18, -1, 20, 21,
944  22, 8, 9, 10, 11, 12, 13, 14, 15, 16,
945  17, 18, 14, 20, 21, 22, -1, 19, -1, -1,
946  -1, 23, -1, 25, 14, 15, 16, 17, 18, -1,
947  20, 21, 22, 16, 17, 18, -1, 20, 21, 22
948 };
949 
950 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
951  symbol of state STATE-NUM. */
952 static const yytype_uint8 yystos[] =
953 {
954  0, 14, 19, 23, 25, 27, 29, 29, 29, 29,
955  23, 0, 5, 6, 7, 8, 9, 10, 11, 12,
956  13, 14, 15, 16, 17, 18, 20, 21, 22, 24,
957  28, 29, 29, 29, 29, 29, 29, 29, 29, 29,
958  29, 29, 29, 29, 29, 29, 29, 29, 29, 3,
959  24, 4, 29, 29
960 };
961 
962 #define yyerrok (yyerrstatus = 0)
963 #define yyclearin (yychar = YYEMPTY)
964 #define YYEMPTY (-2)
965 #define YYEOF 0
966 
967 #define YYACCEPT goto yyacceptlab
968 #define YYABORT goto yyabortlab
969 #define YYERROR goto yyerrorlab
970 
971 
972 /* Like YYERROR except do call yyerror. This remains here temporarily
973  to ease the transition to the new meaning of YYERROR, for GCC.
974  Once GCC version 2 has supplanted version 1, this can go. However,
975  YYFAIL appears to be in use. Nevertheless, it is formally deprecated
976  in Bison 2.4.2's NEWS entry, where a plan to phase it out is
977  discussed. */
978 
979 #define YYFAIL goto yyerrlab
980 #if defined YYFAIL
981  /* This is here to suppress warnings from the GCC cpp's
982  -Wunused-macros. Normally we don't worry about that warning, but
983  some users do, and we want to make it easy for users to remove
984  YYFAIL uses, which will produce warnings from Bison 2.5. */
985 #endif
986 
987 #define YYRECOVERING() (!!yyerrstatus)
988 
989 #define YYBACKUP(Token, Value) \
990 do \
991  if (yychar == YYEMPTY && yylen == 1) \
992  { \
993  yychar = (Token); \
994  yylval = (Value); \
995  YYPOPSTACK (1); \
996  goto yybackup; \
997  } \
998  else \
999  { \
1000  yyerror (YY_("syntax error: cannot back up")); \
1001  YYERROR; \
1002  } \
1003 while (YYID (0))
1004 
1005 
1006 #define YYTERROR 1
1007 #define YYERRCODE 256
1008 
1009 
1010 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
1011  If N is 0, then set CURRENT to the empty location which ends
1012  the previous symbol: RHS[0] (always defined). */
1013 
1014 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
1015 #ifndef YYLLOC_DEFAULT
1016 # define YYLLOC_DEFAULT(Current, Rhs, N) \
1017  do \
1018  if (YYID (N)) \
1019  { \
1020  (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
1021  (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
1022  (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
1023  (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
1024  } \
1025  else \
1026  { \
1027  (Current).first_line = (Current).last_line = \
1028  YYRHSLOC (Rhs, 0).last_line; \
1029  (Current).first_column = (Current).last_column = \
1030  YYRHSLOC (Rhs, 0).last_column; \
1031  } \
1032  while (YYID (0))
1033 #endif
1034 
1035 
1036 /* YY_LOCATION_PRINT -- Print the location on the stream.
1037  This macro was not mandated originally: define only if we know
1038  we won't break user code: when these are the locations we know. */
1039 
1040 #ifndef YY_LOCATION_PRINT
1041 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1042 # define YY_LOCATION_PRINT(File, Loc) \
1043  fprintf (File, "%d.%d-%d.%d", \
1044  (Loc).first_line, (Loc).first_column, \
1045  (Loc).last_line, (Loc).last_column)
1046 # else
1047 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1048 # endif
1049 #endif
1050 
1051 
1052 /* YYLEX -- calling `yylex' with the right arguments. */
1053 
1054 #ifdef YYLEX_PARAM
1055 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
1056 #else
1057 # define YYLEX yylex (&yylval, &yylloc)
1058 #endif
1059 
1060 /* Enable debugging if requested. */
1061 #if YYDEBUG
1062 
1063 # ifndef YYFPRINTF
1064 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1065 # define YYFPRINTF fprintf
1066 # endif
1067 
1068 # define YYDPRINTF(Args) \
1069 do { \
1070  if (yydebug) \
1071  YYFPRINTF Args; \
1072 } while (YYID (0))
1073 
1074 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1075 do { \
1076  if (yydebug) \
1077  { \
1078  YYFPRINTF (stderr, "%s ", Title); \
1079  yy_symbol_print (stderr, \
1080  Type, Value, Location); \
1081  YYFPRINTF (stderr, "\n"); \
1082  } \
1083 } while (YYID (0))
1084 
1085 
1086 /*--------------------------------.
1087 | Print this symbol on YYOUTPUT. |
1088 `--------------------------------*/
1089 
1090 /*ARGSUSED*/
1091 #if (defined __STDC__ || defined __C99__FUNC__ \
1092  || defined __cplusplus || defined _MSC_VER)
1093 static void
1094 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
1095 #else
1096 static void
1097 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
1098  FILE *yyoutput;
1099  int yytype;
1100  YYSTYPE const * const yyvaluep;
1101  YYLTYPE const * const yylocationp;
1102 #endif
1103 {
1104  if (!yyvaluep)
1105  return;
1106  YYUSE (yylocationp);
1107 # ifdef YYPRINT
1108  if (yytype < YYNTOKENS)
1109  YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1110 # else
1111  YYUSE (yyoutput);
1112 # endif
1113  switch (yytype)
1114  {
1115  default:
1116  break;
1117  }
1118 }
1119 
1120 
1121 /*--------------------------------.
1122 | Print this symbol on YYOUTPUT. |
1123 `--------------------------------*/
1124 
1125 #if (defined __STDC__ || defined __C99__FUNC__ \
1126  || defined __cplusplus || defined _MSC_VER)
1127 static void
1128 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
1129 #else
1130 static void
1131 yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
1132  FILE *yyoutput;
1133  int yytype;
1134  YYSTYPE const * const yyvaluep;
1135  YYLTYPE const * const yylocationp;
1136 #endif
1137 {
1138  if (yytype < YYNTOKENS)
1139  YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1140  else
1141  YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1142 
1143  YY_LOCATION_PRINT (yyoutput, *yylocationp);
1144  YYFPRINTF (yyoutput, ": ");
1145  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
1146  YYFPRINTF (yyoutput, ")");
1147 }
1148 
1149 /*------------------------------------------------------------------.
1150 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1151 | TOP (included). |
1152 `------------------------------------------------------------------*/
1153 
1154 #if (defined __STDC__ || defined __C99__FUNC__ \
1155  || defined __cplusplus || defined _MSC_VER)
1156 static void
1157 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1158 #else
1159 static void
1160 yy_stack_print (yybottom, yytop)
1161  yytype_int16 *yybottom;
1162  yytype_int16 *yytop;
1163 #endif
1164 {
1165  YYFPRINTF (stderr, "Stack now");
1166  for (; yybottom <= yytop; yybottom++)
1167  {
1168  int yybot = *yybottom;
1169  YYFPRINTF (stderr, " %d", yybot);
1170  }
1171  YYFPRINTF (stderr, "\n");
1172 }
1173 
1174 # define YY_STACK_PRINT(Bottom, Top) \
1175 do { \
1176  if (yydebug) \
1177  yy_stack_print ((Bottom), (Top)); \
1178 } while (YYID (0))
1179 
1180 
1181 /*------------------------------------------------.
1182 | Report that the YYRULE is going to be reduced. |
1183 `------------------------------------------------*/
1184 
1185 #if (defined __STDC__ || defined __C99__FUNC__ \
1186  || defined __cplusplus || defined _MSC_VER)
1187 static void
1188 yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
1189 #else
1190 static void
1191 yy_reduce_print (yyvsp, yylsp, yyrule)
1192  YYSTYPE *yyvsp;
1193  YYLTYPE *yylsp;
1194  int yyrule;
1195 #endif
1196 {
1197  int yynrhs = yyr2[yyrule];
1198  int yyi;
1199  unsigned long int yylno = yyrline[yyrule];
1200  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1201  yyrule - 1, yylno);
1202  /* The symbols being reduced. */
1203  for (yyi = 0; yyi < yynrhs; yyi++)
1204  {
1205  YYFPRINTF (stderr, " $%d = ", yyi + 1);
1206  yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1207  &(yyvsp[(yyi + 1) - (yynrhs)])
1208  , &(yylsp[(yyi + 1) - (yynrhs)]) );
1209  YYFPRINTF (stderr, "\n");
1210  }
1211 }
1212 
1213 # define YY_REDUCE_PRINT(Rule) \
1214 do { \
1215  if (yydebug) \
1216  yy_reduce_print (yyvsp, yylsp, Rule); \
1217 } while (YYID (0))
1218 
1219 /* Nonzero means print parse trace. It is left uninitialized so that
1220  multiple parsers can coexist. */
1221 int yydebug;
1222 #else /* !YYDEBUG */
1223 # define YYDPRINTF(Args)
1224 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1225 # define YY_STACK_PRINT(Bottom, Top)
1226 # define YY_REDUCE_PRINT(Rule)
1227 #endif /* !YYDEBUG */
1228 
1229 
1230 /* YYINITDEPTH -- initial size of the parser's stacks. */
1231 #ifndef YYINITDEPTH
1232 # define YYINITDEPTH 200
1233 #endif
1234 
1235 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1236  if the built-in stack extension method is used).
1237 
1238  Do not make this value too large; the results are undefined if
1239  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1240  evaluated with infinite-precision integer arithmetic. */
1241 
1242 #ifndef YYMAXDEPTH
1243 # define YYMAXDEPTH 10000
1244 #endif
1245 
1246 
1247 #if YYERROR_VERBOSE
1248 
1249 # ifndef yystrlen
1250 # if defined __GLIBC__ && defined _STRING_H
1251 # define yystrlen strlen
1252 # else
1253 /* Return the length of YYSTR. */
1254 #if (defined __STDC__ || defined __C99__FUNC__ \
1255  || defined __cplusplus || defined _MSC_VER)
1256 static YYSIZE_T
1257 yystrlen (const char *yystr)
1258 #else
1259 static YYSIZE_T
1260 yystrlen (yystr)
1261  const char *yystr;
1262 #endif
1264  YYSIZE_T yylen;
1265  for (yylen = 0; yystr[yylen]; yylen++)
1266  continue;
1267  return yylen;
1268 }
1269 # endif
1270 # endif
1271 
1272 # ifndef yystpcpy
1273 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1274 # define yystpcpy stpcpy
1275 # else
1276 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1277  YYDEST. */
1278 #if (defined __STDC__ || defined __C99__FUNC__ \
1279  || defined __cplusplus || defined _MSC_VER)
1280 static char *
1281 yystpcpy (char *yydest, const char *yysrc)
1282 #else
1283 static char *
1284 yystpcpy (yydest, yysrc)
1285  char *yydest;
1286  const char *yysrc;
1287 #endif
1288 {
1289  char *yyd = yydest;
1290  const char *yys = yysrc;
1291 
1292  while ((*yyd++ = *yys++) != '\0')
1293  continue;
1294 
1295  return yyd - 1;
1296 }
1297 # endif
1298 # endif
1299 
1300 # ifndef yytnamerr
1301 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1302  quotes and backslashes, so that it's suitable for yyerror. The
1303  heuristic is that double-quoting is unnecessary unless the string
1304  contains an apostrophe, a comma, or backslash (other than
1305  backslash-backslash). YYSTR is taken from yytname. If YYRES is
1306  null, do not copy; instead, return the length of what the result
1307  would have been. */
1308 static YYSIZE_T
1309 yytnamerr (char *yyres, const char *yystr)
1310 {
1311  if (*yystr == '"')
1312  {
1313  YYSIZE_T yyn = 0;
1314  char const *yyp = yystr;
1315 
1316  for (;;)
1317  switch (*++yyp)
1318  {
1319  case '\'':
1320  case ',':
1321  goto do_not_strip_quotes;
1322 
1323  case '\\':
1324  if (*++yyp != '\\')
1325  goto do_not_strip_quotes;
1326  /* Fall through. */
1327  default:
1328  if (yyres)
1329  yyres[yyn] = *yyp;
1330  yyn++;
1331  break;
1332 
1333  case '"':
1334  if (yyres)
1335  yyres[yyn] = '\0';
1336  return yyn;
1337  }
1338  do_not_strip_quotes: ;
1339  }
1340 
1341  if (! yyres)
1342  return yystrlen (yystr);
1343 
1344  return yystpcpy (yyres, yystr) - yyres;
1345 }
1346 # endif
1347 
1348 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1349  about the unexpected token YYTOKEN for the state stack whose top is
1350  YYSSP.
1351 
1352  Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1353  not large enough to hold the message. In that case, also set
1354  *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1355  required number of bytes is too large to store. */
1356 static int
1358  yytype_int16 *yyssp, int yytoken)
1359 {
1360  YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1361  YYSIZE_T yysize = yysize0;
1362  YYSIZE_T yysize1;
1363  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1364  /* Internationalized format string. */
1365  const char *yyformat = 0;
1366  /* Arguments of yyformat. */
1367  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1368  /* Number of reported tokens (one for the "unexpected", one per
1369  "expected"). */
1370  int yycount = 0;
1371 
1372  /* There are many possibilities here to consider:
1373  - Assume YYFAIL is not used. It's too flawed to consider. See
1374  <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1375  for details. YYERROR is fine as it does not invoke this
1376  function.
1377  - If this state is a consistent state with a default action, then
1378  the only way this function was invoked is if the default action
1379  is an error action. In that case, don't check for expected
1380  tokens because there are none.
1381  - The only way there can be no lookahead present (in yychar) is if
1382  this state is a consistent state with a default action. Thus,
1383  detecting the absence of a lookahead is sufficient to determine
1384  that there is no unexpected or expected token to report. In that
1385  case, just report a simple "syntax error".
1386  - Don't assume there isn't a lookahead just because this state is a
1387  consistent state with a default action. There might have been a
1388  previous inconsistent state, consistent state with a non-default
1389  action, or user semantic action that manipulated yychar.
1390  - Of course, the expected token list depends on states to have
1391  correct lookahead information, and it depends on the parser not
1392  to perform extra reductions after fetching a lookahead from the
1393  scanner and before detecting a syntax error. Thus, state merging
1394  (from LALR or IELR) and default reductions corrupt the expected
1395  token list. However, the list is correct for canonical LR with
1396  one exception: it will still contain any token that will not be
1397  accepted due to an error action in a later state.
1398  */
1399  if (yytoken != YYEMPTY)
1400  {
1401  int yyn = yypact[*yyssp];
1402  yyarg[yycount++] = yytname[yytoken];
1403  if (!yypact_value_is_default (yyn))
1404  {
1405  /* Start YYX at -YYN if negative to avoid negative indexes in
1406  YYCHECK. In other words, skip the first -YYN actions for
1407  this state because they are default actions. */
1408  int yyxbegin = yyn < 0 ? -yyn : 0;
1409  /* Stay within bounds of both yycheck and yytname. */
1410  int yychecklim = YYLAST - yyn + 1;
1411  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1412  int yyx;
1413 
1414  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1415  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1416  && !yytable_value_is_error (yytable[yyx + yyn]))
1417  {
1418  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1419  {
1420  yycount = 1;
1421  yysize = yysize0;
1422  break;
1423  }
1424  yyarg[yycount++] = yytname[yyx];
1425  yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1426  if (! (yysize <= yysize1
1427  && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1428  return 2;
1429  yysize = yysize1;
1430  }
1431  }
1432  }
1433 
1434  switch (yycount)
1435  {
1436 # define YYCASE_(N, S) \
1437  case N: \
1438  yyformat = S; \
1439  break
1440  YYCASE_(0, YY_("syntax error"));
1441  YYCASE_(1, YY_("syntax error, unexpected %s"));
1442  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1443  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1444  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1445  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1446 # undef YYCASE_
1447  }
1448 
1449  yysize1 = yysize + yystrlen (yyformat);
1450  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1451  return 2;
1452  yysize = yysize1;
1453 
1454  if (*yymsg_alloc < yysize)
1455  {
1456  *yymsg_alloc = 2 * yysize;
1457  if (! (yysize <= *yymsg_alloc
1458  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1459  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1460  return 1;
1461  }
1462 
1463  /* Avoid sprintf, as that infringes on the user's name space.
1464  Don't have undefined behavior even if the translation
1465  produced a string with the wrong number of "%s"s. */
1466  {
1467  char *yyp = *yymsg;
1468  int yyi = 0;
1469  while ((*yyp = *yyformat) != '\0')
1470  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1471  {
1472  yyp += yytnamerr (yyp, yyarg[yyi++]);
1473  yyformat += 2;
1474  }
1475  else
1476  {
1477  yyp++;
1478  yyformat++;
1479  }
1480  }
1481  return 0;
1482 }
1483 #endif /* YYERROR_VERBOSE */
1484 
1485 /*-----------------------------------------------.
1486 | Release the memory associated to this symbol. |
1487 `-----------------------------------------------*/
1488 
1489 /*ARGSUSED*/
1490 #if (defined __STDC__ || defined __C99__FUNC__ \
1491  || defined __cplusplus || defined _MSC_VER)
1492 static void
1493 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
1494 #else
1495 static void
1496 yydestruct (yymsg, yytype, yyvaluep, yylocationp)
1497  const char *yymsg;
1498  int yytype;
1499  YYSTYPE *yyvaluep;
1500  YYLTYPE *yylocationp;
1501 #endif
1502 {
1503  YYUSE (yyvaluep);
1504  YYUSE (yylocationp);
1505 
1506  if (!yymsg)
1507  yymsg = "Deleting";
1508  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1509 
1510  switch (yytype)
1511  {
1512  case 4: /* "TOK_COLONCOLON" */
1513 
1514 /* Line 1391 of yacc.c */
1515 #line 368 "ast_expr2.y"
1516  { free_value((yyvaluep->val)); };
1517 
1518 /* Line 1391 of yacc.c */
1519 #line 1520 "ast_expr2.c"
1520  break;
1521  case 5: /* "TOK_COND" */
1522 
1523 /* Line 1391 of yacc.c */
1524 #line 368 "ast_expr2.y"
1525  { free_value((yyvaluep->val)); };
1526 
1527 /* Line 1391 of yacc.c */
1528 #line 1529 "ast_expr2.c"
1529  break;
1530  case 6: /* "TOK_OR" */
1531 
1532 /* Line 1391 of yacc.c */
1533 #line 368 "ast_expr2.y"
1534  { free_value((yyvaluep->val)); };
1535 
1536 /* Line 1391 of yacc.c */
1537 #line 1538 "ast_expr2.c"
1538  break;
1539  case 7: /* "TOK_AND" */
1540 
1541 /* Line 1391 of yacc.c */
1542 #line 368 "ast_expr2.y"
1543  { free_value((yyvaluep->val)); };
1544 
1545 /* Line 1391 of yacc.c */
1546 #line 1547 "ast_expr2.c"
1547  break;
1548  case 8: /* "TOK_NE" */
1549 
1550 /* Line 1391 of yacc.c */
1551 #line 368 "ast_expr2.y"
1552  { free_value((yyvaluep->val)); };
1553 
1554 /* Line 1391 of yacc.c */
1555 #line 1556 "ast_expr2.c"
1556  break;
1557  case 9: /* "TOK_LE" */
1558 
1559 /* Line 1391 of yacc.c */
1560 #line 368 "ast_expr2.y"
1561  { free_value((yyvaluep->val)); };
1562 
1563 /* Line 1391 of yacc.c */
1564 #line 1565 "ast_expr2.c"
1565  break;
1566  case 10: /* "TOK_GE" */
1567 
1568 /* Line 1391 of yacc.c */
1569 #line 368 "ast_expr2.y"
1570  { free_value((yyvaluep->val)); };
1571 
1572 /* Line 1391 of yacc.c */
1573 #line 1574 "ast_expr2.c"
1574  break;
1575  case 11: /* "TOK_LT" */
1576 
1577 /* Line 1391 of yacc.c */
1578 #line 368 "ast_expr2.y"
1579  { free_value((yyvaluep->val)); };
1580 
1581 /* Line 1391 of yacc.c */
1582 #line 1583 "ast_expr2.c"
1583  break;
1584  case 12: /* "TOK_GT" */
1585 
1586 /* Line 1391 of yacc.c */
1587 #line 368 "ast_expr2.y"
1588  { free_value((yyvaluep->val)); };
1589 
1590 /* Line 1391 of yacc.c */
1591 #line 1592 "ast_expr2.c"
1592  break;
1593  case 13: /* "TOK_EQ" */
1594 
1595 /* Line 1391 of yacc.c */
1596 #line 368 "ast_expr2.y"
1597  { free_value((yyvaluep->val)); };
1598 
1599 /* Line 1391 of yacc.c */
1600 #line 1601 "ast_expr2.c"
1601  break;
1602  case 14: /* "TOK_MINUS" */
1603 
1604 /* Line 1391 of yacc.c */
1605 #line 368 "ast_expr2.y"
1606  { free_value((yyvaluep->val)); };
1607 
1608 /* Line 1391 of yacc.c */
1609 #line 1610 "ast_expr2.c"
1610  break;
1611  case 15: /* "TOK_PLUS" */
1612 
1613 /* Line 1391 of yacc.c */
1614 #line 368 "ast_expr2.y"
1615  { free_value((yyvaluep->val)); };
1616 
1617 /* Line 1391 of yacc.c */
1618 #line 1619 "ast_expr2.c"
1619  break;
1620  case 16: /* "TOK_MOD" */
1621 
1622 /* Line 1391 of yacc.c */
1623 #line 368 "ast_expr2.y"
1624  { free_value((yyvaluep->val)); };
1625 
1626 /* Line 1391 of yacc.c */
1627 #line 1628 "ast_expr2.c"
1628  break;
1629  case 17: /* "TOK_DIV" */
1630 
1631 /* Line 1391 of yacc.c */
1632 #line 368 "ast_expr2.y"
1633  { free_value((yyvaluep->val)); };
1634 
1635 /* Line 1391 of yacc.c */
1636 #line 1637 "ast_expr2.c"
1637  break;
1638  case 18: /* "TOK_MULT" */
1639 
1640 /* Line 1391 of yacc.c */
1641 #line 368 "ast_expr2.y"
1642  { free_value((yyvaluep->val)); };
1643 
1644 /* Line 1391 of yacc.c */
1645 #line 1646 "ast_expr2.c"
1646  break;
1647  case 19: /* "TOK_COMPL" */
1648 
1649 /* Line 1391 of yacc.c */
1650 #line 368 "ast_expr2.y"
1651  { free_value((yyvaluep->val)); };
1652 
1653 /* Line 1391 of yacc.c */
1654 #line 1655 "ast_expr2.c"
1655  break;
1656  case 20: /* "TOK_TILDETILDE" */
1657 
1658 /* Line 1391 of yacc.c */
1659 #line 368 "ast_expr2.y"
1660  { free_value((yyvaluep->val)); };
1661 
1662 /* Line 1391 of yacc.c */
1663 #line 1664 "ast_expr2.c"
1664  break;
1665  case 21: /* "TOK_EQTILDE" */
1666 
1667 /* Line 1391 of yacc.c */
1668 #line 368 "ast_expr2.y"
1669  { free_value((yyvaluep->val)); };
1670 
1671 /* Line 1391 of yacc.c */
1672 #line 1673 "ast_expr2.c"
1673  break;
1674  case 22: /* "TOK_COLON" */
1675 
1676 /* Line 1391 of yacc.c */
1677 #line 368 "ast_expr2.y"
1678  { free_value((yyvaluep->val)); };
1679 
1680 /* Line 1391 of yacc.c */
1681 #line 1682 "ast_expr2.c"
1682  break;
1683  case 23: /* "TOK_LP" */
1684 
1685 /* Line 1391 of yacc.c */
1686 #line 368 "ast_expr2.y"
1687  { free_value((yyvaluep->val)); };
1688 
1689 /* Line 1391 of yacc.c */
1690 #line 1691 "ast_expr2.c"
1691  break;
1692  case 24: /* "TOK_RP" */
1693 
1694 /* Line 1391 of yacc.c */
1695 #line 368 "ast_expr2.y"
1696  { free_value((yyvaluep->val)); };
1697 
1698 /* Line 1391 of yacc.c */
1699 #line 1700 "ast_expr2.c"
1700  break;
1701  case 25: /* "TOKEN" */
1702 
1703 /* Line 1391 of yacc.c */
1704 #line 368 "ast_expr2.y"
1705  { free_value((yyvaluep->val)); };
1706 
1707 /* Line 1391 of yacc.c */
1708 #line 1709 "ast_expr2.c"
1709  break;
1710  case 29: /* "expr" */
1711 
1712 /* Line 1391 of yacc.c */
1713 #line 368 "ast_expr2.y"
1714  { free_value((yyvaluep->val)); };
1715 
1716 /* Line 1391 of yacc.c */
1717 #line 1718 "ast_expr2.c"
1718  break;
1719 
1720  default:
1721  break;
1722  }
1723 }
1724 
1725 
1726 /* Prevent warnings from -Wmissing-prototypes. */
1727 #ifdef YYPARSE_PARAM
1728 #if defined __STDC__ || defined __cplusplus
1729 int yyparse (void *YYPARSE_PARAM);
1730 #else
1731 int yyparse ();
1732 #endif
1733 #else /* ! YYPARSE_PARAM */
1734 #if defined __STDC__ || defined __cplusplus
1735 int yyparse (void);
1736 #else
1737 int yyparse ();
1738 #endif
1739 #endif /* ! YYPARSE_PARAM */
1740 
1741 
1742 /*----------.
1743 | yyparse. |
1744 `----------*/
1745 
1746 #ifdef YYPARSE_PARAM
1747 #if (defined __STDC__ || defined __C99__FUNC__ \
1748  || defined __cplusplus || defined _MSC_VER)
1749 int
1750 yyparse (void *YYPARSE_PARAM)
1751 #else
1752 int
1753 yyparse (YYPARSE_PARAM)
1754  void *YYPARSE_PARAM;
1755 #endif
1756 #else /* ! YYPARSE_PARAM */
1757 #if (defined __STDC__ || defined __C99__FUNC__ \
1758  || defined __cplusplus || defined _MSC_VER)
1759 int
1760 yyparse (void)
1761 #else
1762 int
1763 yyparse ()
1764 
1765 #endif
1766 #endif
1768 /* The lookahead symbol. */
1769 int yychar;
1770 
1771 /* The semantic value of the lookahead symbol. */
1772 YYSTYPE yylval;
1773 
1774 /* Location data for the lookahead symbol. */
1776 
1777  /* Number of syntax errors so far. */
1778  int yynerrs;
1779 
1780  int yystate;
1781  /* Number of tokens to shift before error messages enabled. */
1783 
1784  /* The stacks and their tools:
1785  `yyss': related to states.
1786  `yyvs': related to semantic values.
1787  `yyls': related to locations.
1788 
1789  Refer to the stacks thru separate pointers, to allow yyoverflow
1790  to reallocate them elsewhere. */
1791 
1792  /* The state stack. */
1793  yytype_int16 yyssa[YYINITDEPTH];
1794  yytype_int16 *yyss;
1795  yytype_int16 *yyssp;
1796 
1797  /* The semantic value stack. */
1801 
1802  /* The location stack. */
1806 
1807  /* The locations where the error started and ended. */
1809 
1811 
1812  int yyn;
1814  /* Lookahead token as an internal (translated) token number. */
1815  int yytoken;
1816  /* The variables used to return semantic value and location from the
1817  action routines. */
1820 
1821 #if YYERROR_VERBOSE
1822  /* Buffer for error messages, and its allocated size. */
1823  char yymsgbuf[128];
1824  char *yymsg = yymsgbuf;
1826 #endif
1827 
1828 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1829 
1830  /* The number of symbols on the RHS of the reduced rule.
1831  Keep to zero when no symbol should be popped. */
1832  int yylen = 0;
1833 
1834  yytoken = 0;
1835  yyss = yyssa;
1836  yyvs = yyvsa;
1837  yyls = yylsa;
1838  yystacksize = YYINITDEPTH;
1839 
1840  YYDPRINTF ((stderr, "Starting parse\n"));
1841 
1842  yystate = 0;
1843  yyerrstatus = 0;
1844  yynerrs = 0;
1845  yychar = YYEMPTY; /* Cause a token to be read. */
1846 
1847  /* Initialize stack pointers.
1848  Waste one element of value and location stack
1849  so that they stay on the same level as the state stack.
1850  The wasted elements are never initialized. */
1851  yyssp = yyss;
1852  yyvsp = yyvs;
1853  yylsp = yyls;
1854 
1855 #if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1856  /* Initialize the default location before parsing starts. */
1857  yylloc.first_line = yylloc.last_line = 1;
1858  yylloc.first_column = yylloc.last_column = 1;
1859 #endif
1860 
1862 
1863 /*------------------------------------------------------------.
1864 | yynewstate -- Push a new state, which is found in yystate. |
1865 `------------------------------------------------------------*/
1866  yynewstate:
1867  /* In all cases, when you get here, the value and location stacks
1868  have just been pushed. So pushing a state here evens the stacks. */
1869  yyssp++;
1870 
1871  yysetstate:
1872  *yyssp = yystate;
1873 
1874  if (yyss + yystacksize - 1 <= yyssp)
1875  {
1876  /* Get the current used size of the three stacks, in elements. */
1877  YYSIZE_T yysize = yyssp - yyss + 1;
1878 
1879 #ifdef yyoverflow
1880  {
1881  /* Give user a chance to reallocate the stack. Use copies of
1882  these so that the &'s don't force the real ones into
1883  memory. */
1884  YYSTYPE *yyvs1 = yyvs;
1885  yytype_int16 *yyss1 = yyss;
1886  YYLTYPE *yyls1 = yyls;
1887 
1888  /* Each stack pointer address is followed by the size of the
1889  data in use in that stack, in bytes. This used to be a
1890  conditional around just the two extra args, but that might
1891  be undefined if yyoverflow is a macro. */
1892  yyoverflow (YY_("memory exhausted"),
1893  &yyss1, yysize * sizeof (*yyssp),
1894  &yyvs1, yysize * sizeof (*yyvsp),
1895  &yyls1, yysize * sizeof (*yylsp),
1896  &yystacksize);
1897 
1898  yyls = yyls1;
1899  yyss = yyss1;
1900  yyvs = yyvs1;
1901  }
1902 #else /* no yyoverflow */
1903 # ifndef YYSTACK_RELOCATE
1904  goto yyexhaustedlab;
1905 # else
1906  /* Extend the stack our own way. */
1907  if (YYMAXDEPTH <= yystacksize)
1908  goto yyexhaustedlab;
1909  yystacksize *= 2;
1910  if (YYMAXDEPTH < yystacksize)
1911  yystacksize = YYMAXDEPTH;
1912 
1913  {
1914  yytype_int16 *yyss1 = yyss;
1915  union yyalloc *yyptr =
1916  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1917  if (! yyptr)
1918  goto yyexhaustedlab;
1919  YYSTACK_RELOCATE (yyss_alloc, yyss);
1920  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1921  YYSTACK_RELOCATE (yyls_alloc, yyls);
1922 # undef YYSTACK_RELOCATE
1923  if (yyss1 != yyssa)
1924  YYSTACK_FREE (yyss1);
1925  }
1926 # endif
1927 #endif /* no yyoverflow */
1928 
1929  yyssp = yyss + yysize - 1;
1930  yyvsp = yyvs + yysize - 1;
1931  yylsp = yyls + yysize - 1;
1932 
1933  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1934  (unsigned long int) yystacksize));
1935 
1936  if (yyss + yystacksize - 1 <= yyssp)
1937  YYABORT;
1938  }
1939 
1940  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1941 
1942  if (yystate == YYFINAL)
1944 
1945  goto yybackup;
1946 
1947 /*-----------.
1948 | yybackup. |
1949 `-----------*/
1950 yybackup:
1951 
1952  /* Do appropriate processing given the current state. Read a
1953  lookahead token if we need one and don't already have one. */
1954 
1955  /* First try to decide what to do without reference to lookahead token. */
1956  yyn = yypact[yystate];
1957  if (yypact_value_is_default (yyn))
1959 
1960  /* Not known => get a lookahead token if don't already have one. */
1961 
1962  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1963  if (yychar == YYEMPTY)
1964  {
1965  YYDPRINTF ((stderr, "Reading a token: "));
1966  yychar = YYLEX;
1967  }
1968 
1969  if (yychar <= YYEOF)
1970  {
1971  yychar = yytoken = YYEOF;
1972  YYDPRINTF ((stderr, "Now at end of input.\n"));
1973  }
1974  else
1975  {
1976  yytoken = YYTRANSLATE (yychar);
1977  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1978  }
1979 
1980  /* If the proper action on seeing token YYTOKEN is to reduce or to
1981  detect an error, take that action. */
1982  yyn += yytoken;
1983  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1984  goto yydefault;
1985  yyn = yytable[yyn];
1986  if (yyn <= 0)
1987  {
1988  if (yytable_value_is_error (yyn))
1989  goto yyerrlab;
1990  yyn = -yyn;
1991  goto yyreduce;
1992  }
1993 
1994  /* Count tokens shifted since error; after three, turn off error
1995  status. */
1996  if (yyerrstatus)
1997  yyerrstatus--;
1998 
1999  /* Shift the lookahead token. */
2000  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
2001 
2002  /* Discard the shifted token. */
2003  yychar = YYEMPTY;
2004 
2005  yystate = yyn;
2006  *++yyvsp = yylval;
2007  *++yylsp = yylloc;
2009 
2010 
2011 /*-----------------------------------------------------------.
2012 | yydefault -- do the default action for the current state. |
2013 `-----------------------------------------------------------*/
2014 yydefault:
2015  yyn = yydefact[yystate];
2016  if (yyn == 0)
2017  goto yyerrlab;
2018  goto yyreduce;
2019 
2020 
2021 /*-----------------------------.
2022 | yyreduce -- Do a reduction. |
2023 `-----------------------------*/
2024 yyreduce:
2025  /* yyn is the number of a rule to reduce with. */
2026  yylen = yyr2[yyn];
2027 
2028  /* If YYLEN is nonzero, implement the default value of the action:
2029  `$$ = $1'.
2030 
2031  Otherwise, the following line sets YYVAL to garbage.
2032  This behavior is undocumented and Bison
2033  users should not rely upon it. Assigning to YYVAL
2034  unconditionally makes the parser a bit smaller, and it avoids a
2035  GCC warning that YYVAL may be used uninitialized. */
2036  yyval = yyvsp[1-yylen];
2037 
2038  /* Default location. */
2039  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
2040  YY_REDUCE_PRINT (yyn);
2041  switch (yyn)
2042  {
2043  case 2:
2044 
2045 /* Line 1806 of yacc.c */
2046 #line 374 "ast_expr2.y"
2047  { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
2048  ((struct parse_io *)parseio)->val->type = (yyvsp[(1) - (1)].val)->type;
2049  if( (yyvsp[(1) - (1)].val)->type == AST_EXPR_number )
2050  ((struct parse_io *)parseio)->val->u.i = (yyvsp[(1) - (1)].val)->u.i;
2051  else
2052  ((struct parse_io *)parseio)->val->u.s = (yyvsp[(1) - (1)].val)->u.s;
2053  free((yyvsp[(1) - (1)].val));
2054  }
2055  break;
2056 
2057  case 3:
2058 
2059 /* Line 1806 of yacc.c */
2060 #line 382 "ast_expr2.y"
2061  {/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
2062  ((struct parse_io *)parseio)->val->type = AST_EXPR_string;
2063  ((struct parse_io *)parseio)->val->u.s = strdup("");
2064  }
2065  break;
2066 
2067  case 4:
2068 
2069 /* Line 1806 of yacc.c */
2070 #line 389 "ast_expr2.y"
2071  { (yyval.arglist) = alloc_expr_node(AST_EXPR_NODE_VAL); (yyval.arglist)->val = (yyvsp[(1) - (1)].val);}
2072  break;
2073 
2074  case 5:
2075 
2076 /* Line 1806 of yacc.c */
2077 #line 390 "ast_expr2.y"
2079  struct expr_node *t;
2080  DESTROY((yyvsp[(2) - (3)].val));
2081  for (t=(yyvsp[(1) - (3)].arglist);t->right;t=t->right)
2082  ;
2083  (yyval.arglist) = (yyvsp[(1) - (3)].arglist); t->right = x; x->val = (yyvsp[(3) - (3)].val);}
2084  break;
2085 
2086  case 6:
2087 
2088 /* Line 1806 of yacc.c */
2089 #line 396 "ast_expr2.y"
2091  struct expr_node *t; /* NULL args should OK */
2092  DESTROY((yyvsp[(2) - (2)].val));
2093  for (t=(yyvsp[(1) - (2)].arglist);t->right;t=t->right)
2094  ;
2095  (yyval.arglist) = (yyvsp[(1) - (2)].arglist); t->right = x; x->val = make_str("");}
2096  break;
2097 
2098  case 7:
2099 
2100 /* Line 1806 of yacc.c */
2101 #line 405 "ast_expr2.y"
2102  { (yyval.val) = op_func((yyvsp[(1) - (4)].val),(yyvsp[(3) - (4)].arglist), ((struct parse_io *)parseio)->chan);
2103  DESTROY((yyvsp[(2) - (4)].val));
2104  DESTROY((yyvsp[(4) - (4)].val));
2105  DESTROY((yyvsp[(1) - (4)].val));
2106  destroy_arglist((yyvsp[(3) - (4)].arglist));
2107  }
2108  break;
2109 
2110  case 8:
2111 
2112 /* Line 1806 of yacc.c */
2113 #line 411 "ast_expr2.y"
2114  {(yyval.val) = (yyvsp[(1) - (1)].val);}
2115  break;
2116 
2117  case 9:
2118 
2119 /* Line 1806 of yacc.c */
2120 #line 412 "ast_expr2.y"
2121  { (yyval.val) = (yyvsp[(2) - (3)].val);
2122  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2123  (yyloc).first_line=0; (yyloc).last_line=0;
2124  DESTROY((yyvsp[(1) - (3)].val)); DESTROY((yyvsp[(3) - (3)].val)); }
2125  break;
2126 
2127  case 10:
2128 
2129 /* Line 1806 of yacc.c */
2130 #line 416 "ast_expr2.y"
2131  { (yyval.val) = op_or ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2132  DESTROY((yyvsp[(2) - (3)].val));
2133  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2134  (yyloc).first_line=0; (yyloc).last_line=0;}
2135  break;
2136 
2137  case 11:
2138 
2139 /* Line 1806 of yacc.c */
2140 #line 420 "ast_expr2.y"
2141  { (yyval.val) = op_and ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2142  DESTROY((yyvsp[(2) - (3)].val));
2143  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2144  (yyloc).first_line=0; (yyloc).last_line=0;}
2145  break;
2146 
2147  case 12:
2148 
2149 /* Line 1806 of yacc.c */
2150 #line 424 "ast_expr2.y"
2151  { (yyval.val) = op_eq ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2152  DESTROY((yyvsp[(2) - (3)].val));
2153  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2154  (yyloc).first_line=0; (yyloc).last_line=0;}
2155  break;
2156 
2157  case 13:
2158 
2159 /* Line 1806 of yacc.c */
2160 #line 428 "ast_expr2.y"
2161  { (yyval.val) = op_gt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2162  DESTROY((yyvsp[(2) - (3)].val));
2163  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2164  (yyloc).first_line=0; (yyloc).last_line=0;}
2165  break;
2166 
2167  case 14:
2168 
2169 /* Line 1806 of yacc.c */
2170 #line 432 "ast_expr2.y"
2171  { (yyval.val) = op_lt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2172  DESTROY((yyvsp[(2) - (3)].val));
2173  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2174  (yyloc).first_line=0; (yyloc).last_line=0;}
2175  break;
2176 
2177  case 15:
2178 
2179 /* Line 1806 of yacc.c */
2180 #line 436 "ast_expr2.y"
2181  { (yyval.val) = op_ge ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2182  DESTROY((yyvsp[(2) - (3)].val));
2183  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2184  (yyloc).first_line=0; (yyloc).last_line=0;}
2185  break;
2186 
2187  case 16:
2188 
2189 /* Line 1806 of yacc.c */
2190 #line 440 "ast_expr2.y"
2191  { (yyval.val) = op_le ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2192  DESTROY((yyvsp[(2) - (3)].val));
2193  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2194  (yyloc).first_line=0; (yyloc).last_line=0;}
2195  break;
2196 
2197  case 17:
2198 
2199 /* Line 1806 of yacc.c */
2200 #line 444 "ast_expr2.y"
2201  { (yyval.val) = op_ne ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2202  DESTROY((yyvsp[(2) - (3)].val));
2203  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2204  (yyloc).first_line=0; (yyloc).last_line=0;}
2205  break;
2206 
2207  case 18:
2208 
2209 /* Line 1806 of yacc.c */
2210 #line 448 "ast_expr2.y"
2211  { (yyval.val) = op_plus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2212  DESTROY((yyvsp[(2) - (3)].val));
2213  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2214  (yyloc).first_line=0; (yyloc).last_line=0;}
2215  break;
2216 
2217  case 19:
2218 
2219 /* Line 1806 of yacc.c */
2220 #line 452 "ast_expr2.y"
2221  { (yyval.val) = op_minus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2222  DESTROY((yyvsp[(2) - (3)].val));
2223  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2224  (yyloc).first_line=0; (yyloc).last_line=0;}
2225  break;
2226 
2227  case 20:
2228 
2229 /* Line 1806 of yacc.c */
2230 #line 456 "ast_expr2.y"
2231  { (yyval.val) = op_negate ((yyvsp[(2) - (2)].val));
2232  DESTROY((yyvsp[(1) - (2)].val));
2233  (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column;
2234  (yyloc).first_line=0; (yyloc).last_line=0;}
2235  break;
2236 
2237  case 21:
2238 
2239 /* Line 1806 of yacc.c */
2240 #line 460 "ast_expr2.y"
2241  { (yyval.val) = op_compl ((yyvsp[(2) - (2)].val));
2242  DESTROY((yyvsp[(1) - (2)].val));
2243  (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column;
2244  (yyloc).first_line=0; (yyloc).last_line=0;}
2245  break;
2246 
2247  case 22:
2248 
2249 /* Line 1806 of yacc.c */
2250 #line 464 "ast_expr2.y"
2251  { (yyval.val) = op_times ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2252  DESTROY((yyvsp[(2) - (3)].val));
2253  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2254  (yyloc).first_line=0; (yyloc).last_line=0;}
2255  break;
2256 
2257  case 23:
2258 
2259 /* Line 1806 of yacc.c */
2260 #line 468 "ast_expr2.y"
2261  { (yyval.val) = op_div ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2262  DESTROY((yyvsp[(2) - (3)].val));
2263  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2264  (yyloc).first_line=0; (yyloc).last_line=0;}
2265  break;
2266 
2267  case 24:
2268 
2269 /* Line 1806 of yacc.c */
2270 #line 472 "ast_expr2.y"
2271  { (yyval.val) = op_rem ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2272  DESTROY((yyvsp[(2) - (3)].val));
2273  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2274  (yyloc).first_line=0; (yyloc).last_line=0;}
2275  break;
2276 
2277  case 25:
2278 
2279 /* Line 1806 of yacc.c */
2280 #line 476 "ast_expr2.y"
2281  { (yyval.val) = op_colon ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2282  DESTROY((yyvsp[(2) - (3)].val));
2283  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2284  (yyloc).first_line=0; (yyloc).last_line=0;}
2285  break;
2286 
2287  case 26:
2288 
2289 /* Line 1806 of yacc.c */
2290 #line 480 "ast_expr2.y"
2291  { (yyval.val) = op_eqtilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2292  DESTROY((yyvsp[(2) - (3)].val));
2293  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2294  (yyloc).first_line=0; (yyloc).last_line=0;}
2295  break;
2296 
2297  case 27:
2298 
2299 /* Line 1806 of yacc.c */
2300 #line 484 "ast_expr2.y"
2301  { (yyval.val) = op_cond ((yyvsp[(1) - (5)].val), (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val));
2302  DESTROY((yyvsp[(2) - (5)].val));
2303  DESTROY((yyvsp[(4) - (5)].val));
2304  (yyloc).first_column = (yylsp[(1) - (5)]).first_column; (yyloc).last_column = (yylsp[(3) - (5)]).last_column;
2305  (yyloc).first_line=0; (yyloc).last_line=0;}
2306  break;
2307 
2308  case 28:
2309 
2310 /* Line 1806 of yacc.c */
2311 #line 489 "ast_expr2.y"
2312  { (yyval.val) = op_tildetilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2313  DESTROY((yyvsp[(2) - (3)].val));
2314  (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2315  (yyloc).first_line=0; (yyloc).last_line=0;}
2316  break;
2317 
2318 
2319 
2320 /* Line 1806 of yacc.c */
2321 #line 2322 "ast_expr2.c"
2322  default: break;
2323  }
2324  /* User semantic actions sometimes alter yychar, and that requires
2325  that yytoken be updated with the new translation. We take the
2326  approach of translating immediately before every use of yytoken.
2327  One alternative is translating here after every semantic action,
2328  but that translation would be missed if the semantic action invokes
2329  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2330  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2331  incorrect destructor might then be invoked immediately. In the
2332  case of YYERROR or YYBACKUP, subsequent parser actions might lead
2333  to an incorrect destructor call or verbose syntax error message
2334  before the lookahead is translated. */
2335  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2336 
2337  YYPOPSTACK (yylen);
2338  yylen = 0;
2339  YY_STACK_PRINT (yyss, yyssp);
2340 
2341  *++yyvsp = yyval;
2342  *++yylsp = yyloc;
2343 
2344  /* Now `shift' the result of the reduction. Determine what state
2345  that goes to, based on the state we popped back to and the rule
2346  number reduced by. */
2347 
2348  yyn = yyr1[yyn];
2349 
2350  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2351  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2352  yystate = yytable[yystate];
2353  else
2354  yystate = yydefgoto[yyn - YYNTOKENS];
2355 
2356  goto yynewstate;
2357 
2358 
2359 /*------------------------------------.
2360 | yyerrlab -- here on detecting error |
2361 `------------------------------------*/
2362 yyerrlab:
2363  /* Make sure we have latest lookahead translation. See comments at
2364  user semantic actions for why this is necessary. */
2365  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2366 
2367  /* If not already recovering from an error, report this error. */
2368  if (!yyerrstatus)
2369  {
2370  ++yynerrs;
2371 #if ! YYERROR_VERBOSE
2372  yyerror (YY_("syntax error"));
2373 #else
2374 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2375  yyssp, yytoken)
2376  {
2377  char const *yymsgp = YY_("syntax error");
2378  int yysyntax_error_status;
2379  yysyntax_error_status = YYSYNTAX_ERROR;
2380  if (yysyntax_error_status == 0)
2381  yymsgp = yymsg;
2382  else if (yysyntax_error_status == 1)
2383  {
2384  if (yymsg != yymsgbuf)
2385  YYSTACK_FREE (yymsg);
2386  yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2387  if (!yymsg)
2388  {
2389  yymsg = yymsgbuf;
2390  yymsg_alloc = sizeof yymsgbuf;
2391  yysyntax_error_status = 2;
2392  }
2393  else
2394  {
2395  yysyntax_error_status = YYSYNTAX_ERROR;
2396  yymsgp = yymsg;
2397  }
2398  }
2399  yyerror (yymsgp);
2400  if (yysyntax_error_status == 2)
2401  goto yyexhaustedlab;
2402  }
2403 # undef YYSYNTAX_ERROR
2404 #endif
2405  }
2406 
2407  yyerror_range[1] = yylloc;
2408 
2409  if (yyerrstatus == 3)
2410  {
2411  /* If just tried and failed to reuse lookahead token after an
2412  error, discard it. */
2413 
2414  if (yychar <= YYEOF)
2415  {
2416  /* Return failure if at end of input. */
2417  if (yychar == YYEOF)
2418  YYABORT;
2419  }
2420  else
2421  {
2422  yydestruct ("Error: discarding",
2423  yytoken, &yylval, &yylloc);
2424  yychar = YYEMPTY;
2425  }
2426  }
2427 
2428  /* Else will try to reuse lookahead token after shifting the error
2429  token. */
2431 
2432 
2433 /*---------------------------------------------------.
2434 | yyerrorlab -- error raised explicitly by YYERROR. |
2435 `---------------------------------------------------*/
2436 yyerrorlab:
2437 
2438  /* Pacify compilers like GCC when the user code never invokes
2439  YYERROR and the label yyerrorlab therefore never appears in user
2440  code. */
2441  if (/*CONSTCOND*/ 0)
2442  goto yyerrorlab;
2443 
2444  yyerror_range[1] = yylsp[1-yylen];
2445  /* Do not reclaim the symbols of the rule which action triggered
2446  this YYERROR. */
2447  YYPOPSTACK (yylen);
2448  yylen = 0;
2449  YY_STACK_PRINT (yyss, yyssp);
2450  yystate = *yyssp;
2451  goto yyerrlab1;
2452 
2453 
2454 /*-------------------------------------------------------------.
2455 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2456 `-------------------------------------------------------------*/
2457 yyerrlab1:
2458  yyerrstatus = 3; /* Each real token shifted decrements this. */
2459 
2460  for (;;)
2461  {
2462  yyn = yypact[yystate];
2463  if (!yypact_value_is_default (yyn))
2464  {
2465  yyn += YYTERROR;
2466  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2467  {
2468  yyn = yytable[yyn];
2469  if (0 < yyn)
2470  break;
2471  }
2472  }
2473 
2474  /* Pop the current state because it cannot handle the error token. */
2475  if (yyssp == yyss)
2476  YYABORT;
2477 
2478  yyerror_range[1] = *yylsp;
2479  yydestruct ("Error: popping",
2480  yystos[yystate], yyvsp, yylsp);
2481  YYPOPSTACK (1);
2482  yystate = *yyssp;
2483  YY_STACK_PRINT (yyss, yyssp);
2484  }
2485 
2486  *++yyvsp = yylval;
2487 
2488  yyerror_range[2] = yylloc;
2489  /* Using YYLLOC is tempting, but would change the location of
2490  the lookahead. YYLOC is available though. */
2491  YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
2492  *++yylsp = yyloc;
2493 
2494  /* Shift the error token. */
2495  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2496 
2497  yystate = yyn;
2498  goto yynewstate;
2499 
2500 
2501 /*-------------------------------------.
2502 | yyacceptlab -- YYACCEPT comes here. |
2503 `-------------------------------------*/
2504 yyacceptlab:
2505  yyresult = 0;
2506  goto yyreturn;
2507 
2508 /*-----------------------------------.
2509 | yyabortlab -- YYABORT comes here. |
2510 `-----------------------------------*/
2511 yyabortlab:
2512  yyresult = 1;
2513  goto yyreturn;
2514 
2515 #if !defined(yyoverflow) || YYERROR_VERBOSE
2516 /*-------------------------------------------------.
2517 | yyexhaustedlab -- memory exhaustion comes here. |
2518 `-------------------------------------------------*/
2519 yyexhaustedlab:
2520  yyerror (YY_("memory exhausted"));
2521  yyresult = 2;
2522  /* Fall through. */
2523 #endif
2524 
2525 yyreturn:
2526  if (yychar != YYEMPTY)
2527  {
2528  /* Make sure we have latest lookahead translation. See comments at
2529  user semantic actions for why this is necessary. */
2530  yytoken = YYTRANSLATE (yychar);
2531  yydestruct ("Cleanup: discarding lookahead",
2532  yytoken, &yylval, &yylloc);
2533  }
2534  /* Do not reclaim the symbols of the rule which action triggered
2535  this YYABORT or YYACCEPT. */
2536  YYPOPSTACK (yylen);
2537  YY_STACK_PRINT (yyss, yyssp);
2538  while (yyssp != yyss)
2539  {
2540  yydestruct ("Cleanup: popping",
2541  yystos[*yyssp], yyvsp, yylsp);
2542  YYPOPSTACK (1);
2543  }
2544 #ifndef yyoverflow
2545  if (yyss != yyssa)
2546  YYSTACK_FREE (yyss);
2547 #endif
2548 #if YYERROR_VERBOSE
2549  if (yymsg != yymsgbuf)
2550  YYSTACK_FREE (yymsg);
2551 #endif
2552  /* Make sure YYID is used. */
2553  return YYID (yyresult);
2554 }
2555 
2556 
2557 
2558 /* Line 2067 of yacc.c */
2559 #line 495 "ast_expr2.y"
2560 
2561 
2562 static struct expr_node *alloc_expr_node(enum node_type nt)
2563 {
2564  struct expr_node *x = calloc(1,sizeof(struct expr_node));
2565  if (!x) {
2566  ast_log(LOG_ERROR, "Allocation for expr_node FAILED!!\n");
2567  return 0;
2568  }
2569  x->type = nt;
2570  return x;
2571 }
2572 
2573 
2574 
2575 static struct val *
2577 {
2578  struct val *vp;
2579 
2580  vp = (struct val *) malloc (sizeof (*vp));
2581  if (vp == NULL) {
2582  ast_log(LOG_WARNING, "malloc() failed\n");
2583  return(NULL);
2584  }
2585 
2586  vp->type = AST_EXPR_number;
2587  vp->u.i = i;
2588  return vp;
2589 }
2590 
2591 static struct val *
2592 make_str (const char *s)
2593 {
2594  struct val *vp;
2595  size_t i;
2596  int isint; /* this started out being a test for an integer, but then ended up being a test for a float */
2597 
2598  vp = (struct val *) malloc (sizeof (*vp));
2599  if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) {
2600  if (vp) {
2601  free(vp);
2602  }
2603  ast_log(LOG_WARNING,"malloc() failed\n");
2604  return(NULL);
2605  }
2606 
2607  for (i = 0, isint = (isdigit(s[0]) || s[0] == '-' || s[0]=='.'); isint && i < strlen(s); i++)
2608  {
2609  if (!isdigit(s[i]) && s[i] != '.') {
2610  isint = 0;
2611  break;
2612  }
2613  }
2614  if (isint)
2616  else
2617  vp->type = AST_EXPR_string;
2618 
2619  return vp;
2620 }
2621 
2622 
2623 static void
2624 free_value (struct val *vp)
2625 {
2626  if (vp==NULL) {
2627  return;
2628  }
2629  if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
2630  free (vp->u.s);
2631  free(vp);
2632 }
2633 
2634 
2635 static int
2636 to_number (struct val *vp)
2637 {
2638  FP___TYPE i;
2639 
2640  if (vp == NULL) {
2641  ast_log(LOG_WARNING,"vp==NULL in to_number()\n");
2642  return(0);
2643  }
2644 
2645  if (vp->type == AST_EXPR_number)
2646  return 1;
2647 
2648  if (vp->type == AST_EXPR_string)
2649  return 0;
2650 
2651  /* vp->type == AST_EXPR_numeric_string, make it numeric */
2652  errno = 0;
2653  i = FUNC_STRTOD(vp->u.s, (char**)0); /* either strtod, or strtold on a good day */
2654  if (errno != 0) {
2655  ast_log(LOG_WARNING,"Conversion of %s to number under/overflowed!\n", vp->u.s);
2656  free(vp->u.s);
2657  vp->u.s = 0;
2658  return(0);
2659  }
2660  free (vp->u.s);
2661  vp->u.i = i;
2662  vp->type = AST_EXPR_number;
2663  return 1;
2664 }
2665 
2666 static void
2667 strip_quotes(struct val *vp)
2668 {
2669  if (vp->type != AST_EXPR_string && vp->type != AST_EXPR_numeric_string)
2670  return;
2671 
2672  if( vp->u.s[0] == '"' && vp->u.s[strlen(vp->u.s)-1] == '"' )
2673  {
2674  char *f, *t;
2675  f = vp->u.s;
2676  t = vp->u.s;
2677 
2678  while( *f )
2679  {
2680  if( *f && *f != '"' )
2681  *t++ = *f++;
2682  else
2683  f++;
2684  }
2685  *t = *f;
2686  }
2687 }
2688 
2689 static void
2690 to_string (struct val *vp)
2691 {
2692  char *tmp;
2693 
2694  if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
2695  return;
2696 
2697  tmp = malloc ((size_t)25);
2698  if (tmp == NULL) {
2699  ast_log(LOG_WARNING,"malloc() failed\n");
2700  return;
2701  }
2702 
2703  sprintf(tmp, FP___PRINTF, vp->u.i);
2704  vp->type = AST_EXPR_string;
2705  vp->u.s = tmp;
2706 }
2707 
2708 
2709 static int
2710 isstring (struct val *vp)
2711 {
2712  /* only TRUE if this string is not a valid number */
2713  return (vp->type == AST_EXPR_string);
2714 }
2715 
2716 
2717 static int
2718 is_zero_or_null (struct val *vp)
2719 {
2720  if (vp->type == AST_EXPR_number) {
2721  return (vp->u.i == 0);
2722  } else {
2723  return (*vp->u.s == 0 || (to_number(vp) && vp->u.i == 0));
2724  }
2725  /* NOTREACHED */
2726 }
2727 
2728 #ifdef STANDALONE2
2729 
2730 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
2731 {
2732  va_list vars;
2733  va_start(vars,fmt);
2734 
2735  printf("LOG: lev:%d file:%s line:%d func: %s ",
2736  level, file, line, function);
2737  vprintf(fmt, vars);
2738  fflush(stdout);
2739  va_end(vars);
2740 }
2741 
2742 
2743 int main(int argc,char **argv) {
2744  char s[4096];
2745  char out[4096];
2746  FILE *infile;
2747 
2748  if( !argv[1] )
2749  exit(20);
2750 
2751  if( access(argv[1],F_OK)== 0 )
2752  {
2753  int ret;
2754 
2755  infile = fopen(argv[1],"r");
2756  if( !infile )
2757  {
2758  printf("Sorry, couldn't open %s for reading!\n", argv[1]);
2759  exit(10);
2760  }
2761  while( fgets(s,sizeof(s),infile) )
2762  {
2763  if( s[strlen(s)-1] == '\n' )
2764  s[strlen(s)-1] = 0;
2765 
2766  ret = ast_expr(s, out, sizeof(out), NULL);
2767  printf("Expression: %s Result: [%d] '%s'\n",
2768  s, ret, out);
2769  }
2770  fclose(infile);
2771  }
2772  else
2773  {
2774  if (ast_expr(argv[1], s, sizeof(s), NULL))
2775  printf("=====%s======\n",s);
2776  else
2777  printf("No result\n");
2778  }
2779  return 0;
2780 }
2781 
2782 #endif
2783 
2784 #undef ast_yyerror
2785 #define ast_yyerror(x) ast_yyerror(x, YYLTYPE *yylloc, struct parse_io *parseio)
2786 
2787 /* I put the ast_yyerror func in the flex input file,
2788  because it refers to the buffer state. Best to
2789  let it access the BUFFER stuff there and not trying
2790  define all the structs, macros etc. in this file! */
2791 
2792 static void destroy_arglist(struct expr_node *arglist)
2793 {
2794  struct expr_node *arglist_next;
2795 
2796  while (arglist)
2797  {
2798  arglist_next = arglist->right;
2799  if (arglist->val)
2800  free_value(arglist->val);
2801  arglist->val = 0;
2802  arglist->right = 0;
2803  free(arglist);
2804  arglist = arglist_next;
2805  }
2806 }
2807 
2808 #if !defined(STANDALONE) && !defined(STANDALONE2)
2809 static char *compose_func_args(struct expr_node *arglist)
2810 {
2811  struct expr_node *t = arglist;
2812  char *argbuf;
2813  int total_len = 0;
2814 
2815  while (t) {
2816  if (t != arglist)
2817  total_len += 1; /* for the sep */
2818  if (t->val) {
2819  if (t->val->type == AST_EXPR_number)
2820  total_len += 25; /* worst case */
2821  else
2822  total_len += strlen(t->val->u.s);
2823  }
2824 
2825  t = t->right;
2826  }
2827  total_len++; /* for the null */
2828  ast_log(LOG_NOTICE,"argbuf allocated %d bytes;\n", total_len);
2829  argbuf = malloc(total_len);
2830  argbuf[0] = 0;
2831  t = arglist;
2832  while (t) {
2833  char numbuf[30];
2834 
2835  if (t != arglist)
2836  strcat(argbuf,",");
2837 
2838  if (t->val) {
2839  if (t->val->type == AST_EXPR_number) {
2840  sprintf(numbuf,FP___PRINTF,t->val->u.i);
2841  strcat(argbuf,numbuf);
2842  } else
2843  strcat(argbuf,t->val->u.s);
2844  }
2845  t = t->right;
2846  }
2847  ast_log(LOG_NOTICE,"argbuf uses %d bytes;\n", (int) strlen(argbuf));
2848  return argbuf;
2849 }
2850 
2851 static int is_really_num(char *str)
2852 {
2853  if ( strspn(str,"-0123456789. ") == strlen(str))
2854  return 1;
2855  else
2856  return 0;
2857 }
2858 #endif
2859 
2860 static struct val *op_func(struct val *funcname, struct expr_node *arglist, struct ast_channel *chan)
2861 {
2862  if (strspn(funcname->u.s,"ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789") == strlen(funcname->u.s))
2863  {
2864  struct val *result;
2865  if (0) {
2866 #ifdef FUNC_COS
2867  } else if (strcmp(funcname->u.s,"COS") == 0) {
2868  if (arglist && !arglist->right && arglist->val){
2869  to_number(arglist->val);
2870  result = make_number(FUNC_COS(arglist->val->u.i));
2871  return result;
2872  } else {
2873  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2874  return make_number(0.0);
2875  }
2876 #endif
2877 #ifdef FUNC_SIN
2878  } else if (strcmp(funcname->u.s,"SIN") == 0) {
2879  if (arglist && !arglist->right && arglist->val){
2880  to_number(arglist->val);
2881  result = make_number(FUNC_SIN(arglist->val->u.i));
2882  return result;
2883  } else {
2884  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2885  return make_number(0.0);
2886  }
2887 #endif
2888 #ifdef FUNC_TAN
2889  } else if (strcmp(funcname->u.s,"TAN") == 0) {
2890  if (arglist && !arglist->right && arglist->val){
2891  to_number(arglist->val);
2892  result = make_number(FUNC_TAN(arglist->val->u.i));
2893  return result;
2894  } else {
2895  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2896  return make_number(0.0);
2897  }
2898 #endif
2899 #ifdef FUNC_ACOS
2900  } else if (strcmp(funcname->u.s,"ACOS") == 0) {
2901  if (arglist && !arglist->right && arglist->val){
2902  to_number(arglist->val);
2903  result = make_number(FUNC_ACOS(arglist->val->u.i));
2904  return result;
2905  } else {
2906  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2907  return make_number(0.0);
2908  }
2909 #endif
2910 #ifdef FUNC_ASIN
2911  } else if (strcmp(funcname->u.s,"ASIN") == 0) {
2912  if (arglist && !arglist->right && arglist->val){
2913  to_number(arglist->val);
2914  result = make_number(FUNC_ASIN(arglist->val->u.i));
2915  return result;
2916  } else {
2917  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2918  return make_number(0.0);
2919  }
2920 #endif
2921 #ifdef FUNC_ATAN
2922  } else if (strcmp(funcname->u.s,"ATAN") == 0) {
2923  if (arglist && !arglist->right && arglist->val){
2924  to_number(arglist->val);
2925  result = make_number(FUNC_ATAN(arglist->val->u.i));
2926  return result;
2927  } else {
2928  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2929  return make_number(0.0);
2930  }
2931 #endif
2932 #ifdef FUNC_ATAN2
2933  } else if (strcmp(funcname->u.s,"ATAN2") == 0) {
2934  if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
2935  to_number(arglist->val);
2936  to_number(arglist->right->val);
2937  result = make_number(FUNC_ATAN2(arglist->val->u.i, arglist->right->val->u.i));
2938  return result;
2939  } else {
2940  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2941  return make_number(0.0);
2942  }
2943 #endif
2944 #ifdef FUNC_POW
2945  } else if (strcmp(funcname->u.s,"POW") == 0) {
2946  if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
2947  to_number(arglist->val);
2948  to_number(arglist->right->val);
2949  result = make_number(FUNC_POW(arglist->val->u.i, arglist->right->val->u.i));
2950  return result;
2951  } else {
2952  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2953  return make_number(0.0);
2954  }
2955 #endif
2956 #ifdef FUNC_SQRT
2957  } else if (strcmp(funcname->u.s,"SQRT") == 0) {
2958  if (arglist && !arglist->right && arglist->val){
2959  to_number(arglist->val);
2960  result = make_number(FUNC_SQRT(arglist->val->u.i));
2961  return result;
2962  } else {
2963  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2964  return make_number(0.0);
2965  }
2966 #endif
2967 #ifdef FUNC_FLOOR
2968  } else if (strcmp(funcname->u.s,"FLOOR") == 0) {
2969  if (arglist && !arglist->right && arglist->val){
2970  to_number(arglist->val);
2971  result = make_number(FUNC_FLOOR(arglist->val->u.i));
2972  return result;
2973  } else {
2974  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2975  return make_number(0.0);
2976  }
2977 #endif
2978 #ifdef FUNC_CEIL
2979  } else if (strcmp(funcname->u.s,"CEIL") == 0) {
2980  if (arglist && !arglist->right && arglist->val){
2981  to_number(arglist->val);
2982  result = make_number(FUNC_CEIL(arglist->val->u.i));
2983  return result;
2984  } else {
2985  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2986  return make_number(0.0);
2987  }
2988 #endif
2989 #ifdef FUNC_ROUND
2990  } else if (strcmp(funcname->u.s,"ROUND") == 0) {
2991  if (arglist && !arglist->right && arglist->val){
2992  to_number(arglist->val);
2993  result = make_number(FUNC_ROUND(arglist->val->u.i));
2994  return result;
2995  } else {
2996  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2997  return make_number(0.0);
2998  }
2999 #endif /* defined(FUNC_ROUND) */
3000 #ifdef FUNC_RINT
3001  } else if (strcmp(funcname->u.s,"RINT") == 0) {
3002  if (arglist && !arglist->right && arglist->val){
3003  to_number(arglist->val);
3004  result = make_number(FUNC_RINT(arglist->val->u.i));
3005  return result;
3006  } else {
3007  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3008  return make_number(0.0);
3009  }
3010 #endif
3011 #ifdef FUNC_TRUNC
3012  } else if (strcmp(funcname->u.s,"TRUNC") == 0) {
3013  if (arglist && !arglist->right && arglist->val){
3014  to_number(arglist->val);
3015  result = make_number(FUNC_TRUNC(arglist->val->u.i));
3016  return result;
3017  } else {
3018  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3019  return make_number(0.0);
3020  }
3021 #endif /* defined(FUNC_TRUNC) */
3022 #ifdef FUNC_EXP
3023  } else if (strcmp(funcname->u.s,"EXP") == 0) {
3024  if (arglist && !arglist->right && arglist->val){
3025  to_number(arglist->val);
3026  result = make_number(FUNC_EXP(arglist->val->u.i));
3027  return result;
3028  } else {
3029  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3030  return make_number(0.0);
3031  }
3032 #endif
3033 #ifdef FUNC_EXP2
3034  } else if (strcmp(funcname->u.s,"EXP2") == 0) {
3035  if (arglist && !arglist->right && arglist->val){
3036  to_number(arglist->val);
3037  result = make_number(FUNC_EXP2(arglist->val->u.i));
3038  return result;
3039  } else {
3040  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3041  return make_number(0.0);
3042  }
3043 #endif
3044 #ifdef FUNC_EXP10
3045  } else if (strcmp(funcname->u.s,"EXP10") == 0) {
3046  if (arglist && !arglist->right && arglist->val){
3047  to_number(arglist->val);
3048  result = make_number(FUNC_EXP10(arglist->val->u.i));
3049  return result;
3050  } else {
3051  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3052  return make_number(0.0);
3053  }
3054 #endif
3055 #ifdef FUNC_LOG
3056  } else if (strcmp(funcname->u.s,"LOG") == 0) {
3057  if (arglist && !arglist->right && arglist->val){
3058  to_number(arglist->val);
3059  result = make_number(FUNC_LOG(arglist->val->u.i));
3060  return result;
3061  } else {
3062  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3063  return make_number(0.0);
3064  }
3065 #endif
3066 #ifdef FUNC_LOG2
3067  } else if (strcmp(funcname->u.s,"LOG2") == 0) {
3068  if (arglist && !arglist->right && arglist->val){
3069  to_number(arglist->val);
3070  result = make_number(FUNC_LOG2(arglist->val->u.i));
3071  return result;
3072  } else {
3073  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3074  return make_number(0.0);
3075  }
3076 #endif
3077 #ifdef FUNC_LOG10
3078  } else if (strcmp(funcname->u.s,"LOG10") == 0) {
3079  if (arglist && !arglist->right && arglist->val){
3080  to_number(arglist->val);
3081  result = make_number(FUNC_LOG10(arglist->val->u.i));
3082  return result;
3083  } else {
3084  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3085  return make_number(0.0);
3086  }
3087 #endif
3088 #ifdef FUNC_REMAINDER
3089  } else if (strcmp(funcname->u.s,"REMAINDER") == 0) {
3090  if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
3091  to_number(arglist->val);
3092  to_number(arglist->right->val);
3093  result = make_number(FUNC_REMAINDER(arglist->val->u.i, arglist->right->val->u.i));
3094  return result;
3095  } else {
3096  ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3097  return make_number(0.0);
3098  }
3099 #endif
3100  } else {
3101  /* is this a custom function we should execute and collect the results of? */
3102 #if !defined(STANDALONE) && !defined(STANDALONE2)
3103  struct ast_custom_function *f = ast_custom_function_find(funcname->u.s);
3104  if (!chan)
3105  ast_log(LOG_WARNING,"Hey! chan is NULL.\n");
3106  if (!f)
3107  ast_log(LOG_WARNING,"Hey! could not find func %s.\n", funcname->u.s);
3108 
3109  if (f && chan) {
3110  if (f->read) {
3111  char workspace[512];
3112  char *argbuf = compose_func_args(arglist);
3113  f->read(chan, funcname->u.s, argbuf, workspace, sizeof(workspace));
3114  free(argbuf);
3115  if (is_really_num(workspace))
3116  return make_number(FUNC_STRTOD(workspace,(char **)NULL));
3117  else
3118  return make_str(workspace);
3119  } else {
3120  ast_log(LOG_ERROR,"Error! Function '%s' cannot be read!\n", funcname->u.s);
3121  return (make_number ((FP___TYPE)0.0));
3122  }
3123 
3124  } else {
3125  ast_log(LOG_ERROR, "Error! '%s' doesn't appear to be an available function!\n", funcname->u.s);
3126  return (make_number ((FP___TYPE)0.0));
3127  }
3128 #else
3129  ast_log(LOG_ERROR, "Error! '%s' is not available in the standalone version!\n", funcname->u.s);
3130  return (make_number ((FP___TYPE)0.0));
3131 #endif
3132  }
3133  }
3134  else
3135  {
3136  ast_log(LOG_ERROR, "Error! '%s' is not possibly a function name!\n", funcname->u.s);
3137  return (make_number ((FP___TYPE)0.0));
3138  }
3139  return (make_number ((FP___TYPE)0.0));
3140 }
3141 
3142 
3143 static struct val *
3144 op_or (struct val *a, struct val *b)
3145 {
3146  if (is_zero_or_null (a)) {
3147  free_value (a);
3148  return (b);
3149  } else {
3150  free_value (b);
3151  return (a);
3152  }
3153 }
3154 
3155 static struct val *
3156 op_and (struct val *a, struct val *b)
3157 {
3158  if (is_zero_or_null (a) || is_zero_or_null (b)) {
3159  free_value (a);
3160  free_value (b);
3161  return (make_number ((FP___TYPE)0.0));
3162  } else {
3163  free_value (b);
3164  return (a);
3165  }
3166 }
3167 
3168 static struct val *
3169 op_eq (struct val *a, struct val *b)
3170 {
3171  struct val *r;
3172 
3173  if (isstring (a) || isstring (b)) {
3174  to_string (a);
3175  to_string (b);
3176  r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) == 0));
3177  } else {
3178 #ifdef DEBUG_FOR_CONVERSIONS
3179  char buffer[2000];
3180  sprintf(buffer,"Converting '%s' and '%s' ", a->u.s, b->u.s);
3181 #endif
3182  (void)to_number(a);
3183  (void)to_number(b);
3184 #ifdef DEBUG_FOR_CONVERSIONS
3185  ast_log(LOG_WARNING,"%s to '%lld' and '%lld'\n", buffer, a->u.i, b->u.i);
3186 #endif
3187  r = make_number ((FP___TYPE)(a->u.i == b->u.i));
3188  }
3189 
3190  free_value (a);
3191  free_value (b);
3192  return r;
3193 }
3194 
3195 static struct val *
3196 op_gt (struct val *a, struct val *b)
3197 {
3198  struct val *r;
3199 
3200  if (isstring (a) || isstring (b)) {
3201  to_string (a);
3202  to_string (b);
3203  r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) > 0));
3204  } else {
3205  (void)to_number(a);
3206  (void)to_number(b);
3207  r = make_number ((FP___TYPE)(a->u.i > b->u.i));
3208  }
3209 
3210  free_value (a);
3211  free_value (b);
3212  return r;
3213 }
3214 
3215 static struct val *
3216 op_lt (struct val *a, struct val *b)
3217 {
3218  struct val *r;
3219 
3220  if (isstring (a) || isstring (b)) {
3221  to_string (a);
3222  to_string (b);
3223  r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) < 0));
3224  } else {
3225  (void)to_number(a);
3226  (void)to_number(b);
3227  r = make_number ((FP___TYPE)(a->u.i < b->u.i));
3228  }
3229 
3230  free_value (a);
3231  free_value (b);
3232  return r;
3233 }
3234 
3235 static struct val *
3236 op_ge (struct val *a, struct val *b)
3237 {
3238  struct val *r;
3239 
3240  if (isstring (a) || isstring (b)) {
3241  to_string (a);
3242  to_string (b);
3243  r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) >= 0));
3244  } else {
3245  (void)to_number(a);
3246  (void)to_number(b);
3247  r = make_number ((FP___TYPE)(a->u.i >= b->u.i));
3248  }
3249 
3250  free_value (a);
3251  free_value (b);
3252  return r;
3253 }
3254 
3255 static struct val *
3256 op_le (struct val *a, struct val *b)
3257 {
3258  struct val *r;
3259 
3260  if (isstring (a) || isstring (b)) {
3261  to_string (a);
3262  to_string (b);
3263  r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) <= 0));
3264  } else {
3265  (void)to_number(a);
3266  (void)to_number(b);
3267  r = make_number ((FP___TYPE)(a->u.i <= b->u.i));
3268  }
3269 
3270  free_value (a);
3271  free_value (b);
3272  return r;
3273 }
3274 
3275 static struct val *
3276 op_cond (struct val *a, struct val *b, struct val *c)
3277 {
3278  struct val *r;
3279 
3280  if( isstring(a) )
3281  {
3282  if( strlen(a->u.s) && strcmp(a->u.s, "\"\"") != 0 && strcmp(a->u.s,"0") != 0 )
3283  {
3284  free_value(a);
3285  free_value(c);
3286  r = b;
3287  }
3288  else
3289  {
3290  free_value(a);
3291  free_value(b);
3292  r = c;
3293  }
3294  }
3295  else
3296  {
3297  (void)to_number(a);
3298  if( a->u.i )
3299  {
3300  free_value(a);
3301  free_value(c);
3302  r = b;
3303  }
3304  else
3305  {
3306  free_value(a);
3307  free_value(b);
3308  r = c;
3309  }
3310  }
3311  return r;
3312 }
3313 
3314 static struct val *
3315 op_ne (struct val *a, struct val *b)
3316 {
3317  struct val *r;
3318 
3319  if (isstring (a) || isstring (b)) {
3320  to_string (a);
3321  to_string (b);
3322  r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) != 0));
3323  } else {
3324  (void)to_number(a);
3325  (void)to_number(b);
3326  r = make_number ((FP___TYPE)(a->u.i != b->u.i));
3327  }
3328 
3329  free_value (a);
3330  free_value (b);
3331  return r;
3332 }
3333 
3334 static int
3336 {
3337  /* sum of two positive numbers must be positive */
3338  if (a > 0 && b > 0 && r <= 0)
3339  return 1;
3340  /* sum of two negative numbers must be negative */
3341  if (a < 0 && b < 0 && r >= 0)
3342  return 1;
3343  /* all other cases are OK */
3344  return 0;
3345 }
3346 
3347 static struct val *
3348 op_plus (struct val *a, struct val *b)
3349 {
3350  struct val *r;
3351 
3352  if (!to_number (a)) {
3353  if( !extra_error_message_supplied )
3354  ast_log(LOG_WARNING,"non-numeric argument\n");
3355  if (!to_number (b)) {
3356  free_value(a);
3357  free_value(b);
3358  return make_number(0);
3359  } else {
3360  free_value(a);
3361  return (b);
3362  }
3363  } else if (!to_number(b)) {
3364  free_value(b);
3365  return (a);
3366  }
3367 
3368  r = make_number (a->u.i + b->u.i);
3369  if (chk_plus (a->u.i, b->u.i, r->u.i)) {
3370  ast_log(LOG_WARNING,"overflow\n");
3371  }
3372  free_value (a);
3373  free_value (b);
3374  return r;
3375 }
3376 
3377 static int
3379 {
3380  /* special case subtraction of QUAD_MIN */
3381  if (b == QUAD_MIN) {
3382  if (a >= 0)
3383  return 1;
3384  else
3385  return 0;
3386  }
3387  /* this is allowed for b != QUAD_MIN */
3388  return chk_plus (a, -b, r);
3389 }
3390 
3391 static struct val *
3392 op_minus (struct val *a, struct val *b)
3393 {
3394  struct val *r;
3395 
3396  if (!to_number (a)) {
3397  if( !extra_error_message_supplied )
3398  ast_log(LOG_WARNING, "non-numeric argument\n");
3399  if (!to_number (b)) {
3400  free_value(a);
3401  free_value(b);
3402  return make_number(0);
3403  } else {
3404  r = make_number(0 - b->u.i);
3405  free_value(a);
3406  free_value(b);
3407  return (r);
3408  }
3409  } else if (!to_number(b)) {
3410  if( !extra_error_message_supplied )
3411  ast_log(LOG_WARNING, "non-numeric argument\n");
3412  free_value(b);
3413  return (a);
3414  }
3415 
3416  r = make_number (a->u.i - b->u.i);
3417  if (chk_minus (a->u.i, b->u.i, r->u.i)) {
3418  ast_log(LOG_WARNING, "overflow\n");
3419  }
3420  free_value (a);
3421  free_value (b);
3422  return r;
3423 }
3424 
3425 static struct val *
3426 op_negate (struct val *a)
3427 {
3428  struct val *r;
3429 
3430  if (!to_number (a) ) {
3431  free_value(a);
3432  if( !extra_error_message_supplied )
3433  ast_log(LOG_WARNING, "non-numeric argument\n");
3434  return make_number(0);
3435  }
3436 
3437  r = make_number (- a->u.i);
3438  if (chk_minus (0, a->u.i, r->u.i)) {
3439  ast_log(LOG_WARNING, "overflow\n");
3440  }
3441  free_value (a);
3442  return r;
3443 }
3444 
3445 static struct val *
3446 op_compl (struct val *a)
3447 {
3448  int v1 = 1;
3449  struct val *r;
3450 
3451  if( !a )
3452  {
3453  v1 = 0;
3454  }
3455  else
3456  {
3457  switch( a->type )
3458  {
3459  case AST_EXPR_number:
3460  if( a->u.i == 0 )
3461  v1 = 0;
3462  break;
3463 
3464  case AST_EXPR_string:
3465  if( a->u.s == 0 )
3466  v1 = 0;
3467  else
3468  {
3469  if( a->u.s[0] == 0 )
3470  v1 = 0;
3471  else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' )
3472  v1 = 0;
3473  else
3474  v1 = atoi(a->u.s);
3475  }
3476  break;
3477 
3479  if( a->u.s == 0 )
3480  v1 = 0;
3481  else
3482  {
3483  if( a->u.s[0] == 0 )
3484  v1 = 0;
3485  else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' )
3486  v1 = 0;
3487  else
3488  v1 = atoi(a->u.s);
3489  }
3490  break;
3491  }
3492  }
3493 
3494  r = make_number (!v1);
3495  free_value (a);
3496  return r;
3497 }
3498 
3499 static int
3501 {
3502  /* special case: first operand is 0, no overflow possible */
3503  if (a == 0)
3504  return 0;
3505  /* cerify that result of division matches second operand */
3506  if (r / a != b)
3507  return 1;
3508  return 0;
3509 }
3510 
3511 static struct val *
3512 op_times (struct val *a, struct val *b)
3513 {
3514  struct val *r;
3515 
3516  if (!to_number (a) || !to_number (b)) {
3517  free_value(a);
3518  free_value(b);
3519  if( !extra_error_message_supplied )
3520  ast_log(LOG_WARNING, "non-numeric argument\n");
3521  return(make_number(0));
3522  }
3523 
3524  r = make_number (a->u.i * b->u.i);
3525  if (chk_times (a->u.i, b->u.i, r->u.i)) {
3526  ast_log(LOG_WARNING, "overflow\n");
3527  }
3528  free_value (a);
3529  free_value (b);
3530  return (r);
3531 }
3532 
3533 static int
3535 {
3536  /* div by zero has been taken care of before */
3537  /* only QUAD_MIN / -1 causes overflow */
3538  if (a == QUAD_MIN && b == -1)
3539  return 1;
3540  /* everything else is OK */
3541  return 0;
3542 }
3543 
3544 static struct val *
3545 op_div (struct val *a, struct val *b)
3546 {
3547  struct val *r;
3548 
3549  if (!to_number (a)) {
3550  free_value(a);
3551  free_value(b);
3552  if( !extra_error_message_supplied )
3553  ast_log(LOG_WARNING, "non-numeric argument\n");
3554  return make_number(0);
3555  } else if (!to_number (b)) {
3556  free_value(a);
3557  free_value(b);
3558  if( !extra_error_message_supplied )
3559  ast_log(LOG_WARNING, "non-numeric argument\n");
3560  return make_number(INT_MAX);
3561  }
3562 
3563  if (b->u.i == 0) {
3564  ast_log(LOG_WARNING, "division by zero\n");
3565  free_value(a);
3566  free_value(b);
3567  return make_number(INT_MAX);
3568  }
3569 
3570  r = make_number (a->u.i / b->u.i);
3571  if (chk_div (a->u.i, b->u.i)) {
3572  ast_log(LOG_WARNING, "overflow\n");
3573  }
3574  free_value (a);
3575  free_value (b);
3576  return r;
3577 }
3578 
3579 static struct val *
3580 op_rem (struct val *a, struct val *b)
3581 {
3582  struct val *r;
3583 
3584  if (!to_number (a) || !to_number (b)) {
3585  if( !extra_error_message_supplied )
3586  ast_log(LOG_WARNING, "non-numeric argument\n");
3587  free_value(a);
3588  free_value(b);
3589  return make_number(0);
3590  }
3591 
3592  if (b->u.i == 0) {
3593  ast_log(LOG_WARNING, "div by zero\n");
3594  free_value(a);
3595  return(b);
3596  }
3597 
3598  r = make_number (FUNC_FMOD(a->u.i, b->u.i)); /* either fmod or fmodl if FP___TYPE is available */
3599  /* chk_rem necessary ??? */
3600  free_value (a);
3601  free_value (b);
3602  return r;
3603 }
3604 
3605 
3606 static struct val *
3607 op_colon (struct val *a, struct val *b)
3608 {
3609  regex_t rp;
3610  regmatch_t rm[2];
3611  char errbuf[256];
3612  int eval;
3613  struct val *v;
3614 
3615  /* coerce to both arguments to strings */
3616  to_string(a);
3617  to_string(b);
3618  /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */
3619  strip_quotes(a);
3620  strip_quotes(b);
3621  /* compile regular expression */
3622  if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) {
3623  regerror (eval, &rp, errbuf, sizeof(errbuf));
3624  ast_log(LOG_WARNING, "regcomp() error : %s\n", errbuf);
3625  free_value(a);
3626  free_value(b);
3627  return make_str("");
3628  }
3629 
3630  /* compare string against pattern */
3631  /* remember that patterns are anchored to the beginning of the line */
3632  if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 && rm[0].rm_so == 0) {
3633  if (rm[1].rm_so >= 0) {
3634  *(a->u.s + rm[1].rm_eo) = '\0';
3635  v = make_str (a->u.s + rm[1].rm_so);
3636 
3637  } else {
3638  v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so));
3639  }
3640  } else {
3641  if (rp.re_nsub == 0) {
3642  v = make_number ((FP___TYPE)0);
3643  } else {
3644  v = make_str ("");
3645  }
3646  }
3647 
3648  /* free arguments and pattern buffer */
3649  free_value (a);
3650  free_value (b);
3651  regfree (&rp);
3652 
3653  return v;
3654 }
3655 
3656 
3657 static struct val *
3658 op_eqtilde (struct val *a, struct val *b)
3659 {
3660  regex_t rp;
3661  regmatch_t rm[2];
3662  char errbuf[256];
3663  int eval;
3664  struct val *v;
3665 
3666  /* coerce to both arguments to strings */
3667  to_string(a);
3668  to_string(b);
3669  /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */
3670  strip_quotes(a);
3671  strip_quotes(b);
3672  /* compile regular expression */
3673  if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) {
3674  regerror (eval, &rp, errbuf, sizeof(errbuf));
3675  ast_log(LOG_WARNING, "regcomp() error : %s\n", errbuf);
3676  free_value(a);
3677  free_value(b);
3678  return make_str("");
3679  }
3680 
3681  /* compare string against pattern */
3682  /* remember that patterns are anchored to the beginning of the line */
3683  if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 ) {
3684  if (rm[1].rm_so >= 0) {
3685  *(a->u.s + rm[1].rm_eo) = '\0';
3686  v = make_str (a->u.s + rm[1].rm_so);
3687 
3688  } else {
3689  v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so));
3690  }
3691  } else {
3692  if (rp.re_nsub == 0) {
3693  v = make_number ((FP___TYPE)0.0);
3694  } else {
3695  v = make_str ("");
3696  }
3697  }
3698 
3699  /* free arguments and pattern buffer */
3700  free_value (a);
3701  free_value (b);
3702  regfree (&rp);
3703 
3704  return v;
3705 }
3706 
3707 static struct val * /* this is a string concat operator */
3708 op_tildetilde (struct val *a, struct val *b)
3709 {
3710  struct val *v;
3711  char *vs;
3712 
3713  /* coerce to both arguments to strings */
3714  to_string(a);
3715  to_string(b);
3716  /* strip double quotes from both -- */
3717  strip_quotes(a);
3718  strip_quotes(b);
3719 
3720  vs = malloc(strlen(a->u.s)+strlen(b->u.s)+1);
3721  strcpy(vs,a->u.s);
3722  strcat(vs,b->u.s);
3723 
3724  v = make_str(vs);
3725 
3726  /* free arguments */
3727  free_value(a);
3728  free_value(b);
3729 
3730  return v;
3731 }
3732 
char yymsgbuf[128]
Definition: ast_expr2.c:1823
static const yytype_uint8 yydefact[]
Definition: ast_expr2.c:865
#define FUNC_STRTOD
Definition: ast_expr2.c:199
#define FUNC_ATAN
Definition: ast_expr2.c:145
#define FUNC_FLOOR
Definition: ast_expr2.c:205
static struct val * op_gt(struct val *a, struct val *b)
Definition: ast_expr2.c:3196
Main Channel structure associated with a channel.
Definition: channel.h:742
#define YYSTACK_ALLOC
Definition: ast_expr2.c:639
#define YYINITDEPTH
Definition: ast_expr2.c:1232
yytype_int16 * yyss
Definition: ast_expr2.c:1794
#define FUNC_LOG2
Definition: ast_expr2.c:249
struct parse_io * parseio
Definition: ael.tab.c:1485
Asterisk main include file. File version handling, generic pbx functions.
#define YYUSE(e)
Definition: ast_expr2.c:577
static struct val * op_ge(struct val *a, struct val *b)
Definition: ast_expr2.c:3236
unsigned char yytype_uint8
Definition: ast_expr2.c:523
#define YYLLOC_DEFAULT(Current, Rhs, N)
Definition: ast_expr2.c:1016
#define malloc(a)
Definition: astmm.h:88
#define yydebug
Definition: ast_expr2.c:70
int main(int argc, char *argv[])
static struct val * op_eqtilde(struct val *a, struct val *b)
Definition: ast_expr2.c:3658
#define FUNC_CEIL
Definition: ast_expr2.c:211
#define yyerror
Definition: ast_expr2.c:67
Definition: ast_expr2.c:325
FP___TYPE i
Definition: ast_expr2.c:329
#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
Definition: ast_expr2.c:1224
#define YYPOPSTACK(N)
Definition: ast_expr2.c:1828
#define FP___TYPE
Definition: ast_expr2.c:111
YYSIZE_T yymsg_alloc
Definition: ast_expr2.c:1825
static const yytype_uint8 yyr1[]
Definition: ast_expr2.c:847
static struct val * op_rem(struct val *a, struct val *b)
Definition: ast_expr2.c:3580
static const yytype_uint8 yytable[]
Definition: ast_expr2.c:904
goto yyerrlab
Definition: ast_expr2.c:2017
#define YYACCEPT
Definition: ast_expr2.c:967
yytype_int16 * yyssp
Definition: ast_expr2.c:1795
yytype_int16 yyssa[YYINITDEPTH]
Definition: ast_expr2.c:1793
static int chk_times(FP___TYPE a, FP___TYPE b, FP___TYPE r)
Definition: ast_expr2.c:3500
int yytype
Definition: ast_expr2.c:1498
#define LOG_WARNING
Definition: logger.h:144
YYSTYPE yyvsa[YYINITDEPTH]
Definition: ast_expr2.c:1798
#define yynerrs
Definition: ast_expr2.c:71
#define YYSYNTAX_ERROR
static int yysyntax_error(YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken)
Definition: ast_expr2.c:1357
static const yytype_int16 yypact[]
Definition: ast_expr2.c:884
#define YYABORT
Definition: ast_expr2.c:968
int last_line
Definition: ast_expr2.h:95
yylloc first_column
Definition: ast_expr2.c:1858
YYLTYPE * yylsp
Definition: ast_expr2.c:1805
#define YYTRANSLATE(YYX)
Definition: ast_expr2.c:750
#define YY_REDUCE_PRINT(Rule)
Definition: ast_expr2.c:1226
struct val * val
Definition: ast_expr2.c:478
#define yypact_value_is_default(yystate)
Definition: ast_expr2.c:924
static const yytype_int8 yydefgoto[]
Definition: ast_expr2.c:876
#define FUNC_FMOD
Definition: ast_expr2.c:193
int extra_error_message_supplied
Definition: ast_expr2f.c:2465
int last_column
Definition: ast_expr2.c:397
struct val * val
Definition: ast_expr2.c:351
static void to_string(struct val *vp)
Definition: ast_expr2.c:2690
static struct val * op_le(struct val *a, struct val *b)
Definition: ast_expr2.c:3256
#define YYEOF
Definition: ast_expr2.c:965
yyscan_t scanner
Definition: ael_structs.h:78
enum node_type type
Definition: ast_expr2.c:339
const char * str
Definition: app_jack.c:144
int ast_yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)
#define YYSTACK_ALLOC_MAXIMUM
Definition: ast_expr2.c:642
static struct val * op_colon(struct val *a, struct val *b)
Definition: ast_expr2.c:3607
static YYSIZE_T yytnamerr(char *yyres, const char *yystr)
Definition: ast_expr2.c:1309
struct expr_node * arglist
Definition: ast_expr2.c:479
static struct expr_node * alloc_expr_node(enum node_type)
Definition: ast_expr2.c:2562
#define calloc(a, b)
Definition: astmm.h:79
int yystate
Definition: ast_expr2.c:1780
struct ast_channel * chan
Definition: ast_expr2.c:353
goto yysetstate
Definition: ast_expr2.c:1861
#define FUNC_SIN
Definition: ast_expr2.c:121
#define ast_yyerror(x)
Definition: ast_expr2.c:2785
#define FUNC_EXP10
Definition: ast_expr2.c:241
short int yytype_int16
Definition: ast_expr2.c:544
#define YYTERROR
Definition: ast_expr2.c:1006
#define YYSIZE_T
Definition: ast_expr2.c:557
enum valtype type
Definition: ast_expr2.c:326
char * s
Definition: ast_expr2.c:328
YYLTYPE * yyls
Definition: ast_expr2.c:1804
static struct val * make_str(const char *s)
Definition: ast_expr2.c:2592
YYLTYPE yylsa[YYINITDEPTH]
Definition: ast_expr2.c:1803
union YYSTYPE YYSTYPE
struct expr_node * right
Definition: ast_expr2.c:342
static struct val * op_div(struct val *a, struct val *b)
Definition: ast_expr2.c:3545
#define yychar
Definition: ast_expr2.c:69
#define FUNC_TRUNC
Definition: ast_expr2.c:223
return yylen
Definition: ast_expr2.c:1267
static void destroy_arglist(struct expr_node *arglist)
Definition: ast_expr2.c:2792
static struct val * op_cond(struct val *a, struct val *b, struct val *c)
Definition: ast_expr2.c:3276
#define yytable_value_is_error(yytable_value)
Definition: ast_expr2.c:927
#define YYID(n)
Definition: ast_expr2.c:584
#define FUNC_ATAN2
Definition: ast_expr2.c:151
static char *char * yydest
Definition: ast_expr2.c:1285
Data structure associated with a custom dialplan function.
Definition: pbx.h:95
static struct val * op_and(struct val *a, struct val *b)
Definition: ast_expr2.c:3156
#define YYEMPTY
Definition: ast_expr2.c:964
#define YYSTACK_BYTES(N)
Definition: ast_expr2.c:688
#define YYLTYPE
Definition: ast_expr2.c:400
YYSTYPE yyval
Definition: ast_expr2.c:1818
static int chk_minus(FP___TYPE a, FP___TYPE b, FP___TYPE r)
Definition: ast_expr2.c:3378
YYSTYPE yyvs_alloc
Definition: ast_expr2.c:679
YYSTYPE * yyvsp
Definition: ast_expr2.c:1800
node_type
Definition: ast_expr2.c:333
int first_line
Definition: ast_expr2.c:393
union val::@218 u
static int chk_div __P((FP___TYPE, FP___TYPE))
#define YYFINAL
Definition: ast_expr2.c:733
int yyn
Definition: ast_expr2.c:1812
static struct val * op_tildetilde(struct val *a, struct val *b)
Definition: ast_expr2.c:3708
int last_column
Definition: ast_expr2.h:96
struct yyltype yyltype
int first_line
Definition: ast_expr2.h:93
#define FUNC_LOG
Definition: ast_expr2.c:181
Core PBX routines and definitions.
goto yynewstate
Definition: ast_expr2.c:2008
short int yytype_int8
Definition: ast_expr2.c:532
#define YYLAST
Definition: ast_expr2.c:735
static const yytype_uint8 yytranslate[]
Definition: ast_expr2.c:754
#define FUNC_ACOS
Definition: ast_expr2.c:133
struct ast_custom_function * ast_custom_function_find(const char *name)
Definition: pbx.c:3800
#define FP___PRINTF
Definition: ast_expr2.c:110
static char * compose_func_args(struct expr_node *arglist)
Definition: ast_expr2.c:2809
static int chk_div(FP___TYPE a, FP___TYPE b)
Definition: ast_expr2.c:3534
#define LOG_ERROR
Definition: logger.h:155
char extra_error_message[4095]
Definition: ast_expr2f.c:2464
static struct val * op_func(struct val *funcname, struct expr_node *arglist, struct ast_channel *chan)
Definition: ast_expr2.c:2860
#define free(a)
Definition: astmm.h:94
unsigned short int yytype_uint16
Definition: ast_expr2.c:538
static int to_number(struct val *vp)
Definition: ast_expr2.c:2636
yydestruct("Cleanup: discarding lookahead", yytoken,&yylval,&yylloc)
#define YYNTOKENS
Definition: ast_expr2.c:738
int yyerrstatus
Definition: ast_expr2.c:1782
goto yyreturn
Definition: ast_expr2.c:2506
#define FUNC_ASIN
Definition: ast_expr2.c:139
#define yyparse
Definition: ast_expr2.c:65
static const yytype_uint8 yystos[]
Definition: ast_expr2.c:952
static struct val * op_compl(struct val *a)
Definition: ast_expr2.c:3446
YYSTYPE * yyvs
Definition: ast_expr2.c:1799
struct val * val
Definition: ast_expr2.c:340
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
goto yyerrlab1
Definition: ast_expr2.c:2430
#define YYMAXDEPTH
Definition: ast_expr2.c:1243
#define LOG_NOTICE
Definition: logger.h:133
YYLTYPE yyls_alloc
Definition: ast_expr2.c:680
#define FUNC_RINT
Definition: ast_expr2.c:169
#define FUNC_EXP2
Definition: ast_expr2.c:233
static void const char * yymsg
Definition: ast_expr2.c:1497
static int isstring(struct val *vp)
Definition: ast_expr2.c:2710
YYLTYPE yyerror_range[3]
Definition: ast_expr2.c:1808
static struct val * op_minus(struct val *a, struct val *b)
Definition: ast_expr2.c:3392
struct expr_node * left
Definition: ast_expr2.c:341
int errno
#define FUNC_COS
Definition: ast_expr2.c:115
static struct val * op_lt(struct val *a, struct val *b)
Definition: ast_expr2.c:3216
#define FUNC_LOG10
Definition: ast_expr2.c:261
const char * yys
Definition: ast_expr2.c:1290
static struct ast_format f[]
Definition: format_g726.c:181
static const char *const yytname[]
Definition: ast_expr2.c:825
#define YY_(msgid)
Definition: ast_expr2.c:571
#define YY_LOCATION_PRINT(File, Loc)
Definition: ast_expr2.c:1042
static int chk_plus(FP___TYPE a, FP___TYPE b, FP___TYPE r)
Definition: ast_expr2.c:3335
#define YYPARSE_PARAM
Definition: ast_expr2.c:311
static const char type[]
Definition: chan_nbs.c:57
#define YYSTACK_FREE
Definition: ast_expr2.c:640
#define YYLEX
Definition: ast_expr2.c:1055
Support for logging to various files, console and syslog Configuration in file logger.conf.
static void free_value(struct val *vp)
Definition: ast_expr2.c:2624
YYSIZE_T yystacksize
Definition: ast_expr2.c:1810
goto yydefault
Definition: ast_expr2.c:1958
#define YY_STACK_PRINT(Bottom, Top)
Definition: ast_expr2.c:1225
static struct val * op_plus(struct val *a, struct val *b)
Definition: ast_expr2.c:3348
yytype_int16 yyss_alloc
Definition: ast_expr2.c:678
int yyresult
Definition: ast_expr2.c:1813
static const yytype_int8 yypgoto[]
Definition: ast_expr2.c:895
#define DESTROY(x)
Definition: ast_expr2.c:412
ast_acf_read_fn_t read
Definition: pbx.h:106
#define FUNC_SQRT
Definition: ast_expr2.c:163
static const yytype_int8 yycheck[]
Definition: ast_expr2.c:930
void * yyscan_t
Definition: ael_structs.h:71
int last_line
Definition: ast_expr2.c:396
YYLTYPE yyloc
Definition: ast_expr2.c:1819
int first_column
Definition: ast_expr2.c:394
#define FUNC_TAN
Definition: ast_expr2.c:127
int first_column
Definition: ast_expr2.h:94
#define YYCASE_(N, S)
goto yybackup
Definition: ast_expr2.c:1945
#define yylloc
Definition: ast_expr2.c:72
yytokentype
Definition: ast_expr2.c:442
#define FUNC_POW
Definition: ast_expr2.c:157
return yyd
Definition: ast_expr2.c:1295
const char * yysrc
Definition: ast_expr2.c:1286
YYLTYPE * yylocationp
Definition: ast_expr2.c:1500
static struct val * op_ne(struct val *a, struct val *b)
Definition: ast_expr2.c:3315
static struct val * op_negate(struct val *a)
Definition: ast_expr2.c:3426
char * string
Definition: ast_expr2.c:350
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
Definition: ast_expr2.c:699
static struct val * op_or(struct val *a, struct val *b)
Definition: ast_expr2.c:3144
static struct val * make_number(FP___TYPE i)
Definition: ast_expr2.c:2576
valtype
Definition: ast_expr2.c:317
#define QUAD_MIN
Definition: ast_expr2.c:305
#define strdup(a)
Definition: astmm.h:106
static struct val * op_times(struct val *a, struct val *b)
Definition: ast_expr2.c:3512
#define FUNC_EXP
Definition: ast_expr2.c:175
#define yylval
Definition: ast_expr2.c:68
YYSTYPE * yyvaluep
Definition: ast_expr2.c:1499
static snd_pcm_format_t format
Definition: chan_alsa.c:93
static struct val * op_eq(struct val *a, struct val *b)
Definition: ast_expr2.c:3169
static const yytype_uint8 yyr2[]
Definition: ast_expr2.c:855
#define FUNC_ROUND
Definition: ast_expr2.c:217
int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
Evaluate the given expression.
Definition: ast_expr2f.c:2396
static int is_really_num(char *str)
Definition: ast_expr2.c:2851
#define YYDPRINTF(Args)
Definition: ast_expr2.c:1223
static int is_zero_or_null(struct val *vp)
Definition: ast_expr2.c:2718
goto yyreduce
Definition: ast_expr2.c:2018
static void strip_quotes(struct val *vp)
Definition: ast_expr2.c:2667
#define FUNC_REMAINDER
Definition: ast_expr2.c:187
int yytoken
Definition: ast_expr2.c:1815
yylloc first_line
Definition: ast_expr2.c:1857
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
Definition: asterisk.h:180
static YYSIZE_T const char * yystr
Definition: ast_expr2.c:1261