#include "asterisk.h"
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <locale.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <regex.h>
#include <limits.h>
#include "asterisk/ast_expr.h"
#include "asterisk/logger.h"
#include "asterisk/pbx.h"
Go to the source code of this file.
Data Structures | |
struct | expr_node |
struct | parse_io |
struct | val |
union | yyalloc |
struct | yyltype |
union | YYSTYPE |
Defines | |
#define | ast_yyerror(x) ast_yyerror(x, YYLTYPE *yylloc, struct parse_io *parseio) |
#define | ast_yyerror(x) ast_yyerror(x,&yyloc,parseio) |
#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);} |
#define | FP___PRINTF "%.16g" |
#define | FP___TYPE double |
#define | FUNC_ACOS acosl |
#define | FUNC_ASIN asinl |
#define | FUNC_ATAN atanl |
#define | FUNC_ATAN2 atan2l |
#define | FUNC_CEIL ceill |
#define | FUNC_COS cosl |
#define | FUNC_EXP expl |
#define | FUNC_EXP10 exp10l |
#define | FUNC_EXP2 exp2l |
#define | FUNC_FLOOR floorl |
#define | FUNC_FMOD fmodl |
#define | FUNC_LOG logl |
#define | FUNC_LOG10 log10l |
#define | FUNC_LOG2 log2l |
#define | FUNC_POW powl |
#define | FUNC_REMAINDER remainderl |
#define | FUNC_RINT rintl |
#define | FUNC_ROUND roundl |
#define | FUNC_SIN sinl |
#define | FUNC_SQRT sqrtl |
#define | FUNC_STRTOD strtold |
#define | FUNC_TAN tanl |
#define | FUNC_TRUNC truncl |
#define | QUAD_MAX (0x7fffffffffffffffLL) |
#define | QUAD_MIN (-0x7fffffffffffffffLL-1) |
#define | YY_(msgid) msgid |
#define | YY_LOCATION_PRINT(File, Loc) |
#define | YY_REDUCE_PRINT(Rule) |
#define | YY_STACK_PRINT(Bottom, Top) |
#define | YY_SYMBOL_PRINT(Title, Type, Value, Location) |
#define | YYABORT goto yyabortlab |
#define | YYACCEPT goto yyacceptlab |
#define | YYBACKUP(Token, Value) |
#define | YYBISON 1 |
#define | YYBISON_VERSION "2.5" |
#define | YYCASE_(N, S) |
#define | yychar ast_yychar |
#define | yyclearin (yychar = YYEMPTY) |
#define | YYCOPY(To, From, Count) |
#define | YYCOPY_NEEDED 1 |
#define | YYDEBUG 0 |
#define | yydebug ast_yydebug |
#define | YYDPRINTF(Args) |
#define | YYEMPTY (-2) |
#define | YYENABLE_NLS 0 |
#define | YYEOF 0 |
#define | YYERRCODE 256 |
#define | yyerrok (yyerrstatus = 0) |
#define | YYERROR goto yyerrorlab |
#define | yyerror ast_yyerror |
#define | YYERROR_VERBOSE 1 |
#define | YYERROR_VERBOSE 1 |
#define | YYFAIL goto yyerrlab |
#define | YYFINAL 11 |
#define | YYFREE free |
#define | YYID(n) (n) |
#define | YYINITDEPTH 200 |
#define | YYLAST 159 |
#define | YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) |
#define | yylex ast_yylex |
#define | YYLEX_PARAM ((struct parse_io *)parseio)->scanner |
#define | yylloc ast_yylloc |
#define | YYLLOC_DEFAULT(Current, Rhs, N) |
#define | YYLSP_NEEDED 1 |
#define | YYLTYPE yyltype |
#define | YYLTYPE_IS_TRIVIAL 1 |
#define | yylval ast_yylval |
#define | YYMALLOC malloc |
#define | YYMAXDEPTH 10000 |
#define | YYMAXUTOK 280 |
#define | yynerrs ast_yynerrs |
#define | YYNNTS 4 |
#define | YYNRULES 28 |
#define | YYNSTATES 54 |
#define | YYNTOKENS 26 |
#define | YYPACT_NINF -18 |
#define | yypact_value_is_default(yystate) ((yystate) == (-18)) |
#define | yyparse ast_yyparse |
#define | YYPARSE_PARAM parseio |
#define | YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) |
#define | YYPULL 1 |
#define | YYPURE 1 |
#define | YYPUSH 0 |
#define | YYRECOVERING() (!!yyerrstatus) |
#define | YYRHSLOC(Rhs, K) ((Rhs)[K]) |
#define | YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
#define | YYSIZE_T unsigned int |
#define | YYSKELETON_NAME "yacc.c" |
#define | YYSTACK_ALLOC YYMALLOC |
#define | YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
#define | YYSTACK_BYTES(N) |
#define | YYSTACK_FREE YYFREE |
#define | YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
#define | YYSTACK_RELOCATE(Stack_alloc, Stack) |
#define | yystype YYSTYPE |
#define | YYSTYPE_IS_DECLARED 1 |
#define | YYSTYPE_IS_TRIVIAL 1 |
#define | YYSYNTAX_ERROR |
#define | YYTABLE_NINF -1 |
#define | yytable_value_is_error(yytable_value) YYID (0) |
#define | YYTERROR 1 |
#define | YYTOKEN_TABLE 0 |
#define | YYTRANSLATE(YYX) ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
#define | YYUNDEFTOK 2 |
#define | YYUSE(e) ((void) (e)) |
Typedefs | |
typedef void * | yyscan_t |
typedef short int | yytype_int16 |
typedef short int | yytype_int8 |
typedef unsigned short int | yytype_uint16 |
typedef unsigned char | yytype_uint8 |
Enumerations | |
enum | node_type { AST_EXPR_NODE_COMMA, AST_EXPR_NODE_STRING, AST_EXPR_NODE_VAL } |
enum | valtype { AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string } |
enum | yytokentype { TOK_COMMA = 258, TOK_COLONCOLON = 259, TOK_COND = 260, TOK_OR = 261, TOK_AND = 262, TOK_NE = 263, TOK_LE = 264, TOK_GE = 265, TOK_LT = 266, TOK_GT = 267, TOK_EQ = 268, TOK_MINUS = 269, TOK_PLUS = 270, TOK_MOD = 271, TOK_DIV = 272, TOK_MULT = 273, TOK_COMPL = 274, TOK_TILDETILDE = 275, TOK_EQTILDE = 276, TOK_COLON = 277, TOK_LP = 278, TOK_RP = 279, TOKEN = 280 } |
Functions | |
int ast_yylex | __P ((YYSTYPE *, YYLTYPE *, yyscan_t)) |
static struct val *op_cond | __P ((struct val *, struct val *, struct val *)) |
static struct val *op_and | __P ((struct val *, struct val *)) |
static struct val *make_str | __P ((const char *)) |
static struct val *make_number | __P ((FP___TYPE)) |
static void free_value | __P ((struct val *)) |
static int chk_minus | __P ((FP___TYPE, FP___TYPE, FP___TYPE)) |
static int chk_div | __P ((FP___TYPE, FP___TYPE)) |
static struct expr_node * | alloc_expr_node (enum node_type) |
int | ast_yyerror (const char *, YYLTYPE *, struct parse_io *) |
static int | chk_div (FP___TYPE a, FP___TYPE b) |
static int | chk_minus (FP___TYPE a, FP___TYPE b, FP___TYPE r) |
static int | chk_plus (FP___TYPE a, FP___TYPE b, FP___TYPE r) |
static int | chk_times (FP___TYPE a, FP___TYPE b, FP___TYPE r) |
static char * | compose_func_args (struct expr_node *arglist) |
static void | destroy_arglist (struct expr_node *arglist) |
static void | free_value (struct val *vp) |
static int | is_really_num (char *str) |
static int | is_zero_or_null (struct val *vp) |
static int | isstring (struct val *vp) |
static struct val * | make_number (FP___TYPE i) |
static struct val * | make_str (const char *s) |
static struct val * | op_and (struct val *a, struct val *b) |
static struct val * | op_colon (struct val *a, struct val *b) |
static struct val * | op_compl (struct val *a) |
static struct val * | op_cond (struct val *a, struct val *b, struct val *c) |
static struct val * | op_div (struct val *a, struct val *b) |
static struct val * | op_eq (struct val *a, struct val *b) |
static struct val * | op_eqtilde (struct val *a, struct val *b) |
static struct val * | op_func (struct val *funcname, struct expr_node *arglist, struct ast_channel *chan) |
static struct val * | op_ge (struct val *a, struct val *b) |
static struct val * | op_gt (struct val *a, struct val *b) |
static struct val * | op_le (struct val *a, struct val *b) |
static struct val * | op_lt (struct val *a, struct val *b) |
static struct val * | op_minus (struct val *a, struct val *b) |
static struct val * | op_ne (struct val *a, struct val *b) |
static struct val * | op_negate (struct val *a) |
static struct val * | op_or (struct val *a, struct val *b) |
static struct val * | op_plus (struct val *a, struct val *b) |
static struct val * | op_rem (struct val *a, struct val *b) |
static struct val * | op_tildetilde (struct val *a, struct val *b) |
static struct val * | op_times (struct val *a, struct val *b) |
static void | strip_quotes (struct val *vp) |
static int | to_number (struct val *vp) |
static void | to_string (struct val *vp) |
static void | yydestruct (char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) const |
int | yyparse (void *YYPARSE_PARAM) |
int | yyparse () |
static char * | yystpcpy (char *yydest, const char *yysrc) |
static YYSIZE_T | yystrlen (char *yystr) const |
static int | yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) |
static YYSIZE_T | yytnamerr (char *yyres, const char *yystr) |
Variables | |
char | extra_error_message [4095] |
int | extra_error_message_supplied |
static const yytype_int8 | yycheck [] |
static const yytype_uint8 | yydefact [] |
static const yytype_int8 | yydefgoto [] |
static const yytype_int16 | yypact [] |
static const yytype_int8 | yypgoto [] |
static const yytype_uint8 | yyr1 [] |
static const yytype_uint8 | yyr2 [] |
static const yytype_uint8 | yystos [] |
static const yytype_uint8 | yytable [] |
static const char *const | yytname [] |
static const yytype_uint8 | yytranslate [] |
Definition at line 2785 of file ast_expr2.c.
#define ast_yyerror | ( | x | ) | ast_yyerror(x,&yyloc,parseio) |
Definition at line 2785 of file ast_expr2.c.
#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);} |
#define FP___PRINTF "%.16g" |
Definition at line 110 of file ast_expr2.c.
Referenced by ast_expr(), ast_str_expr(), compose_func_args(), and to_string().
#define FP___TYPE double |
Definition at line 111 of file ast_expr2.c.
Referenced by op_and(), op_colon(), op_eq(), op_eqtilde(), op_func(), op_ge(), op_gt(), op_le(), op_lt(), op_ne(), and to_number().
#define FUNC_ACOS acosl |
#define FUNC_ASIN asinl |
#define FUNC_ATAN atanl |
#define FUNC_ATAN2 atan2l |
#define FUNC_CEIL ceill |
#define FUNC_COS cosl |
#define FUNC_EXP expl |
#define FUNC_EXP10 exp10l |
#define FUNC_EXP2 exp2l |
Definition at line 233 of file ast_expr2.c.
Referenced by op_func().
#define FUNC_FLOOR floorl |
#define FUNC_FMOD fmodl |
#define FUNC_LOG logl |
#define FUNC_LOG10 log10l |
#define FUNC_LOG2 log2l |
#define FUNC_POW powl |
#define FUNC_REMAINDER remainderl |
#define FUNC_RINT rintl |
#define FUNC_ROUND roundl |
#define FUNC_SIN sinl |
#define FUNC_SQRT sqrtl |
#define FUNC_STRTOD strtold |
#define FUNC_TAN tanl |
#define FUNC_TRUNC truncl |
#define QUAD_MAX (0x7fffffffffffffffLL) |
Definition at line 308 of file ast_expr2.c.
#define QUAD_MIN (-0x7fffffffffffffffLL-1) |
Definition at line 305 of file ast_expr2.c.
#define YY_ | ( | msgid | ) | msgid |
#define YY_LOCATION_PRINT | ( | File, | |||
Loc | ) |
Value:
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
(Loc).last_line, (Loc).last_column)
Definition at line 1042 of file ast_expr2.c.
#define YY_REDUCE_PRINT | ( | Rule | ) |
#define YY_STACK_PRINT | ( | Bottom, | |||
Top | ) |
#define YY_SYMBOL_PRINT | ( | Title, | |||
Type, | |||||
Value, | |||||
Location | ) |
#define YYABORT goto yyabortlab |
#define YYACCEPT goto yyacceptlab |
#define YYBACKUP | ( | Token, | |||
Value | ) |
Definition at line 989 of file ast_expr2.c.
#define YYBISON 1 |
Definition at line 44 of file ast_expr2.c.
#define YYBISON_VERSION "2.5" |
Definition at line 47 of file ast_expr2.c.
#define YYCASE_ | ( | N, | |||
S | ) |
#define yychar ast_yychar |
#define yyclearin (yychar = YYEMPTY) |
Definition at line 963 of file ast_expr2.c.
#define YYCOPY | ( | To, | |||
From, | |||||
Count | ) |
Definition at line 720 of file ast_expr2.c.
#define YYCOPY_NEEDED 1 |
Definition at line 692 of file ast_expr2.c.
#define YYDEBUG 0 |
Definition at line 420 of file ast_expr2.c.
#define yydebug ast_yydebug |
Definition at line 70 of file ast_expr2.c.
#define YYDPRINTF | ( | Args | ) |
#define YYEMPTY (-2) |
#define YYENABLE_NLS 0 |
Definition at line 310 of file ast_expr2.c.
#define YYEOF 0 |
#define YYERRCODE 256 |
Definition at line 1007 of file ast_expr2.c.
#define yyerrok (yyerrstatus = 0) |
Definition at line 962 of file ast_expr2.c.
#define YYERROR goto yyerrorlab |
Definition at line 969 of file ast_expr2.c.
#define yyerror ast_yyerror |
#define YYERROR_VERBOSE 1 |
Definition at line 426 of file ast_expr2.c.
#define YYERROR_VERBOSE 1 |
Definition at line 426 of file ast_expr2.c.
#define YYFAIL goto yyerrlab |
Definition at line 979 of file ast_expr2.c.
#define YYFINAL 11 |
#define YYFREE free |
Definition at line 660 of file ast_expr2.c.
#define YYID | ( | n | ) | (n) |
#define YYINITDEPTH 200 |
#define YYLAST 159 |
#define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) |
#define yylex ast_yylex |
Definition at line 66 of file ast_expr2.c.
#define YYLEX_PARAM ((struct parse_io *)parseio)->scanner |
Definition at line 312 of file ast_expr2.c.
#define yylloc ast_yylloc |
Definition at line 72 of file ast_expr2.c.
Referenced by ast_yyget_lloc(), ast_yyset_lloc(), and yyparse().
#define YYLLOC_DEFAULT | ( | Current, | |||
Rhs, | |||||
N | ) |
#define YYLSP_NEEDED 1 |
Definition at line 62 of file ast_expr2.c.
Definition at line 400 of file ast_expr2.c.
#define YYLTYPE_IS_TRIVIAL 1 |
Definition at line 401 of file ast_expr2.c.
#define yylval ast_yylval |
Definition at line 68 of file ast_expr2.c.
Referenced by ast_yyget_lval(), ast_yyset_lval(), and yyparse().
#define YYMALLOC malloc |
Definition at line 653 of file ast_expr2.c.
#define YYMAXDEPTH 10000 |
#define YYMAXUTOK 280 |
Definition at line 748 of file ast_expr2.c.
#define yynerrs ast_yynerrs |
#define YYNNTS 4 |
Definition at line 740 of file ast_expr2.c.
#define YYNRULES 28 |
Definition at line 742 of file ast_expr2.c.
#define YYNSTATES 54 |
Definition at line 744 of file ast_expr2.c.
#define YYNTOKENS 26 |
#define YYPACT_NINF -18 |
Definition at line 883 of file ast_expr2.c.
#define yypact_value_is_default | ( | yystate | ) | ((yystate) == (-18)) |
#define yyparse ast_yyparse |
Definition at line 65 of file ast_expr2.c.
#define YYPARSE_PARAM parseio |
Definition at line 311 of file ast_expr2.c.
#define YYPOPSTACK | ( | N | ) | (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) |
Referenced by yyparse().
#define YYPULL 1 |
Definition at line 59 of file ast_expr2.c.
#define YYPURE 1 |
Definition at line 53 of file ast_expr2.c.
#define YYPUSH 0 |
Definition at line 56 of file ast_expr2.c.
#define YYRECOVERING | ( | ) | (!!yyerrstatus) |
Definition at line 987 of file ast_expr2.c.
#define YYRHSLOC | ( | Rhs, | |||
K | ) | ((Rhs)[K]) |
Definition at line 1014 of file ast_expr2.c.
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
Definition at line 561 of file ast_expr2.c.
#define YYSIZE_T unsigned int |
Definition at line 557 of file ast_expr2.c.
Referenced by yyparse(), yystrlen(), yysyntax_error(), and yytnamerr().
#define YYSKELETON_NAME "yacc.c" |
Definition at line 50 of file ast_expr2.c.
#define YYSTACK_ALLOC YYMALLOC |
#define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
#define YYSTACK_BYTES | ( | N | ) |
Value:
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM)
Definition at line 688 of file ast_expr2.c.
Referenced by yyparse().
#define YYSTACK_FREE YYFREE |
#define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
Definition at line 684 of file ast_expr2.c.
#define YYSTACK_RELOCATE | ( | Stack_alloc, | |||
Stack | ) |
#define yystype YYSTYPE |
Definition at line 487 of file ast_expr2.c.
#define YYSTYPE_IS_DECLARED 1 |
Definition at line 488 of file ast_expr2.c.
#define YYSTYPE_IS_TRIVIAL 1 |
Definition at line 486 of file ast_expr2.c.
#define YYSYNTAX_ERROR |
#define YYTABLE_NINF -1 |
Definition at line 903 of file ast_expr2.c.
#define yytable_value_is_error | ( | yytable_value | ) | YYID (0) |
#define YYTERROR 1 |
#define YYTOKEN_TABLE 0 |
Definition at line 433 of file ast_expr2.c.
#define YYTRANSLATE | ( | YYX | ) | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
#define YYUNDEFTOK 2 |
Definition at line 747 of file ast_expr2.c.
#define YYUSE | ( | e | ) | ((void) (e)) |
typedef void* yyscan_t |
Definition at line 346 of file ast_expr2.c.
typedef short int yytype_int16 |
Definition at line 544 of file ast_expr2.c.
typedef short int yytype_int8 |
Definition at line 532 of file ast_expr2.c.
typedef unsigned short int yytype_uint16 |
Definition at line 538 of file ast_expr2.c.
typedef unsigned char yytype_uint8 |
Definition at line 523 of file ast_expr2.c.
enum node_type |
Definition at line 333 of file ast_expr2.c.
00333 { 00334 AST_EXPR_NODE_COMMA, AST_EXPR_NODE_STRING, AST_EXPR_NODE_VAL 00335 } ;
enum valtype |
Definition at line 317 of file ast_expr2.c.
00317 { 00318 AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string 00319 } ;
enum yytokentype |
Definition at line 442 of file ast_expr2.c.
00442 { 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 };
static struct val* make_str __P | ( | (const char *) | ) | [static] |
static struct val* make_number __P | ( | (FP___TYPE) | ) | [static] |
static void to_string __P | ( | (struct val *) | ) | [static] |
static int chk_times __P | ( | (FP___TYPE, FP___TYPE, FP___TYPE) | ) | [static] |
static int chk_div __P | ( | (FP___TYPE, FP___TYPE) | ) | [static] |
static struct expr_node * alloc_expr_node | ( | enum | node_type | ) | [static] |
Definition at line 2562 of file ast_expr2.c.
References ast_log(), calloc, LOG_ERROR, and expr_node::type.
Referenced by yyparse().
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 }
static int chk_div | ( | FP___TYPE | a, | |
FP___TYPE | b | |||
) | [static] |
Definition at line 3534 of file ast_expr2.c.
References QUAD_MIN.
Referenced by op_div().
03535 { 03536 /* div by zero has been taken care of before */ 03537 /* only QUAD_MIN / -1 causes overflow */ 03538 if (a == QUAD_MIN && b == -1) 03539 return 1; 03540 /* everything else is OK */ 03541 return 0; 03542 }
static int chk_minus | ( | FP___TYPE | a, | |
FP___TYPE | b, | |||
FP___TYPE | r | |||
) | [static] |
Definition at line 3378 of file ast_expr2.c.
References chk_plus(), and QUAD_MIN.
Referenced by op_minus(), and op_negate().
03379 { 03380 /* special case subtraction of QUAD_MIN */ 03381 if (b == QUAD_MIN) { 03382 if (a >= 0) 03383 return 1; 03384 else 03385 return 0; 03386 } 03387 /* this is allowed for b != QUAD_MIN */ 03388 return chk_plus (a, -b, r); 03389 }
static int chk_plus | ( | FP___TYPE | a, | |
FP___TYPE | b, | |||
FP___TYPE | r | |||
) | [static] |
Definition at line 3335 of file ast_expr2.c.
Referenced by chk_minus(), and op_plus().
03336 { 03337 /* sum of two positive numbers must be positive */ 03338 if (a > 0 && b > 0 && r <= 0) 03339 return 1; 03340 /* sum of two negative numbers must be negative */ 03341 if (a < 0 && b < 0 && r >= 0) 03342 return 1; 03343 /* all other cases are OK */ 03344 return 0; 03345 }
static int chk_times | ( | FP___TYPE | a, | |
FP___TYPE | b, | |||
FP___TYPE | r | |||
) | [static] |
Definition at line 3500 of file ast_expr2.c.
Referenced by op_times().
03501 { 03502 /* special case: first operand is 0, no overflow possible */ 03503 if (a == 0) 03504 return 0; 03505 /* cerify that result of division matches second operand */ 03506 if (r / a != b) 03507 return 1; 03508 return 0; 03509 }
static char* compose_func_args | ( | struct expr_node * | arglist | ) | [static] |
Definition at line 2809 of file ast_expr2.c.
References AST_EXPR_number, ast_log(), FP___PRINTF, val::i, LOG_NOTICE, malloc, expr_node::right, val::s, val::type, val::u, and expr_node::val.
Referenced by op_func().
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; /* for the sep */ 02818 if (t->val) { 02819 if (t->val->type == AST_EXPR_number) 02820 total_len += 25; /* worst case */ 02821 else 02822 total_len += strlen(t->val->u.s); 02823 } 02824 02825 t = t->right; 02826 } 02827 total_len++; /* for the null */ 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 }
static void destroy_arglist | ( | struct expr_node * | arglist | ) | [static] |
Definition at line 2792 of file ast_expr2.c.
References free, free_value(), expr_node::right, and expr_node::val.
Referenced by yyparse().
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 }
static void free_value | ( | struct val * | vp | ) | [static] |
Definition at line 2624 of file ast_expr2.c.
References AST_EXPR_numeric_string, free, val::s, val::type, and val::u.
Referenced by destroy_arglist(), op_and(), op_colon(), op_compl(), op_cond(), op_div(), op_eq(), op_eqtilde(), op_ge(), op_gt(), op_le(), op_lt(), op_minus(), op_ne(), op_negate(), op_or(), op_plus(), op_rem(), op_tildetilde(), op_times(), and yydestruct().
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 }
static int is_really_num | ( | char * | str | ) | [static] |
Definition at line 2851 of file ast_expr2.c.
Referenced by op_func().
02852 { 02853 if ( strspn(str,"-0123456789. ") == strlen(str)) 02854 return 1; 02855 else 02856 return 0; 02857 }
static int is_zero_or_null | ( | struct val * | vp | ) | [static] |
Definition at line 2718 of file ast_expr2.c.
References AST_EXPR_number, val::i, val::s, to_number(), val::type, and val::u.
Referenced by op_and(), and op_or().
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 /* NOTREACHED */ 02726 }
static int isstring | ( | struct val * | vp | ) | [static] |
static struct val* make_number | ( | FP___TYPE | i | ) | [static] |
Definition at line 2576 of file ast_expr2.c.
References AST_EXPR_number, ast_log(), LOG_WARNING, and malloc.
Referenced by op_and(), op_colon(), op_compl(), op_div(), op_eq(), op_eqtilde(), op_func(), op_ge(), op_gt(), op_le(), op_lt(), op_minus(), op_ne(), op_negate(), op_plus(), op_rem(), and op_times().
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 }
static struct val* make_str | ( | const char * | s | ) | [static] |
Definition at line 2592 of file ast_expr2.c.
References AST_EXPR_numeric_string, ast_log(), free, val::i, LOG_WARNING, malloc, and strdup.
Referenced by op_colon(), op_eqtilde(), op_func(), op_tildetilde(), and yyparse().
02593 { 02594 struct val *vp; 02595 size_t i; 02596 int isint; /* this started out being a test for an integer, but then ended up being a test for a float */ 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 }
Definition at line 3156 of file ast_expr2.c.
References FP___TYPE, free_value(), is_zero_or_null(), and make_number().
Referenced by yyparse().
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 }
Definition at line 3607 of file ast_expr2.c.
References ast_log(), FP___TYPE, free_value(), LOG_WARNING, make_number(), make_str(), val::s, strip_quotes(), to_string(), and val::u.
Referenced by yyparse().
03608 { 03609 regex_t rp; 03610 regmatch_t rm[2]; 03611 char errbuf[256]; 03612 int eval; 03613 struct val *v; 03614 03615 /* coerce to both arguments to strings */ 03616 to_string(a); 03617 to_string(b); 03618 /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */ 03619 strip_quotes(a); 03620 strip_quotes(b); 03621 /* compile regular expression */ 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 /* compare string against pattern */ 03631 /* remember that patterns are anchored to the beginning of the line */ 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 /* free arguments and pattern buffer */ 03649 free_value (a); 03650 free_value (b); 03651 regfree (&rp); 03652 03653 return v; 03654 }
Definition at line 3446 of file ast_expr2.c.
References AST_EXPR_number, AST_EXPR_numeric_string, free_value(), val::i, make_number(), val::s, val::type, and val::u.
Referenced by yyparse().
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 }
Definition at line 3276 of file ast_expr2.c.
References free_value(), val::i, isstring(), val::s, to_number(), and val::u.
Referenced by yyparse().
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 }
Definition at line 3545 of file ast_expr2.c.
References ast_log(), chk_div(), free_value(), LOG_WARNING, make_number(), and to_number().
Referenced by yyparse().
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 }
Definition at line 3169 of file ast_expr2.c.
References ast_log(), FP___TYPE, free_value(), isstring(), LOG_WARNING, make_number(), to_number(), and to_string().
Referenced by yyparse().
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 }
Definition at line 3658 of file ast_expr2.c.
References ast_log(), FP___TYPE, free_value(), LOG_WARNING, make_number(), make_str(), val::s, strip_quotes(), to_string(), and val::u.
Referenced by yyparse().
03659 { 03660 regex_t rp; 03661 regmatch_t rm[2]; 03662 char errbuf[256]; 03663 int eval; 03664 struct val *v; 03665 03666 /* coerce to both arguments to strings */ 03667 to_string(a); 03668 to_string(b); 03669 /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */ 03670 strip_quotes(a); 03671 strip_quotes(b); 03672 /* compile regular expression */ 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 /* compare string against pattern */ 03682 /* remember that patterns are anchored to the beginning of the line */ 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 /* free arguments and pattern buffer */ 03700 free_value (a); 03701 free_value (b); 03702 regfree (&rp); 03703 03704 return v; 03705 }
static struct val * op_func | ( | struct val * | funcname, | |
struct expr_node * | arglist, | |||
struct ast_channel * | chan | |||
) | [static] |
Definition at line 2860 of file ast_expr2.c.
References ast_custom_function_find(), ast_log(), compose_func_args(), f, FP___TYPE, free, FUNC_ACOS, FUNC_ASIN, FUNC_ATAN, FUNC_ATAN2, FUNC_CEIL, FUNC_COS, FUNC_EXP, FUNC_EXP10, FUNC_EXP2, FUNC_FLOOR, FUNC_LOG, FUNC_LOG10, FUNC_LOG2, FUNC_POW, FUNC_REMAINDER, FUNC_RINT, FUNC_ROUND, FUNC_SIN, FUNC_SQRT, FUNC_STRTOD, FUNC_TAN, FUNC_TRUNC, val::i, is_really_num(), LOG_ERROR, LOG_WARNING, make_number(), make_str(), ast_format::read, expr_node::right, val::s, to_number(), val::u, and expr_node::val.
Referenced by yyparse().
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 /* defined(FUNC_ROUND) */ 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 /* defined(FUNC_TRUNC) */ 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 /* is this a custom function we should execute and collect the results of? */ 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 }
Definition at line 3236 of file ast_expr2.c.
References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().
Referenced by yyparse().
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 }
Definition at line 3196 of file ast_expr2.c.
References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().
Referenced by yyparse().
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 }
Definition at line 3256 of file ast_expr2.c.
References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().
Referenced by yyparse().
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 }
Definition at line 3216 of file ast_expr2.c.
References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().
Referenced by yyparse().
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 }
Definition at line 3392 of file ast_expr2.c.
References ast_log(), chk_minus(), free_value(), val::i, LOG_WARNING, make_number(), to_number(), and val::u.
Referenced by yyparse().
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 }
Definition at line 3315 of file ast_expr2.c.
References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().
Referenced by yyparse().
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 }
Definition at line 3426 of file ast_expr2.c.
References ast_log(), chk_minus(), free_value(), val::i, LOG_WARNING, make_number(), to_number(), and val::u.
Referenced by yyparse().
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 }
Definition at line 3144 of file ast_expr2.c.
References free_value(), and is_zero_or_null().
Referenced by yyparse().
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 }
Definition at line 3348 of file ast_expr2.c.
References ast_log(), chk_plus(), free_value(), val::i, LOG_WARNING, make_number(), to_number(), and val::u.
Referenced by yyparse().
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 }
Definition at line 3580 of file ast_expr2.c.
References ast_log(), free_value(), FUNC_FMOD, LOG_WARNING, make_number(), and to_number().
Referenced by yyparse().
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)); /* either fmod or fmodl if FP___TYPE is available */ 03599 /* chk_rem necessary ??? */ 03600 free_value (a); 03601 free_value (b); 03602 return r; 03603 }
Definition at line 3708 of file ast_expr2.c.
References free_value(), make_str(), malloc, val::s, strip_quotes(), to_string(), and val::u.
Referenced by yyparse().
03709 { 03710 struct val *v; 03711 char *vs; 03712 03713 /* coerce to both arguments to strings */ 03714 to_string(a); 03715 to_string(b); 03716 /* strip double quotes from both -- */ 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 /* free arguments */ 03727 free_value(a); 03728 free_value(b); 03729 03730 return v; 03731 }
Definition at line 3512 of file ast_expr2.c.
References ast_log(), chk_times(), free_value(), val::i, LOG_WARNING, make_number(), to_number(), and val::u.
Referenced by yyparse().
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 }
static void strip_quotes | ( | struct val * | vp | ) | [static] |
Definition at line 2667 of file ast_expr2.c.
References AST_EXPR_numeric_string, f, val::s, val::type, and val::u.
Referenced by op_colon(), op_eqtilde(), and op_tildetilde().
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 }
static int to_number | ( | struct val * | vp | ) | [static] |
Definition at line 2636 of file ast_expr2.c.
References AST_EXPR_number, ast_log(), errno, FP___TYPE, free, FUNC_STRTOD, val::i, LOG_WARNING, val::s, val::type, and val::u.
Referenced by is_zero_or_null(), op_cond(), op_div(), op_eq(), op_func(), op_ge(), op_gt(), op_le(), op_lt(), op_minus(), op_ne(), op_negate(), op_plus(), op_rem(), and op_times().
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 /* vp->type == AST_EXPR_numeric_string, make it numeric */ 02652 errno = 0; 02653 i = FUNC_STRTOD(vp->u.s, (char**)0); /* either strtod, or strtold on a good day */ 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 }
static void to_string | ( | struct val * | vp | ) | [static] |
Definition at line 2690 of file ast_expr2.c.
References AST_EXPR_numeric_string, ast_log(), FP___PRINTF, val::i, LOG_WARNING, malloc, val::s, val::type, and val::u.
Referenced by op_colon(), op_eq(), op_eqtilde(), op_ge(), op_gt(), op_le(), op_lt(), op_ne(), and op_tildetilde().
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 }
static void yydestruct | ( | char * | yymsg, | |
int | yytype, | |||
YYSTYPE * | yyvaluep, | |||
YYLTYPE * | yylocationp | |||
) | const [static] |
Definition at line 1496 of file ast_expr2.c.
References free_value(), YYSTYPE::val, YY_SYMBOL_PRINT, and YYUSE.
Referenced by yyparse().
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: /* "TOK_COLONCOLON" */ 01513 01514 /* Line 1391 of yacc.c */ 01515 #line 368 "ast_expr2.y" 01516 { free_value((yyvaluep->val)); }; 01517 01518 /* Line 1391 of yacc.c */ 01519 #line 1520 "ast_expr2.c" 01520 break; 01521 case 5: /* "TOK_COND" */ 01522 01523 /* Line 1391 of yacc.c */ 01524 #line 368 "ast_expr2.y" 01525 { free_value((yyvaluep->val)); }; 01526 01527 /* Line 1391 of yacc.c */ 01528 #line 1529 "ast_expr2.c" 01529 break; 01530 case 6: /* "TOK_OR" */ 01531 01532 /* Line 1391 of yacc.c */ 01533 #line 368 "ast_expr2.y" 01534 { free_value((yyvaluep->val)); }; 01535 01536 /* Line 1391 of yacc.c */ 01537 #line 1538 "ast_expr2.c" 01538 break; 01539 case 7: /* "TOK_AND" */ 01540 01541 /* Line 1391 of yacc.c */ 01542 #line 368 "ast_expr2.y" 01543 { free_value((yyvaluep->val)); }; 01544 01545 /* Line 1391 of yacc.c */ 01546 #line 1547 "ast_expr2.c" 01547 break; 01548 case 8: /* "TOK_NE" */ 01549 01550 /* Line 1391 of yacc.c */ 01551 #line 368 "ast_expr2.y" 01552 { free_value((yyvaluep->val)); }; 01553 01554 /* Line 1391 of yacc.c */ 01555 #line 1556 "ast_expr2.c" 01556 break; 01557 case 9: /* "TOK_LE" */ 01558 01559 /* Line 1391 of yacc.c */ 01560 #line 368 "ast_expr2.y" 01561 { free_value((yyvaluep->val)); }; 01562 01563 /* Line 1391 of yacc.c */ 01564 #line 1565 "ast_expr2.c" 01565 break; 01566 case 10: /* "TOK_GE" */ 01567 01568 /* Line 1391 of yacc.c */ 01569 #line 368 "ast_expr2.y" 01570 { free_value((yyvaluep->val)); }; 01571 01572 /* Line 1391 of yacc.c */ 01573 #line 1574 "ast_expr2.c" 01574 break; 01575 case 11: /* "TOK_LT" */ 01576 01577 /* Line 1391 of yacc.c */ 01578 #line 368 "ast_expr2.y" 01579 { free_value((yyvaluep->val)); }; 01580 01581 /* Line 1391 of yacc.c */ 01582 #line 1583 "ast_expr2.c" 01583 break; 01584 case 12: /* "TOK_GT" */ 01585 01586 /* Line 1391 of yacc.c */ 01587 #line 368 "ast_expr2.y" 01588 { free_value((yyvaluep->val)); }; 01589 01590 /* Line 1391 of yacc.c */ 01591 #line 1592 "ast_expr2.c" 01592 break; 01593 case 13: /* "TOK_EQ" */ 01594 01595 /* Line 1391 of yacc.c */ 01596 #line 368 "ast_expr2.y" 01597 { free_value((yyvaluep->val)); }; 01598 01599 /* Line 1391 of yacc.c */ 01600 #line 1601 "ast_expr2.c" 01601 break; 01602 case 14: /* "TOK_MINUS" */ 01603 01604 /* Line 1391 of yacc.c */ 01605 #line 368 "ast_expr2.y" 01606 { free_value((yyvaluep->val)); }; 01607 01608 /* Line 1391 of yacc.c */ 01609 #line 1610 "ast_expr2.c" 01610 break; 01611 case 15: /* "TOK_PLUS" */ 01612 01613 /* Line 1391 of yacc.c */ 01614 #line 368 "ast_expr2.y" 01615 { free_value((yyvaluep->val)); }; 01616 01617 /* Line 1391 of yacc.c */ 01618 #line 1619 "ast_expr2.c" 01619 break; 01620 case 16: /* "TOK_MOD" */ 01621 01622 /* Line 1391 of yacc.c */ 01623 #line 368 "ast_expr2.y" 01624 { free_value((yyvaluep->val)); }; 01625 01626 /* Line 1391 of yacc.c */ 01627 #line 1628 "ast_expr2.c" 01628 break; 01629 case 17: /* "TOK_DIV" */ 01630 01631 /* Line 1391 of yacc.c */ 01632 #line 368 "ast_expr2.y" 01633 { free_value((yyvaluep->val)); }; 01634 01635 /* Line 1391 of yacc.c */ 01636 #line 1637 "ast_expr2.c" 01637 break; 01638 case 18: /* "TOK_MULT" */ 01639 01640 /* Line 1391 of yacc.c */ 01641 #line 368 "ast_expr2.y" 01642 { free_value((yyvaluep->val)); }; 01643 01644 /* Line 1391 of yacc.c */ 01645 #line 1646 "ast_expr2.c" 01646 break; 01647 case 19: /* "TOK_COMPL" */ 01648 01649 /* Line 1391 of yacc.c */ 01650 #line 368 "ast_expr2.y" 01651 { free_value((yyvaluep->val)); }; 01652 01653 /* Line 1391 of yacc.c */ 01654 #line 1655 "ast_expr2.c" 01655 break; 01656 case 20: /* "TOK_TILDETILDE" */ 01657 01658 /* Line 1391 of yacc.c */ 01659 #line 368 "ast_expr2.y" 01660 { free_value((yyvaluep->val)); }; 01661 01662 /* Line 1391 of yacc.c */ 01663 #line 1664 "ast_expr2.c" 01664 break; 01665 case 21: /* "TOK_EQTILDE" */ 01666 01667 /* Line 1391 of yacc.c */ 01668 #line 368 "ast_expr2.y" 01669 { free_value((yyvaluep->val)); }; 01670 01671 /* Line 1391 of yacc.c */ 01672 #line 1673 "ast_expr2.c" 01673 break; 01674 case 22: /* "TOK_COLON" */ 01675 01676 /* Line 1391 of yacc.c */ 01677 #line 368 "ast_expr2.y" 01678 { free_value((yyvaluep->val)); }; 01679 01680 /* Line 1391 of yacc.c */ 01681 #line 1682 "ast_expr2.c" 01682 break; 01683 case 23: /* "TOK_LP" */ 01684 01685 /* Line 1391 of yacc.c */ 01686 #line 368 "ast_expr2.y" 01687 { free_value((yyvaluep->val)); }; 01688 01689 /* Line 1391 of yacc.c */ 01690 #line 1691 "ast_expr2.c" 01691 break; 01692 case 24: /* "TOK_RP" */ 01693 01694 /* Line 1391 of yacc.c */ 01695 #line 368 "ast_expr2.y" 01696 { free_value((yyvaluep->val)); }; 01697 01698 /* Line 1391 of yacc.c */ 01699 #line 1700 "ast_expr2.c" 01700 break; 01701 case 25: /* "TOKEN" */ 01702 01703 /* Line 1391 of yacc.c */ 01704 #line 368 "ast_expr2.y" 01705 { free_value((yyvaluep->val)); }; 01706 01707 /* Line 1391 of yacc.c */ 01708 #line 1709 "ast_expr2.c" 01709 break; 01710 case 29: /* "expr" */ 01711 01712 /* Line 1391 of yacc.c */ 01713 #line 368 "ast_expr2.y" 01714 { free_value((yyvaluep->val)); }; 01715 01716 /* Line 1391 of yacc.c */ 01717 #line 1718 "ast_expr2.c" 01718 break; 01719 01720 default: 01721 break; 01722 } 01723 }
int yyparse | ( | void * | YYPARSE_PARAM | ) |
Definition at line 1753 of file ast_expr2.c.
References alloc_expr_node(), YYSTYPE::arglist, AST_EXPR_number, calloc, DESTROY, destroy_arglist(), free, make_str(), op_and(), op_colon(), op_compl(), op_cond(), op_div(), op_eq(), op_eqtilde(), op_func(), op_ge(), op_gt(), op_le(), op_lt(), op_minus(), op_ne(), op_negate(), op_or(), op_plus(), op_rem(), op_tildetilde(), op_times(), expr_node::right, strdup, type, expr_node::val, YYSTYPE::val, YY_, YY_REDUCE_PRINT, YY_STACK_PRINT, YY_SYMBOL_PRINT, YYABORT, YYACCEPT, yychar, yydestruct(), YYDPRINTF, YYEMPTY, YYEOF, yyerror, YYFINAL, YYID, YYINITDEPTH, YYLAST, YYLEX, yylloc, YYLLOC_DEFAULT, yyalloc::yyls_alloc, yylval, YYMAXDEPTH, yynerrs, YYNTOKENS, yypact_value_is_default, YYPOPSTACK, YYSIZE_T, yyalloc::yyss_alloc, YYSTACK_ALLOC, YYSTACK_BYTES, YYSTACK_FREE, YYSTACK_RELOCATE, YYSYNTAX_ERROR, yytable_value_is_error, YYTERROR, YYTRANSLATE, and yyalloc::yyvs_alloc.
01767 { 01768 /* The lookahead symbol. */ 01769 int yychar; 01770 01771 /* The semantic value of the lookahead symbol. */ 01772 YYSTYPE yylval; 01773 01774 /* Location data for the lookahead symbol. */ 01775 YYLTYPE yylloc; 01776 01777 /* Number of syntax errors so far. */ 01778 int yynerrs; 01779 01780 int yystate; 01781 /* Number of tokens to shift before error messages enabled. */ 01782 int yyerrstatus; 01783 01784 /* The stacks and their tools: 01785 `yyss': related to states. 01786 `yyvs': related to semantic values. 01787 `yyls': related to locations. 01788 01789 Refer to the stacks thru separate pointers, to allow yyoverflow 01790 to reallocate them elsewhere. */ 01791 01792 /* The state stack. */ 01793 yytype_int16 yyssa[YYINITDEPTH]; 01794 yytype_int16 *yyss; 01795 yytype_int16 *yyssp; 01796 01797 /* The semantic value stack. */ 01798 YYSTYPE yyvsa[YYINITDEPTH]; 01799 YYSTYPE *yyvs; 01800 YYSTYPE *yyvsp; 01801 01802 /* The location stack. */ 01803 YYLTYPE yylsa[YYINITDEPTH]; 01804 YYLTYPE *yyls; 01805 YYLTYPE *yylsp; 01806 01807 /* The locations where the error started and ended. */ 01808 YYLTYPE yyerror_range[3]; 01809 01810 YYSIZE_T yystacksize; 01811 01812 int yyn; 01813 int yyresult; 01814 /* Lookahead token as an internal (translated) token number. */ 01815 int yytoken; 01816 /* The variables used to return semantic value and location from the 01817 action routines. */ 01818 YYSTYPE yyval; 01819 YYLTYPE yyloc; 01820 01821 #if YYERROR_VERBOSE 01822 /* Buffer for error messages, and its allocated size. */ 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 /* The number of symbols on the RHS of the reduced rule. 01831 Keep to zero when no symbol should be popped. */ 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; /* Cause a token to be read. */ 01846 01847 /* Initialize stack pointers. 01848 Waste one element of value and location stack 01849 so that they stay on the same level as the state stack. 01850 The wasted elements are never initialized. */ 01851 yyssp = yyss; 01852 yyvsp = yyvs; 01853 yylsp = yyls; 01854 01855 #if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL 01856 /* Initialize the default location before parsing starts. */ 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 | yynewstate -- Push a new state, which is found in yystate. | 01865 `------------------------------------------------------------*/ 01866 yynewstate: 01867 /* In all cases, when you get here, the value and location stacks 01868 have just been pushed. So pushing a state here evens the stacks. */ 01869 yyssp++; 01870 01871 yysetstate: 01872 *yyssp = yystate; 01873 01874 if (yyss + yystacksize - 1 <= yyssp) 01875 { 01876 /* Get the current used size of the three stacks, in elements. */ 01877 YYSIZE_T yysize = yyssp - yyss + 1; 01878 01879 #ifdef yyoverflow 01880 { 01881 /* Give user a chance to reallocate the stack. Use copies of 01882 these so that the &'s don't force the real ones into 01883 memory. */ 01884 YYSTYPE *yyvs1 = yyvs; 01885 yytype_int16 *yyss1 = yyss; 01886 YYLTYPE *yyls1 = yyls; 01887 01888 /* Each stack pointer address is followed by the size of the 01889 data in use in that stack, in bytes. This used to be a 01890 conditional around just the two extra args, but that might 01891 be undefined if yyoverflow is a macro. */ 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 /* no yyoverflow */ 01903 # ifndef YYSTACK_RELOCATE 01904 goto yyexhaustedlab; 01905 # else 01906 /* Extend the stack our own way. */ 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 /* no yyoverflow */ 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 | yybackup. | 01949 `-----------*/ 01950 yybackup: 01951 01952 /* Do appropriate processing given the current state. Read a 01953 lookahead token if we need one and don't already have one. */ 01954 01955 /* First try to decide what to do without reference to lookahead token. */ 01956 yyn = yypact[yystate]; 01957 if (yypact_value_is_default (yyn)) 01958 goto yydefault; 01959 01960 /* Not known => get a lookahead token if don't already have one. */ 01961 01962 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ 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 /* If the proper action on seeing token YYTOKEN is to reduce or to 01981 detect an error, take that action. */ 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 /* Count tokens shifted since error; after three, turn off error 01995 status. */ 01996 if (yyerrstatus) 01997 yyerrstatus--; 01998 01999 /* Shift the lookahead token. */ 02000 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 02001 02002 /* Discard the shifted token. */ 02003 yychar = YYEMPTY; 02004 02005 yystate = yyn; 02006 *++yyvsp = yylval; 02007 *++yylsp = yylloc; 02008 goto yynewstate; 02009 02010 02011 /*-----------------------------------------------------------. 02012 | yydefault -- do the default action for the current state. | 02013 `-----------------------------------------------------------*/ 02014 yydefault: 02015 yyn = yydefact[yystate]; 02016 if (yyn == 0) 02017 goto yyerrlab; 02018 goto yyreduce; 02019 02020 02021 /*-----------------------------. 02022 | yyreduce -- Do a reduction. | 02023 `-----------------------------*/ 02024 yyreduce: 02025 /* yyn is the number of a rule to reduce with. */ 02026 yylen = yyr2[yyn]; 02027 02028 /* If YYLEN is nonzero, implement the default value of the action: 02029 `$$ = $1'. 02030 02031 Otherwise, the following line sets YYVAL to garbage. 02032 This behavior is undocumented and Bison 02033 users should not rely upon it. Assigning to YYVAL 02034 unconditionally makes the parser a bit smaller, and it avoids a 02035 GCC warning that YYVAL may be used uninitialized. */ 02036 yyval = yyvsp[1-yylen]; 02037 02038 /* Default location. */ 02039 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); 02040 YY_REDUCE_PRINT (yyn); 02041 switch (yyn) 02042 { 02043 case 2: 02044 02045 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 02060 #line 382 "ast_expr2.y" 02061 {/* nothing */ ((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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 02089 #line 396 "ast_expr2.y" 02090 {struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL); 02091 struct expr_node *t; /* NULL args should OK */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 02113 #line 411 "ast_expr2.y" 02114 {(yyval.val) = (yyvsp[(1) - (1)].val);} 02115 break; 02116 02117 case 9: 02118 02119 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 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 /* Line 1806 of yacc.c */ 02321 #line 2322 "ast_expr2.c" 02322 default: break; 02323 } 02324 /* User semantic actions sometimes alter yychar, and that requires 02325 that yytoken be updated with the new translation. We take the 02326 approach of translating immediately before every use of yytoken. 02327 One alternative is translating here after every semantic action, 02328 but that translation would be missed if the semantic action invokes 02329 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or 02330 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an 02331 incorrect destructor might then be invoked immediately. In the 02332 case of YYERROR or YYBACKUP, subsequent parser actions might lead 02333 to an incorrect destructor call or verbose syntax error message 02334 before the lookahead is translated. */ 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 /* Now `shift' the result of the reduction. Determine what state 02345 that goes to, based on the state we popped back to and the rule 02346 number reduced by. */ 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 | yyerrlab -- here on detecting error | 02361 `------------------------------------*/ 02362 yyerrlab: 02363 /* Make sure we have latest lookahead translation. See comments at 02364 user semantic actions for why this is necessary. */ 02365 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); 02366 02367 /* If not already recovering from an error, report this error. */ 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 /* If just tried and failed to reuse lookahead token after an 02412 error, discard it. */ 02413 02414 if (yychar <= YYEOF) 02415 { 02416 /* Return failure if at end of input. */ 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 /* Else will try to reuse lookahead token after shifting the error 02429 token. */ 02430 goto yyerrlab1; 02431 02432 02433 /*---------------------------------------------------. 02434 | yyerrorlab -- error raised explicitly by YYERROR. | 02435 `---------------------------------------------------*/ 02436 yyerrorlab: 02437 02438 /* Pacify compilers like GCC when the user code never invokes 02439 YYERROR and the label yyerrorlab therefore never appears in user 02440 code. */ 02441 if (/*CONSTCOND*/ 0) 02442 goto yyerrorlab; 02443 02444 yyerror_range[1] = yylsp[1-yylen]; 02445 /* Do not reclaim the symbols of the rule which action triggered 02446 this YYERROR. */ 02447 YYPOPSTACK (yylen); 02448 yylen = 0; 02449 YY_STACK_PRINT (yyss, yyssp); 02450 yystate = *yyssp; 02451 goto yyerrlab1; 02452 02453 02454 /*-------------------------------------------------------------. 02455 | yyerrlab1 -- common code for both syntax error and YYERROR. | 02456 `-------------------------------------------------------------*/ 02457 yyerrlab1: 02458 yyerrstatus = 3; /* Each real token shifted decrements this. */ 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 /* Pop the current state because it cannot handle the error token. */ 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 /* Using YYLLOC is tempting, but would change the location of 02490 the lookahead. YYLOC is available though. */ 02491 YYLLOC_DEFAULT (yyloc, yyerror_range, 2); 02492 *++yylsp = yyloc; 02493 02494 /* Shift the error token. */ 02495 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); 02496 02497 yystate = yyn; 02498 goto yynewstate; 02499 02500 02501 /*-------------------------------------. 02502 | yyacceptlab -- YYACCEPT comes here. | 02503 `-------------------------------------*/ 02504 yyacceptlab: 02505 yyresult = 0; 02506 goto yyreturn; 02507 02508 /*-----------------------------------. 02509 | yyabortlab -- YYABORT comes here. | 02510 `-----------------------------------*/ 02511 yyabortlab: 02512 yyresult = 1; 02513 goto yyreturn; 02514 02515 #if !defined(yyoverflow) || YYERROR_VERBOSE 02516 /*-------------------------------------------------. 02517 | yyexhaustedlab -- memory exhaustion comes here. | 02518 `-------------------------------------------------*/ 02519 yyexhaustedlab: 02520 yyerror (YY_("memory exhausted")); 02521 yyresult = 2; 02522 /* Fall through. */ 02523 #endif 02524 02525 yyreturn: 02526 if (yychar != YYEMPTY) 02527 { 02528 /* Make sure we have latest lookahead translation. See comments at 02529 user semantic actions for why this is necessary. */ 02530 yytoken = YYTRANSLATE (yychar); 02531 yydestruct ("Cleanup: discarding lookahead", 02532 yytoken, &yylval, &yylloc); 02533 } 02534 /* Do not reclaim the symbols of the rule which action triggered 02535 this YYABORT or YYACCEPT. */ 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 /* Make sure YYID is used. */ 02553 return YYID (yyresult); 02554 }
int yyparse | ( | ) |
static char* yystpcpy | ( | char * | yydest, | |
const char * | yysrc | |||
) | [static] |
Definition at line 1284 of file ast_expr2.c.
Referenced by yytnamerr().
01288 { 01289 char *yyd = yydest; 01290 const char *yys = yysrc; 01291 01292 while ((*yyd++ = *yys++) != '\0') 01293 continue; 01294 01295 return yyd - 1; 01296 }
static YYSIZE_T yystrlen | ( | char * | yystr | ) | const [static] |
Definition at line 1260 of file ast_expr2.c.
References YYSIZE_T.
Referenced by yysyntax_error(), and yytnamerr().
01263 { 01264 YYSIZE_T yylen; 01265 for (yylen = 0; yystr[yylen]; yylen++) 01266 continue; 01267 return yylen; 01268 }
static int yysyntax_error | ( | YYSIZE_T * | yymsg_alloc, | |
char ** | yymsg, | |||
yytype_int16 * | yyssp, | |||
int | yytoken | |||
) | [static] |
Definition at line 1357 of file ast_expr2.c.
References YY_, YYCASE_, YYEMPTY, YYLAST, YYNTOKENS, yypact_value_is_default, YYSIZE_T, YYSTACK_ALLOC_MAXIMUM, yystrlen(), yytable_value_is_error, YYTERROR, and yytnamerr().
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 /* Internationalized format string. */ 01365 const char *yyformat = 0; 01366 /* Arguments of yyformat. */ 01367 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 01368 /* Number of reported tokens (one for the "unexpected", one per 01369 "expected"). */ 01370 int yycount = 0; 01371 01372 /* There are many possibilities here to consider: 01373 - Assume YYFAIL is not used. It's too flawed to consider. See 01374 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html> 01375 for details. YYERROR is fine as it does not invoke this 01376 function. 01377 - If this state is a consistent state with a default action, then 01378 the only way this function was invoked is if the default action 01379 is an error action. In that case, don't check for expected 01380 tokens because there are none. 01381 - The only way there can be no lookahead present (in yychar) is if 01382 this state is a consistent state with a default action. Thus, 01383 detecting the absence of a lookahead is sufficient to determine 01384 that there is no unexpected or expected token to report. In that 01385 case, just report a simple "syntax error". 01386 - Don't assume there isn't a lookahead just because this state is a 01387 consistent state with a default action. There might have been a 01388 previous inconsistent state, consistent state with a non-default 01389 action, or user semantic action that manipulated yychar. 01390 - Of course, the expected token list depends on states to have 01391 correct lookahead information, and it depends on the parser not 01392 to perform extra reductions after fetching a lookahead from the 01393 scanner and before detecting a syntax error. Thus, state merging 01394 (from LALR or IELR) and default reductions corrupt the expected 01395 token list. However, the list is correct for canonical LR with 01396 one exception: it will still contain any token that will not be 01397 accepted due to an error action in a later state. 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 /* Start YYX at -YYN if negative to avoid negative indexes in 01406 YYCHECK. In other words, skip the first -YYN actions for 01407 this state because they are default actions. */ 01408 int yyxbegin = yyn < 0 ? -yyn : 0; 01409 /* Stay within bounds of both yycheck and yytname. */ 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 /* Avoid sprintf, as that infringes on the user's name space. 01464 Don't have undefined behavior even if the translation 01465 produced a string with the wrong number of "%s"s. */ 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 }
static YYSIZE_T yytnamerr | ( | char * | yyres, | |
const char * | yystr | |||
) | [static] |
Definition at line 1309 of file ast_expr2.c.
References YYSIZE_T, yystpcpy(), and yystrlen().
Referenced by yysyntax_error().
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 /* Fall through. */ 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 }
char extra_error_message[4095] |
Definition at line 2464 of file ast_expr2f.c.
Definition at line 2465 of file ast_expr2f.c.
const yytype_int8 yycheck[] [static] |
Definition at line 930 of file ast_expr2.c.
const yytype_uint8 yydefact[] [static] |
Definition at line 865 of file ast_expr2.c.
const yytype_int8 yydefgoto[] [static] |
const yytype_int16 yypact[] [static] |
Definition at line 884 of file ast_expr2.c.
const yytype_int8 yypgoto[] [static] |
const yytype_uint8 yyr1[] [static] |
Definition at line 847 of file ast_expr2.c.
const yytype_uint8 yyr2[] [static] |
Definition at line 855 of file ast_expr2.c.
const yytype_uint8 yystos[] [static] |
Definition at line 952 of file ast_expr2.c.
const yytype_uint8 yytable[] [static] |
Definition at line 904 of file ast_expr2.c.
const char* const yytname[] [static] |
Definition at line 825 of file ast_expr2.c.
const yytype_uint8 yytranslate[] [static] |
Definition at line 754 of file ast_expr2.c.