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

Generated on Thu Oct 11 06:42:01 2012 for Asterisk - the Open Source PBX by  doxygen 1.5.6