ast_expr2.c

Go to the documentation of this file.
00001 
00002 /* A Bison parser, made by GNU Bison 2.4.1.  */
00003 
00004 /* Skeleton implementation for Bison's Yacc-like parsers in C
00005    
00006       Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
00007    Free Software Foundation, Inc.
00008    
00009    This program is free software: you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation, either version 3 of the License, or
00012    (at your option) any later version.
00013    
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.
00018    
00019    You should have received a copy of the GNU General Public License
00020    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00021 
00022 /* As a special exception, you may create a larger work that contains
00023    part or all of the Bison parser skeleton and distribute that work
00024    under terms of your choice, so long as that work isn't itself a
00025    parser generator using the skeleton or a modified version thereof
00026    as a parser skeleton.  Alternatively, if you modify or redistribute
00027    the parser skeleton itself, you may (at your option) remove this
00028    special exception, which will cause the skeleton and the resulting
00029    Bison output files to be licensed under the GNU General Public
00030    License without this special exception.
00031    
00032    This special exception was added by the Free Software Foundation in
00033    version 2.2 of Bison.  */
00034 
00035 /* C LALR(1) parser skeleton written by Richard Stallman, by
00036    simplifying the original so-called "semantic" parser.  */
00037 
00038 /* All symbols defined below should begin with yy or YY, to avoid
00039    infringing on user name space.  This should be done even for local
00040    variables, as they might otherwise be expanded by user macros.
00041    There are some unavoidable exceptions within include files to
00042    define necessary library symbols; they are noted "INFRINGES ON
00043    USER NAME SPACE" below.  */
00044 
00045 /* Identify Bison output.  */
00046 #define YYBISON 1
00047 
00048 /* Bison version.  */
00049 #define YYBISON_VERSION "2.4.1"
00050 
00051 /* Skeleton name.  */
00052 #define YYSKELETON_NAME "yacc.c"
00053 
00054 /* Pure parsers.  */
00055 #define YYPURE 1
00056 
00057 /* Push parsers.  */
00058 #define YYPUSH 0
00059 
00060 /* Pull parsers.  */
00061 #define YYPULL 1
00062 
00063 /* Using locations.  */
00064 #define YYLSP_NEEDED 1
00065 
00066 /* Substitute the variable and function names.  */
00067 #define yyparse         ast_yyparse
00068 #define yylex           ast_yylex
00069 #define yyerror         ast_yyerror
00070 #define yylval          ast_yylval
00071 #define yychar          ast_yychar
00072 #define yydebug         ast_yydebug
00073 #define yynerrs         ast_yynerrs
00074 #define yylloc          ast_yylloc
00075 
00076 /* Copy the first part of user declarations.  */
00077 
00078 /* Line 189 of yacc.c  */
00079 #line 1 "ast_expr2.y"
00080 
00081 /* Written by Pace Willisson (pace@blitz.com) 
00082  * and placed in the public domain.
00083  *
00084  * Largely rewritten by J.T. Conklin (jtc@wimsey.com)
00085  *
00086  * And then overhauled twice by Steve Murphy (murf@digium.com)
00087  * to add double-quoted strings, allow mult. spaces, improve
00088  * error messages, and then to fold in a flex scanner for the 
00089  * yylex operation.
00090  *
00091  * $FreeBSD: src/bin/expr/expr.y,v 1.16 2000/07/22 10:59:36 se Exp $
00092  */
00093 
00094 #define WRAP_LIBC_MALLOC
00095 #include "asterisk.h"
00096 
00097 #include <sys/types.h>
00098 #include <stdio.h>
00099 
00100 #if !defined(STANDALONE) && !defined(STANDALONE2)  \
00101    
00102 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 423978 $")
00103 #else
00104 #ifndef __USE_ISOC99
00105 #define __USE_ISOC99 1
00106 #endif
00107 #endif
00108 
00109 #ifdef __USE_ISOC99
00110 #define FP___PRINTF "%.18Lg"
00111 #define FP___TYPE    long double
00112 #else
00113 #define FP___PRINTF "%.16g"
00114 #define FP___TYPE    double
00115 #endif
00116 
00117 #ifdef HAVE_COSL
00118 #define FUNC_COS   cosl
00119 #elif defined(HAVE_COS)
00120 #define FUNC_COS  (long double)cos
00121 #endif
00122 
00123 #ifdef HAVE_SINL
00124 #define FUNC_SIN   sinl
00125 #elif defined(HAVE_SIN)
00126 #define FUNC_SIN  (long double)sin
00127 #endif
00128 
00129 #ifdef HAVE_TANL
00130 #define FUNC_TAN   tanl
00131 #elif defined(HAVE_TAN)
00132 #define FUNC_TAN  (long double)tan
00133 #endif
00134 
00135 #ifdef HAVE_ACOSL
00136 #define FUNC_ACOS   acosl
00137 #elif defined(HAVE_ACOS)
00138 #define FUNC_ACOS (long double)acos
00139 #endif
00140 
00141 #ifdef HAVE_ASINL
00142 #define FUNC_ASIN   asinl
00143 #elif defined(HAVE_ASIN)
00144 #define FUNC_ASIN (long double)asin
00145 #endif
00146 
00147 #ifdef HAVE_ATANL
00148 #define FUNC_ATAN   atanl
00149 #elif defined(HAVE_ATAN)
00150 #define FUNC_ATAN (long double)atan
00151 #endif
00152 
00153 #ifdef HAVE_ATAN2L
00154 #define FUNC_ATAN2   atan2l
00155 #elif defined(HAVE_ATAN2)
00156 #define FUNC_ATAN2   (long double)atan2
00157 #endif
00158 
00159 #ifdef HAVE_POWL
00160 #define FUNC_POW   powl
00161 #elif defined(HAVE_POW)
00162 #define FUNC_POW  (long double)pow
00163 #endif
00164 
00165 #ifdef HAVE_SQRTL
00166 #define FUNC_SQRT   sqrtl
00167 #elif defined(HAVE_SQRT)
00168 #define FUNC_SQRT (long double)sqrt
00169 #endif
00170 
00171 #ifdef HAVE_RINTL
00172 #define FUNC_RINT   rintl
00173 #elif defined(HAVE_RINT)
00174 #define FUNC_RINT (long double)rint
00175 #endif
00176 
00177 #ifdef HAVE_EXPL
00178 #define FUNC_EXP   expl
00179 #elif defined(HAVE_EXP)
00180 #define FUNC_EXP  (long double)exp
00181 #endif
00182 
00183 #ifdef HAVE_LOGL
00184 #define FUNC_LOG   logl
00185 #elif defined(HAVE_LOG)
00186 #define FUNC_LOG  (long double)log
00187 #endif
00188 
00189 #ifdef HAVE_REMAINDERL
00190 #define FUNC_REMAINDER   remainderl
00191 #elif defined(HAVE_REMAINDER)
00192 #define FUNC_REMAINDER  (long double)remainder
00193 #endif
00194 
00195 #ifdef HAVE_FMODL
00196 #define FUNC_FMOD   fmodl
00197 #elif defined(HAVE_FMOD)
00198 #define FUNC_FMOD (long double)fmod
00199 #endif
00200 
00201 #ifdef HAVE_STRTOLD
00202 #define FUNC_STRTOD  strtold
00203 #elif defined(HAVE_STRTOD)
00204 #define FUNC_STRTOD  (long double)strtod
00205 #endif
00206 
00207 #ifdef HAVE_FLOORL
00208 #define FUNC_FLOOR      floorl
00209 #elif defined(HAVE_FLOOR)
00210 #define FUNC_FLOOR   (long double)floor
00211 #endif
00212 
00213 #ifdef HAVE_CEILL
00214 #define FUNC_CEIL      ceill
00215 #elif defined(HAVE_CEIL)
00216 #define FUNC_CEIL (long double)ceil
00217 #endif
00218 
00219 #ifdef HAVE_ROUNDL
00220 #define FUNC_ROUND     roundl
00221 #elif defined(HAVE_ROUND)
00222 #define FUNC_ROUND     (long double)round
00223 #endif
00224 
00225 #ifdef HAVE_TRUNCL
00226 #define FUNC_TRUNC     truncl
00227 #elif defined(HAVE_TRUNC)
00228 #define FUNC_TRUNC     (long double)trunc
00229 #endif
00230 
00231 /*! \note
00232  * Oddly enough, some platforms have some ISO C99 functions, but not others, so
00233  * we define the missing functions in terms of their mathematical identities.
00234  */
00235 #ifdef HAVE_EXP2L
00236 #define FUNC_EXP2       exp2l
00237 #elif (defined(HAVE_EXPL) && defined(HAVE_LOGL))
00238 #define  FUNC_EXP2(x)   expl((x) * logl(2.0))
00239 #elif (defined(HAVE_EXP) && defined(HAVE_LOG))
00240 #define  FUNC_EXP2(x)   (long double)exp((x) * log(2.0))
00241 #endif
00242 
00243 #ifdef HAVE_EXP10L
00244 #define FUNC_EXP10       exp10l
00245 #elif (defined(HAVE_EXPL) && defined(HAVE_LOGL))
00246 #define  FUNC_EXP10(x)  expl((x) * logl(10.0))
00247 #elif (defined(HAVE_EXP) && defined(HAVE_LOG))
00248 #define  FUNC_EXP10(x)  (long double)exp((x) * log(10.0))
00249 #endif
00250 
00251 #ifdef HAVE_LOG2L
00252 #define FUNC_LOG2       log2l
00253 #elif defined(HAVE_LOGL)
00254 #define  FUNC_LOG2(x)   (logl(x) / logl(2.0))
00255 #elif defined(HAVE_LOG10L)
00256 #define  FUNC_LOG2(x)   (log10l(x) / log10l(2.0))
00257 #elif defined(HAVE_LOG2)
00258 #define FUNC_LOG2       (long double)log2
00259 #elif defined(HAVE_LOG)
00260 #define  FUNC_LOG2(x)   ((long double)log(x) / log(2.0))
00261 #endif
00262 
00263 #ifdef HAVE_LOG10L
00264 #define FUNC_LOG10       log10l
00265 #elif defined(HAVE_LOGL)
00266 #define  FUNC_LOG10(x)  (logl(x) / logl(10.0))
00267 #elif defined(HAVE_LOG2L)
00268 #define  FUNC_LOG10(x)  (log2l(x) / log2l(10.0))
00269 #elif defined(HAVE_LOG10)
00270 #define  FUNC_LOG10(x)  (long double)log10(x)
00271 #elif defined(HAVE_LOG)
00272 #define  FUNC_LOG10(x)  ((long double)log(x) / log(10.0))
00273 #endif
00274 
00275 
00276 #include <stdlib.h>
00277 #ifndef _GNU_SOURCE
00278 #define _GNU_SOURCE
00279 #endif
00280 #include <string.h>
00281 #include <math.h>
00282 #include <locale.h>
00283 #include <unistd.h>
00284 #include <ctype.h>
00285 #if !defined(SOLARIS) && !defined(__CYGWIN__)
00286    /* #include <err.h> */
00287 #else
00288 #define quad_t int64_t
00289 #endif
00290 #include <errno.h>
00291 #include <regex.h>
00292 #include <limits.h>
00293 
00294 #include "asterisk/ast_expr.h"
00295 #include "asterisk/logger.h"
00296 #if !defined(STANDALONE) && !defined(STANDALONE2)
00297 #include "asterisk/pbx.h"
00298 #endif
00299 
00300 #if defined(LONG_LONG_MIN) && !defined(QUAD_MIN)
00301 #define QUAD_MIN LONG_LONG_MIN
00302 #endif
00303 #if defined(LONG_LONG_MAX) && !defined(QUAD_MAX)
00304 #define QUAD_MAX LONG_LONG_MAX
00305 #endif
00306 
00307 #  if ! defined(QUAD_MIN)
00308 #   define QUAD_MIN     (-0x7fffffffffffffffLL-1)
00309 #  endif
00310 #  if ! defined(QUAD_MAX)
00311 #   define QUAD_MAX     (0x7fffffffffffffffLL)
00312 #  endif
00313 #define YYENABLE_NLS 0
00314 #define YYPARSE_PARAM parseio
00315 #define YYLEX_PARAM ((struct parse_io *)parseio)->scanner
00316 #define YYERROR_VERBOSE 1
00317 extern char extra_error_message[4095];
00318 extern int extra_error_message_supplied;
00319 
00320 enum valtype {
00321    AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string
00322 } ;
00323 
00324 #if defined(STANDALONE) || defined(STANDALONE2)
00325 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf,5,6)));
00326 #endif
00327 
00328 struct val {
00329    enum valtype type;
00330    union {
00331       char *s;
00332       FP___TYPE i; /* either long double, or just double, on a bad day */
00333    } u;
00334 } ;
00335 
00336 enum node_type {
00337    AST_EXPR_NODE_COMMA, AST_EXPR_NODE_STRING, AST_EXPR_NODE_VAL
00338 } ;
00339 
00340 struct expr_node 
00341 {
00342    enum node_type type;
00343    struct val *val;
00344    struct expr_node *left;
00345    struct expr_node *right;
00346 };
00347 
00348 
00349 typedef void *yyscan_t;
00350 
00351 struct parse_io
00352 {
00353    char *string;
00354    struct val *val;
00355    yyscan_t scanner;
00356    struct ast_channel *chan;
00357 };
00358  
00359 static int     chk_div __P((FP___TYPE, FP___TYPE));
00360 static int     chk_minus __P((FP___TYPE, FP___TYPE, FP___TYPE));
00361 static int     chk_plus __P((FP___TYPE, FP___TYPE, FP___TYPE));
00362 static int     chk_times __P((FP___TYPE, FP___TYPE, FP___TYPE));
00363 static void    free_value __P((struct val *));
00364 static int     is_zero_or_null __P((struct val *));
00365 static int     isstring __P((struct val *));
00366 static struct val *make_number __P((FP___TYPE));
00367 static struct val *make_str __P((const char *));
00368 static struct val *op_and __P((struct val *, struct val *));
00369 static struct val *op_colon __P((struct val *, struct val *));
00370 static struct val *op_eqtilde __P((struct val *, struct val *));
00371 static struct val *op_tildetilde __P((struct val *, struct val *));
00372 static struct val *op_div __P((struct val *, struct val *));
00373 static struct val *op_eq __P((struct val *, struct val *));
00374 static struct val *op_ge __P((struct val *, struct val *));
00375 static struct val *op_gt __P((struct val *, struct val *));
00376 static struct val *op_le __P((struct val *, struct val *));
00377 static struct val *op_lt __P((struct val *, struct val *));
00378 static struct val *op_cond __P((struct val *, struct val *, struct val *));
00379 static struct val *op_minus __P((struct val *, struct val *));
00380 static struct val *op_negate __P((struct val *));
00381 static struct val *op_compl __P((struct val *));
00382 static struct val *op_ne __P((struct val *, struct val *));
00383 static struct val *op_or __P((struct val *, struct val *));
00384 static struct val *op_plus __P((struct val *, struct val *));
00385 static struct val *op_rem __P((struct val *, struct val *));
00386 static struct val *op_times __P((struct val *, struct val *));
00387 static struct val   *op_func(struct val *funcname, struct expr_node *arglist, struct ast_channel *chan);
00388 static int     to_number __P((struct val *));
00389 static void    to_string __P((struct val *));
00390 static struct expr_node *alloc_expr_node(enum node_type);
00391 static void destroy_arglist(struct expr_node *arglist);
00392 
00393 /* uh, if I want to predeclare yylex with a YYLTYPE, I have to predeclare the yyltype... sigh */
00394 typedef struct yyltype
00395 {
00396   int first_line;
00397   int first_column;
00398 
00399   int last_line;
00400   int last_column;
00401 } yyltype;
00402 
00403 # define YYLTYPE yyltype
00404 # define YYLTYPE_IS_TRIVIAL 1
00405 
00406 /* we will get warning about no prototype for yylex! But we can't
00407    define it here, we have no definition yet for YYSTYPE. */
00408 
00409 int      ast_yyerror(const char *,YYLTYPE *, struct parse_io *);
00410  
00411 /* I wanted to add args to the yyerror routine, so I could print out
00412    some useful info about the error. Not as easy as it looks, but it
00413    is possible. */
00414 #define ast_yyerror(x) ast_yyerror(x,&yyloc,parseio)
00415 #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);}
00416 
00417 
00418 /* Line 189 of yacc.c  */
00419 #line 419 "ast_expr2.c"
00420 
00421 /* Enabling traces.  */
00422 #ifndef YYDEBUG
00423 # define YYDEBUG 0
00424 #endif
00425 
00426 /* Enabling verbose error messages.  */
00427 #ifdef YYERROR_VERBOSE
00428 # undef YYERROR_VERBOSE
00429 # define YYERROR_VERBOSE 1
00430 #else
00431 # define YYERROR_VERBOSE 0
00432 #endif
00433 
00434 /* Enabling the token table.  */
00435 #ifndef YYTOKEN_TABLE
00436 # define YYTOKEN_TABLE 0
00437 #endif
00438 
00439 
00440 /* Tokens.  */
00441 #ifndef YYTOKENTYPE
00442 # define YYTOKENTYPE
00443    /* Put the tokens into the symbol table, so that GDB and other debuggers
00444       know about them.  */
00445    enum yytokentype {
00446      TOK_COMMA = 258,
00447      TOK_COLONCOLON = 259,
00448      TOK_COND = 260,
00449      TOK_OR = 261,
00450      TOK_AND = 262,
00451      TOK_NE = 263,
00452      TOK_LE = 264,
00453      TOK_GE = 265,
00454      TOK_LT = 266,
00455      TOK_GT = 267,
00456      TOK_EQ = 268,
00457      TOK_MINUS = 269,
00458      TOK_PLUS = 270,
00459      TOK_MOD = 271,
00460      TOK_DIV = 272,
00461      TOK_MULT = 273,
00462      TOK_COMPL = 274,
00463      TOK_TILDETILDE = 275,
00464      TOK_EQTILDE = 276,
00465      TOK_COLON = 277,
00466      TOK_LP = 278,
00467      TOK_RP = 279,
00468      TOKEN = 280
00469    };
00470 #endif
00471 
00472 
00473 
00474 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
00475 typedef union YYSTYPE
00476 {
00477 
00478 /* Line 214 of yacc.c  */
00479 #line 345 "ast_expr2.y"
00480 
00481    struct val *val;
00482    struct expr_node *arglist;
00483 
00484 
00485 
00486 /* Line 214 of yacc.c  */
00487 #line 487 "ast_expr2.c"
00488 } YYSTYPE;
00489 # define YYSTYPE_IS_TRIVIAL 1
00490 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
00491 # define YYSTYPE_IS_DECLARED 1
00492 #endif
00493 
00494 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
00495 typedef struct YYLTYPE
00496 {
00497   int first_line;
00498   int first_column;
00499   int last_line;
00500   int last_column;
00501 } YYLTYPE;
00502 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
00503 # define YYLTYPE_IS_DECLARED 1
00504 # define YYLTYPE_IS_TRIVIAL 1
00505 #endif
00506 
00507 
00508 /* Copy the second part of user declarations.  */
00509 
00510 /* Line 264 of yacc.c  */
00511 #line 350 "ast_expr2.y"
00512 
00513 extern int     ast_yylex __P((YYSTYPE *, YYLTYPE *, yyscan_t));
00514 
00515 
00516 /* Line 264 of yacc.c  */
00517 #line 517 "ast_expr2.c"
00518 
00519 #ifdef short
00520 # undef short
00521 #endif
00522 
00523 #ifdef YYTYPE_UINT8
00524 typedef YYTYPE_UINT8 yytype_uint8;
00525 #else
00526 typedef unsigned char yytype_uint8;
00527 #endif
00528 
00529 #ifdef YYTYPE_INT8
00530 typedef YYTYPE_INT8 yytype_int8;
00531 #elif (defined __STDC__ || defined __C99__FUNC__ \
00532      || defined __cplusplus || defined _MSC_VER)
00533 typedef signed char yytype_int8;
00534 #else
00535 typedef short int yytype_int8;
00536 #endif
00537 
00538 #ifdef YYTYPE_UINT16
00539 typedef YYTYPE_UINT16 yytype_uint16;
00540 #else
00541 typedef unsigned short int yytype_uint16;
00542 #endif
00543 
00544 #ifdef YYTYPE_INT16
00545 typedef YYTYPE_INT16 yytype_int16;
00546 #else
00547 typedef short int yytype_int16;
00548 #endif
00549 
00550 #ifndef YYSIZE_T
00551 # ifdef __SIZE_TYPE__
00552 #  define YYSIZE_T __SIZE_TYPE__
00553 # elif defined size_t
00554 #  define YYSIZE_T size_t
00555 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
00556      || defined __cplusplus || defined _MSC_VER)
00557 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
00558 #  define YYSIZE_T size_t
00559 # else
00560 #  define YYSIZE_T unsigned int
00561 # endif
00562 #endif
00563 
00564 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
00565 
00566 #ifndef YY_
00567 # if YYENABLE_NLS
00568 #  if ENABLE_NLS
00569 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
00570 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
00571 #  endif
00572 # endif
00573 # ifndef YY_
00574 #  define YY_(msgid) msgid
00575 # endif
00576 #endif
00577 
00578 /* Suppress unused-variable warnings by "using" E.  */
00579 #if ! defined lint || defined __GNUC__
00580 # define YYUSE(e) ((void) (e))
00581 #else
00582 # define YYUSE(e) /* empty */
00583 #endif
00584 
00585 /* Identity function, used to suppress warnings about constant conditions.  */
00586 #ifndef lint
00587 # define YYID(n) (n)
00588 #else
00589 #if (defined __STDC__ || defined __C99__FUNC__ \
00590      || defined __cplusplus || defined _MSC_VER)
00591 static int
00592 YYID (int yyi)
00593 #else
00594 static int
00595 YYID (yyi)
00596     int yyi;
00597 #endif
00598 {
00599   return yyi;
00600 }
00601 #endif
00602 
00603 #if ! defined yyoverflow || YYERROR_VERBOSE
00604 
00605 /* The parser invokes alloca or malloc; define the necessary symbols.  */
00606 
00607 # ifdef YYSTACK_USE_ALLOCA
00608 #  if YYSTACK_USE_ALLOCA
00609 #   ifdef __GNUC__
00610 #    define YYSTACK_ALLOC __builtin_alloca
00611 #   elif defined __BUILTIN_VA_ARG_INCR
00612 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
00613 #   elif defined _AIX
00614 #    define YYSTACK_ALLOC __alloca
00615 #   elif defined _MSC_VER
00616 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
00617 #    define alloca _alloca
00618 #   else
00619 #    define YYSTACK_ALLOC alloca
00620 #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00621      || defined __cplusplus || defined _MSC_VER)
00622 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
00623 #     ifndef _STDLIB_H
00624 #      define _STDLIB_H 1
00625 #     endif
00626 #    endif
00627 #   endif
00628 #  endif
00629 # endif
00630 
00631 # ifdef YYSTACK_ALLOC
00632    /* Pacify GCC's `empty if-body' warning.  */
00633 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
00634 #  ifndef YYSTACK_ALLOC_MAXIMUM
00635     /* The OS might guarantee only one guard page at the bottom of the stack,
00636        and a page size can be as small as 4096 bytes.  So we cannot safely
00637        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
00638        to allow for a few compiler-allocated temporary stack slots.  */
00639 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
00640 #  endif
00641 # else
00642 #  define YYSTACK_ALLOC YYMALLOC
00643 #  define YYSTACK_FREE YYFREE
00644 #  ifndef YYSTACK_ALLOC_MAXIMUM
00645 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
00646 #  endif
00647 #  if (defined __cplusplus && ! defined _STDLIB_H \
00648        && ! ((defined YYMALLOC || defined malloc) \
00649         && (defined YYFREE || defined free)))
00650 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
00651 #   ifndef _STDLIB_H
00652 #    define _STDLIB_H 1
00653 #   endif
00654 #  endif
00655 #  ifndef YYMALLOC
00656 #   define YYMALLOC malloc
00657 #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00658      || defined __cplusplus || defined _MSC_VER)
00659 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
00660 #   endif
00661 #  endif
00662 #  ifndef YYFREE
00663 #   define YYFREE free
00664 #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00665      || defined __cplusplus || defined _MSC_VER)
00666 void free (void *); /* INFRINGES ON USER NAME SPACE */
00667 #   endif
00668 #  endif
00669 # endif
00670 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
00671 
00672 
00673 #if (! defined yyoverflow \
00674      && (! defined __cplusplus \
00675     || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
00676         && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
00677 
00678 /* A type that is properly aligned for any stack member.  */
00679 union yyalloc
00680 {
00681   yytype_int16 yyss_alloc;
00682   YYSTYPE yyvs_alloc;
00683   YYLTYPE yyls_alloc;
00684 };
00685 
00686 /* The size of the maximum gap between one aligned stack and the next.  */
00687 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
00688 
00689 /* The size of an array large to enough to hold all stacks, each with
00690    N elements.  */
00691 # define YYSTACK_BYTES(N) \
00692      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
00693       + 2 * YYSTACK_GAP_MAXIMUM)
00694 
00695 /* Copy COUNT objects from FROM to TO.  The source and destination do
00696    not overlap.  */
00697 # ifndef YYCOPY
00698 #  if defined __GNUC__ && 1 < __GNUC__
00699 #   define YYCOPY(To, From, Count) \
00700       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
00701 #  else
00702 #   define YYCOPY(To, From, Count)     \
00703       do             \
00704    {              \
00705      YYSIZE_T yyi;            \
00706      for (yyi = 0; yyi < (Count); yyi++)  \
00707        (To)[yyi] = (From)[yyi];     \
00708    }              \
00709       while (YYID (0))
00710 #  endif
00711 # endif
00712 
00713 /* Relocate STACK from its old location to the new one.  The
00714    local variables YYSIZE and YYSTACKSIZE give the old and new number of
00715    elements in the stack, and YYPTR gives the new location of the
00716    stack.  Advance YYPTR to a properly aligned location for the next
00717    stack.  */
00718 # define YYSTACK_RELOCATE(Stack_alloc, Stack)            \
00719     do                           \
00720       {                          \
00721    YYSIZE_T yynewbytes;                \
00722    YYCOPY (&yyptr->Stack_alloc, Stack, yysize);       \
00723    Stack = &yyptr->Stack_alloc;              \
00724    yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
00725    yyptr += yynewbytes / sizeof (*yyptr);          \
00726       }                          \
00727     while (YYID (0))
00728 
00729 #endif
00730 
00731 /* YYFINAL -- State number of the termination state.  */
00732 #define YYFINAL  11
00733 /* YYLAST -- Last index in YYTABLE.  */
00734 #define YYLAST   159
00735 
00736 /* YYNTOKENS -- Number of terminals.  */
00737 #define YYNTOKENS  26
00738 /* YYNNTS -- Number of nonterminals.  */
00739 #define YYNNTS  4
00740 /* YYNRULES -- Number of rules.  */
00741 #define YYNRULES  28
00742 /* YYNRULES -- Number of states.  */
00743 #define YYNSTATES  54
00744 
00745 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
00746 #define YYUNDEFTOK  2
00747 #define YYMAXUTOK   280
00748 
00749 #define YYTRANSLATE(YYX)                  \
00750   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
00751 
00752 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
00753 static const yytype_uint8 yytranslate[] =
00754 {
00755        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00756        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00757        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00758        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00759        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00760        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00761        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00762        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00763        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00764        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00765        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00766        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00767        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00768        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00769        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00770        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00771        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00772        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00773        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00774        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00775        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00776        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00777        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00778        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00779        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00780        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
00781        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
00782       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
00783       25
00784 };
00785 
00786 #if YYDEBUG
00787 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
00788    YYRHS.  */
00789 static const yytype_uint8 yyprhs[] =
00790 {
00791        0,     0,     3,     5,     6,     8,    12,    15,    20,    22,
00792       26,    30,    34,    38,    42,    46,    50,    54,    58,    62,
00793       66,    69,    72,    76,    80,    84,    88,    92,    98
00794 };
00795 
00796 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
00797 static const yytype_int8 yyrhs[] =
00798 {
00799       27,     0,    -1,    29,    -1,    -1,    29,    -1,    28,     3,
00800       29,    -1,    28,     3,    -1,    25,    23,    28,    24,    -1,
00801       25,    -1,    23,    29,    24,    -1,    29,     6,    29,    -1,
00802       29,     7,    29,    -1,    29,    13,    29,    -1,    29,    12,
00803       29,    -1,    29,    11,    29,    -1,    29,    10,    29,    -1,
00804       29,     9,    29,    -1,    29,     8,    29,    -1,    29,    15,
00805       29,    -1,    29,    14,    29,    -1,    14,    29,    -1,    19,
00806       29,    -1,    29,    18,    29,    -1,    29,    17,    29,    -1,
00807       29,    16,    29,    -1,    29,    22,    29,    -1,    29,    21,
00808       29,    -1,    29,     5,    29,     4,    29,    -1,    29,    20,
00809       29,    -1
00810 };
00811 
00812 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
00813 static const yytype_uint16 yyrline[] =
00814 {
00815        0,   374,   374,   382,   389,   390,   396,   405,   411,   412,
00816      416,   420,   424,   428,   432,   436,   440,   444,   448,   452,
00817      456,   460,   464,   468,   472,   476,   480,   484,   489
00818 };
00819 #endif
00820 
00821 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
00822 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
00823    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
00824 static const char *const yytname[] =
00825 {
00826   "$end", "error", "$undefined", "TOK_COMMA", "TOK_COLONCOLON",
00827   "TOK_COND", "TOK_OR", "TOK_AND", "TOK_NE", "TOK_LE", "TOK_GE", "TOK_LT",
00828   "TOK_GT", "TOK_EQ", "TOK_MINUS", "TOK_PLUS", "TOK_MOD", "TOK_DIV",
00829   "TOK_MULT", "TOK_COMPL", "TOK_TILDETILDE", "TOK_EQTILDE", "TOK_COLON",
00830   "TOK_LP", "TOK_RP", "TOKEN", "$accept", "start", "arglist", "expr", 0
00831 };
00832 #endif
00833 
00834 # ifdef YYPRINT
00835 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
00836    token YYLEX-NUM.  */
00837 static const yytype_uint16 yytoknum[] =
00838 {
00839        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
00840      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
00841      275,   276,   277,   278,   279,   280
00842 };
00843 # endif
00844 
00845 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
00846 static const yytype_uint8 yyr1[] =
00847 {
00848        0,    26,    27,    27,    28,    28,    28,    29,    29,    29,
00849       29,    29,    29,    29,    29,    29,    29,    29,    29,    29,
00850       29,    29,    29,    29,    29,    29,    29,    29,    29
00851 };
00852 
00853 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
00854 static const yytype_uint8 yyr2[] =
00855 {
00856        0,     2,     1,     0,     1,     3,     2,     4,     1,     3,
00857        3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
00858        2,     2,     3,     3,     3,     3,     3,     5,     3
00859 };
00860 
00861 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
00862    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
00863    means the default is an error.  */
00864 static const yytype_uint8 yydefact[] =
00865 {
00866        3,     0,     0,     0,     8,     0,     2,    20,    21,     0,
00867        0,     1,     0,     0,     0,     0,     0,     0,     0,     0,
00868        0,     0,     0,     0,     0,     0,     0,     0,     0,     9,
00869        0,     4,     0,    10,    11,    17,    16,    15,    14,    13,
00870       12,    19,    18,    24,    23,    22,    28,    26,    25,     6,
00871        7,     0,     5,    27
00872 };
00873 
00874 /* YYDEFGOTO[NTERM-NUM].  */
00875 static const yytype_int8 yydefgoto[] =
00876 {
00877       -1,     5,    30,     6
00878 };
00879 
00880 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
00881    STATE-NUM.  */
00882 #define YYPACT_NINF -18
00883 static const yytype_int16 yypact[] =
00884 {
00885      118,   118,   118,   118,   -15,     6,    65,   -17,   -17,    25,
00886      118,   -18,   118,   118,   118,   118,   118,   118,   118,   118,
00887      118,   118,   118,   118,   118,   118,   118,   118,   118,   -18,
00888        4,    65,    47,    98,   113,   130,   130,   130,   130,   130,
00889      130,   137,   137,   -17,   -17,   -17,   -18,   -18,   -18,   118,
00890      -18,   118,    65,    82
00891 };
00892 
00893 /* YYPGOTO[NTERM-NUM].  */
00894 static const yytype_int8 yypgoto[] =
00895 {
00896      -18,   -18,   -18,    -1
00897 };
00898 
00899 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
00900    positive, shift that token.  If negative, reduce the rule which
00901    number is the opposite.  If zero, do what YYDEFACT says.
00902    If YYTABLE_NINF, syntax error.  */
00903 #define YYTABLE_NINF -1
00904 static const yytype_uint8 yytable[] =
00905 {
00906        7,     8,     9,    26,    27,    28,    11,    49,    10,    31,
00907        0,    32,    33,    34,    35,    36,    37,    38,    39,    40,
00908       41,    42,    43,    44,    45,    46,    47,    48,    50,     0,
00909       12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
00910       22,    23,    24,    25,     0,    26,    27,    28,    52,    29,
00911       53,    51,    12,    13,    14,    15,    16,    17,    18,    19,
00912       20,    21,    22,    23,    24,    25,     0,    26,    27,    28,
00913       12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
00914       22,    23,    24,    25,     0,    26,    27,    28,    13,    14,
00915       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
00916       25,     0,    26,    27,    28,    14,    15,    16,    17,    18,
00917       19,    20,    21,    22,    23,    24,    25,     0,    26,    27,
00918       28,    15,    16,    17,    18,    19,    20,    21,    22,    23,
00919       24,    25,     1,    26,    27,    28,     0,     2,     0,     0,
00920        0,     3,     0,     4,    21,    22,    23,    24,    25,     0,
00921       26,    27,    28,    23,    24,    25,     0,    26,    27,    28
00922 };
00923 
00924 static const yytype_int8 yycheck[] =
00925 {
00926        1,     2,     3,    20,    21,    22,     0,     3,    23,    10,
00927       -1,    12,    13,    14,    15,    16,    17,    18,    19,    20,
00928       21,    22,    23,    24,    25,    26,    27,    28,    24,    -1,
00929        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
00930       15,    16,    17,    18,    -1,    20,    21,    22,    49,    24,
00931       51,     4,     5,     6,     7,     8,     9,    10,    11,    12,
00932       13,    14,    15,    16,    17,    18,    -1,    20,    21,    22,
00933        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
00934       15,    16,    17,    18,    -1,    20,    21,    22,     6,     7,
00935        8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
00936       18,    -1,    20,    21,    22,     7,     8,     9,    10,    11,
00937       12,    13,    14,    15,    16,    17,    18,    -1,    20,    21,
00938       22,     8,     9,    10,    11,    12,    13,    14,    15,    16,
00939       17,    18,    14,    20,    21,    22,    -1,    19,    -1,    -1,
00940       -1,    23,    -1,    25,    14,    15,    16,    17,    18,    -1,
00941       20,    21,    22,    16,    17,    18,    -1,    20,    21,    22
00942 };
00943 
00944 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
00945    symbol of state STATE-NUM.  */
00946 static const yytype_uint8 yystos[] =
00947 {
00948        0,    14,    19,    23,    25,    27,    29,    29,    29,    29,
00949       23,     0,     5,     6,     7,     8,     9,    10,    11,    12,
00950       13,    14,    15,    16,    17,    18,    20,    21,    22,    24,
00951       28,    29,    29,    29,    29,    29,    29,    29,    29,    29,
00952       29,    29,    29,    29,    29,    29,    29,    29,    29,     3,
00953       24,     4,    29,    29
00954 };
00955 
00956 #define yyerrok      (yyerrstatus = 0)
00957 #define yyclearin (yychar = YYEMPTY)
00958 #define YYEMPTY      (-2)
00959 #define YYEOF     0
00960 
00961 #define YYACCEPT  goto yyacceptlab
00962 #define YYABORT      goto yyabortlab
00963 #define YYERROR      goto yyerrorlab
00964 
00965 
00966 /* Like YYERROR except do call yyerror.  This remains here temporarily
00967    to ease the transition to the new meaning of YYERROR, for GCC.
00968    Once GCC version 2 has supplanted version 1, this can go.  */
00969 
00970 #define YYFAIL    goto yyerrlab
00971 
00972 #define YYRECOVERING()  (!!yyerrstatus)
00973 
00974 #define YYBACKUP(Token, Value)               \
00975 do                      \
00976   if (yychar == YYEMPTY && yylen == 1)          \
00977     {                      \
00978       yychar = (Token);                \
00979       yylval = (Value);                \
00980       yytoken = YYTRANSLATE (yychar);           \
00981       YYPOPSTACK (1);                  \
00982       goto yybackup;                \
00983     }                      \
00984   else                        \
00985     {                      \
00986       yyerror (YY_("syntax error: cannot back up")); \
00987       YYERROR;                   \
00988     }                      \
00989 while (YYID (0))
00990 
00991 
00992 #define YYTERROR  1
00993 #define YYERRCODE 256
00994 
00995 
00996 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
00997    If N is 0, then set CURRENT to the empty location which ends
00998    the previous symbol: RHS[0] (always defined).  */
00999 
01000 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
01001 #ifndef YYLLOC_DEFAULT
01002 # define YYLLOC_DEFAULT(Current, Rhs, N)           \
01003     do                           \
01004       if (YYID (N))                                                    \
01005    {                       \
01006      (Current).first_line   = YYRHSLOC (Rhs, 1).first_line; \
01007      (Current).first_column = YYRHSLOC (Rhs, 1).first_column;  \
01008      (Current).last_line    = YYRHSLOC (Rhs, N).last_line;     \
01009      (Current).last_column  = YYRHSLOC (Rhs, N).last_column;   \
01010    }                       \
01011       else                       \
01012    {                       \
01013      (Current).first_line   = (Current).last_line   =    \
01014        YYRHSLOC (Rhs, 0).last_line;          \
01015      (Current).first_column = (Current).last_column =    \
01016        YYRHSLOC (Rhs, 0).last_column;           \
01017    }                       \
01018     while (YYID (0))
01019 #endif
01020 
01021 
01022 /* YY_LOCATION_PRINT -- Print the location on the stream.
01023    This macro was not mandated originally: define only if we know
01024    we won't break user code: when these are the locations we know.  */
01025 
01026 #ifndef YY_LOCATION_PRINT
01027 # if YYLTYPE_IS_TRIVIAL
01028 #  define YY_LOCATION_PRINT(File, Loc)       \
01029      fprintf (File, "%d.%d-%d.%d",        \
01030          (Loc).first_line, (Loc).first_column,  \
01031          (Loc).last_line,  (Loc).last_column)
01032 # else
01033 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
01034 # endif
01035 #endif
01036 
01037 
01038 /* YYLEX -- calling `yylex' with the right arguments.  */
01039 
01040 #ifdef YYLEX_PARAM
01041 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
01042 #else
01043 # define YYLEX yylex (&yylval, &yylloc)
01044 #endif
01045 
01046 /* Enable debugging if requested.  */
01047 #if YYDEBUG
01048 
01049 # ifndef YYFPRINTF
01050 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
01051 #  define YYFPRINTF fprintf
01052 # endif
01053 
01054 # define YYDPRINTF(Args)         \
01055 do {                 \
01056   if (yydebug)             \
01057     YYFPRINTF Args;           \
01058 } while (YYID (0))
01059 
01060 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)           \
01061 do {                            \
01062   if (yydebug)                        \
01063     {                           \
01064       YYFPRINTF (stderr, "%s ", Title);                 \
01065       yy_symbol_print (stderr,                    \
01066         Type, Value, Location); \
01067       YYFPRINTF (stderr, "\n");                   \
01068     }                           \
01069 } while (YYID (0))
01070 
01071 
01072 /*--------------------------------.
01073 | Print this symbol on YYOUTPUT.  |
01074 `--------------------------------*/
01075 
01076 /*ARGSUSED*/
01077 #if (defined __STDC__ || defined __C99__FUNC__ \
01078      || defined __cplusplus || defined _MSC_VER)
01079 static void
01080 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
01081 #else
01082 static void
01083 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
01084     FILE *yyoutput;
01085     int yytype;
01086     YYSTYPE const * const yyvaluep;
01087     YYLTYPE const * const yylocationp;
01088 #endif
01089 {
01090   if (!yyvaluep)
01091     return;
01092   YYUSE (yylocationp);
01093 # ifdef YYPRINT
01094   if (yytype < YYNTOKENS)
01095     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
01096 # else
01097   YYUSE (yyoutput);
01098 # endif
01099   switch (yytype)
01100     {
01101       default:
01102    break;
01103     }
01104 }
01105 
01106 
01107 /*--------------------------------.
01108 | Print this symbol on YYOUTPUT.  |
01109 `--------------------------------*/
01110 
01111 #if (defined __STDC__ || defined __C99__FUNC__ \
01112      || defined __cplusplus || defined _MSC_VER)
01113 static void
01114 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
01115 #else
01116 static void
01117 yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
01118     FILE *yyoutput;
01119     int yytype;
01120     YYSTYPE const * const yyvaluep;
01121     YYLTYPE const * const yylocationp;
01122 #endif
01123 {
01124   if (yytype < YYNTOKENS)
01125     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
01126   else
01127     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
01128 
01129   YY_LOCATION_PRINT (yyoutput, *yylocationp);
01130   YYFPRINTF (yyoutput, ": ");
01131   yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
01132   YYFPRINTF (yyoutput, ")");
01133 }
01134 
01135 /*------------------------------------------------------------------.
01136 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
01137 | TOP (included).                                                   |
01138 `------------------------------------------------------------------*/
01139 
01140 #if (defined __STDC__ || defined __C99__FUNC__ \
01141      || defined __cplusplus || defined _MSC_VER)
01142 static void
01143 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
01144 #else
01145 static void
01146 yy_stack_print (yybottom, yytop)
01147     yytype_int16 *yybottom;
01148     yytype_int16 *yytop;
01149 #endif
01150 {
01151   YYFPRINTF (stderr, "Stack now");
01152   for (; yybottom <= yytop; yybottom++)
01153     {
01154       int yybot = *yybottom;
01155       YYFPRINTF (stderr, " %d", yybot);
01156     }
01157   YYFPRINTF (stderr, "\n");
01158 }
01159 
01160 # define YY_STACK_PRINT(Bottom, Top)            \
01161 do {                       \
01162   if (yydebug)                   \
01163     yy_stack_print ((Bottom), (Top));           \
01164 } while (YYID (0))
01165 
01166 
01167 /*------------------------------------------------.
01168 | Report that the YYRULE is going to be reduced.  |
01169 `------------------------------------------------*/
01170 
01171 #if (defined __STDC__ || defined __C99__FUNC__ \
01172      || defined __cplusplus || defined _MSC_VER)
01173 static void
01174 yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
01175 #else
01176 static void
01177 yy_reduce_print (yyvsp, yylsp, yyrule)
01178     YYSTYPE *yyvsp;
01179     YYLTYPE *yylsp;
01180     int yyrule;
01181 #endif
01182 {
01183   int yynrhs = yyr2[yyrule];
01184   int yyi;
01185   unsigned long int yylno = yyrline[yyrule];
01186   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
01187         yyrule - 1, yylno);
01188   /* The symbols being reduced.  */
01189   for (yyi = 0; yyi < yynrhs; yyi++)
01190     {
01191       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
01192       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
01193              &(yyvsp[(yyi + 1) - (yynrhs)])
01194              , &(yylsp[(yyi + 1) - (yynrhs)])             );
01195       YYFPRINTF (stderr, "\n");
01196     }
01197 }
01198 
01199 # define YY_REDUCE_PRINT(Rule)      \
01200 do {              \
01201   if (yydebug)          \
01202     yy_reduce_print (yyvsp, yylsp, Rule); \
01203 } while (YYID (0))
01204 
01205 /* Nonzero means print parse trace.  It is left uninitialized so that
01206    multiple parsers can coexist.  */
01207 int yydebug;
01208 #else /* !YYDEBUG */
01209 # define YYDPRINTF(Args)
01210 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
01211 # define YY_STACK_PRINT(Bottom, Top)
01212 # define YY_REDUCE_PRINT(Rule)
01213 #endif /* !YYDEBUG */
01214 
01215 
01216 /* YYINITDEPTH -- initial size of the parser's stacks.  */
01217 #ifndef  YYINITDEPTH
01218 # define YYINITDEPTH 200
01219 #endif
01220 
01221 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
01222    if the built-in stack extension method is used).
01223 
01224    Do not make this value too large; the results are undefined if
01225    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
01226    evaluated with infinite-precision integer arithmetic.  */
01227 
01228 #ifndef YYMAXDEPTH
01229 # define YYMAXDEPTH 10000
01230 #endif
01231 
01232 
01233 
01234 #if YYERROR_VERBOSE
01235 
01236 # ifndef yystrlen
01237 #  if defined __GLIBC__ && defined _STRING_H
01238 #   define yystrlen strlen
01239 #  else
01240 /* Return the length of YYSTR.  */
01241 #if (defined __STDC__ || defined __C99__FUNC__ \
01242      || defined __cplusplus || defined _MSC_VER)
01243 static YYSIZE_T
01244 yystrlen (const char *yystr)
01245 #else
01246 static YYSIZE_T
01247 yystrlen (yystr)
01248     const char *yystr;
01249 #endif
01250 {
01251   YYSIZE_T yylen;
01252   for (yylen = 0; yystr[yylen]; yylen++)
01253     continue;
01254   return yylen;
01255 }
01256 #  endif
01257 # endif
01258 
01259 # ifndef yystpcpy
01260 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
01261 #   define yystpcpy stpcpy
01262 #  else
01263 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
01264    YYDEST.  */
01265 #if (defined __STDC__ || defined __C99__FUNC__ \
01266      || defined __cplusplus || defined _MSC_VER)
01267 static char *
01268 yystpcpy (char *yydest, const char *yysrc)
01269 #else
01270 static char *
01271 yystpcpy (yydest, yysrc)
01272     char *yydest;
01273     const char *yysrc;
01274 #endif
01275 {
01276   char *yyd = yydest;
01277   const char *yys = yysrc;
01278 
01279   while ((*yyd++ = *yys++) != '\0')
01280     continue;
01281 
01282   return yyd - 1;
01283 }
01284 #  endif
01285 # endif
01286 
01287 # ifndef yytnamerr
01288 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
01289    quotes and backslashes, so that it's suitable for yyerror.  The
01290    heuristic is that double-quoting is unnecessary unless the string
01291    contains an apostrophe, a comma, or backslash (other than
01292    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
01293    null, do not copy; instead, return the length of what the result
01294    would have been.  */
01295 static YYSIZE_T
01296 yytnamerr (char *yyres, const char *yystr)
01297 {
01298   if (*yystr == '"')
01299     {
01300       YYSIZE_T yyn = 0;
01301       char const *yyp = yystr;
01302 
01303       for (;;)
01304    switch (*++yyp)
01305      {
01306      case '\'':
01307      case ',':
01308        goto do_not_strip_quotes;
01309 
01310      case '\\':
01311        if (*++yyp != '\\')
01312          goto do_not_strip_quotes;
01313        /* Fall through.  */
01314      default:
01315        if (yyres)
01316          yyres[yyn] = *yyp;
01317        yyn++;
01318        break;
01319 
01320      case '"':
01321        if (yyres)
01322          yyres[yyn] = '\0';
01323        return yyn;
01324      }
01325     do_not_strip_quotes: ;
01326     }
01327 
01328   if (! yyres)
01329     return yystrlen (yystr);
01330 
01331   return yystpcpy (yyres, yystr) - yyres;
01332 }
01333 # endif
01334 
01335 /* Copy into YYRESULT an error message about the unexpected token
01336    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
01337    including the terminating null byte.  If YYRESULT is null, do not
01338    copy anything; just return the number of bytes that would be
01339    copied.  As a special case, return 0 if an ordinary "syntax error"
01340    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
01341    size calculation.  */
01342 static YYSIZE_T
01343 yysyntax_error (char *yyresult, int yystate, int yychar)
01344 {
01345   int yyn = yypact[yystate];
01346 
01347   if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
01348     return 0;
01349   else
01350     {
01351       int yytype = YYTRANSLATE (yychar);
01352       YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
01353       YYSIZE_T yysize = yysize0;
01354       YYSIZE_T yysize1;
01355       int yysize_overflow = 0;
01356       enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
01357       char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
01358       int yyx;
01359 
01360 # if 0
01361       /* This is so xgettext sees the translatable formats that are
01362     constructed on the fly.  */
01363       YY_("syntax error, unexpected %s");
01364       YY_("syntax error, unexpected %s, expecting %s");
01365       YY_("syntax error, unexpected %s, expecting %s or %s");
01366       YY_("syntax error, unexpected %s, expecting %s or %s or %s");
01367       YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
01368 # endif
01369       char *yyfmt;
01370       char const *yyf;
01371       static char const yyunexpected[] = "syntax error, unexpected %s";
01372       static char const yyexpecting[] = ", expecting %s";
01373       static char const yyor[] = " or %s";
01374       char yyformat[sizeof yyunexpected
01375           + sizeof yyexpecting - 1
01376           + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
01377              * (sizeof yyor - 1))];
01378       char const *yyprefix = yyexpecting;
01379 
01380       /* Start YYX at -YYN if negative to avoid negative indexes in
01381     YYCHECK.  */
01382       int yyxbegin = yyn < 0 ? -yyn : 0;
01383 
01384       /* Stay within bounds of both yycheck and yytname.  */
01385       int yychecklim = YYLAST - yyn + 1;
01386       int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
01387       int yycount = 1;
01388 
01389       yyarg[0] = yytname[yytype];
01390       yyfmt = yystpcpy (yyformat, yyunexpected);
01391 
01392       for (yyx = yyxbegin; yyx < yyxend; ++yyx)
01393    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
01394      {
01395        if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
01396          {
01397       yycount = 1;
01398       yysize = yysize0;
01399       yyformat[sizeof yyunexpected - 1] = '\0';
01400       break;
01401          }
01402        yyarg[yycount++] = yytname[yyx];
01403        yysize1 = yysize + yytnamerr (0, yytname[yyx]);
01404        yysize_overflow |= (yysize1 < yysize);
01405        yysize = yysize1;
01406        yyfmt = yystpcpy (yyfmt, yyprefix);
01407        yyprefix = yyor;
01408      }
01409 
01410       yyf = YY_(yyformat);
01411       yysize1 = yysize + yystrlen (yyf);
01412       yysize_overflow |= (yysize1 < yysize);
01413       yysize = yysize1;
01414 
01415       if (yysize_overflow)
01416    return YYSIZE_MAXIMUM;
01417 
01418       if (yyresult)
01419    {
01420      /* Avoid sprintf, as that infringes on the user's name space.
01421         Don't have undefined behavior even if the translation
01422         produced a string with the wrong number of "%s"s.  */
01423      char *yyp = yyresult;
01424      int yyi = 0;
01425      while ((*yyp = *yyf) != '\0')
01426        {
01427          if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
01428       {
01429         yyp += yytnamerr (yyp, yyarg[yyi++]);
01430         yyf += 2;
01431       }
01432          else
01433       {
01434         yyp++;
01435         yyf++;
01436       }
01437        }
01438    }
01439       return yysize;
01440     }
01441 }
01442 #endif /* YYERROR_VERBOSE */
01443 
01444 
01445 /*-----------------------------------------------.
01446 | Release the memory associated to this symbol.  |
01447 `-----------------------------------------------*/
01448 
01449 /*ARGSUSED*/
01450 #if (defined __STDC__ || defined __C99__FUNC__ \
01451      || defined __cplusplus || defined _MSC_VER)
01452 static void
01453 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
01454 #else
01455 static void
01456 yydestruct (yymsg, yytype, yyvaluep, yylocationp)
01457     const char *yymsg;
01458     int yytype;
01459     YYSTYPE *yyvaluep;
01460     YYLTYPE *yylocationp;
01461 #endif
01462 {
01463   YYUSE (yyvaluep);
01464   YYUSE (yylocationp);
01465 
01466   if (!yymsg)
01467     yymsg = "Deleting";
01468   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
01469 
01470   switch (yytype)
01471     {
01472       case 4: /* "TOK_COLONCOLON" */
01473 
01474 /* Line 1000 of yacc.c  */
01475 #line 368 "ast_expr2.y"
01476    {  free_value((yyvaluep->val)); };
01477 
01478 /* Line 1000 of yacc.c  */
01479 #line 1479 "ast_expr2.c"
01480    break;
01481       case 5: /* "TOK_COND" */
01482 
01483 /* Line 1000 of yacc.c  */
01484 #line 368 "ast_expr2.y"
01485    {  free_value((yyvaluep->val)); };
01486 
01487 /* Line 1000 of yacc.c  */
01488 #line 1488 "ast_expr2.c"
01489    break;
01490       case 6: /* "TOK_OR" */
01491 
01492 /* Line 1000 of yacc.c  */
01493 #line 368 "ast_expr2.y"
01494    {  free_value((yyvaluep->val)); };
01495 
01496 /* Line 1000 of yacc.c  */
01497 #line 1497 "ast_expr2.c"
01498    break;
01499       case 7: /* "TOK_AND" */
01500 
01501 /* Line 1000 of yacc.c  */
01502 #line 368 "ast_expr2.y"
01503    {  free_value((yyvaluep->val)); };
01504 
01505 /* Line 1000 of yacc.c  */
01506 #line 1506 "ast_expr2.c"
01507    break;
01508       case 8: /* "TOK_NE" */
01509 
01510 /* Line 1000 of yacc.c  */
01511 #line 368 "ast_expr2.y"
01512    {  free_value((yyvaluep->val)); };
01513 
01514 /* Line 1000 of yacc.c  */
01515 #line 1515 "ast_expr2.c"
01516    break;
01517       case 9: /* "TOK_LE" */
01518 
01519 /* Line 1000 of yacc.c  */
01520 #line 368 "ast_expr2.y"
01521    {  free_value((yyvaluep->val)); };
01522 
01523 /* Line 1000 of yacc.c  */
01524 #line 1524 "ast_expr2.c"
01525    break;
01526       case 10: /* "TOK_GE" */
01527 
01528 /* Line 1000 of yacc.c  */
01529 #line 368 "ast_expr2.y"
01530    {  free_value((yyvaluep->val)); };
01531 
01532 /* Line 1000 of yacc.c  */
01533 #line 1533 "ast_expr2.c"
01534    break;
01535       case 11: /* "TOK_LT" */
01536 
01537 /* Line 1000 of yacc.c  */
01538 #line 368 "ast_expr2.y"
01539    {  free_value((yyvaluep->val)); };
01540 
01541 /* Line 1000 of yacc.c  */
01542 #line 1542 "ast_expr2.c"
01543    break;
01544       case 12: /* "TOK_GT" */
01545 
01546 /* Line 1000 of yacc.c  */
01547 #line 368 "ast_expr2.y"
01548    {  free_value((yyvaluep->val)); };
01549 
01550 /* Line 1000 of yacc.c  */
01551 #line 1551 "ast_expr2.c"
01552    break;
01553       case 13: /* "TOK_EQ" */
01554 
01555 /* Line 1000 of yacc.c  */
01556 #line 368 "ast_expr2.y"
01557    {  free_value((yyvaluep->val)); };
01558 
01559 /* Line 1000 of yacc.c  */
01560 #line 1560 "ast_expr2.c"
01561    break;
01562       case 14: /* "TOK_MINUS" */
01563 
01564 /* Line 1000 of yacc.c  */
01565 #line 368 "ast_expr2.y"
01566    {  free_value((yyvaluep->val)); };
01567 
01568 /* Line 1000 of yacc.c  */
01569 #line 1569 "ast_expr2.c"
01570    break;
01571       case 15: /* "TOK_PLUS" */
01572 
01573 /* Line 1000 of yacc.c  */
01574 #line 368 "ast_expr2.y"
01575    {  free_value((yyvaluep->val)); };
01576 
01577 /* Line 1000 of yacc.c  */
01578 #line 1578 "ast_expr2.c"
01579    break;
01580       case 16: /* "TOK_MOD" */
01581 
01582 /* Line 1000 of yacc.c  */
01583 #line 368 "ast_expr2.y"
01584    {  free_value((yyvaluep->val)); };
01585 
01586 /* Line 1000 of yacc.c  */
01587 #line 1587 "ast_expr2.c"
01588    break;
01589       case 17: /* "TOK_DIV" */
01590 
01591 /* Line 1000 of yacc.c  */
01592 #line 368 "ast_expr2.y"
01593    {  free_value((yyvaluep->val)); };
01594 
01595 /* Line 1000 of yacc.c  */
01596 #line 1596 "ast_expr2.c"
01597    break;
01598       case 18: /* "TOK_MULT" */
01599 
01600 /* Line 1000 of yacc.c  */
01601 #line 368 "ast_expr2.y"
01602    {  free_value((yyvaluep->val)); };
01603 
01604 /* Line 1000 of yacc.c  */
01605 #line 1605 "ast_expr2.c"
01606    break;
01607       case 19: /* "TOK_COMPL" */
01608 
01609 /* Line 1000 of yacc.c  */
01610 #line 368 "ast_expr2.y"
01611    {  free_value((yyvaluep->val)); };
01612 
01613 /* Line 1000 of yacc.c  */
01614 #line 1614 "ast_expr2.c"
01615    break;
01616       case 20: /* "TOK_TILDETILDE" */
01617 
01618 /* Line 1000 of yacc.c  */
01619 #line 368 "ast_expr2.y"
01620    {  free_value((yyvaluep->val)); };
01621 
01622 /* Line 1000 of yacc.c  */
01623 #line 1623 "ast_expr2.c"
01624    break;
01625       case 21: /* "TOK_EQTILDE" */
01626 
01627 /* Line 1000 of yacc.c  */
01628 #line 368 "ast_expr2.y"
01629    {  free_value((yyvaluep->val)); };
01630 
01631 /* Line 1000 of yacc.c  */
01632 #line 1632 "ast_expr2.c"
01633    break;
01634       case 22: /* "TOK_COLON" */
01635 
01636 /* Line 1000 of yacc.c  */
01637 #line 368 "ast_expr2.y"
01638    {  free_value((yyvaluep->val)); };
01639 
01640 /* Line 1000 of yacc.c  */
01641 #line 1641 "ast_expr2.c"
01642    break;
01643       case 23: /* "TOK_LP" */
01644 
01645 /* Line 1000 of yacc.c  */
01646 #line 368 "ast_expr2.y"
01647    {  free_value((yyvaluep->val)); };
01648 
01649 /* Line 1000 of yacc.c  */
01650 #line 1650 "ast_expr2.c"
01651    break;
01652       case 24: /* "TOK_RP" */
01653 
01654 /* Line 1000 of yacc.c  */
01655 #line 368 "ast_expr2.y"
01656    {  free_value((yyvaluep->val)); };
01657 
01658 /* Line 1000 of yacc.c  */
01659 #line 1659 "ast_expr2.c"
01660    break;
01661       case 25: /* "TOKEN" */
01662 
01663 /* Line 1000 of yacc.c  */
01664 #line 368 "ast_expr2.y"
01665    {  free_value((yyvaluep->val)); };
01666 
01667 /* Line 1000 of yacc.c  */
01668 #line 1668 "ast_expr2.c"
01669    break;
01670       case 29: /* "expr" */
01671 
01672 /* Line 1000 of yacc.c  */
01673 #line 368 "ast_expr2.y"
01674    {  free_value((yyvaluep->val)); };
01675 
01676 /* Line 1000 of yacc.c  */
01677 #line 1677 "ast_expr2.c"
01678    break;
01679 
01680       default:
01681    break;
01682     }
01683 }
01684 
01685 /* Prevent warnings from -Wmissing-prototypes.  */
01686 #ifdef YYPARSE_PARAM
01687 #if defined __STDC__ || defined __cplusplus
01688 int yyparse (void *YYPARSE_PARAM);
01689 #else
01690 int yyparse ();
01691 #endif
01692 #else /* ! YYPARSE_PARAM */
01693 #if defined __STDC__ || defined __cplusplus
01694 int yyparse (void);
01695 #else
01696 int yyparse ();
01697 #endif
01698 #endif /* ! YYPARSE_PARAM */
01699 
01700 
01701 
01702 
01703 
01704 /*-------------------------.
01705 | yyparse or yypush_parse.  |
01706 `-------------------------*/
01707 
01708 #ifdef YYPARSE_PARAM
01709 #if (defined __STDC__ || defined __C99__FUNC__ \
01710      || defined __cplusplus || defined _MSC_VER)
01711 int
01712 yyparse (void *YYPARSE_PARAM)
01713 #else
01714 int
01715 yyparse (YYPARSE_PARAM)
01716     void *YYPARSE_PARAM;
01717 #endif
01718 #else /* ! YYPARSE_PARAM */
01719 #if (defined __STDC__ || defined __C99__FUNC__ \
01720      || defined __cplusplus || defined _MSC_VER)
01721 int
01722 yyparse (void)
01723 #else
01724 int
01725 yyparse ()
01726 
01727 #endif
01728 #endif
01729 {
01730 /* The lookahead symbol.  */
01731 int yychar;
01732 
01733 /* The semantic value of the lookahead symbol.  */
01734 YYSTYPE yylval;
01735 
01736 /* Location data for the lookahead symbol.  */
01737 YYLTYPE yylloc;
01738 
01739     /* Number of syntax errors so far.  */
01740     int yynerrs;
01741 
01742     int yystate;
01743     /* Number of tokens to shift before error messages enabled.  */
01744     int yyerrstatus;
01745 
01746     /* The stacks and their tools:
01747        `yyss': related to states.
01748        `yyvs': related to semantic values.
01749        `yyls': related to locations.
01750 
01751        Refer to the stacks thru separate pointers, to allow yyoverflow
01752        to reallocate them elsewhere.  */
01753 
01754     /* The state stack.  */
01755     yytype_int16 yyssa[YYINITDEPTH];
01756     yytype_int16 *yyss;
01757     yytype_int16 *yyssp;
01758 
01759     /* The semantic value stack.  */
01760     YYSTYPE yyvsa[YYINITDEPTH];
01761     YYSTYPE *yyvs;
01762     YYSTYPE *yyvsp;
01763 
01764     /* The location stack.  */
01765     YYLTYPE yylsa[YYINITDEPTH];
01766     YYLTYPE *yyls;
01767     YYLTYPE *yylsp;
01768 
01769     /* The locations where the error started and ended.  */
01770     YYLTYPE yyerror_range[2];
01771 
01772     YYSIZE_T yystacksize;
01773 
01774   int yyn;
01775   int yyresult;
01776   /* Lookahead token as an internal (translated) token number.  */
01777   int yytoken;
01778   /* The variables used to return semantic value and location from the
01779      action routines.  */
01780   YYSTYPE yyval;
01781   YYLTYPE yyloc;
01782 
01783 #if YYERROR_VERBOSE
01784   /* Buffer for error messages, and its allocated size.  */
01785   char yymsgbuf[128];
01786   char *yymsg = yymsgbuf;
01787   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
01788 #endif
01789 
01790 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
01791 
01792   /* The number of symbols on the RHS of the reduced rule.
01793      Keep to zero when no symbol should be popped.  */
01794   int yylen = 0;
01795 
01796   yytoken = 0;
01797   yyss = yyssa;
01798   yyvs = yyvsa;
01799   yyls = yylsa;
01800   yystacksize = YYINITDEPTH;
01801 
01802   YYDPRINTF ((stderr, "Starting parse\n"));
01803 
01804   yystate = 0;
01805   yyerrstatus = 0;
01806   yynerrs = 0;
01807   yychar = YYEMPTY; /* Cause a token to be read.  */
01808 
01809   /* Initialize stack pointers.
01810      Waste one element of value and location stack
01811      so that they stay on the same level as the state stack.
01812      The wasted elements are never initialized.  */
01813   yyssp = yyss;
01814   yyvsp = yyvs;
01815   yylsp = yyls;
01816 
01817 #if YYLTYPE_IS_TRIVIAL
01818   /* Initialize the default location before parsing starts.  */
01819   yylloc.first_line   = yylloc.last_line   = 1;
01820   yylloc.first_column = yylloc.last_column = 1;
01821 #endif
01822 
01823   goto yysetstate;
01824 
01825 /*------------------------------------------------------------.
01826 | yynewstate -- Push a new state, which is found in yystate.  |
01827 `------------------------------------------------------------*/
01828  yynewstate:
01829   /* In all cases, when you get here, the value and location stacks
01830      have just been pushed.  So pushing a state here evens the stacks.  */
01831   yyssp++;
01832 
01833  yysetstate:
01834   *yyssp = yystate;
01835 
01836   if (yyss + yystacksize - 1 <= yyssp)
01837     {
01838       /* Get the current used size of the three stacks, in elements.  */
01839       YYSIZE_T yysize = yyssp - yyss + 1;
01840 
01841 #ifdef yyoverflow
01842       {
01843    /* Give user a chance to reallocate the stack.  Use copies of
01844       these so that the &'s don't force the real ones into
01845       memory.  */
01846    YYSTYPE *yyvs1 = yyvs;
01847    yytype_int16 *yyss1 = yyss;
01848    YYLTYPE *yyls1 = yyls;
01849 
01850    /* Each stack pointer address is followed by the size of the
01851       data in use in that stack, in bytes.  This used to be a
01852       conditional around just the two extra args, but that might
01853       be undefined if yyoverflow is a macro.  */
01854    yyoverflow (YY_("memory exhausted"),
01855           &yyss1, yysize * sizeof (*yyssp),
01856           &yyvs1, yysize * sizeof (*yyvsp),
01857           &yyls1, yysize * sizeof (*yylsp),
01858           &yystacksize);
01859 
01860    yyls = yyls1;
01861    yyss = yyss1;
01862    yyvs = yyvs1;
01863       }
01864 #else /* no yyoverflow */
01865 # ifndef YYSTACK_RELOCATE
01866       goto yyexhaustedlab;
01867 # else
01868       /* Extend the stack our own way.  */
01869       if (YYMAXDEPTH <= yystacksize)
01870    goto yyexhaustedlab;
01871       yystacksize *= 2;
01872       if (YYMAXDEPTH < yystacksize)
01873    yystacksize = YYMAXDEPTH;
01874 
01875       {
01876    yytype_int16 *yyss1 = yyss;
01877    union yyalloc *yyptr =
01878      (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
01879    if (! yyptr)
01880      goto yyexhaustedlab;
01881    YYSTACK_RELOCATE (yyss_alloc, yyss);
01882    YYSTACK_RELOCATE (yyvs_alloc, yyvs);
01883    YYSTACK_RELOCATE (yyls_alloc, yyls);
01884 #  undef YYSTACK_RELOCATE
01885    if (yyss1 != yyssa)
01886      YYSTACK_FREE (yyss1);
01887       }
01888 # endif
01889 #endif /* no yyoverflow */
01890 
01891       yyssp = yyss + yysize - 1;
01892       yyvsp = yyvs + yysize - 1;
01893       yylsp = yyls + yysize - 1;
01894 
01895       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
01896         (unsigned long int) yystacksize));
01897 
01898       if (yyss + yystacksize - 1 <= yyssp)
01899    YYABORT;
01900     }
01901 
01902   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
01903 
01904   if (yystate == YYFINAL)
01905     YYACCEPT;
01906 
01907   goto yybackup;
01908 
01909 /*-----------.
01910 | yybackup.  |
01911 `-----------*/
01912 yybackup:
01913 
01914   /* Do appropriate processing given the current state.  Read a
01915      lookahead token if we need one and don't already have one.  */
01916 
01917   /* First try to decide what to do without reference to lookahead token.  */
01918   yyn = yypact[yystate];
01919   if (yyn == YYPACT_NINF)
01920     goto yydefault;
01921 
01922   /* Not known => get a lookahead token if don't already have one.  */
01923 
01924   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
01925   if (yychar == YYEMPTY)
01926     {
01927       YYDPRINTF ((stderr, "Reading a token: "));
01928       yychar = YYLEX;
01929     }
01930 
01931   if (yychar <= YYEOF)
01932     {
01933       yychar = yytoken = YYEOF;
01934       YYDPRINTF ((stderr, "Now at end of input.\n"));
01935     }
01936   else
01937     {
01938       yytoken = YYTRANSLATE (yychar);
01939       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
01940     }
01941 
01942   /* If the proper action on seeing token YYTOKEN is to reduce or to
01943      detect an error, take that action.  */
01944   yyn += yytoken;
01945   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
01946     goto yydefault;
01947   yyn = yytable[yyn];
01948   if (yyn <= 0)
01949     {
01950       if (yyn == 0 || yyn == YYTABLE_NINF)
01951    goto yyerrlab;
01952       yyn = -yyn;
01953       goto yyreduce;
01954     }
01955 
01956   /* Count tokens shifted since error; after three, turn off error
01957      status.  */
01958   if (yyerrstatus)
01959     yyerrstatus--;
01960 
01961   /* Shift the lookahead token.  */
01962   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
01963 
01964   /* Discard the shifted token.  */
01965   yychar = YYEMPTY;
01966 
01967   yystate = yyn;
01968   *++yyvsp = yylval;
01969   *++yylsp = yylloc;
01970   goto yynewstate;
01971 
01972 
01973 /*-----------------------------------------------------------.
01974 | yydefault -- do the default action for the current state.  |
01975 `-----------------------------------------------------------*/
01976 yydefault:
01977   yyn = yydefact[yystate];
01978   if (yyn == 0)
01979     goto yyerrlab;
01980   goto yyreduce;
01981 
01982 
01983 /*-----------------------------.
01984 | yyreduce -- Do a reduction.  |
01985 `-----------------------------*/
01986 yyreduce:
01987   /* yyn is the number of a rule to reduce with.  */
01988   yylen = yyr2[yyn];
01989 
01990   /* If YYLEN is nonzero, implement the default value of the action:
01991      `$$ = $1'.
01992 
01993      Otherwise, the following line sets YYVAL to garbage.
01994      This behavior is undocumented and Bison
01995      users should not rely upon it.  Assigning to YYVAL
01996      unconditionally makes the parser a bit smaller, and it avoids a
01997      GCC warning that YYVAL may be used uninitialized.  */
01998   yyval = yyvsp[1-yylen];
01999 
02000   /* Default location.  */
02001   YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
02002   YY_REDUCE_PRINT (yyn);
02003   switch (yyn)
02004     {
02005         case 2:
02006 
02007 /* Line 1455 of yacc.c  */
02008 #line 374 "ast_expr2.y"
02009     { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
02010               ((struct parse_io *)parseio)->val->type = (yyvsp[(1) - (1)].val)->type;
02011               if( (yyvsp[(1) - (1)].val)->type == AST_EXPR_number )
02012               ((struct parse_io *)parseio)->val->u.i = (yyvsp[(1) - (1)].val)->u.i;
02013               else
02014               ((struct parse_io *)parseio)->val->u.s = (yyvsp[(1) - (1)].val)->u.s; 
02015            free((yyvsp[(1) - (1)].val));
02016          ;}
02017     break;
02018 
02019   case 3:
02020 
02021 /* Line 1455 of yacc.c  */
02022 #line 382 "ast_expr2.y"
02023     {/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
02024               ((struct parse_io *)parseio)->val->type = AST_EXPR_string;
02025            ((struct parse_io *)parseio)->val->u.s = strdup(""); 
02026          ;}
02027     break;
02028 
02029   case 4:
02030 
02031 /* Line 1455 of yacc.c  */
02032 #line 389 "ast_expr2.y"
02033     { (yyval.arglist) = alloc_expr_node(AST_EXPR_NODE_VAL); (yyval.arglist)->val = (yyvsp[(1) - (1)].val);;}
02034     break;
02035 
02036   case 5:
02037 
02038 /* Line 1455 of yacc.c  */
02039 #line 390 "ast_expr2.y"
02040     {struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL);
02041                                  struct expr_node *t;
02042                          DESTROY((yyvsp[(2) - (3)].val));
02043                                  for (t=(yyvsp[(1) - (3)].arglist);t->right;t=t->right)
02044                                 ;
02045                                  (yyval.arglist) = (yyvsp[(1) - (3)].arglist); t->right = x; x->val = (yyvsp[(3) - (3)].val);;}
02046     break;
02047 
02048   case 6:
02049 
02050 /* Line 1455 of yacc.c  */
02051 #line 396 "ast_expr2.y"
02052     {struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL);
02053                                  struct expr_node *t;  /* NULL args should OK */
02054                          DESTROY((yyvsp[(2) - (2)].val));
02055                                  for (t=(yyvsp[(1) - (2)].arglist);t->right;t=t->right)
02056                                 ;
02057                                  (yyval.arglist) = (yyvsp[(1) - (2)].arglist); t->right = x; x->val = make_str("");;}
02058     break;
02059 
02060   case 7:
02061 
02062 /* Line 1455 of yacc.c  */
02063 #line 405 "ast_expr2.y"
02064     { (yyval.val) = op_func((yyvsp[(1) - (4)].val),(yyvsp[(3) - (4)].arglist), ((struct parse_io *)parseio)->chan);
02065                                   DESTROY((yyvsp[(2) - (4)].val));
02066                            DESTROY((yyvsp[(4) - (4)].val));
02067                            DESTROY((yyvsp[(1) - (4)].val));
02068                            destroy_arglist((yyvsp[(3) - (4)].arglist));
02069                                   ;}
02070     break;
02071 
02072   case 8:
02073 
02074 /* Line 1455 of yacc.c  */
02075 #line 411 "ast_expr2.y"
02076     {(yyval.val) = (yyvsp[(1) - (1)].val);;}
02077     break;
02078 
02079   case 9:
02080 
02081 /* Line 1455 of yacc.c  */
02082 #line 412 "ast_expr2.y"
02083     { (yyval.val) = (yyvsp[(2) - (3)].val);
02084                           (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02085                      (yyloc).first_line=0; (yyloc).last_line=0;
02086                      DESTROY((yyvsp[(1) - (3)].val)); DESTROY((yyvsp[(3) - (3)].val)); ;}
02087     break;
02088 
02089   case 10:
02090 
02091 /* Line 1455 of yacc.c  */
02092 #line 416 "ast_expr2.y"
02093     { (yyval.val) = op_or ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
02094                   DESTROY((yyvsp[(2) - (3)].val)); 
02095                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02096                    (yyloc).first_line=0; (yyloc).last_line=0;;}
02097     break;
02098 
02099   case 11:
02100 
02101 /* Line 1455 of yacc.c  */
02102 #line 420 "ast_expr2.y"
02103     { (yyval.val) = op_and ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02104                   DESTROY((yyvsp[(2) - (3)].val)); 
02105                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02106                           (yyloc).first_line=0; (yyloc).last_line=0;;}
02107     break;
02108 
02109   case 12:
02110 
02111 /* Line 1455 of yacc.c  */
02112 #line 424 "ast_expr2.y"
02113     { (yyval.val) = op_eq ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
02114                   DESTROY((yyvsp[(2) - (3)].val)); 
02115                         (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
02116                    (yyloc).first_line=0; (yyloc).last_line=0;;}
02117     break;
02118 
02119   case 13:
02120 
02121 /* Line 1455 of yacc.c  */
02122 #line 428 "ast_expr2.y"
02123     { (yyval.val) = op_gt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
02124                   DESTROY((yyvsp[(2) - (3)].val)); 
02125                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
02126                    (yyloc).first_line=0; (yyloc).last_line=0;;}
02127     break;
02128 
02129   case 14:
02130 
02131 /* Line 1455 of yacc.c  */
02132 #line 432 "ast_expr2.y"
02133     { (yyval.val) = op_lt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02134                   DESTROY((yyvsp[(2) - (3)].val)); 
02135                         (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02136                    (yyloc).first_line=0; (yyloc).last_line=0;;}
02137     break;
02138 
02139   case 15:
02140 
02141 /* Line 1455 of yacc.c  */
02142 #line 436 "ast_expr2.y"
02143     { (yyval.val) = op_ge ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02144                   DESTROY((yyvsp[(2) - (3)].val)); 
02145                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02146                     (yyloc).first_line=0; (yyloc).last_line=0;;}
02147     break;
02148 
02149   case 16:
02150 
02151 /* Line 1455 of yacc.c  */
02152 #line 440 "ast_expr2.y"
02153     { (yyval.val) = op_le ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02154                   DESTROY((yyvsp[(2) - (3)].val)); 
02155                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02156                     (yyloc).first_line=0; (yyloc).last_line=0;;}
02157     break;
02158 
02159   case 17:
02160 
02161 /* Line 1455 of yacc.c  */
02162 #line 444 "ast_expr2.y"
02163     { (yyval.val) = op_ne ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02164                   DESTROY((yyvsp[(2) - (3)].val)); 
02165                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02166                     (yyloc).first_line=0; (yyloc).last_line=0;;}
02167     break;
02168 
02169   case 18:
02170 
02171 /* Line 1455 of yacc.c  */
02172 #line 448 "ast_expr2.y"
02173     { (yyval.val) = op_plus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02174                   DESTROY((yyvsp[(2) - (3)].val)); 
02175                           (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02176                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02177     break;
02178 
02179   case 19:
02180 
02181 /* Line 1455 of yacc.c  */
02182 #line 452 "ast_expr2.y"
02183     { (yyval.val) = op_minus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02184                   DESTROY((yyvsp[(2) - (3)].val)); 
02185                            (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02186                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02187     break;
02188 
02189   case 20:
02190 
02191 /* Line 1455 of yacc.c  */
02192 #line 456 "ast_expr2.y"
02193     { (yyval.val) = op_negate ((yyvsp[(2) - (2)].val)); 
02194                   DESTROY((yyvsp[(1) - (2)].val)); 
02195                            (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column; 
02196                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02197     break;
02198 
02199   case 21:
02200 
02201 /* Line 1455 of yacc.c  */
02202 #line 460 "ast_expr2.y"
02203     { (yyval.val) = op_compl ((yyvsp[(2) - (2)].val)); 
02204                   DESTROY((yyvsp[(1) - (2)].val)); 
02205                            (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column; 
02206                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02207     break;
02208 
02209   case 22:
02210 
02211 /* Line 1455 of yacc.c  */
02212 #line 464 "ast_expr2.y"
02213     { (yyval.val) = op_times ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02214                   DESTROY((yyvsp[(2) - (3)].val)); 
02215                           (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02216                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02217     break;
02218 
02219   case 23:
02220 
02221 /* Line 1455 of yacc.c  */
02222 #line 468 "ast_expr2.y"
02223     { (yyval.val) = op_div ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02224                   DESTROY((yyvsp[(2) - (3)].val)); 
02225                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02226                     (yyloc).first_line=0; (yyloc).last_line=0;;}
02227     break;
02228 
02229   case 24:
02230 
02231 /* Line 1455 of yacc.c  */
02232 #line 472 "ast_expr2.y"
02233     { (yyval.val) = op_rem ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02234                   DESTROY((yyvsp[(2) - (3)].val)); 
02235                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02236                     (yyloc).first_line=0; (yyloc).last_line=0;;}
02237     break;
02238 
02239   case 25:
02240 
02241 /* Line 1455 of yacc.c  */
02242 #line 476 "ast_expr2.y"
02243     { (yyval.val) = op_colon ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02244                   DESTROY((yyvsp[(2) - (3)].val)); 
02245                            (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02246                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02247     break;
02248 
02249   case 26:
02250 
02251 /* Line 1455 of yacc.c  */
02252 #line 480 "ast_expr2.y"
02253     { (yyval.val) = op_eqtilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02254                   DESTROY((yyvsp[(2) - (3)].val)); 
02255                            (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02256                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02257     break;
02258 
02259   case 27:
02260 
02261 /* Line 1455 of yacc.c  */
02262 #line 484 "ast_expr2.y"
02263     { (yyval.val) = op_cond ((yyvsp[(1) - (5)].val), (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val)); 
02264                   DESTROY((yyvsp[(2) - (5)].val)); 
02265                   DESTROY((yyvsp[(4) - (5)].val)); 
02266                            (yyloc).first_column = (yylsp[(1) - (5)]).first_column; (yyloc).last_column = (yylsp[(3) - (5)]).last_column; 
02267                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02268     break;
02269 
02270   case 28:
02271 
02272 /* Line 1455 of yacc.c  */
02273 #line 489 "ast_expr2.y"
02274     { (yyval.val) = op_tildetilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02275                   DESTROY((yyvsp[(2) - (3)].val)); 
02276                            (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02277                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02278     break;
02279 
02280 
02281 
02282 /* Line 1455 of yacc.c  */
02283 #line 2283 "ast_expr2.c"
02284       default: break;
02285     }
02286   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
02287 
02288   YYPOPSTACK (yylen);
02289   yylen = 0;
02290   YY_STACK_PRINT (yyss, yyssp);
02291 
02292   *++yyvsp = yyval;
02293   *++yylsp = yyloc;
02294 
02295   /* Now `shift' the result of the reduction.  Determine what state
02296      that goes to, based on the state we popped back to and the rule
02297      number reduced by.  */
02298 
02299   yyn = yyr1[yyn];
02300 
02301   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
02302   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
02303     yystate = yytable[yystate];
02304   else
02305     yystate = yydefgoto[yyn - YYNTOKENS];
02306 
02307   goto yynewstate;
02308 
02309 
02310 /*------------------------------------.
02311 | yyerrlab -- here on detecting error |
02312 `------------------------------------*/
02313 yyerrlab:
02314   /* If not already recovering from an error, report this error.  */
02315   if (!yyerrstatus)
02316     {
02317       ++yynerrs;
02318 #if ! YYERROR_VERBOSE
02319       yyerror (YY_("syntax error"));
02320 #else
02321       {
02322    YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
02323    if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
02324      {
02325        YYSIZE_T yyalloc = 2 * yysize;
02326        if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
02327          yyalloc = YYSTACK_ALLOC_MAXIMUM;
02328        if (yymsg != yymsgbuf)
02329          YYSTACK_FREE (yymsg);
02330        yymsg = (char *) YYSTACK_ALLOC (yyalloc);
02331        if (yymsg)
02332          yymsg_alloc = yyalloc;
02333        else
02334          {
02335       yymsg = yymsgbuf;
02336       yymsg_alloc = sizeof yymsgbuf;
02337          }
02338      }
02339 
02340    if (0 < yysize && yysize <= yymsg_alloc)
02341      {
02342        (void) yysyntax_error (yymsg, yystate, yychar);
02343        yyerror (yymsg);
02344      }
02345    else
02346      {
02347        yyerror (YY_("syntax error"));
02348        if (yysize != 0)
02349          goto yyexhaustedlab;
02350      }
02351       }
02352 #endif
02353     }
02354 
02355   yyerror_range[0] = yylloc;
02356 
02357   if (yyerrstatus == 3)
02358     {
02359       /* If just tried and failed to reuse lookahead token after an
02360     error, discard it.  */
02361 
02362       if (yychar <= YYEOF)
02363    {
02364      /* Return failure if at end of input.  */
02365      if (yychar == YYEOF)
02366        YYABORT;
02367    }
02368       else
02369    {
02370      yydestruct ("Error: discarding",
02371             yytoken, &yylval, &yylloc);
02372      yychar = YYEMPTY;
02373    }
02374     }
02375 
02376   /* Else will try to reuse lookahead token after shifting the error
02377      token.  */
02378   goto yyerrlab1;
02379 
02380 
02381 /*---------------------------------------------------.
02382 | yyerrorlab -- error raised explicitly by YYERROR.  |
02383 `---------------------------------------------------*/
02384 yyerrorlab:
02385 
02386   /* Pacify compilers like GCC when the user code never invokes
02387      YYERROR and the label yyerrorlab therefore never appears in user
02388      code.  */
02389   if (/*CONSTCOND*/ 0)
02390      goto yyerrorlab;
02391 
02392   yyerror_range[0] = yylsp[1-yylen];
02393   /* Do not reclaim the symbols of the rule which action triggered
02394      this YYERROR.  */
02395   YYPOPSTACK (yylen);
02396   yylen = 0;
02397   YY_STACK_PRINT (yyss, yyssp);
02398   yystate = *yyssp;
02399   goto yyerrlab1;
02400 
02401 
02402 /*-------------------------------------------------------------.
02403 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
02404 `-------------------------------------------------------------*/
02405 yyerrlab1:
02406   yyerrstatus = 3;   /* Each real token shifted decrements this.  */
02407 
02408   for (;;)
02409     {
02410       yyn = yypact[yystate];
02411       if (yyn != YYPACT_NINF)
02412    {
02413      yyn += YYTERROR;
02414      if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
02415        {
02416          yyn = yytable[yyn];
02417          if (0 < yyn)
02418       break;
02419        }
02420    }
02421 
02422       /* Pop the current state because it cannot handle the error token.  */
02423       if (yyssp == yyss)
02424    YYABORT;
02425 
02426       yyerror_range[0] = *yylsp;
02427       yydestruct ("Error: popping",
02428         yystos[yystate], yyvsp, yylsp);
02429       YYPOPSTACK (1);
02430       yystate = *yyssp;
02431       YY_STACK_PRINT (yyss, yyssp);
02432     }
02433 
02434   *++yyvsp = yylval;
02435 
02436   yyerror_range[1] = yylloc;
02437   /* Using YYLLOC is tempting, but would change the location of
02438      the lookahead.  YYLOC is available though.  */
02439   YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
02440   *++yylsp = yyloc;
02441 
02442   /* Shift the error token.  */
02443   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
02444 
02445   yystate = yyn;
02446   goto yynewstate;
02447 
02448 
02449 /*-------------------------------------.
02450 | yyacceptlab -- YYACCEPT comes here.  |
02451 `-------------------------------------*/
02452 yyacceptlab:
02453   yyresult = 0;
02454   goto yyreturn;
02455 
02456 /*-----------------------------------.
02457 | yyabortlab -- YYABORT comes here.  |
02458 `-----------------------------------*/
02459 yyabortlab:
02460   yyresult = 1;
02461   goto yyreturn;
02462 
02463 #if !defined(yyoverflow) || YYERROR_VERBOSE
02464 /*-------------------------------------------------.
02465 | yyexhaustedlab -- memory exhaustion comes here.  |
02466 `-------------------------------------------------*/
02467 yyexhaustedlab:
02468   yyerror (YY_("memory exhausted"));
02469   yyresult = 2;
02470   /* Fall through.  */
02471 #endif
02472 
02473 yyreturn:
02474   if (yychar != YYEMPTY)
02475      yydestruct ("Cleanup: discarding lookahead",
02476        yytoken, &yylval, &yylloc);
02477   /* Do not reclaim the symbols of the rule which action triggered
02478      this YYABORT or YYACCEPT.  */
02479   YYPOPSTACK (yylen);
02480   YY_STACK_PRINT (yyss, yyssp);
02481   while (yyssp != yyss)
02482     {
02483       yydestruct ("Cleanup: popping",
02484         yystos[*yyssp], yyvsp, yylsp);
02485       YYPOPSTACK (1);
02486     }
02487 #ifndef yyoverflow
02488   if (yyss != yyssa)
02489     YYSTACK_FREE (yyss);
02490 #endif
02491 #if YYERROR_VERBOSE
02492   if (yymsg != yymsgbuf)
02493     YYSTACK_FREE (yymsg);
02494 #endif
02495   /* Make sure YYID is used.  */
02496   return YYID (yyresult);
02497 }
02498 
02499 
02500 
02501 /* Line 1675 of yacc.c  */
02502 #line 495 "ast_expr2.y"
02503 
02504 
02505 static struct expr_node *alloc_expr_node(enum node_type nt)
02506 {
02507    struct expr_node *x = calloc(1,sizeof(struct expr_node));
02508    if (!x) {
02509       ast_log(LOG_ERROR, "Allocation for expr_node FAILED!!\n");
02510       return 0;
02511    }
02512    x->type = nt;
02513    return x;
02514 }
02515 
02516 
02517 
02518 static struct val *
02519 make_number (FP___TYPE i)
02520 {
02521    struct val *vp;
02522 
02523    vp = (struct val *) malloc (sizeof (*vp));
02524    if (vp == NULL) {
02525       ast_log(LOG_WARNING, "malloc() failed\n");
02526       return(NULL);
02527    }
02528 
02529    vp->type = AST_EXPR_number;
02530    vp->u.i  = i;
02531    return vp; 
02532 }
02533 
02534 static struct val *
02535 make_str (const char *s)
02536 {
02537    struct val *vp;
02538    size_t i;
02539    int isint; /* this started out being a test for an integer, but then ended up being a test for a float */
02540 
02541    vp = (struct val *) malloc (sizeof (*vp));
02542    if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) {
02543       if (vp) {
02544          free(vp);
02545       }
02546       ast_log(LOG_WARNING,"malloc() failed\n");
02547       return(NULL);
02548    }
02549 
02550    for (i = 0, isint = (isdigit(s[0]) || s[0] == '-' || s[0]=='.'); isint && i < strlen(s); i++)
02551    {
02552       if (!isdigit(s[i]) && s[i] != '.') {
02553          isint = 0;
02554          break;
02555       }
02556    }
02557    if (isint)
02558       vp->type = AST_EXPR_numeric_string;
02559    else  
02560       vp->type = AST_EXPR_string;
02561 
02562    return vp;
02563 }
02564 
02565 
02566 static void
02567 free_value (struct val *vp)
02568 {  
02569    if (vp==NULL) {
02570       return;
02571    }
02572    if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
02573       free (vp->u.s);   
02574    free(vp);
02575 }
02576 
02577 
02578 static int
02579 to_number (struct val *vp)
02580 {
02581    FP___TYPE i;
02582    
02583    if (vp == NULL) {
02584       ast_log(LOG_WARNING,"vp==NULL in to_number()\n");
02585       return(0);
02586    }
02587 
02588    if (vp->type == AST_EXPR_number)
02589       return 1;
02590 
02591    if (vp->type == AST_EXPR_string)
02592       return 0;
02593 
02594    /* vp->type == AST_EXPR_numeric_string, make it numeric */
02595    errno = 0;
02596    i  = FUNC_STRTOD(vp->u.s, (char**)0); /* either strtod, or strtold on a good day */
02597    if (errno != 0) {
02598       ast_log(LOG_WARNING,"Conversion of %s to number under/overflowed!\n", vp->u.s);
02599       free(vp->u.s);
02600       vp->u.s = 0;
02601       return(0);
02602    }
02603    free (vp->u.s);
02604    vp->u.i = i;
02605    vp->type = AST_EXPR_number;
02606    return 1;
02607 }
02608 
02609 static void
02610 strip_quotes(struct val *vp)
02611 {
02612    if (vp->type != AST_EXPR_string && vp->type != AST_EXPR_numeric_string)
02613       return;
02614    
02615    if( vp->u.s[0] == '"' && vp->u.s[strlen(vp->u.s)-1] == '"' )
02616    {
02617       char *f, *t;
02618       f = vp->u.s;
02619       t = vp->u.s;
02620       
02621       while( *f )
02622       {
02623          if( *f  && *f != '"' )
02624             *t++ = *f++;
02625          else
02626             f++;
02627       }
02628       *t = *f;
02629    }
02630 }
02631 
02632 static void
02633 to_string (struct val *vp)
02634 {
02635    char *tmp;
02636 
02637    if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
02638       return;
02639 
02640    tmp = malloc ((size_t)25);
02641    if (tmp == NULL) {
02642       ast_log(LOG_WARNING,"malloc() failed\n");
02643       return;
02644    }
02645 
02646    sprintf(tmp, FP___PRINTF, vp->u.i);
02647    vp->type = AST_EXPR_string;
02648    vp->u.s  = tmp;
02649 }
02650 
02651 
02652 static int
02653 isstring (struct val *vp)
02654 {
02655    /* only TRUE if this string is not a valid number */
02656    return (vp->type == AST_EXPR_string);
02657 }
02658 
02659 
02660 static int
02661 is_zero_or_null (struct val *vp)
02662 {
02663    if (vp->type == AST_EXPR_number) {
02664       return (vp->u.i == 0);
02665    } else {
02666       return (*vp->u.s == 0 || (to_number(vp) && vp->u.i == 0));
02667    }
02668    /* NOTREACHED */
02669 }
02670 
02671 #ifdef STANDALONE2
02672 
02673 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
02674 {
02675    va_list vars;
02676    va_start(vars,fmt);
02677    
02678         printf("LOG: lev:%d file:%s  line:%d func: %s  ",
02679                    level, file, line, function);
02680    vprintf(fmt, vars);
02681    fflush(stdout);
02682    va_end(vars);
02683 }
02684 
02685 
02686 int main(int argc,char **argv) {
02687    char s[4096];
02688    char out[4096];
02689    FILE *infile;
02690    
02691    if( !argv[1] )
02692       exit(20);
02693    
02694    if( access(argv[1],F_OK)== 0 )
02695    {
02696       int ret;
02697       
02698       infile = fopen(argv[1],"r");
02699       if( !infile )
02700       {
02701          printf("Sorry, couldn't open %s for reading!\n", argv[1]);
02702          exit(10);
02703       }
02704       while( fgets(s,sizeof(s),infile) )
02705       {
02706          if( s[strlen(s)-1] == '\n' )
02707             s[strlen(s)-1] = 0;
02708          
02709          ret = ast_expr(s, out, sizeof(out), NULL);
02710          printf("Expression: %s    Result: [%d] '%s'\n",
02711                s, ret, out);
02712       }
02713       fclose(infile);
02714    }
02715    else
02716    {
02717       if (ast_expr(argv[1], s, sizeof(s), NULL))
02718          printf("=====%s======\n",s);
02719       else
02720          printf("No result\n");
02721    }
02722    return 0;
02723 }
02724 
02725 #endif
02726 
02727 #undef ast_yyerror
02728 #define ast_yyerror(x) ast_yyerror(x, YYLTYPE *yylloc, struct parse_io *parseio)
02729 
02730 /* I put the ast_yyerror func in the flex input file,
02731    because it refers to the buffer state. Best to
02732    let it access the BUFFER stuff there and not trying
02733    define all the structs, macros etc. in this file! */
02734 
02735 static void destroy_arglist(struct expr_node *arglist)
02736 {
02737    struct expr_node *arglist_next;
02738    
02739    while (arglist)
02740    {
02741       arglist_next = arglist->right;
02742       if (arglist->val)
02743          free_value(arglist->val);
02744       arglist->val = 0;
02745       arglist->right = 0;
02746       free(arglist);
02747       arglist = arglist_next;
02748    }
02749 }
02750 
02751 #if !defined(STANDALONE) && !defined(STANDALONE2)
02752 static char *compose_func_args(struct expr_node *arglist)
02753 {
02754    struct expr_node *t = arglist;
02755    char *argbuf;
02756    int total_len = 0;
02757    
02758    while (t) {
02759       if (t != arglist)
02760          total_len += 1; /* for the sep */
02761       if (t->val) {
02762          if (t->val->type == AST_EXPR_number)
02763             total_len += 25; /* worst case */
02764          else
02765             total_len += strlen(t->val->u.s);
02766       }
02767       
02768       t = t->right;
02769    }
02770    total_len++; /* for the null */
02771    ast_log(LOG_NOTICE,"argbuf allocated %d bytes;\n", total_len);
02772    argbuf = malloc(total_len);
02773    argbuf[0] = 0;
02774    t = arglist;
02775    while (t) {
02776       char numbuf[30];
02777       
02778       if (t != arglist)
02779          strcat(argbuf,",");
02780       
02781       if (t->val) {
02782          if (t->val->type == AST_EXPR_number) {
02783             sprintf(numbuf,FP___PRINTF,t->val->u.i);
02784             strcat(argbuf,numbuf);
02785          } else
02786             strcat(argbuf,t->val->u.s);
02787       }
02788       t = t->right;
02789    }
02790    ast_log(LOG_NOTICE,"argbuf uses %d bytes;\n", (int) strlen(argbuf));
02791    return argbuf;
02792 }
02793 
02794 static int is_really_num(char *str)
02795 {
02796    if ( strspn(str,"-0123456789.    ") == strlen(str))
02797       return 1;
02798    else
02799       return 0;
02800 }
02801 #endif
02802 
02803 static struct val *op_func(struct val *funcname, struct expr_node *arglist, struct ast_channel *chan)
02804 {
02805    if (strspn(funcname->u.s,"ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789") == strlen(funcname->u.s))
02806    {
02807       struct val *result;
02808       if (0) {
02809 #ifdef FUNC_COS
02810       } else if (strcmp(funcname->u.s,"COS") == 0) {
02811          if (arglist && !arglist->right && arglist->val){
02812             to_number(arglist->val);
02813             result = make_number(FUNC_COS(arglist->val->u.i));
02814             return result;
02815          } else {
02816             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02817             return make_number(0.0);
02818          }
02819 #endif
02820 #ifdef FUNC_SIN
02821       } else if (strcmp(funcname->u.s,"SIN") == 0) {
02822          if (arglist && !arglist->right && arglist->val){
02823             to_number(arglist->val);
02824             result = make_number(FUNC_SIN(arglist->val->u.i));
02825             return result;
02826          } else {
02827             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02828             return make_number(0.0);
02829          }
02830 #endif
02831 #ifdef FUNC_TAN
02832       } else if (strcmp(funcname->u.s,"TAN") == 0) {
02833          if (arglist && !arglist->right && arglist->val){
02834             to_number(arglist->val);
02835             result = make_number(FUNC_TAN(arglist->val->u.i));
02836             return result;
02837          } else {
02838             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02839             return make_number(0.0);
02840          }
02841 #endif
02842 #ifdef FUNC_ACOS
02843       } else if (strcmp(funcname->u.s,"ACOS") == 0) {
02844          if (arglist && !arglist->right && arglist->val){
02845             to_number(arglist->val);
02846             result = make_number(FUNC_ACOS(arglist->val->u.i));
02847             return result;
02848          } else {
02849             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02850             return make_number(0.0);
02851          }
02852 #endif
02853 #ifdef FUNC_ASIN
02854       } else if (strcmp(funcname->u.s,"ASIN") == 0) {
02855          if (arglist && !arglist->right && arglist->val){
02856             to_number(arglist->val);
02857             result = make_number(FUNC_ASIN(arglist->val->u.i));
02858             return result;
02859          } else {
02860             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02861             return make_number(0.0);
02862          }
02863 #endif
02864 #ifdef FUNC_ATAN
02865       } else if (strcmp(funcname->u.s,"ATAN") == 0) {
02866          if (arglist && !arglist->right && arglist->val){
02867             to_number(arglist->val);
02868             result = make_number(FUNC_ATAN(arglist->val->u.i));
02869             return result;
02870          } else {
02871             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02872             return make_number(0.0);
02873          }
02874 #endif
02875 #ifdef FUNC_ATAN2
02876       } else if (strcmp(funcname->u.s,"ATAN2") == 0) {
02877          if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
02878             to_number(arglist->val);
02879             to_number(arglist->right->val);
02880             result = make_number(FUNC_ATAN2(arglist->val->u.i, arglist->right->val->u.i));
02881             return result;
02882          } else {
02883             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02884             return make_number(0.0);
02885          }
02886 #endif
02887 #ifdef FUNC_POW
02888       } else if (strcmp(funcname->u.s,"POW") == 0) {
02889          if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
02890             to_number(arglist->val);
02891             to_number(arglist->right->val);
02892             result = make_number(FUNC_POW(arglist->val->u.i, arglist->right->val->u.i));
02893             return result;
02894          } else {
02895             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02896             return make_number(0.0);
02897          }
02898 #endif
02899 #ifdef FUNC_SQRT
02900       } else if (strcmp(funcname->u.s,"SQRT") == 0) {
02901          if (arglist && !arglist->right && arglist->val){
02902             to_number(arglist->val);
02903             result = make_number(FUNC_SQRT(arglist->val->u.i));
02904             return result;
02905          } else {
02906             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02907             return make_number(0.0);
02908          }
02909 #endif
02910 #ifdef FUNC_FLOOR
02911       } else if (strcmp(funcname->u.s,"FLOOR") == 0) {
02912          if (arglist && !arglist->right && arglist->val){
02913             to_number(arglist->val);
02914             result = make_number(FUNC_FLOOR(arglist->val->u.i));
02915             return result;
02916          } else {
02917             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02918             return make_number(0.0);
02919          }
02920 #endif
02921 #ifdef FUNC_CEIL
02922       } else if (strcmp(funcname->u.s,"CEIL") == 0) {
02923          if (arglist && !arglist->right && arglist->val){
02924             to_number(arglist->val);
02925             result = make_number(FUNC_CEIL(arglist->val->u.i));
02926             return result;
02927          } else {
02928             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02929             return make_number(0.0);
02930          }
02931 #endif
02932 #ifdef FUNC_ROUND
02933       } else if (strcmp(funcname->u.s,"ROUND") == 0) {
02934          if (arglist && !arglist->right && arglist->val){
02935             to_number(arglist->val);
02936             result = make_number(FUNC_ROUND(arglist->val->u.i));
02937             return result;
02938          } else {
02939             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02940             return make_number(0.0);
02941          }
02942 #endif /* defined(FUNC_ROUND) */
02943 #ifdef FUNC_RINT
02944       } else if (strcmp(funcname->u.s,"RINT") == 0) {
02945          if (arglist && !arglist->right && arglist->val){
02946             to_number(arglist->val);
02947             result = make_number(FUNC_RINT(arglist->val->u.i));
02948             return result;
02949          } else {
02950             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02951             return make_number(0.0);
02952          }
02953 #endif
02954 #ifdef FUNC_TRUNC
02955       } else if (strcmp(funcname->u.s,"TRUNC") == 0) {
02956          if (arglist && !arglist->right && arglist->val){
02957             to_number(arglist->val);
02958             result = make_number(FUNC_TRUNC(arglist->val->u.i));
02959             return result;
02960          } else {
02961             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02962             return make_number(0.0);
02963          }
02964 #endif /* defined(FUNC_TRUNC) */
02965 #ifdef FUNC_EXP
02966       } else if (strcmp(funcname->u.s,"EXP") == 0) {
02967          if (arglist && !arglist->right && arglist->val){
02968             to_number(arglist->val);
02969             result = make_number(FUNC_EXP(arglist->val->u.i));
02970             return result;
02971          } else {
02972             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02973             return make_number(0.0);
02974          }
02975 #endif
02976 #ifdef FUNC_EXP2
02977       } else if (strcmp(funcname->u.s,"EXP2") == 0) {
02978          if (arglist && !arglist->right && arglist->val){
02979             to_number(arglist->val);
02980             result = make_number(FUNC_EXP2(arglist->val->u.i));
02981             return result;
02982          } else {
02983             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02984             return make_number(0.0);
02985          }
02986 #endif
02987 #ifdef FUNC_EXP10
02988       } else if (strcmp(funcname->u.s,"EXP10") == 0) {
02989          if (arglist && !arglist->right && arglist->val){
02990             to_number(arglist->val);
02991             result = make_number(FUNC_EXP10(arglist->val->u.i));
02992             return result;
02993          } else {
02994             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02995             return make_number(0.0);
02996          }
02997 #endif
02998 #ifdef FUNC_LOG
02999       } else if (strcmp(funcname->u.s,"LOG") == 0) {
03000          if (arglist && !arglist->right && arglist->val){
03001             to_number(arglist->val);
03002             result = make_number(FUNC_LOG(arglist->val->u.i));
03003             return result;
03004          } else {
03005             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
03006             return make_number(0.0);
03007          }
03008 #endif
03009 #ifdef FUNC_LOG2
03010       } else if (strcmp(funcname->u.s,"LOG2") == 0) {
03011          if (arglist && !arglist->right && arglist->val){
03012             to_number(arglist->val);
03013             result = make_number(FUNC_LOG2(arglist->val->u.i));
03014             return result;
03015          } else {
03016             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
03017             return make_number(0.0);
03018          }
03019 #endif
03020 #ifdef FUNC_LOG10
03021       } else if (strcmp(funcname->u.s,"LOG10") == 0) {
03022          if (arglist && !arglist->right && arglist->val){
03023             to_number(arglist->val);
03024             result = make_number(FUNC_LOG10(arglist->val->u.i));
03025             return result;
03026          } else {
03027             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
03028             return make_number(0.0);
03029          }
03030 #endif
03031 #ifdef FUNC_REMAINDER
03032       } else if (strcmp(funcname->u.s,"REMAINDER") == 0) {
03033          if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
03034             to_number(arglist->val);
03035             to_number(arglist->right->val);
03036             result = make_number(FUNC_REMAINDER(arglist->val->u.i, arglist->right->val->u.i));
03037             return result;
03038          } else {
03039             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
03040             return make_number(0.0);
03041          }
03042 #endif
03043       } else if (strcmp(funcname->u.s, "ABS") == 0) {
03044          if (arglist && !arglist->right && arglist->val) {
03045             to_number(arglist->val);
03046             result = make_number(arglist->val->u.i < 0 ? arglist->val->u.i * -1 : arglist->val->u.i);
03047             return result;
03048          } else {
03049             ast_log(LOG_WARNING, "Wrong args to %s() function\n", funcname->u.s);
03050             return make_number(0.0);
03051          }
03052       } else {
03053          /* is this a custom function we should execute and collect the results of? */
03054 #if !defined(STANDALONE) && !defined(STANDALONE2)
03055          struct ast_custom_function *f = ast_custom_function_find(funcname->u.s);
03056          if (!chan)
03057             ast_log(LOG_WARNING,"Hey! chan is NULL.\n");
03058          if (!f)
03059             ast_log(LOG_WARNING,"Hey! could not find func %s.\n", funcname->u.s);
03060          
03061          if (f && chan) {
03062             if (f->read) {
03063                char workspace[512];
03064                char *argbuf = compose_func_args(arglist);
03065                f->read(chan, funcname->u.s, argbuf, workspace, sizeof(workspace));
03066                free(argbuf);
03067                if (is_really_num(workspace))
03068                   return make_number(FUNC_STRTOD(workspace,(char **)NULL));
03069                else
03070                   return make_str(workspace);
03071             } else {
03072                ast_log(LOG_ERROR,"Error! Function '%s' cannot be read!\n", funcname->u.s);
03073                return (make_number ((FP___TYPE)0.0));
03074             }
03075             
03076          } else {
03077             ast_log(LOG_ERROR, "Error! '%s' doesn't appear to be an available function!\n", funcname->u.s);
03078             return (make_number ((FP___TYPE)0.0));
03079          }
03080 #else
03081          ast_log(LOG_ERROR, "Error! '%s' is not available in the standalone version!\n", funcname->u.s);
03082          return (make_number ((FP___TYPE)0.0));
03083 #endif
03084       }
03085    }
03086    else
03087    {
03088       ast_log(LOG_ERROR, "Error! '%s' is not possibly a function name!\n", funcname->u.s);
03089       return (make_number ((FP___TYPE)0.0));
03090    }
03091    return (make_number ((FP___TYPE)0.0));
03092 }
03093 
03094 
03095 static struct val *
03096 op_or (struct val *a, struct val *b)
03097 {
03098    if (is_zero_or_null (a)) {
03099       free_value (a);
03100       return (b);
03101    } else {
03102       free_value (b);
03103       return (a);
03104    }
03105 }
03106       
03107 static struct val *
03108 op_and (struct val *a, struct val *b)
03109 {
03110    if (is_zero_or_null (a) || is_zero_or_null (b)) {
03111       free_value (a);
03112       free_value (b);
03113       return (make_number ((FP___TYPE)0.0));
03114    } else {
03115       free_value (b);
03116       return (a);
03117    }
03118 }
03119 
03120 static struct val *
03121 op_eq (struct val *a, struct val *b)
03122 {
03123    struct val *r; 
03124 
03125    if (isstring (a) || isstring (b)) {
03126       to_string (a);
03127       to_string (b); 
03128       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) == 0));
03129    } else {
03130 #ifdef DEBUG_FOR_CONVERSIONS
03131       char buffer[2000];
03132       sprintf(buffer,"Converting '%s' and '%s' ", a->u.s, b->u.s);
03133 #endif
03134       (void)to_number(a);
03135       (void)to_number(b);
03136 #ifdef DEBUG_FOR_CONVERSIONS
03137       ast_log(LOG_WARNING,"%s to '%lld' and '%lld'\n", buffer, a->u.i, b->u.i);
03138 #endif
03139       r = make_number ((FP___TYPE)(a->u.i == b->u.i));
03140    }
03141 
03142    free_value (a);
03143    free_value (b);
03144    return r;
03145 }
03146 
03147 static struct val *
03148 op_gt (struct val *a, struct val *b)
03149 {
03150    struct val *r;
03151 
03152    if (isstring (a) || isstring (b)) {
03153       to_string (a);
03154       to_string (b);
03155       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) > 0));
03156    } else {
03157       (void)to_number(a);
03158       (void)to_number(b);
03159       r = make_number ((FP___TYPE)(a->u.i > b->u.i));
03160    }
03161 
03162    free_value (a);
03163    free_value (b);
03164    return r;
03165 }
03166 
03167 static struct val *
03168 op_lt (struct val *a, struct val *b)
03169 {
03170    struct val *r;
03171 
03172    if (isstring (a) || isstring (b)) {
03173       to_string (a);
03174       to_string (b);
03175       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) < 0));
03176    } else {
03177       (void)to_number(a);
03178       (void)to_number(b);
03179       r = make_number ((FP___TYPE)(a->u.i < b->u.i));
03180    }
03181 
03182    free_value (a);
03183    free_value (b);
03184    return r;
03185 }
03186 
03187 static struct val *
03188 op_ge (struct val *a, struct val *b)
03189 {
03190    struct val *r;
03191 
03192    if (isstring (a) || isstring (b)) {
03193       to_string (a);
03194       to_string (b);
03195       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) >= 0));
03196    } else {
03197       (void)to_number(a);
03198       (void)to_number(b);
03199       r = make_number ((FP___TYPE)(a->u.i >= b->u.i));
03200    }
03201 
03202    free_value (a);
03203    free_value (b);
03204    return r;
03205 }
03206 
03207 static struct val *
03208 op_le (struct val *a, struct val *b)
03209 {
03210    struct val *r;
03211 
03212    if (isstring (a) || isstring (b)) {
03213       to_string (a);
03214       to_string (b);
03215       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) <= 0));
03216    } else {
03217       (void)to_number(a);
03218       (void)to_number(b);
03219       r = make_number ((FP___TYPE)(a->u.i <= b->u.i));
03220    }
03221 
03222    free_value (a);
03223    free_value (b);
03224    return r;
03225 }
03226 
03227 static struct val *
03228 op_cond (struct val *a, struct val *b, struct val *c)
03229 {
03230    struct val *r;
03231 
03232    if( isstring(a) )
03233    {
03234       if( strlen(a->u.s) && strcmp(a->u.s, "\"\"") != 0 && strcmp(a->u.s,"0") != 0 )
03235       {
03236          free_value(a);
03237          free_value(c);
03238          r = b;
03239       }
03240       else
03241       {
03242          free_value(a);
03243          free_value(b);
03244          r = c;
03245       }
03246    }
03247    else
03248    {
03249       (void)to_number(a);
03250       if( a->u.i )
03251       {
03252          free_value(a);
03253          free_value(c);
03254          r = b;
03255       }
03256       else
03257       {
03258          free_value(a);
03259          free_value(b);
03260          r = c;
03261       }
03262    }
03263    return r;
03264 }
03265 
03266 static struct val *
03267 op_ne (struct val *a, struct val *b)
03268 {
03269    struct val *r;
03270 
03271    if (isstring (a) || isstring (b)) {
03272       to_string (a);
03273       to_string (b);
03274       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) != 0));
03275    } else {
03276       (void)to_number(a);
03277       (void)to_number(b);
03278       r = make_number ((FP___TYPE)(a->u.i != b->u.i));
03279    }
03280 
03281    free_value (a);
03282    free_value (b);
03283    return r;
03284 }
03285 
03286 static int
03287 chk_plus (FP___TYPE a, FP___TYPE b, FP___TYPE r)
03288 {
03289    /* sum of two positive numbers must be positive */
03290    if (a > 0 && b > 0 && r <= 0)
03291       return 1;
03292    /* sum of two negative numbers must be negative */
03293    if (a < 0 && b < 0 && r >= 0)
03294       return 1;
03295    /* all other cases are OK */
03296    return 0;
03297 }
03298 
03299 static struct val *
03300 op_plus (struct val *a, struct val *b)
03301 {
03302    struct val *r;
03303 
03304    if (!to_number (a)) {
03305       if( !extra_error_message_supplied )
03306          ast_log(LOG_WARNING,"non-numeric argument\n");
03307       if (!to_number (b)) {
03308          free_value(a);
03309          free_value(b);
03310          return make_number(0);
03311       } else {
03312          free_value(a);
03313          return (b);
03314       }
03315    } else if (!to_number(b)) {
03316       free_value(b);
03317       return (a);
03318    }
03319 
03320    r = make_number (a->u.i + b->u.i);
03321    if (chk_plus (a->u.i, b->u.i, r->u.i)) {
03322       ast_log(LOG_WARNING,"overflow\n");
03323    }
03324    free_value (a);
03325    free_value (b);
03326    return r;
03327 }
03328 
03329 static int
03330 chk_minus (FP___TYPE a, FP___TYPE b, FP___TYPE r)
03331 {
03332    /* special case subtraction of QUAD_MIN */
03333    if (b == QUAD_MIN) {
03334       if (a >= 0)
03335          return 1;
03336       else
03337          return 0;
03338    }
03339    /* this is allowed for b != QUAD_MIN */
03340    return chk_plus (a, -b, r);
03341 }
03342 
03343 static struct val *
03344 op_minus (struct val *a, struct val *b)
03345 {
03346    struct val *r;
03347 
03348    if (!to_number (a)) {
03349       if( !extra_error_message_supplied )
03350          ast_log(LOG_WARNING, "non-numeric argument\n");
03351       if (!to_number (b)) {
03352          free_value(a);
03353          free_value(b);
03354          return make_number(0);
03355       } else {
03356          r = make_number(0 - b->u.i);
03357          free_value(a);
03358          free_value(b);
03359          return (r);
03360       }
03361    } else if (!to_number(b)) {
03362       if( !extra_error_message_supplied )
03363          ast_log(LOG_WARNING, "non-numeric argument\n");
03364       free_value(b);
03365       return (a);
03366    }
03367 
03368    r = make_number (a->u.i - b->u.i);
03369    if (chk_minus (a->u.i, b->u.i, r->u.i)) {
03370       ast_log(LOG_WARNING, "overflow\n");
03371    }
03372    free_value (a);
03373    free_value (b);
03374    return r;
03375 }
03376 
03377 static struct val *
03378 op_negate (struct val *a)
03379 {
03380    struct val *r;
03381 
03382    if (!to_number (a) ) {
03383       free_value(a);
03384       if( !extra_error_message_supplied )
03385          ast_log(LOG_WARNING, "non-numeric argument\n");
03386       return make_number(0);
03387    }
03388 
03389    r = make_number (- a->u.i);
03390    if (chk_minus (0, a->u.i, r->u.i)) {
03391       ast_log(LOG_WARNING, "overflow\n");
03392    }
03393    free_value (a);
03394    return r;
03395 }
03396 
03397 static struct val *
03398 op_compl (struct val *a)
03399 {
03400    int v1 = 1;
03401    struct val *r;
03402    
03403    if( !a )
03404    {
03405       v1 = 0;
03406    }
03407    else
03408    {
03409       switch( a->type )
03410       {
03411       case AST_EXPR_number:
03412          if( a->u.i == 0 )
03413             v1 = 0;
03414          break;
03415          
03416       case AST_EXPR_string:
03417          if( a->u.s == 0 )
03418             v1 = 0;
03419          else
03420          {
03421             if( a->u.s[0] == 0 )
03422                v1 = 0;
03423             else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' )
03424                v1 = 0;
03425             else
03426                v1 = atoi(a->u.s);
03427          }
03428          break;
03429          
03430       case AST_EXPR_numeric_string:
03431          if( a->u.s == 0 )
03432             v1 = 0;
03433          else
03434          {
03435             if( a->u.s[0] == 0 )
03436                v1 = 0;
03437             else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' )
03438                v1 = 0;
03439             else
03440                v1 = atoi(a->u.s);
03441          }
03442          break;
03443       }
03444    }
03445    
03446    r = make_number (!v1);
03447    free_value (a);
03448    return r;
03449 }
03450 
03451 static int
03452 chk_times (FP___TYPE a, FP___TYPE b, FP___TYPE r)
03453 {
03454    /* special case: first operand is 0, no overflow possible */
03455    if (a == 0)
03456       return 0;
03457    /* cerify that result of division matches second operand */
03458    if (r / a != b)
03459       return 1;
03460    return 0;
03461 }
03462 
03463 static struct val *
03464 op_times (struct val *a, struct val *b)
03465 {
03466    struct val *r;
03467 
03468    if (!to_number (a) || !to_number (b)) {
03469       free_value(a);
03470       free_value(b);
03471       if( !extra_error_message_supplied )
03472          ast_log(LOG_WARNING, "non-numeric argument\n");
03473       return(make_number(0));
03474    }
03475 
03476    r = make_number (a->u.i * b->u.i);
03477    if (chk_times (a->u.i, b->u.i, r->u.i)) {
03478       ast_log(LOG_WARNING, "overflow\n");
03479    }
03480    free_value (a);
03481    free_value (b);
03482    return (r);
03483 }
03484 
03485 static int
03486 chk_div (FP___TYPE a, FP___TYPE b)
03487 {
03488    /* div by zero has been taken care of before */
03489    /* only QUAD_MIN / -1 causes overflow */
03490    if (a == QUAD_MIN && b == -1)
03491       return 1;
03492    /* everything else is OK */
03493    return 0;
03494 }
03495 
03496 static struct val *
03497 op_div (struct val *a, struct val *b)
03498 {
03499    struct val *r;
03500 
03501    if (!to_number (a)) {
03502       free_value(a);
03503       free_value(b);
03504       if( !extra_error_message_supplied )
03505          ast_log(LOG_WARNING, "non-numeric argument\n");
03506       return make_number(0);
03507    } else if (!to_number (b)) {
03508       free_value(a);
03509       free_value(b);
03510       if( !extra_error_message_supplied )
03511          ast_log(LOG_WARNING, "non-numeric argument\n");
03512       return make_number(INT_MAX);
03513    }
03514 
03515    if (b->u.i == 0) {
03516       ast_log(LOG_WARNING, "division by zero\n");     
03517       free_value(a);
03518       free_value(b);
03519       return make_number(INT_MAX);
03520    }
03521 
03522    r = make_number (a->u.i / b->u.i);
03523    if (chk_div (a->u.i, b->u.i)) {
03524       ast_log(LOG_WARNING, "overflow\n");
03525    }
03526    free_value (a);
03527    free_value (b);
03528    return r;
03529 }
03530    
03531 static struct val *
03532 op_rem (struct val *a, struct val *b)
03533 {
03534    struct val *r;
03535 
03536    if (!to_number (a) || !to_number (b)) {
03537       if( !extra_error_message_supplied )
03538          ast_log(LOG_WARNING, "non-numeric argument\n");
03539       free_value(a);
03540       free_value(b);
03541       return make_number(0);
03542    }
03543 
03544    if (b->u.i == 0) {
03545       ast_log(LOG_WARNING, "div by zero\n");
03546       free_value(a);
03547       return(b);
03548    }
03549 
03550    r = make_number (FUNC_FMOD(a->u.i, b->u.i)); /* either fmod or fmodl if FP___TYPE is available */
03551    /* chk_rem necessary ??? */
03552    free_value (a);
03553    free_value (b);
03554    return r;
03555 }
03556    
03557 
03558 static struct val *
03559 op_colon (struct val *a, struct val *b)
03560 {
03561    regex_t rp;
03562    regmatch_t rm[2];
03563    char errbuf[256];
03564    int eval;
03565    struct val *v;
03566 
03567    /* coerce to both arguments to strings */
03568    to_string(a);
03569    to_string(b);
03570    /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */
03571    strip_quotes(a);
03572    strip_quotes(b);
03573    /* compile regular expression */
03574    if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) {
03575       regerror (eval, &rp, errbuf, sizeof(errbuf));
03576       ast_log(LOG_WARNING, "regcomp() error : %s\n", errbuf);
03577       free_value(a);
03578       free_value(b);
03579       return make_str("");    
03580    }
03581 
03582    /* compare string against pattern */
03583    /* remember that patterns are anchored to the beginning of the line */
03584    if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 && rm[0].rm_so == 0) {
03585       if (rm[1].rm_so >= 0) {
03586          *(a->u.s + rm[1].rm_eo) = '\0';
03587          v = make_str (a->u.s + rm[1].rm_so);
03588 
03589       } else {
03590          v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so));
03591       }
03592    } else {
03593       if (rp.re_nsub == 0) {
03594          v = make_number ((FP___TYPE)0);
03595       } else {
03596          v = make_str ("");
03597       }
03598    }
03599 
03600    /* free arguments and pattern buffer */
03601    free_value (a);
03602    free_value (b);
03603    regfree (&rp);
03604 
03605    return v;
03606 }
03607    
03608 
03609 static struct val *
03610 op_eqtilde (struct val *a, struct val *b)
03611 {
03612    regex_t rp;
03613    regmatch_t rm[2];
03614    char errbuf[256];
03615    int eval;
03616    struct val *v;
03617 
03618    /* coerce to both arguments to strings */
03619    to_string(a);
03620    to_string(b);
03621    /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */
03622    strip_quotes(a);
03623    strip_quotes(b);
03624    /* compile regular expression */
03625    if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) {
03626       regerror (eval, &rp, errbuf, sizeof(errbuf));
03627       ast_log(LOG_WARNING, "regcomp() error : %s\n", errbuf);
03628       free_value(a);
03629       free_value(b);
03630       return make_str("");    
03631    }
03632 
03633    /* compare string against pattern */
03634    /* remember that patterns are anchored to the beginning of the line */
03635    if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 ) {
03636       if (rm[1].rm_so >= 0) {
03637          *(a->u.s + rm[1].rm_eo) = '\0';
03638          v = make_str (a->u.s + rm[1].rm_so);
03639 
03640       } else {
03641          v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so));
03642       }
03643    } else {
03644       if (rp.re_nsub == 0) {
03645          v = make_number ((FP___TYPE)0.0);
03646       } else {
03647          v = make_str ("");
03648       }
03649    }
03650 
03651    /* free arguments and pattern buffer */
03652    free_value (a);
03653    free_value (b);
03654    regfree (&rp);
03655 
03656    return v;
03657 }
03658 
03659 static struct val *  /* this is a string concat operator */
03660 op_tildetilde (struct val *a, struct val *b)
03661 {
03662    struct val *v;
03663    char *vs;
03664 
03665    /* coerce to both arguments to strings */
03666    to_string(a);
03667    to_string(b);
03668    /* strip double quotes from both -- */
03669    strip_quotes(a);
03670    strip_quotes(b);
03671    
03672    vs = malloc(strlen(a->u.s)+strlen(b->u.s)+1);
03673    strcpy(vs,a->u.s);
03674    strcat(vs,b->u.s);
03675 
03676    v = make_str(vs);
03677 
03678    /* free arguments */
03679    free_value(a);
03680    free_value(b);
03681 
03682    return v;
03683 }
03684 

Generated on Thu Apr 16 06:27:14 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6