Mon Mar 19 11:30:22 2012

Asterisk developer's documentation


ast_expr2.c

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

Generated on Mon Mar 19 11:30:22 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7