Sat Apr 26 2014 22:01:28

Asterisk developer's documentation


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