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

Generated on Thu Jul 9 13:40:22 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7