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