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