Wed Oct 28 11:45:28 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: 203447 $")
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       return;
02401    }
02402    if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
02403       free (vp->u.s);   
02404    free(vp);
02405 }
02406 
02407 
02408 static int
02409 to_number (struct val *vp)
02410 {
02411    FP___TYPE i;
02412    
02413    if (vp == NULL) {
02414       ast_log(LOG_WARNING,"vp==NULL in to_number()\n");
02415       return(0);
02416    }
02417 
02418    if (vp->type == AST_EXPR_number)
02419       return 1;
02420 
02421    if (vp->type == AST_EXPR_string)
02422       return 0;
02423 
02424    /* vp->type == AST_EXPR_numeric_string, make it numeric */
02425    errno = 0;
02426    i  = FUNC_STRTOD(vp->u.s, (char**)0); /* either strtod, or strtold on a good day */
02427    if (errno != 0) {
02428       ast_log(LOG_WARNING,"Conversion of %s to number under/overflowed!\n", vp->u.s);
02429       free(vp->u.s);
02430       vp->u.s = 0;
02431       return(0);
02432    }
02433    free (vp->u.s);
02434    vp->u.i = i;
02435    vp->type = AST_EXPR_number;
02436    return 1;
02437 }
02438 
02439 static void
02440 strip_quotes(struct val *vp)
02441 {
02442    if (vp->type != AST_EXPR_string && vp->type != AST_EXPR_numeric_string)
02443       return;
02444    
02445    if( vp->u.s[0] == '"' && vp->u.s[strlen(vp->u.s)-1] == '"' )
02446    {
02447       char *f, *t;
02448       f = vp->u.s;
02449       t = vp->u.s;
02450       
02451       while( *f )
02452       {
02453          if( *f  && *f != '"' )
02454             *t++ = *f++;
02455          else
02456             f++;
02457       }
02458       *t = *f;
02459    }
02460 }
02461 
02462 static void
02463 to_string (struct val *vp)
02464 {
02465    char *tmp;
02466 
02467    if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
02468       return;
02469 
02470    tmp = malloc ((size_t)25);
02471    if (tmp == NULL) {
02472       ast_log(LOG_WARNING,"malloc() failed\n");
02473       return;
02474    }
02475 
02476    sprintf(tmp, FP___PRINTF, vp->u.i);
02477    vp->type = AST_EXPR_string;
02478    vp->u.s  = tmp;
02479 }
02480 
02481 
02482 static int
02483 isstring (struct val *vp)
02484 {
02485    /* only TRUE if this string is not a valid number */
02486    return (vp->type == AST_EXPR_string);
02487 }
02488 
02489 
02490 static int
02491 is_zero_or_null (struct val *vp)
02492 {
02493    if (vp->type == AST_EXPR_number) {
02494       return (vp->u.i == 0);
02495    } else {
02496       return (*vp->u.s == 0 || (to_number(vp) && vp->u.i == 0));
02497    }
02498    /* NOTREACHED */
02499 }
02500 
02501 #ifdef STANDALONE2
02502 
02503 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
02504 {
02505    va_list vars;
02506    va_start(vars,fmt);
02507    
02508         printf("LOG: lev:%d file:%s  line:%d func: %s  ",
02509                    level, file, line, function);
02510    vprintf(fmt, vars);
02511    fflush(stdout);
02512    va_end(vars);
02513 }
02514 
02515 
02516 int main(int argc,char **argv) {
02517    char s[4096];
02518    char out[4096];
02519    FILE *infile;
02520    
02521    if( !argv[1] )
02522       exit(20);
02523    
02524    if( access(argv[1],F_OK)== 0 )
02525    {
02526       int ret;
02527       
02528       infile = fopen(argv[1],"r");
02529       if( !infile )
02530       {
02531          printf("Sorry, couldn't open %s for reading!\n", argv[1]);
02532          exit(10);
02533       }
02534       while( fgets(s,sizeof(s),infile) )
02535       {
02536          if( s[strlen(s)-1] == '\n' )
02537             s[strlen(s)-1] = 0;
02538          
02539          ret = ast_expr(s, out, sizeof(out), NULL);
02540          printf("Expression: %s    Result: [%d] '%s'\n",
02541                s, ret, out);
02542       }
02543       fclose(infile);
02544    }
02545    else
02546    {
02547       if (ast_expr(argv[1], s, sizeof(s), NULL))
02548          printf("=====%s======\n",s);
02549       else
02550          printf("No result\n");
02551    }
02552    return 0;
02553 }
02554 
02555 #endif
02556 
02557 #undef ast_yyerror
02558 #define ast_yyerror(x) ast_yyerror(x, YYLTYPE *yylloc, struct parse_io *parseio)
02559 
02560 /* I put the ast_yyerror func in the flex input file,
02561    because it refers to the buffer state. Best to
02562    let it access the BUFFER stuff there and not trying
02563    define all the structs, macros etc. in this file! */
02564 
02565 static void destroy_arglist(struct expr_node *arglist)
02566 {
02567    struct expr_node *arglist_next;
02568    
02569    while (arglist)
02570    {
02571       arglist_next = arglist->right;
02572       if (arglist->val)
02573          free_value(arglist->val);
02574       arglist->val = 0;
02575       arglist->right = 0;
02576       free(arglist);
02577       arglist = arglist_next;
02578    }
02579 }
02580 
02581 #if !defined(STANDALONE) && !defined(STANDALONE2)
02582 static char *compose_func_args(struct expr_node *arglist)
02583 {
02584    struct expr_node *t = arglist;
02585    char *argbuf;
02586    int total_len = 0;
02587    
02588    while (t) {
02589       if (t != arglist)
02590          total_len += 1; /* for the sep */
02591       if (t->val) {
02592          if (t->val->type == AST_EXPR_number)
02593             total_len += 25; /* worst case */
02594          else
02595             total_len += strlen(t->val->u.s);
02596       }
02597       
02598       t = t->right;
02599    }
02600    total_len++; /* for the null */
02601    ast_log(LOG_NOTICE,"argbuf allocated %d bytes;\n", total_len);
02602    argbuf = malloc(total_len);
02603    argbuf[0] = 0;
02604    t = arglist;
02605    while (t) {
02606       char numbuf[30];
02607       
02608       if (t != arglist)
02609          strcat(argbuf,",");
02610       
02611       if (t->val) {
02612          if (t->val->type == AST_EXPR_number) {
02613             sprintf(numbuf,FP___PRINTF,t->val->u.i);
02614             strcat(argbuf,numbuf);
02615          } else
02616             strcat(argbuf,t->val->u.s);
02617       }
02618       t = t->right;
02619    }
02620    ast_log(LOG_NOTICE,"argbuf uses %d bytes;\n", (int) strlen(argbuf));
02621    return argbuf;
02622 }
02623 
02624 static int is_really_num(char *str)
02625 {
02626    if ( strspn(str,"-0123456789.    ") == strlen(str))
02627       return 1;
02628    else
02629       return 0;
02630 }
02631 #endif
02632 
02633 static struct val *op_func(struct val *funcname, struct expr_node *arglist, struct ast_channel *chan)
02634 {
02635    if (strspn(funcname->u.s,"ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789") == strlen(funcname->u.s))
02636    {
02637       struct val *result;
02638       if (0) {
02639 #ifdef FUNC_COS
02640       } else if (strcmp(funcname->u.s,"COS") == 0) {
02641          if (arglist && !arglist->right && arglist->val){
02642             to_number(arglist->val);
02643             result = make_number(FUNC_COS(arglist->val->u.i));
02644             return result;
02645          } else {
02646             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02647             return make_number(0.0);
02648          }
02649 #endif
02650 #ifdef FUNC_SIN
02651       } else if (strcmp(funcname->u.s,"SIN") == 0) {
02652          if (arglist && !arglist->right && arglist->val){
02653             to_number(arglist->val);
02654             result = make_number(FUNC_SIN(arglist->val->u.i));
02655             return result;
02656          } else {
02657             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02658             return make_number(0.0);
02659          }
02660 #endif
02661 #ifdef FUNC_TAN
02662       } else if (strcmp(funcname->u.s,"TAN") == 0) {
02663          if (arglist && !arglist->right && arglist->val){
02664             to_number(arglist->val);
02665             result = make_number(FUNC_TAN(arglist->val->u.i));
02666             return result;
02667          } else {
02668             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02669             return make_number(0.0);
02670          }
02671 #endif
02672 #ifdef FUNC_ACOS
02673       } else if (strcmp(funcname->u.s,"ACOS") == 0) {
02674          if (arglist && !arglist->right && arglist->val){
02675             to_number(arglist->val);
02676             result = make_number(FUNC_ACOS(arglist->val->u.i));
02677             return result;
02678          } else {
02679             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02680             return make_number(0.0);
02681          }
02682 #endif
02683 #ifdef FUNC_ASIN
02684       } else if (strcmp(funcname->u.s,"ASIN") == 0) {
02685          if (arglist && !arglist->right && arglist->val){
02686             to_number(arglist->val);
02687             result = make_number(FUNC_ASIN(arglist->val->u.i));
02688             return result;
02689          } else {
02690             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02691             return make_number(0.0);
02692          }
02693 #endif
02694 #ifdef FUNC_ATAN
02695       } else if (strcmp(funcname->u.s,"ATAN") == 0) {
02696          if (arglist && !arglist->right && arglist->val){
02697             to_number(arglist->val);
02698             result = make_number(FUNC_ATAN(arglist->val->u.i));
02699             return result;
02700          } else {
02701             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02702             return make_number(0.0);
02703          }
02704 #endif
02705 #ifdef FUNC_ATAN2
02706       } else if (strcmp(funcname->u.s,"ATAN2") == 0) {
02707          if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
02708             to_number(arglist->val);
02709             to_number(arglist->right->val);
02710             result = make_number(FUNC_ATAN2(arglist->val->u.i, arglist->right->val->u.i));
02711             return result;
02712          } else {
02713             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02714             return make_number(0.0);
02715          }
02716 #endif
02717 #ifdef FUNC_POW
02718       } else if (strcmp(funcname->u.s,"POW") == 0) {
02719          if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
02720             to_number(arglist->val);
02721             to_number(arglist->right->val);
02722             result = make_number(FUNC_POW(arglist->val->u.i, arglist->right->val->u.i));
02723             return result;
02724          } else {
02725             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02726             return make_number(0.0);
02727          }
02728 #endif
02729 #ifdef FUNC_SQRT
02730       } else if (strcmp(funcname->u.s,"SQRT") == 0) {
02731          if (arglist && !arglist->right && arglist->val){
02732             to_number(arglist->val);
02733             result = make_number(FUNC_SQRT(arglist->val->u.i));
02734             return result;
02735          } else {
02736             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02737             return make_number(0.0);
02738          }
02739 #endif
02740 #ifdef FUNC_FLOOR
02741       } else if (strcmp(funcname->u.s,"FLOOR") == 0) {
02742          if (arglist && !arglist->right && arglist->val){
02743             to_number(arglist->val);
02744             result = make_number(FUNC_FLOOR(arglist->val->u.i));
02745             return result;
02746          } else {
02747             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02748             return make_number(0.0);
02749          }
02750 #endif
02751 #ifdef FUNC_CEIL
02752       } else if (strcmp(funcname->u.s,"CEIL") == 0) {
02753          if (arglist && !arglist->right && arglist->val){
02754             to_number(arglist->val);
02755             result = make_number(FUNC_CEIL(arglist->val->u.i));
02756             return result;
02757          } else {
02758             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02759             return make_number(0.0);
02760          }
02761 #endif
02762 #ifdef FUNC_ROUND
02763       } else if (strcmp(funcname->u.s,"ROUND") == 0) {
02764          if (arglist && !arglist->right && arglist->val){
02765             to_number(arglist->val);
02766             result = make_number(FUNC_ROUND(arglist->val->u.i));
02767             return result;
02768          } else {
02769             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02770             return make_number(0.0);
02771          }
02772 #endif /* defined(FUNC_ROUND) */
02773 #ifdef FUNC_RINT
02774       } else if (strcmp(funcname->u.s,"RINT") == 0) {
02775          if (arglist && !arglist->right && arglist->val){
02776             to_number(arglist->val);
02777             result = make_number(FUNC_RINT(arglist->val->u.i));
02778             return result;
02779          } else {
02780             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02781             return make_number(0.0);
02782          }
02783 #endif
02784 #ifdef FUNC_TRUNC
02785       } else if (strcmp(funcname->u.s,"TRUNC") == 0) {
02786          if (arglist && !arglist->right && arglist->val){
02787             to_number(arglist->val);
02788             result = make_number(FUNC_TRUNC(arglist->val->u.i));
02789             return result;
02790          } else {
02791             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02792             return make_number(0.0);
02793          }
02794 #endif /* defined(FUNC_TRUNC) */
02795 #ifdef FUNC_EXP
02796       } else if (strcmp(funcname->u.s,"EXP") == 0) {
02797          if (arglist && !arglist->right && arglist->val){
02798             to_number(arglist->val);
02799             result = make_number(FUNC_EXP(arglist->val->u.i));
02800             return result;
02801          } else {
02802             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02803             return make_number(0.0);
02804          }
02805 #endif
02806 #ifdef FUNC_EXP2
02807       } else if (strcmp(funcname->u.s,"EXP2") == 0) {
02808          if (arglist && !arglist->right && arglist->val){
02809             to_number(arglist->val);
02810             result = make_number(FUNC_EXP2(arglist->val->u.i));
02811             return result;
02812          } else {
02813             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02814             return make_number(0.0);
02815          }
02816 #endif
02817 #ifdef FUNC_EXP10
02818       } else if (strcmp(funcname->u.s,"EXP10") == 0) {
02819          if (arglist && !arglist->right && arglist->val){
02820             to_number(arglist->val);
02821             result = make_number(FUNC_EXP10(arglist->val->u.i));
02822             return result;
02823          } else {
02824             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02825             return make_number(0.0);
02826          }
02827 #endif
02828 #ifdef FUNC_LOG
02829       } else if (strcmp(funcname->u.s,"LOG") == 0) {
02830          if (arglist && !arglist->right && arglist->val){
02831             to_number(arglist->val);
02832             result = make_number(FUNC_LOG(arglist->val->u.i));
02833             return result;
02834          } else {
02835             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02836             return make_number(0.0);
02837          }
02838 #endif
02839 #ifdef FUNC_LOG2
02840       } else if (strcmp(funcname->u.s,"LOG2") == 0) {
02841          if (arglist && !arglist->right && arglist->val){
02842             to_number(arglist->val);
02843             result = make_number(FUNC_LOG2(arglist->val->u.i));
02844             return result;
02845          } else {
02846             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02847             return make_number(0.0);
02848          }
02849 #endif
02850 #ifdef FUNC_LOG10
02851       } else if (strcmp(funcname->u.s,"LOG10") == 0) {
02852          if (arglist && !arglist->right && arglist->val){
02853             to_number(arglist->val);
02854             result = make_number(FUNC_LOG10(arglist->val->u.i));
02855             return result;
02856          } else {
02857             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02858             return make_number(0.0);
02859          }
02860 #endif
02861 #ifdef FUNC_REMAINDER
02862       } else if (strcmp(funcname->u.s,"REMAINDER") == 0) {
02863          if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
02864             to_number(arglist->val);
02865             to_number(arglist->right->val);
02866             result = make_number(FUNC_REMAINDER(arglist->val->u.i, arglist->right->val->u.i));
02867             return result;
02868          } else {
02869             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02870             return make_number(0.0);
02871          }
02872 #endif
02873       } else {
02874          /* is this a custom function we should execute and collect the results of? */
02875 #if !defined(STANDALONE) && !defined(STANDALONE2)
02876          struct ast_custom_function *f = ast_custom_function_find(funcname->u.s);
02877          if (!chan)
02878             ast_log(LOG_WARNING,"Hey! chan is NULL.\n");
02879          if (!f)
02880             ast_log(LOG_WARNING,"Hey! could not find func %s.\n", funcname->u.s);
02881          
02882          if (f && chan) {
02883             if (f->read) {
02884                char workspace[512];
02885                char *argbuf = compose_func_args(arglist);
02886                f->read(chan, funcname->u.s, argbuf, workspace, sizeof(workspace));
02887                free(argbuf);
02888                if (is_really_num(workspace))
02889                   return make_number(FUNC_STRTOD(workspace,(char **)NULL));
02890                else
02891                   return make_str(workspace);
02892             } else {
02893                ast_log(LOG_ERROR,"Error! Function '%s' cannot be read!\n", funcname->u.s);
02894                return (make_number ((FP___TYPE)0.0));
02895             }
02896             
02897          } else {
02898             ast_log(LOG_ERROR,"Error! '%s' doesn't appear to be an available function!", funcname->u.s);
02899             return (make_number ((FP___TYPE)0.0));
02900          }
02901 #else
02902          ast_log(LOG_ERROR,"Error! '%s' is not available in the standalone version!", funcname->u.s);
02903          return (make_number ((FP___TYPE)0.0));
02904 #endif
02905       }
02906    }
02907    else
02908    {
02909       ast_log(LOG_ERROR,"Error! '%s' is not possibly a function name!", funcname->u.s);
02910       return (make_number ((FP___TYPE)0.0));
02911    }
02912    return (make_number ((FP___TYPE)0.0));
02913 }
02914 
02915 
02916 static struct val *
02917 op_or (struct val *a, struct val *b)
02918 {
02919    if (is_zero_or_null (a)) {
02920       free_value (a);
02921       return (b);
02922    } else {
02923       free_value (b);
02924       return (a);
02925    }
02926 }
02927       
02928 static struct val *
02929 op_and (struct val *a, struct val *b)
02930 {
02931    if (is_zero_or_null (a) || is_zero_or_null (b)) {
02932       free_value (a);
02933       free_value (b);
02934       return (make_number ((FP___TYPE)0.0));
02935    } else {
02936       free_value (b);
02937       return (a);
02938    }
02939 }
02940 
02941 static struct val *
02942 op_eq (struct val *a, struct val *b)
02943 {
02944    struct val *r; 
02945 
02946    if (isstring (a) || isstring (b)) {
02947       to_string (a);
02948       to_string (b); 
02949       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) == 0));
02950    } else {
02951 #ifdef DEBUG_FOR_CONVERSIONS
02952       char buffer[2000];
02953       sprintf(buffer,"Converting '%s' and '%s' ", a->u.s, b->u.s);
02954 #endif
02955       (void)to_number(a);
02956       (void)to_number(b);
02957 #ifdef DEBUG_FOR_CONVERSIONS
02958       ast_log(LOG_WARNING,"%s to '%lld' and '%lld'\n", buffer, a->u.i, b->u.i);
02959 #endif
02960       r = make_number ((FP___TYPE)(a->u.i == b->u.i));
02961    }
02962 
02963    free_value (a);
02964    free_value (b);
02965    return r;
02966 }
02967 
02968 static struct val *
02969 op_gt (struct val *a, struct val *b)
02970 {
02971    struct val *r;
02972 
02973    if (isstring (a) || isstring (b)) {
02974       to_string (a);
02975       to_string (b);
02976       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) > 0));
02977    } else {
02978       (void)to_number(a);
02979       (void)to_number(b);
02980       r = make_number ((FP___TYPE)(a->u.i > b->u.i));
02981    }
02982 
02983    free_value (a);
02984    free_value (b);
02985    return r;
02986 }
02987 
02988 static struct val *
02989 op_lt (struct val *a, struct val *b)
02990 {
02991    struct val *r;
02992 
02993    if (isstring (a) || isstring (b)) {
02994       to_string (a);
02995       to_string (b);
02996       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) < 0));
02997    } else {
02998       (void)to_number(a);
02999       (void)to_number(b);
03000       r = make_number ((FP___TYPE)(a->u.i < b->u.i));
03001    }
03002 
03003    free_value (a);
03004    free_value (b);
03005    return r;
03006 }
03007 
03008 static struct val *
03009 op_ge (struct val *a, struct val *b)
03010 {
03011    struct val *r;
03012 
03013    if (isstring (a) || isstring (b)) {
03014       to_string (a);
03015       to_string (b);
03016       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) >= 0));
03017    } else {
03018       (void)to_number(a);
03019       (void)to_number(b);
03020       r = make_number ((FP___TYPE)(a->u.i >= b->u.i));
03021    }
03022 
03023    free_value (a);
03024    free_value (b);
03025    return r;
03026 }
03027 
03028 static struct val *
03029 op_le (struct val *a, struct val *b)
03030 {
03031    struct val *r;
03032 
03033    if (isstring (a) || isstring (b)) {
03034       to_string (a);
03035       to_string (b);
03036       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) <= 0));
03037    } else {
03038       (void)to_number(a);
03039       (void)to_number(b);
03040       r = make_number ((FP___TYPE)(a->u.i <= b->u.i));
03041    }
03042 
03043    free_value (a);
03044    free_value (b);
03045    return r;
03046 }
03047 
03048 static struct val *
03049 op_cond (struct val *a, struct val *b, struct val *c)
03050 {
03051    struct val *r;
03052 
03053    if( isstring(a) )
03054    {
03055       if( strlen(a->u.s) && strcmp(a->u.s, "\"\"") != 0 && strcmp(a->u.s,"0") != 0 )
03056       {
03057          free_value(a);
03058          free_value(c);
03059          r = b;
03060       }
03061       else
03062       {
03063          free_value(a);
03064          free_value(b);
03065          r = c;
03066       }
03067    }
03068    else
03069    {
03070       (void)to_number(a);
03071       if( a->u.i )
03072       {
03073          free_value(a);
03074          free_value(c);
03075          r = b;
03076       }
03077       else
03078       {
03079          free_value(a);
03080          free_value(b);
03081          r = c;
03082       }
03083    }
03084    return r;
03085 }
03086 
03087 static struct val *
03088 op_ne (struct val *a, struct val *b)
03089 {
03090    struct val *r;
03091 
03092    if (isstring (a) || isstring (b)) {
03093       to_string (a);
03094       to_string (b);
03095       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) != 0));
03096    } else {
03097       (void)to_number(a);
03098       (void)to_number(b);
03099       r = make_number ((FP___TYPE)(a->u.i != b->u.i));
03100    }
03101 
03102    free_value (a);
03103    free_value (b);
03104    return r;
03105 }
03106 
03107 static int
03108 chk_plus (FP___TYPE a, FP___TYPE b, FP___TYPE r)
03109 {
03110    /* sum of two positive numbers must be positive */
03111    if (a > 0 && b > 0 && r <= 0)
03112       return 1;
03113    /* sum of two negative numbers must be negative */
03114    if (a < 0 && b < 0 && r >= 0)
03115       return 1;
03116    /* all other cases are OK */
03117    return 0;
03118 }
03119 
03120 static struct val *
03121 op_plus (struct val *a, struct val *b)
03122 {
03123    struct val *r;
03124 
03125    if (!to_number (a)) {
03126       if( !extra_error_message_supplied )
03127          ast_log(LOG_WARNING,"non-numeric argument\n");
03128       if (!to_number (b)) {
03129          free_value(a);
03130          free_value(b);
03131          return make_number(0);
03132       } else {
03133          free_value(a);
03134          return (b);
03135       }
03136    } else if (!to_number(b)) {
03137       free_value(b);
03138       return (a);
03139    }
03140 
03141    r = make_number (a->u.i + b->u.i);
03142    if (chk_plus (a->u.i, b->u.i, r->u.i)) {
03143       ast_log(LOG_WARNING,"overflow\n");
03144    }
03145    free_value (a);
03146    free_value (b);
03147    return r;
03148 }
03149 
03150 static int
03151 chk_minus (FP___TYPE a, FP___TYPE b, FP___TYPE r)
03152 {
03153    /* special case subtraction of QUAD_MIN */
03154    if (b == QUAD_MIN) {
03155       if (a >= 0)
03156          return 1;
03157       else
03158          return 0;
03159    }
03160    /* this is allowed for b != QUAD_MIN */
03161    return chk_plus (a, -b, r);
03162 }
03163 
03164 static struct val *
03165 op_minus (struct val *a, struct val *b)
03166 {
03167    struct val *r;
03168 
03169    if (!to_number (a)) {
03170       if( !extra_error_message_supplied )
03171          ast_log(LOG_WARNING, "non-numeric argument\n");
03172       if (!to_number (b)) {
03173          free_value(a);
03174          free_value(b);
03175          return make_number(0);
03176       } else {
03177          r = make_number(0 - b->u.i);
03178          free_value(a);
03179          free_value(b);
03180          return (r);
03181       }
03182    } else if (!to_number(b)) {
03183       if( !extra_error_message_supplied )
03184          ast_log(LOG_WARNING, "non-numeric argument\n");
03185       free_value(b);
03186       return (a);
03187    }
03188 
03189    r = make_number (a->u.i - b->u.i);
03190    if (chk_minus (a->u.i, b->u.i, r->u.i)) {
03191       ast_log(LOG_WARNING, "overflow\n");
03192    }
03193    free_value (a);
03194    free_value (b);
03195    return r;
03196 }
03197 
03198 static struct val *
03199 op_negate (struct val *a)
03200 {
03201    struct val *r;
03202 
03203    if (!to_number (a) ) {
03204       free_value(a);
03205       if( !extra_error_message_supplied )
03206          ast_log(LOG_WARNING, "non-numeric argument\n");
03207       return make_number(0);
03208    }
03209 
03210    r = make_number (- a->u.i);
03211    if (chk_minus (0, a->u.i, r->u.i)) {
03212       ast_log(LOG_WARNING, "overflow\n");
03213    }
03214    free_value (a);
03215    return r;
03216 }
03217 
03218 static struct val *
03219 op_compl (struct val *a)
03220 {
03221    int v1 = 1;
03222    struct val *r;
03223    
03224    if( !a )
03225    {
03226       v1 = 0;
03227    }
03228    else
03229    {
03230       switch( a->type )
03231       {
03232       case AST_EXPR_number:
03233          if( a->u.i == 0 )
03234             v1 = 0;
03235          break;
03236          
03237       case AST_EXPR_string:
03238          if( a->u.s == 0 )
03239             v1 = 0;
03240          else
03241          {
03242             if( a->u.s[0] == 0 )
03243                v1 = 0;
03244             else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' )
03245                v1 = 0;
03246          }
03247          break;
03248          
03249       case AST_EXPR_numeric_string:
03250          if( a->u.s == 0 )
03251             v1 = 0;
03252          else
03253          {
03254             if( a->u.s[0] == 0 )
03255                v1 = 0;
03256             else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' )
03257                v1 = 0;
03258          }
03259          break;
03260       }
03261    }
03262    
03263    r = make_number (!v1);
03264    free_value (a);
03265    return r;
03266 }
03267 
03268 static int
03269 chk_times (FP___TYPE a, FP___TYPE b, FP___TYPE r)
03270 {
03271    /* special case: first operand is 0, no overflow possible */
03272    if (a == 0)
03273       return 0;
03274    /* cerify that result of division matches second operand */
03275    if (r / a != b)
03276       return 1;
03277    return 0;
03278 }
03279 
03280 static struct val *
03281 op_times (struct val *a, struct val *b)
03282 {
03283    struct val *r;
03284 
03285    if (!to_number (a) || !to_number (b)) {
03286       free_value(a);
03287       free_value(b);
03288       if( !extra_error_message_supplied )
03289          ast_log(LOG_WARNING, "non-numeric argument\n");
03290       return(make_number(0));
03291    }
03292 
03293    r = make_number (a->u.i * b->u.i);
03294    if (chk_times (a->u.i, b->u.i, r->u.i)) {
03295       ast_log(LOG_WARNING, "overflow\n");
03296    }
03297    free_value (a);
03298    free_value (b);
03299    return (r);
03300 }
03301 
03302 static int
03303 chk_div (FP___TYPE a, FP___TYPE b)
03304 {
03305    /* div by zero has been taken care of before */
03306    /* only QUAD_MIN / -1 causes overflow */
03307    if (a == QUAD_MIN && b == -1)
03308       return 1;
03309    /* everything else is OK */
03310    return 0;
03311 }
03312 
03313 static struct val *
03314 op_div (struct val *a, struct val *b)
03315 {
03316    struct val *r;
03317 
03318    if (!to_number (a)) {
03319       free_value(a);
03320       free_value(b);
03321       if( !extra_error_message_supplied )
03322          ast_log(LOG_WARNING, "non-numeric argument\n");
03323       return make_number(0);
03324    } else if (!to_number (b)) {
03325       free_value(a);
03326       free_value(b);
03327       if( !extra_error_message_supplied )
03328          ast_log(LOG_WARNING, "non-numeric argument\n");
03329       return make_number(INT_MAX);
03330    }
03331 
03332    if (b->u.i == 0) {
03333       ast_log(LOG_WARNING, "division by zero\n");     
03334       free_value(a);
03335       free_value(b);
03336       return make_number(INT_MAX);
03337    }
03338 
03339    r = make_number (a->u.i / b->u.i);
03340    if (chk_div (a->u.i, b->u.i)) {
03341       ast_log(LOG_WARNING, "overflow\n");
03342    }
03343    free_value (a);
03344    free_value (b);
03345    return r;
03346 }
03347    
03348 static struct val *
03349 op_rem (struct val *a, struct val *b)
03350 {
03351    struct val *r;
03352 
03353    if (!to_number (a) || !to_number (b)) {
03354       if( !extra_error_message_supplied )
03355          ast_log(LOG_WARNING, "non-numeric argument\n");
03356       free_value(a);
03357       free_value(b);
03358       return make_number(0);
03359    }
03360 
03361    if (b->u.i == 0) {
03362       ast_log(LOG_WARNING, "div by zero\n");
03363       free_value(a);
03364       return(b);
03365    }
03366 
03367    r = make_number (FUNC_FMOD(a->u.i, b->u.i)); /* either fmod or fmodl if FP___TYPE is available */
03368    /* chk_rem necessary ??? */
03369    free_value (a);
03370    free_value (b);
03371    return r;
03372 }
03373    
03374 
03375 static struct val *
03376 op_colon (struct val *a, struct val *b)
03377 {
03378    regex_t rp;
03379    regmatch_t rm[2];
03380    char errbuf[256];
03381    int eval;
03382    struct val *v;
03383 
03384    /* coerce to both arguments to strings */
03385    to_string(a);
03386    to_string(b);
03387    /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */
03388    strip_quotes(a);
03389    strip_quotes(b);
03390    /* compile regular expression */
03391    if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) {
03392       regerror (eval, &rp, errbuf, sizeof(errbuf));
03393       ast_log(LOG_WARNING,"regcomp() error : %s",errbuf);
03394       free_value(a);
03395       free_value(b);
03396       return make_str("");    
03397    }
03398 
03399    /* compare string against pattern */
03400    /* remember that patterns are anchored to the beginning of the line */
03401    if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 && rm[0].rm_so == 0) {
03402       if (rm[1].rm_so >= 0) {
03403          *(a->u.s + rm[1].rm_eo) = '\0';
03404          v = make_str (a->u.s + rm[1].rm_so);
03405 
03406       } else {
03407          v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so));
03408       }
03409    } else {
03410       if (rp.re_nsub == 0) {
03411          v = make_number ((FP___TYPE)0);
03412       } else {
03413          v = make_str ("");
03414       }
03415    }
03416 
03417    /* free arguments and pattern buffer */
03418    free_value (a);
03419    free_value (b);
03420    regfree (&rp);
03421 
03422    return v;
03423 }
03424    
03425 
03426 static struct val *
03427 op_eqtilde (struct val *a, struct val *b)
03428 {
03429    regex_t rp;
03430    regmatch_t rm[2];
03431    char errbuf[256];
03432    int eval;
03433    struct val *v;
03434 
03435    /* coerce to both arguments to strings */
03436    to_string(a);
03437    to_string(b);
03438    /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */
03439    strip_quotes(a);
03440    strip_quotes(b);
03441    /* compile regular expression */
03442    if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) {
03443       regerror (eval, &rp, errbuf, sizeof(errbuf));
03444       ast_log(LOG_WARNING,"regcomp() error : %s",errbuf);
03445       free_value(a);
03446       free_value(b);
03447       return make_str("");    
03448    }
03449 
03450    /* compare string against pattern */
03451    /* remember that patterns are anchored to the beginning of the line */
03452    if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 ) {
03453       if (rm[1].rm_so >= 0) {
03454          *(a->u.s + rm[1].rm_eo) = '\0';
03455          v = make_str (a->u.s + rm[1].rm_so);
03456 
03457       } else {
03458          v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so));
03459       }
03460    } else {
03461       if (rp.re_nsub == 0) {
03462          v = make_number ((FP___TYPE)0.0);
03463       } else {
03464          v = make_str ("");
03465       }
03466    }
03467 
03468    /* free arguments and pattern buffer */
03469    free_value (a);
03470    free_value (b);
03471    regfree (&rp);
03472 
03473    return v;
03474 }
03475 

Generated on Wed Oct 28 11:45:28 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6