Fri Jun 19 12:09:30 2009

Asterisk developer's documentation


ast_expr2.c

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

Generated on Fri Jun 19 12:09:30 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7