#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_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 | TOK_AND 262 |
#define | TOK_COLON 277 |
#define | TOK_COLONCOLON 259 |
#define | TOK_COMMA 258 |
#define | TOK_COMPL 274 |
#define | TOK_COND 260 |
#define | TOK_DIV 272 |
#define | TOK_EQ 268 |
#define | TOK_EQTILDE 276 |
#define | TOK_GE 265 |
#define | TOK_GT 267 |
#define | TOK_LE 264 |
#define | TOK_LP 278 |
#define | TOK_LT 266 |
#define | TOK_MINUS 269 |
#define | TOK_MOD 271 |
#define | TOK_MULT 273 |
#define | TOK_NE 263 |
#define | TOK_OR 261 |
#define | TOK_PLUS 270 |
#define | TOK_RP 279 |
#define | TOK_TILDETILDE 275 |
#define | TOKEN 280 |
#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.3" |
#define | yychar ast_yychar |
#define | yyclearin (yychar = YYEMPTY) |
#define | YYCOPY(To, From, Count) |
#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 | yyparse ast_yyparse |
#define | YYPARSE_PARAM parseio |
#define | YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) |
#define | YYPURE 1 |
#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) |
#define | yystype YYSTYPE |
#define | YYSTYPE_IS_DECLARED 1 |
#define | YYSTYPE_IS_TRIVIAL 1 |
#define | YYTABLE_NINF -1 |
#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 YYSIZE_T | yysyntax_error (char *yyresult, int yystate, int yychar) |
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 2576 of file ast_expr2.c.
#define ast_yyerror | ( | x | ) | ast_yyerror(x,&yyloc,parseio) |
Definition at line 2576 of file ast_expr2.c.
#define FP___PRINTF "%.16g" |
Definition at line 164 of file ast_expr2.c.
Referenced by ast_expr(), compose_func_args(), and to_string().
#define FP___TYPE double |
Definition at line 165 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 287 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_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 362 of file ast_expr2.c.
#define QUAD_MIN (-0x7fffffffffffffffLL-1) |
#define TOK_AND 262 |
Definition at line 107 of file ast_expr2.c.
#define TOK_COLON 277 |
Definition at line 122 of file ast_expr2.c.
#define TOK_COLONCOLON 259 |
Definition at line 104 of file ast_expr2.c.
#define TOK_COMMA 258 |
Definition at line 103 of file ast_expr2.c.
#define TOK_COMPL 274 |
Definition at line 119 of file ast_expr2.c.
#define TOK_COND 260 |
Definition at line 105 of file ast_expr2.c.
#define TOK_DIV 272 |
Definition at line 117 of file ast_expr2.c.
#define TOK_EQ 268 |
Definition at line 113 of file ast_expr2.c.
#define TOK_EQTILDE 276 |
Definition at line 121 of file ast_expr2.c.
#define TOK_GE 265 |
Definition at line 110 of file ast_expr2.c.
#define TOK_GT 267 |
Definition at line 112 of file ast_expr2.c.
#define TOK_LE 264 |
Definition at line 109 of file ast_expr2.c.
#define TOK_LP 278 |
Definition at line 123 of file ast_expr2.c.
#define TOK_LT 266 |
Definition at line 111 of file ast_expr2.c.
#define TOK_MINUS 269 |
Definition at line 114 of file ast_expr2.c.
#define TOK_MOD 271 |
Definition at line 116 of file ast_expr2.c.
#define TOK_MULT 273 |
Definition at line 118 of file ast_expr2.c.
#define TOK_NE 263 |
Definition at line 108 of file ast_expr2.c.
#define TOK_OR 261 |
Definition at line 106 of file ast_expr2.c.
#define TOK_PLUS 270 |
Definition at line 115 of file ast_expr2.c.
#define TOK_RP 279 |
Definition at line 124 of file ast_expr2.c.
#define TOK_TILDETILDE 275 |
Definition at line 120 of file ast_expr2.c.
#define TOKEN 280 |
Definition at line 125 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 1034 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 980 of file ast_expr2.c.
#define YYBISON 1 |
Definition at line 47 of file ast_expr2.c.
#define YYBISON_VERSION "2.3" |
Definition at line 50 of file ast_expr2.c.
#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 708 of file ast_expr2.c.
#define YYDEBUG 0 |
Definition at line 471 of file ast_expr2.c.
#define yydebug ast_yydebug |
Definition at line 67 of file ast_expr2.c.
#define YYDPRINTF | ( | Args | ) |
#define YYEMPTY (-2) |
#define YYENABLE_NLS 0 |
Definition at line 364 of file ast_expr2.c.
#define YYEOF 0 |
#define YYERRCODE 256 |
Definition at line 999 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 477 of file ast_expr2.c.
#define YYERROR_VERBOSE 1 |
Definition at line 477 of file ast_expr2.c.
#define YYFAIL goto yyerrlab |
Definition at line 976 of file ast_expr2.c.
#define YYFINAL 11 |
#define YYFREE free |
Definition at line 669 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 63 of file ast_expr2.c.
#define YYLEX_PARAM ((struct parse_io *)parseio)->scanner |
Definition at line 366 of file ast_expr2.c.
#define yylloc ast_yylloc |
Definition at line 69 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 59 of file ast_expr2.c.
Definition at line 454 of file ast_expr2.c.
#define YYLTYPE_IS_TRIVIAL 1 |
Definition at line 455 of file ast_expr2.c.
#define yylval ast_yylval |
Definition at line 65 of file ast_expr2.c.
Referenced by ast_yyget_lval(), ast_yyset_lval(), and yyparse().
#define YYMALLOC malloc |
Definition at line 662 of file ast_expr2.c.
#define YYMAXDEPTH 10000 |
#define YYMAXUTOK 280 |
Definition at line 753 of file ast_expr2.c.
#define yynerrs ast_yynerrs |
#define YYNNTS 4 |
Definition at line 745 of file ast_expr2.c.
#define YYNRULES 28 |
Definition at line 747 of file ast_expr2.c.
#define YYNSTATES 54 |
Definition at line 749 of file ast_expr2.c.
#define YYNTOKENS 26 |
#define YYPACT_NINF -18 |
#define yyparse ast_yyparse |
Definition at line 62 of file ast_expr2.c.
#define YYPARSE_PARAM parseio |
Definition at line 365 of file ast_expr2.c.
#define YYPOPSTACK | ( | N | ) | (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) |
Referenced by yyparse().
#define YYPURE 1 |
Definition at line 56 of file ast_expr2.c.
#define YYRECOVERING | ( | ) | (!!yyerrstatus) |
Definition at line 978 of file ast_expr2.c.
#define YYRHSLOC | ( | Rhs, | |||
K | ) | ((Rhs)[K]) |
Definition at line 1006 of file ast_expr2.c.
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
#define YYSIZE_T unsigned int |
Definition at line 566 of file ast_expr2.c.
Referenced by yyparse(), yystrlen(), yysyntax_error(), and yytnamerr().
#define YYSKELETON_NAME "yacc.c" |
Definition at line 53 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 697 of file ast_expr2.c.
Referenced by yyparse().
#define YYSTACK_FREE YYFREE |
#define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
Definition at line 693 of file ast_expr2.c.
#define YYSTACK_RELOCATE | ( | Stack | ) |
#define yystype YYSTYPE |
Definition at line 497 of file ast_expr2.c.
#define YYSTYPE_IS_DECLARED 1 |
Definition at line 498 of file ast_expr2.c.
#define YYSTYPE_IS_TRIVIAL 1 |
Definition at line 499 of file ast_expr2.c.
#define YYTABLE_NINF -1 |
#define YYTERROR 1 |
#define YYTOKEN_TABLE 0 |
Definition at line 484 of file ast_expr2.c.
#define YYTRANSLATE | ( | YYX | ) | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
#define YYUNDEFTOK 2 |
Definition at line 752 of file ast_expr2.c.
#define YYUSE | ( | e | ) | ((void) (e)) |
typedef void* yyscan_t |
Definition at line 400 of file ast_expr2.c.
typedef short int yytype_int16 |
Definition at line 553 of file ast_expr2.c.
typedef short int yytype_int8 |
Definition at line 541 of file ast_expr2.c.
typedef unsigned short int yytype_uint16 |
Definition at line 547 of file ast_expr2.c.
typedef unsigned char yytype_uint8 |
Definition at line 532 of file ast_expr2.c.
enum node_type |
Definition at line 387 of file ast_expr2.c.
00387 { 00388 AST_EXPR_NODE_COMMA, AST_EXPR_NODE_STRING, AST_EXPR_NODE_VAL 00389 } ;
enum valtype |
Definition at line 371 of file ast_expr2.c.
00371 { 00372 AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string 00373 } ;
enum yytokentype |
Definition at line 76 of file ast_expr2.c.
00076 { 00077 TOK_COMMA = 258, 00078 TOK_COLONCOLON = 259, 00079 TOK_COND = 260, 00080 TOK_OR = 261, 00081 TOK_AND = 262, 00082 TOK_NE = 263, 00083 TOK_LE = 264, 00084 TOK_GE = 265, 00085 TOK_LT = 266, 00086 TOK_GT = 267, 00087 TOK_EQ = 268, 00088 TOK_MINUS = 269, 00089 TOK_PLUS = 270, 00090 TOK_MOD = 271, 00091 TOK_DIV = 272, 00092 TOK_MULT = 273, 00093 TOK_COMPL = 274, 00094 TOK_TILDETILDE = 275, 00095 TOK_EQTILDE = 276, 00096 TOK_COLON = 277, 00097 TOK_LP = 278, 00098 TOK_RP = 279, 00099 TOKEN = 280 00100 };
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 2356 of file ast_expr2.c.
References ast_log(), calloc, LOG_ERROR, and expr_node::type.
Referenced by yyparse().
02357 { 02358 struct expr_node *x = calloc(1,sizeof(struct expr_node)); 02359 if (!x) { 02360 ast_log(LOG_ERROR, "Allocation for expr_node FAILED!!\n"); 02361 return 0; 02362 } 02363 x->type = nt; 02364 return x; 02365 }
static int chk_div | ( | FP___TYPE | a, | |
FP___TYPE | b | |||
) | [static] |
Definition at line 3321 of file ast_expr2.c.
References QUAD_MIN.
Referenced by op_div().
03322 { 03323 /* div by zero has been taken care of before */ 03324 /* only QUAD_MIN / -1 causes overflow */ 03325 if (a == QUAD_MIN && b == -1) 03326 return 1; 03327 /* everything else is OK */ 03328 return 0; 03329 }
static int chk_minus | ( | FP___TYPE | a, | |
FP___TYPE | b, | |||
FP___TYPE | r | |||
) | [static] |
Definition at line 3169 of file ast_expr2.c.
References chk_plus(), and QUAD_MIN.
Referenced by op_minus(), and op_negate().
03170 { 03171 /* special case subtraction of QUAD_MIN */ 03172 if (b == QUAD_MIN) { 03173 if (a >= 0) 03174 return 1; 03175 else 03176 return 0; 03177 } 03178 /* this is allowed for b != QUAD_MIN */ 03179 return chk_plus (a, -b, r); 03180 }
static int chk_plus | ( | FP___TYPE | a, | |
FP___TYPE | b, | |||
FP___TYPE | r | |||
) | [static] |
Definition at line 3126 of file ast_expr2.c.
Referenced by chk_minus(), and op_plus().
03127 { 03128 /* sum of two positive numbers must be positive */ 03129 if (a > 0 && b > 0 && r <= 0) 03130 return 1; 03131 /* sum of two negative numbers must be negative */ 03132 if (a < 0 && b < 0 && r >= 0) 03133 return 1; 03134 /* all other cases are OK */ 03135 return 0; 03136 }
static int chk_times | ( | FP___TYPE | a, | |
FP___TYPE | b, | |||
FP___TYPE | r | |||
) | [static] |
Definition at line 3287 of file ast_expr2.c.
Referenced by op_times().
03288 { 03289 /* special case: first operand is 0, no overflow possible */ 03290 if (a == 0) 03291 return 0; 03292 /* cerify that result of division matches second operand */ 03293 if (r / a != b) 03294 return 1; 03295 return 0; 03296 }
static char* compose_func_args | ( | struct expr_node * | arglist | ) | [static] |
Definition at line 2600 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().
02601 { 02602 struct expr_node *t = arglist; 02603 char *argbuf; 02604 int total_len = 0; 02605 02606 while (t) { 02607 if (t != arglist) 02608 total_len += 1; /* for the sep */ 02609 if (t->val) { 02610 if (t->val->type == AST_EXPR_number) 02611 total_len += 25; /* worst case */ 02612 else 02613 total_len += strlen(t->val->u.s); 02614 } 02615 02616 t = t->right; 02617 } 02618 total_len++; /* for the null */ 02619 ast_log(LOG_NOTICE,"argbuf allocated %d bytes;\n", total_len); 02620 argbuf = malloc(total_len); 02621 argbuf[0] = 0; 02622 t = arglist; 02623 while (t) { 02624 char numbuf[30]; 02625 02626 if (t != arglist) 02627 strcat(argbuf,","); 02628 02629 if (t->val) { 02630 if (t->val->type == AST_EXPR_number) { 02631 sprintf(numbuf,FP___PRINTF,t->val->u.i); 02632 strcat(argbuf,numbuf); 02633 } else 02634 strcat(argbuf,t->val->u.s); 02635 } 02636 t = t->right; 02637 } 02638 ast_log(LOG_NOTICE,"argbuf uses %d bytes;\n", (int) strlen(argbuf)); 02639 return argbuf; 02640 }
static void destroy_arglist | ( | struct expr_node * | arglist | ) | [static] |
Definition at line 2583 of file ast_expr2.c.
References free, free_value(), expr_node::right, and expr_node::val.
Referenced by yyparse().
02584 { 02585 struct expr_node *arglist_next; 02586 02587 while (arglist) 02588 { 02589 arglist_next = arglist->right; 02590 if (arglist->val) 02591 free_value(arglist->val); 02592 arglist->val = 0; 02593 arglist->right = 0; 02594 free(arglist); 02595 arglist = arglist_next; 02596 } 02597 }
static void free_value | ( | struct val * | vp | ) | [static] |
Definition at line 2415 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().
02416 { 02417 if (vp==NULL) { 02418 return; 02419 } 02420 if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string) 02421 free (vp->u.s); 02422 free(vp); 02423 }
static int is_really_num | ( | char * | str | ) | [static] |
Definition at line 2642 of file ast_expr2.c.
Referenced by op_func().
02643 { 02644 if ( strspn(str,"-0123456789. ") == strlen(str)) 02645 return 1; 02646 else 02647 return 0; 02648 }
static int is_zero_or_null | ( | struct val * | vp | ) | [static] |
Definition at line 2509 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().
02510 { 02511 if (vp->type == AST_EXPR_number) { 02512 return (vp->u.i == 0); 02513 } else { 02514 return (*vp->u.s == 0 || (to_number(vp) && vp->u.i == 0)); 02515 } 02516 /* NOTREACHED */ 02517 }
static int isstring | ( | struct val * | vp | ) | [static] |
static struct val* make_number | ( | FP___TYPE | i | ) | [static] |
Definition at line 2370 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().
02371 { 02372 struct val *vp; 02373 02374 vp = (struct val *) malloc (sizeof (*vp)); 02375 if (vp == NULL) { 02376 ast_log(LOG_WARNING, "malloc() failed\n"); 02377 return(NULL); 02378 } 02379 02380 vp->type = AST_EXPR_number; 02381 vp->u.i = i; 02382 return vp; 02383 }
static struct val* make_str | ( | const char * | s | ) | [static] |
Definition at line 2386 of file ast_expr2.c.
References AST_EXPR_numeric_string, ast_log(), LOG_WARNING, malloc, and strdup.
Referenced by op_colon(), op_eqtilde(), op_func(), op_tildetilde(), and yyparse().
02387 { 02388 struct val *vp; 02389 size_t i; 02390 int isint; /* this started out being a test for an integer, but then ended up being a test for a float */ 02391 02392 vp = (struct val *) malloc (sizeof (*vp)); 02393 if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) { 02394 ast_log(LOG_WARNING,"malloc() failed\n"); 02395 return(NULL); 02396 } 02397 02398 for (i = 0, isint = (isdigit(s[0]) || s[0] == '-' || s[0]=='.'); isint && i < strlen(s); i++) 02399 { 02400 if (!isdigit(s[i]) && s[i] != '.') { 02401 isint = 0; 02402 break; 02403 } 02404 } 02405 if (isint) 02406 vp->type = AST_EXPR_numeric_string; 02407 else 02408 vp->type = AST_EXPR_string; 02409 02410 return vp; 02411 }
Definition at line 2947 of file ast_expr2.c.
References FP___TYPE, free_value(), is_zero_or_null(), and make_number().
Referenced by yyparse().
02948 { 02949 if (is_zero_or_null (a) || is_zero_or_null (b)) { 02950 free_value (a); 02951 free_value (b); 02952 return (make_number ((FP___TYPE)0.0)); 02953 } else { 02954 free_value (b); 02955 return (a); 02956 } 02957 }
Definition at line 3394 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().
03395 { 03396 regex_t rp; 03397 regmatch_t rm[2]; 03398 char errbuf[256]; 03399 int eval; 03400 struct val *v; 03401 03402 /* coerce to both arguments to strings */ 03403 to_string(a); 03404 to_string(b); 03405 /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */ 03406 strip_quotes(a); 03407 strip_quotes(b); 03408 /* compile regular expression */ 03409 if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) { 03410 regerror (eval, &rp, errbuf, sizeof(errbuf)); 03411 ast_log(LOG_WARNING,"regcomp() error : %s",errbuf); 03412 free_value(a); 03413 free_value(b); 03414 return make_str(""); 03415 } 03416 03417 /* compare string against pattern */ 03418 /* remember that patterns are anchored to the beginning of the line */ 03419 if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 && rm[0].rm_so == 0) { 03420 if (rm[1].rm_so >= 0) { 03421 *(a->u.s + rm[1].rm_eo) = '\0'; 03422 v = make_str (a->u.s + rm[1].rm_so); 03423 03424 } else { 03425 v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so)); 03426 } 03427 } else { 03428 if (rp.re_nsub == 0) { 03429 v = make_number ((FP___TYPE)0); 03430 } else { 03431 v = make_str (""); 03432 } 03433 } 03434 03435 /* free arguments and pattern buffer */ 03436 free_value (a); 03437 free_value (b); 03438 regfree (&rp); 03439 03440 return v; 03441 }
Definition at line 3237 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().
03238 { 03239 int v1 = 1; 03240 struct val *r; 03241 03242 if( !a ) 03243 { 03244 v1 = 0; 03245 } 03246 else 03247 { 03248 switch( a->type ) 03249 { 03250 case AST_EXPR_number: 03251 if( a->u.i == 0 ) 03252 v1 = 0; 03253 break; 03254 03255 case AST_EXPR_string: 03256 if( a->u.s == 0 ) 03257 v1 = 0; 03258 else 03259 { 03260 if( a->u.s[0] == 0 ) 03261 v1 = 0; 03262 else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' ) 03263 v1 = 0; 03264 } 03265 break; 03266 03267 case AST_EXPR_numeric_string: 03268 if( a->u.s == 0 ) 03269 v1 = 0; 03270 else 03271 { 03272 if( a->u.s[0] == 0 ) 03273 v1 = 0; 03274 else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' ) 03275 v1 = 0; 03276 } 03277 break; 03278 } 03279 } 03280 03281 r = make_number (!v1); 03282 free_value (a); 03283 return r; 03284 }
Definition at line 3067 of file ast_expr2.c.
References free_value(), val::i, isstring(), val::s, to_number(), and val::u.
Referenced by yyparse().
03068 { 03069 struct val *r; 03070 03071 if( isstring(a) ) 03072 { 03073 if( strlen(a->u.s) && strcmp(a->u.s, "\"\"") != 0 && strcmp(a->u.s,"0") != 0 ) 03074 { 03075 free_value(a); 03076 free_value(c); 03077 r = b; 03078 } 03079 else 03080 { 03081 free_value(a); 03082 free_value(b); 03083 r = c; 03084 } 03085 } 03086 else 03087 { 03088 (void)to_number(a); 03089 if( a->u.i ) 03090 { 03091 free_value(a); 03092 free_value(c); 03093 r = b; 03094 } 03095 else 03096 { 03097 free_value(a); 03098 free_value(b); 03099 r = c; 03100 } 03101 } 03102 return r; 03103 }
Definition at line 3332 of file ast_expr2.c.
References ast_log(), chk_div(), free_value(), LOG_WARNING, make_number(), and to_number().
Referenced by yyparse().
03333 { 03334 struct val *r; 03335 03336 if (!to_number (a)) { 03337 free_value(a); 03338 free_value(b); 03339 if( !extra_error_message_supplied ) 03340 ast_log(LOG_WARNING, "non-numeric argument\n"); 03341 return make_number(0); 03342 } else if (!to_number (b)) { 03343 free_value(a); 03344 free_value(b); 03345 if( !extra_error_message_supplied ) 03346 ast_log(LOG_WARNING, "non-numeric argument\n"); 03347 return make_number(INT_MAX); 03348 } 03349 03350 if (b->u.i == 0) { 03351 ast_log(LOG_WARNING, "division by zero\n"); 03352 free_value(a); 03353 free_value(b); 03354 return make_number(INT_MAX); 03355 } 03356 03357 r = make_number (a->u.i / b->u.i); 03358 if (chk_div (a->u.i, b->u.i)) { 03359 ast_log(LOG_WARNING, "overflow\n"); 03360 } 03361 free_value (a); 03362 free_value (b); 03363 return r; 03364 }
Definition at line 2960 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().
02961 { 02962 struct val *r; 02963 02964 if (isstring (a) || isstring (b)) { 02965 to_string (a); 02966 to_string (b); 02967 r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) == 0)); 02968 } else { 02969 #ifdef DEBUG_FOR_CONVERSIONS 02970 char buffer[2000]; 02971 sprintf(buffer,"Converting '%s' and '%s' ", a->u.s, b->u.s); 02972 #endif 02973 (void)to_number(a); 02974 (void)to_number(b); 02975 #ifdef DEBUG_FOR_CONVERSIONS 02976 ast_log(LOG_WARNING,"%s to '%lld' and '%lld'\n", buffer, a->u.i, b->u.i); 02977 #endif 02978 r = make_number ((FP___TYPE)(a->u.i == b->u.i)); 02979 } 02980 02981 free_value (a); 02982 free_value (b); 02983 return r; 02984 }
Definition at line 3445 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().
03446 { 03447 regex_t rp; 03448 regmatch_t rm[2]; 03449 char errbuf[256]; 03450 int eval; 03451 struct val *v; 03452 03453 /* coerce to both arguments to strings */ 03454 to_string(a); 03455 to_string(b); 03456 /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */ 03457 strip_quotes(a); 03458 strip_quotes(b); 03459 /* compile regular expression */ 03460 if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) { 03461 regerror (eval, &rp, errbuf, sizeof(errbuf)); 03462 ast_log(LOG_WARNING,"regcomp() error : %s",errbuf); 03463 free_value(a); 03464 free_value(b); 03465 return make_str(""); 03466 } 03467 03468 /* compare string against pattern */ 03469 /* remember that patterns are anchored to the beginning of the line */ 03470 if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 ) { 03471 if (rm[1].rm_so >= 0) { 03472 *(a->u.s + rm[1].rm_eo) = '\0'; 03473 v = make_str (a->u.s + rm[1].rm_so); 03474 03475 } else { 03476 v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so)); 03477 } 03478 } else { 03479 if (rp.re_nsub == 0) { 03480 v = make_number ((FP___TYPE)0.0); 03481 } else { 03482 v = make_str (""); 03483 } 03484 } 03485 03486 /* free arguments and pattern buffer */ 03487 free_value (a); 03488 free_value (b); 03489 regfree (&rp); 03490 03491 return v; 03492 }
static struct val * op_func | ( | struct val * | funcname, | |
struct expr_node * | arglist, | |||
struct ast_channel * | chan | |||
) | [static] |
Definition at line 2651 of file ast_expr2.c.
References ast_custom_function_find(), ast_log(), chan, 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_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().
02652 { 02653 if (strspn(funcname->u.s,"ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789") == strlen(funcname->u.s)) 02654 { 02655 struct val *result; 02656 if (0) { 02657 #ifdef FUNC_COS 02658 } else if (strcmp(funcname->u.s,"COS") == 0) { 02659 if (arglist && !arglist->right && arglist->val){ 02660 to_number(arglist->val); 02661 result = make_number(FUNC_COS(arglist->val->u.i)); 02662 return result; 02663 } else { 02664 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02665 return make_number(0.0); 02666 } 02667 #endif 02668 #ifdef FUNC_SIN 02669 } else if (strcmp(funcname->u.s,"SIN") == 0) { 02670 if (arglist && !arglist->right && arglist->val){ 02671 to_number(arglist->val); 02672 result = make_number(FUNC_SIN(arglist->val->u.i)); 02673 return result; 02674 } else { 02675 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02676 return make_number(0.0); 02677 } 02678 #endif 02679 #ifdef FUNC_TAN 02680 } else if (strcmp(funcname->u.s,"TAN") == 0) { 02681 if (arglist && !arglist->right && arglist->val){ 02682 to_number(arglist->val); 02683 result = make_number(FUNC_TAN(arglist->val->u.i)); 02684 return result; 02685 } else { 02686 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02687 return make_number(0.0); 02688 } 02689 #endif 02690 #ifdef FUNC_ACOS 02691 } else if (strcmp(funcname->u.s,"ACOS") == 0) { 02692 if (arglist && !arglist->right && arglist->val){ 02693 to_number(arglist->val); 02694 result = make_number(FUNC_ACOS(arglist->val->u.i)); 02695 return result; 02696 } else { 02697 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02698 return make_number(0.0); 02699 } 02700 #endif 02701 #ifdef FUNC_ASIN 02702 } else if (strcmp(funcname->u.s,"ASIN") == 0) { 02703 if (arglist && !arglist->right && arglist->val){ 02704 to_number(arglist->val); 02705 result = make_number(FUNC_ASIN(arglist->val->u.i)); 02706 return result; 02707 } else { 02708 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02709 return make_number(0.0); 02710 } 02711 #endif 02712 #ifdef FUNC_ATAN 02713 } else if (strcmp(funcname->u.s,"ATAN") == 0) { 02714 if (arglist && !arglist->right && arglist->val){ 02715 to_number(arglist->val); 02716 result = make_number(FUNC_ATAN(arglist->val->u.i)); 02717 return result; 02718 } else { 02719 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02720 return make_number(0.0); 02721 } 02722 #endif 02723 #ifdef FUNC_ATAN2 02724 } else if (strcmp(funcname->u.s,"ATAN2") == 0) { 02725 if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){ 02726 to_number(arglist->val); 02727 to_number(arglist->right->val); 02728 result = make_number(FUNC_ATAN2(arglist->val->u.i, arglist->right->val->u.i)); 02729 return result; 02730 } else { 02731 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02732 return make_number(0.0); 02733 } 02734 #endif 02735 #ifdef FUNC_POW 02736 } else if (strcmp(funcname->u.s,"POW") == 0) { 02737 if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){ 02738 to_number(arglist->val); 02739 to_number(arglist->right->val); 02740 result = make_number(FUNC_POW(arglist->val->u.i, arglist->right->val->u.i)); 02741 return result; 02742 } else { 02743 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02744 return make_number(0.0); 02745 } 02746 #endif 02747 #ifdef FUNC_SQRT 02748 } else if (strcmp(funcname->u.s,"SQRT") == 0) { 02749 if (arglist && !arglist->right && arglist->val){ 02750 to_number(arglist->val); 02751 result = make_number(FUNC_SQRT(arglist->val->u.i)); 02752 return result; 02753 } else { 02754 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02755 return make_number(0.0); 02756 } 02757 #endif 02758 #ifdef FUNC_FLOOR 02759 } else if (strcmp(funcname->u.s,"FLOOR") == 0) { 02760 if (arglist && !arglist->right && arglist->val){ 02761 to_number(arglist->val); 02762 result = make_number(FUNC_FLOOR(arglist->val->u.i)); 02763 return result; 02764 } else { 02765 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02766 return make_number(0.0); 02767 } 02768 #endif 02769 #ifdef FUNC_CEIL 02770 } else if (strcmp(funcname->u.s,"CEIL") == 0) { 02771 if (arglist && !arglist->right && arglist->val){ 02772 to_number(arglist->val); 02773 result = make_number(FUNC_CEIL(arglist->val->u.i)); 02774 return result; 02775 } else { 02776 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02777 return make_number(0.0); 02778 } 02779 #endif 02780 #ifdef FUNC_ROUND 02781 } else if (strcmp(funcname->u.s,"ROUND") == 0) { 02782 if (arglist && !arglist->right && arglist->val){ 02783 to_number(arglist->val); 02784 result = make_number(FUNC_ROUND(arglist->val->u.i)); 02785 return result; 02786 } else { 02787 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02788 return make_number(0.0); 02789 } 02790 #endif /* defined(FUNC_ROUND) */ 02791 #ifdef FUNC_RINT 02792 } else if (strcmp(funcname->u.s,"RINT") == 0) { 02793 if (arglist && !arglist->right && arglist->val){ 02794 to_number(arglist->val); 02795 result = make_number(FUNC_RINT(arglist->val->u.i)); 02796 return result; 02797 } else { 02798 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02799 return make_number(0.0); 02800 } 02801 #endif 02802 #ifdef FUNC_TRUNC 02803 } else if (strcmp(funcname->u.s,"TRUNC") == 0) { 02804 if (arglist && !arglist->right && arglist->val){ 02805 to_number(arglist->val); 02806 result = make_number(FUNC_TRUNC(arglist->val->u.i)); 02807 return result; 02808 } else { 02809 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02810 return make_number(0.0); 02811 } 02812 #endif /* defined(FUNC_TRUNC) */ 02813 #ifdef FUNC_EXP 02814 } else if (strcmp(funcname->u.s,"EXP") == 0) { 02815 if (arglist && !arglist->right && arglist->val){ 02816 to_number(arglist->val); 02817 result = make_number(FUNC_EXP(arglist->val->u.i)); 02818 return result; 02819 } else { 02820 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02821 return make_number(0.0); 02822 } 02823 #endif 02824 #ifdef FUNC_EXP2 02825 } else if (strcmp(funcname->u.s,"EXP2") == 0) { 02826 if (arglist && !arglist->right && arglist->val){ 02827 to_number(arglist->val); 02828 result = make_number(FUNC_EXP2(arglist->val->u.i)); 02829 return result; 02830 } else { 02831 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02832 return make_number(0.0); 02833 } 02834 #endif 02835 #ifdef FUNC_EXP10 02836 } else if (strcmp(funcname->u.s,"EXP10") == 0) { 02837 if (arglist && !arglist->right && arglist->val){ 02838 to_number(arglist->val); 02839 result = make_number(FUNC_EXP10(arglist->val->u.i)); 02840 return result; 02841 } else { 02842 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02843 return make_number(0.0); 02844 } 02845 #endif 02846 #ifdef FUNC_LOG 02847 } else if (strcmp(funcname->u.s,"LOG") == 0) { 02848 if (arglist && !arglist->right && arglist->val){ 02849 to_number(arglist->val); 02850 result = make_number(FUNC_LOG(arglist->val->u.i)); 02851 return result; 02852 } else { 02853 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02854 return make_number(0.0); 02855 } 02856 #endif 02857 #ifdef FUNC_LOG2 02858 } else if (strcmp(funcname->u.s,"LOG2") == 0) { 02859 if (arglist && !arglist->right && arglist->val){ 02860 to_number(arglist->val); 02861 result = make_number(FUNC_LOG2(arglist->val->u.i)); 02862 return result; 02863 } else { 02864 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02865 return make_number(0.0); 02866 } 02867 #endif 02868 #ifdef FUNC_LOG10 02869 } else if (strcmp(funcname->u.s,"LOG10") == 0) { 02870 if (arglist && !arglist->right && arglist->val){ 02871 to_number(arglist->val); 02872 result = make_number(FUNC_LOG10(arglist->val->u.i)); 02873 return result; 02874 } else { 02875 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02876 return make_number(0.0); 02877 } 02878 #endif 02879 #ifdef FUNC_REMAINDER 02880 } else if (strcmp(funcname->u.s,"REMAINDER") == 0) { 02881 if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){ 02882 to_number(arglist->val); 02883 to_number(arglist->right->val); 02884 result = make_number(FUNC_REMAINDER(arglist->val->u.i, arglist->right->val->u.i)); 02885 return result; 02886 } else { 02887 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s); 02888 return make_number(0.0); 02889 } 02890 #endif 02891 } else { 02892 /* is this a custom function we should execute and collect the results of? */ 02893 #if !defined(STANDALONE) && !defined(STANDALONE2) 02894 struct ast_custom_function *f = ast_custom_function_find(funcname->u.s); 02895 if (!chan) 02896 ast_log(LOG_WARNING,"Hey! chan is NULL.\n"); 02897 if (!f) 02898 ast_log(LOG_WARNING,"Hey! could not find func %s.\n", funcname->u.s); 02899 02900 if (f && chan) { 02901 if (f->read) { 02902 char workspace[512]; 02903 char *argbuf = compose_func_args(arglist); 02904 f->read(chan, funcname->u.s, argbuf, workspace, sizeof(workspace)); 02905 free(argbuf); 02906 if (is_really_num(workspace)) 02907 return make_number(FUNC_STRTOD(workspace,(char **)NULL)); 02908 else 02909 return make_str(workspace); 02910 } else { 02911 ast_log(LOG_ERROR,"Error! Function '%s' cannot be read!\n", funcname->u.s); 02912 return (make_number ((FP___TYPE)0.0)); 02913 } 02914 02915 } else { 02916 ast_log(LOG_ERROR,"Error! '%s' doesn't appear to be an available function!", funcname->u.s); 02917 return (make_number ((FP___TYPE)0.0)); 02918 } 02919 #else 02920 ast_log(LOG_ERROR,"Error! '%s' is not available in the standalone version!", funcname->u.s); 02921 return (make_number ((FP___TYPE)0.0)); 02922 #endif 02923 } 02924 } 02925 else 02926 { 02927 ast_log(LOG_ERROR,"Error! '%s' is not possibly a function name!", funcname->u.s); 02928 return (make_number ((FP___TYPE)0.0)); 02929 } 02930 return (make_number ((FP___TYPE)0.0)); 02931 }
Definition at line 3027 of file ast_expr2.c.
References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().
Referenced by yyparse().
03028 { 03029 struct val *r; 03030 03031 if (isstring (a) || isstring (b)) { 03032 to_string (a); 03033 to_string (b); 03034 r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) >= 0)); 03035 } else { 03036 (void)to_number(a); 03037 (void)to_number(b); 03038 r = make_number ((FP___TYPE)(a->u.i >= b->u.i)); 03039 } 03040 03041 free_value (a); 03042 free_value (b); 03043 return r; 03044 }
Definition at line 2987 of file ast_expr2.c.
References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().
Referenced by yyparse().
02988 { 02989 struct val *r; 02990 02991 if (isstring (a) || isstring (b)) { 02992 to_string (a); 02993 to_string (b); 02994 r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) > 0)); 02995 } else { 02996 (void)to_number(a); 02997 (void)to_number(b); 02998 r = make_number ((FP___TYPE)(a->u.i > b->u.i)); 02999 } 03000 03001 free_value (a); 03002 free_value (b); 03003 return r; 03004 }
Definition at line 3047 of file ast_expr2.c.
References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().
Referenced by yyparse().
03048 { 03049 struct val *r; 03050 03051 if (isstring (a) || isstring (b)) { 03052 to_string (a); 03053 to_string (b); 03054 r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) <= 0)); 03055 } else { 03056 (void)to_number(a); 03057 (void)to_number(b); 03058 r = make_number ((FP___TYPE)(a->u.i <= b->u.i)); 03059 } 03060 03061 free_value (a); 03062 free_value (b); 03063 return r; 03064 }
Definition at line 3007 of file ast_expr2.c.
References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().
Referenced by yyparse().
03008 { 03009 struct val *r; 03010 03011 if (isstring (a) || isstring (b)) { 03012 to_string (a); 03013 to_string (b); 03014 r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) < 0)); 03015 } else { 03016 (void)to_number(a); 03017 (void)to_number(b); 03018 r = make_number ((FP___TYPE)(a->u.i < b->u.i)); 03019 } 03020 03021 free_value (a); 03022 free_value (b); 03023 return r; 03024 }
Definition at line 3183 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().
03184 { 03185 struct val *r; 03186 03187 if (!to_number (a)) { 03188 if( !extra_error_message_supplied ) 03189 ast_log(LOG_WARNING, "non-numeric argument\n"); 03190 if (!to_number (b)) { 03191 free_value(a); 03192 free_value(b); 03193 return make_number(0); 03194 } else { 03195 r = make_number(0 - b->u.i); 03196 free_value(a); 03197 free_value(b); 03198 return (r); 03199 } 03200 } else if (!to_number(b)) { 03201 if( !extra_error_message_supplied ) 03202 ast_log(LOG_WARNING, "non-numeric argument\n"); 03203 free_value(b); 03204 return (a); 03205 } 03206 03207 r = make_number (a->u.i - b->u.i); 03208 if (chk_minus (a->u.i, b->u.i, r->u.i)) { 03209 ast_log(LOG_WARNING, "overflow\n"); 03210 } 03211 free_value (a); 03212 free_value (b); 03213 return r; 03214 }
Definition at line 3106 of file ast_expr2.c.
References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().
Referenced by yyparse().
03107 { 03108 struct val *r; 03109 03110 if (isstring (a) || isstring (b)) { 03111 to_string (a); 03112 to_string (b); 03113 r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) != 0)); 03114 } else { 03115 (void)to_number(a); 03116 (void)to_number(b); 03117 r = make_number ((FP___TYPE)(a->u.i != b->u.i)); 03118 } 03119 03120 free_value (a); 03121 free_value (b); 03122 return r; 03123 }
Definition at line 3217 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().
03218 { 03219 struct val *r; 03220 03221 if (!to_number (a) ) { 03222 free_value(a); 03223 if( !extra_error_message_supplied ) 03224 ast_log(LOG_WARNING, "non-numeric argument\n"); 03225 return make_number(0); 03226 } 03227 03228 r = make_number (- a->u.i); 03229 if (chk_minus (0, a->u.i, r->u.i)) { 03230 ast_log(LOG_WARNING, "overflow\n"); 03231 } 03232 free_value (a); 03233 return r; 03234 }
Definition at line 2935 of file ast_expr2.c.
References free_value(), and is_zero_or_null().
Referenced by yyparse().
02936 { 02937 if (is_zero_or_null (a)) { 02938 free_value (a); 02939 return (b); 02940 } else { 02941 free_value (b); 02942 return (a); 02943 } 02944 }
Definition at line 3139 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().
03140 { 03141 struct val *r; 03142 03143 if (!to_number (a)) { 03144 if( !extra_error_message_supplied ) 03145 ast_log(LOG_WARNING,"non-numeric argument\n"); 03146 if (!to_number (b)) { 03147 free_value(a); 03148 free_value(b); 03149 return make_number(0); 03150 } else { 03151 free_value(a); 03152 return (b); 03153 } 03154 } else if (!to_number(b)) { 03155 free_value(b); 03156 return (a); 03157 } 03158 03159 r = make_number (a->u.i + b->u.i); 03160 if (chk_plus (a->u.i, b->u.i, r->u.i)) { 03161 ast_log(LOG_WARNING,"overflow\n"); 03162 } 03163 free_value (a); 03164 free_value (b); 03165 return r; 03166 }
Definition at line 3367 of file ast_expr2.c.
References ast_log(), free_value(), FUNC_FMOD, LOG_WARNING, make_number(), and to_number().
Referenced by yyparse().
03368 { 03369 struct val *r; 03370 03371 if (!to_number (a) || !to_number (b)) { 03372 if( !extra_error_message_supplied ) 03373 ast_log(LOG_WARNING, "non-numeric argument\n"); 03374 free_value(a); 03375 free_value(b); 03376 return make_number(0); 03377 } 03378 03379 if (b->u.i == 0) { 03380 ast_log(LOG_WARNING, "div by zero\n"); 03381 free_value(a); 03382 return(b); 03383 } 03384 03385 r = make_number (FUNC_FMOD(a->u.i, b->u.i)); /* either fmod or fmodl if FP___TYPE is available */ 03386 /* chk_rem necessary ??? */ 03387 free_value (a); 03388 free_value (b); 03389 return r; 03390 }
Definition at line 3495 of file ast_expr2.c.
References free_value(), make_str(), malloc, val::s, strip_quotes(), to_string(), and val::u.
Referenced by yyparse().
03496 { 03497 struct val *v; 03498 char *vs; 03499 03500 /* coerce to both arguments to strings */ 03501 to_string(a); 03502 to_string(b); 03503 /* strip double quotes from both -- */ 03504 strip_quotes(a); 03505 strip_quotes(b); 03506 03507 vs = malloc(strlen(a->u.s)+strlen(b->u.s)+1); 03508 strcpy(vs,a->u.s); 03509 strcat(vs,b->u.s); 03510 03511 v = make_str(vs); 03512 03513 /* free arguments */ 03514 free_value(a); 03515 free_value(b); 03516 03517 return v; 03518 }
Definition at line 3299 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().
03300 { 03301 struct val *r; 03302 03303 if (!to_number (a) || !to_number (b)) { 03304 free_value(a); 03305 free_value(b); 03306 if( !extra_error_message_supplied ) 03307 ast_log(LOG_WARNING, "non-numeric argument\n"); 03308 return(make_number(0)); 03309 } 03310 03311 r = make_number (a->u.i * b->u.i); 03312 if (chk_times (a->u.i, b->u.i, r->u.i)) { 03313 ast_log(LOG_WARNING, "overflow\n"); 03314 } 03315 free_value (a); 03316 free_value (b); 03317 return (r); 03318 }
static void strip_quotes | ( | struct val * | vp | ) | [static] |
Definition at line 2458 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().
02459 { 02460 if (vp->type != AST_EXPR_string && vp->type != AST_EXPR_numeric_string) 02461 return; 02462 02463 if( vp->u.s[0] == '"' && vp->u.s[strlen(vp->u.s)-1] == '"' ) 02464 { 02465 char *f, *t; 02466 f = vp->u.s; 02467 t = vp->u.s; 02468 02469 while( *f ) 02470 { 02471 if( *f && *f != '"' ) 02472 *t++ = *f++; 02473 else 02474 f++; 02475 } 02476 *t = *f; 02477 } 02478 }
static int to_number | ( | struct val * | vp | ) | [static] |
Definition at line 2427 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().
02428 { 02429 FP___TYPE i; 02430 02431 if (vp == NULL) { 02432 ast_log(LOG_WARNING,"vp==NULL in to_number()\n"); 02433 return(0); 02434 } 02435 02436 if (vp->type == AST_EXPR_number) 02437 return 1; 02438 02439 if (vp->type == AST_EXPR_string) 02440 return 0; 02441 02442 /* vp->type == AST_EXPR_numeric_string, make it numeric */ 02443 errno = 0; 02444 i = FUNC_STRTOD(vp->u.s, (char**)0); /* either strtod, or strtold on a good day */ 02445 if (errno != 0) { 02446 ast_log(LOG_WARNING,"Conversion of %s to number under/overflowed!\n", vp->u.s); 02447 free(vp->u.s); 02448 vp->u.s = 0; 02449 return(0); 02450 } 02451 free (vp->u.s); 02452 vp->u.i = i; 02453 vp->type = AST_EXPR_number; 02454 return 1; 02455 }
static void to_string | ( | struct val * | vp | ) | [static] |
Definition at line 2481 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().
02482 { 02483 char *tmp; 02484 02485 if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string) 02486 return; 02487 02488 tmp = malloc ((size_t)25); 02489 if (tmp == NULL) { 02490 ast_log(LOG_WARNING,"malloc() failed\n"); 02491 return; 02492 } 02493 02494 sprintf(tmp, FP___PRINTF, vp->u.i); 02495 vp->type = AST_EXPR_string; 02496 vp->u.s = tmp; 02497 }
static void yydestruct | ( | char * | yymsg, | |
int | yytype, | |||
YYSTYPE * | yyvaluep, | |||
YYLTYPE * | yylocationp | |||
) | const [static] |
Definition at line 1459 of file ast_expr2.c.
References free_value(), YYSTYPE::val, YY_SYMBOL_PRINT, and YYUSE.
Referenced by yyparse().
01465 { 01466 YYUSE (yyvaluep); 01467 YYUSE (yylocationp); 01468 01469 if (!yymsg) 01470 yymsg = "Deleting"; 01471 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 01472 01473 switch (yytype) 01474 { 01475 case 4: /* "TOK_COLONCOLON" */ 01476 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01477 { free_value((yyvaluep->val)); }; 01478 #line 1479 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01479 break; 01480 case 5: /* "TOK_COND" */ 01481 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01482 { free_value((yyvaluep->val)); }; 01483 #line 1484 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01484 break; 01485 case 6: /* "TOK_OR" */ 01486 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01487 { free_value((yyvaluep->val)); }; 01488 #line 1489 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01489 break; 01490 case 7: /* "TOK_AND" */ 01491 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01492 { free_value((yyvaluep->val)); }; 01493 #line 1494 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01494 break; 01495 case 8: /* "TOK_NE" */ 01496 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01497 { free_value((yyvaluep->val)); }; 01498 #line 1499 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01499 break; 01500 case 9: /* "TOK_LE" */ 01501 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01502 { free_value((yyvaluep->val)); }; 01503 #line 1504 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01504 break; 01505 case 10: /* "TOK_GE" */ 01506 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01507 { free_value((yyvaluep->val)); }; 01508 #line 1509 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01509 break; 01510 case 11: /* "TOK_LT" */ 01511 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01512 { free_value((yyvaluep->val)); }; 01513 #line 1514 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01514 break; 01515 case 12: /* "TOK_GT" */ 01516 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01517 { free_value((yyvaluep->val)); }; 01518 #line 1519 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01519 break; 01520 case 13: /* "TOK_EQ" */ 01521 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01522 { free_value((yyvaluep->val)); }; 01523 #line 1524 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01524 break; 01525 case 14: /* "TOK_MINUS" */ 01526 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01527 { free_value((yyvaluep->val)); }; 01528 #line 1529 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01529 break; 01530 case 15: /* "TOK_PLUS" */ 01531 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01532 { free_value((yyvaluep->val)); }; 01533 #line 1534 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01534 break; 01535 case 16: /* "TOK_MOD" */ 01536 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01537 { free_value((yyvaluep->val)); }; 01538 #line 1539 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01539 break; 01540 case 17: /* "TOK_DIV" */ 01541 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01542 { free_value((yyvaluep->val)); }; 01543 #line 1544 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01544 break; 01545 case 18: /* "TOK_MULT" */ 01546 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01547 { free_value((yyvaluep->val)); }; 01548 #line 1549 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01549 break; 01550 case 19: /* "TOK_COMPL" */ 01551 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01552 { free_value((yyvaluep->val)); }; 01553 #line 1554 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01554 break; 01555 case 20: /* "TOK_TILDETILDE" */ 01556 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01557 { free_value((yyvaluep->val)); }; 01558 #line 1559 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01559 break; 01560 case 21: /* "TOK_EQTILDE" */ 01561 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01562 { free_value((yyvaluep->val)); }; 01563 #line 1564 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01564 break; 01565 case 22: /* "TOK_COLON" */ 01566 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01567 { free_value((yyvaluep->val)); }; 01568 #line 1569 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01569 break; 01570 case 23: /* "TOK_LP" */ 01571 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01572 { free_value((yyvaluep->val)); }; 01573 #line 1574 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01574 break; 01575 case 24: /* "TOK_RP" */ 01576 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01577 { free_value((yyvaluep->val)); }; 01578 #line 1579 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01579 break; 01580 case 25: /* "TOKEN" */ 01581 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01582 { free_value((yyvaluep->val)); }; 01583 #line 1584 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01584 break; 01585 case 29: /* "expr" */ 01586 #line 368 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01587 { free_value((yyvaluep->val)); }; 01588 #line 1589 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 01589 break; 01590 01591 default: 01592 break; 01593 } 01594 }
int yyparse | ( | void * | YYPARSE_PARAM | ) |
Definition at line 1629 of file ast_expr2.c.
References alloc_expr_node(), YYSTYPE::arglist, AST_EXPR_number, calloc, chan, 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, yylval, YYMAXDEPTH, yynerrs, YYNTOKENS, YYPACT_NINF, YYPOPSTACK, YYSIZE_T, YYSTACK_ALLOC, YYSTACK_ALLOC_MAXIMUM, YYSTACK_BYTES, YYSTACK_FREE, YYSTACK_RELOCATE, yysyntax_error(), YYTABLE_NINF, YYTERROR, YYTRANSLATE, and yyalloc::yyvs.
01643 { 01644 /* The look-ahead symbol. */ 01645 int yychar; 01646 01647 /* The semantic value of the look-ahead symbol. */ 01648 YYSTYPE yylval; 01649 01650 /* Number of syntax errors so far. */ 01651 int yynerrs; 01652 /* Location data for the look-ahead symbol. */ 01653 YYLTYPE yylloc; 01654 01655 int yystate; 01656 int yyn; 01657 int yyresult; 01658 /* Number of tokens to shift before error messages enabled. */ 01659 int yyerrstatus; 01660 /* Look-ahead token as an internal (translated) token number. */ 01661 int yytoken = 0; 01662 #if YYERROR_VERBOSE 01663 /* Buffer for error messages, and its allocated size. */ 01664 char yymsgbuf[128]; 01665 char *yymsg = yymsgbuf; 01666 YYSIZE_T yymsg_alloc = sizeof yymsgbuf; 01667 #endif 01668 01669 /* Three stacks and their tools: 01670 `yyss': related to states, 01671 `yyvs': related to semantic values, 01672 `yyls': related to locations. 01673 01674 Refer to the stacks thru separate pointers, to allow yyoverflow 01675 to reallocate them elsewhere. */ 01676 01677 /* The state stack. */ 01678 yytype_int16 yyssa[YYINITDEPTH]; 01679 yytype_int16 *yyss = yyssa; 01680 yytype_int16 *yyssp; 01681 01682 /* The semantic value stack. */ 01683 YYSTYPE yyvsa[YYINITDEPTH]; 01684 YYSTYPE *yyvs = yyvsa; 01685 YYSTYPE *yyvsp; 01686 01687 /* The location stack. */ 01688 YYLTYPE yylsa[YYINITDEPTH]; 01689 YYLTYPE *yyls = yylsa; 01690 YYLTYPE *yylsp; 01691 /* The locations where the error started and ended. */ 01692 YYLTYPE yyerror_range[2]; 01693 01694 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) 01695 01696 YYSIZE_T yystacksize = YYINITDEPTH; 01697 01698 /* The variables used to return semantic value and location from the 01699 action routines. */ 01700 YYSTYPE yyval; 01701 YYLTYPE yyloc; 01702 01703 /* The number of symbols on the RHS of the reduced rule. 01704 Keep to zero when no symbol should be popped. */ 01705 int yylen = 0; 01706 01707 YYDPRINTF ((stderr, "Starting parse\n")); 01708 01709 yystate = 0; 01710 yyerrstatus = 0; 01711 yynerrs = 0; 01712 yychar = YYEMPTY; /* Cause a token to be read. */ 01713 01714 /* Initialize stack pointers. 01715 Waste one element of value and location stack 01716 so that they stay on the same level as the state stack. 01717 The wasted elements are never initialized. */ 01718 01719 yyssp = yyss; 01720 yyvsp = yyvs; 01721 yylsp = yyls; 01722 #if YYLTYPE_IS_TRIVIAL 01723 /* Initialize the default location before parsing starts. */ 01724 yylloc.first_line = yylloc.last_line = 1; 01725 yylloc.first_column = yylloc.last_column = 0; 01726 #endif 01727 01728 goto yysetstate; 01729 01730 /*------------------------------------------------------------. 01731 | yynewstate -- Push a new state, which is found in yystate. | 01732 `------------------------------------------------------------*/ 01733 yynewstate: 01734 /* In all cases, when you get here, the value and location stacks 01735 have just been pushed. So pushing a state here evens the stacks. */ 01736 yyssp++; 01737 01738 yysetstate: 01739 *yyssp = yystate; 01740 01741 if (yyss + yystacksize - 1 <= yyssp) 01742 { 01743 /* Get the current used size of the three stacks, in elements. */ 01744 YYSIZE_T yysize = yyssp - yyss + 1; 01745 01746 #ifdef yyoverflow 01747 { 01748 /* Give user a chance to reallocate the stack. Use copies of 01749 these so that the &'s don't force the real ones into 01750 memory. */ 01751 YYSTYPE *yyvs1 = yyvs; 01752 yytype_int16 *yyss1 = yyss; 01753 YYLTYPE *yyls1 = yyls; 01754 01755 /* Each stack pointer address is followed by the size of the 01756 data in use in that stack, in bytes. This used to be a 01757 conditional around just the two extra args, but that might 01758 be undefined if yyoverflow is a macro. */ 01759 yyoverflow (YY_("memory exhausted"), 01760 &yyss1, yysize * sizeof (*yyssp), 01761 &yyvs1, yysize * sizeof (*yyvsp), 01762 &yyls1, yysize * sizeof (*yylsp), 01763 &yystacksize); 01764 yyls = yyls1; 01765 yyss = yyss1; 01766 yyvs = yyvs1; 01767 } 01768 #else /* no yyoverflow */ 01769 # ifndef YYSTACK_RELOCATE 01770 goto yyexhaustedlab; 01771 # else 01772 /* Extend the stack our own way. */ 01773 if (YYMAXDEPTH <= yystacksize) 01774 goto yyexhaustedlab; 01775 yystacksize *= 2; 01776 if (YYMAXDEPTH < yystacksize) 01777 yystacksize = YYMAXDEPTH; 01778 01779 { 01780 yytype_int16 *yyss1 = yyss; 01781 union yyalloc *yyptr = 01782 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 01783 if (! yyptr) 01784 goto yyexhaustedlab; 01785 YYSTACK_RELOCATE (yyss); 01786 YYSTACK_RELOCATE (yyvs); 01787 YYSTACK_RELOCATE (yyls); 01788 # undef YYSTACK_RELOCATE 01789 if (yyss1 != yyssa) 01790 YYSTACK_FREE (yyss1); 01791 } 01792 # endif 01793 #endif /* no yyoverflow */ 01794 01795 yyssp = yyss + yysize - 1; 01796 yyvsp = yyvs + yysize - 1; 01797 yylsp = yyls + yysize - 1; 01798 01799 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 01800 (unsigned long int) yystacksize)); 01801 01802 if (yyss + yystacksize - 1 <= yyssp) 01803 YYABORT; 01804 } 01805 01806 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 01807 01808 goto yybackup; 01809 01810 /*-----------. 01811 | yybackup. | 01812 `-----------*/ 01813 yybackup: 01814 01815 /* Do appropriate processing given the current state. Read a 01816 look-ahead token if we need one and don't already have one. */ 01817 01818 /* First try to decide what to do without reference to look-ahead token. */ 01819 yyn = yypact[yystate]; 01820 if (yyn == YYPACT_NINF) 01821 goto yydefault; 01822 01823 /* Not known => get a look-ahead token if don't already have one. */ 01824 01825 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ 01826 if (yychar == YYEMPTY) 01827 { 01828 YYDPRINTF ((stderr, "Reading a token: ")); 01829 yychar = YYLEX; 01830 } 01831 01832 if (yychar <= YYEOF) 01833 { 01834 yychar = yytoken = YYEOF; 01835 YYDPRINTF ((stderr, "Now at end of input.\n")); 01836 } 01837 else 01838 { 01839 yytoken = YYTRANSLATE (yychar); 01840 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 01841 } 01842 01843 /* If the proper action on seeing token YYTOKEN is to reduce or to 01844 detect an error, take that action. */ 01845 yyn += yytoken; 01846 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 01847 goto yydefault; 01848 yyn = yytable[yyn]; 01849 if (yyn <= 0) 01850 { 01851 if (yyn == 0 || yyn == YYTABLE_NINF) 01852 goto yyerrlab; 01853 yyn = -yyn; 01854 goto yyreduce; 01855 } 01856 01857 if (yyn == YYFINAL) 01858 YYACCEPT; 01859 01860 /* Count tokens shifted since error; after three, turn off error 01861 status. */ 01862 if (yyerrstatus) 01863 yyerrstatus--; 01864 01865 /* Shift the look-ahead token. */ 01866 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 01867 01868 /* Discard the shifted token unless it is eof. */ 01869 if (yychar != YYEOF) 01870 yychar = YYEMPTY; 01871 01872 yystate = yyn; 01873 *++yyvsp = yylval; 01874 *++yylsp = yylloc; 01875 goto yynewstate; 01876 01877 01878 /*-----------------------------------------------------------. 01879 | yydefault -- do the default action for the current state. | 01880 `-----------------------------------------------------------*/ 01881 yydefault: 01882 yyn = yydefact[yystate]; 01883 if (yyn == 0) 01884 goto yyerrlab; 01885 goto yyreduce; 01886 01887 01888 /*-----------------------------. 01889 | yyreduce -- Do a reduction. | 01890 `-----------------------------*/ 01891 yyreduce: 01892 /* yyn is the number of a rule to reduce with. */ 01893 yylen = yyr2[yyn]; 01894 01895 /* If YYLEN is nonzero, implement the default value of the action: 01896 `$$ = $1'. 01897 01898 Otherwise, the following line sets YYVAL to garbage. 01899 This behavior is undocumented and Bison 01900 users should not rely upon it. Assigning to YYVAL 01901 unconditionally makes the parser a bit smaller, and it avoids a 01902 GCC warning that YYVAL may be used uninitialized. */ 01903 yyval = yyvsp[1-yylen]; 01904 01905 /* Default location. */ 01906 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); 01907 YY_REDUCE_PRINT (yyn); 01908 switch (yyn) 01909 { 01910 case 2: 01911 #line 374 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01912 { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1); 01913 ((struct parse_io *)parseio)->val->type = (yyvsp[(1) - (1)].val)->type; 01914 if( (yyvsp[(1) - (1)].val)->type == AST_EXPR_number ) 01915 ((struct parse_io *)parseio)->val->u.i = (yyvsp[(1) - (1)].val)->u.i; 01916 else 01917 ((struct parse_io *)parseio)->val->u.s = (yyvsp[(1) - (1)].val)->u.s; 01918 free((yyvsp[(1) - (1)].val)); 01919 ;} 01920 break; 01921 01922 case 3: 01923 #line 382 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01924 {/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1); 01925 ((struct parse_io *)parseio)->val->type = AST_EXPR_string; 01926 ((struct parse_io *)parseio)->val->u.s = strdup(""); 01927 ;} 01928 break; 01929 01930 case 4: 01931 #line 389 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01932 { (yyval.arglist) = alloc_expr_node(AST_EXPR_NODE_VAL); (yyval.arglist)->val = (yyvsp[(1) - (1)].val);;} 01933 break; 01934 01935 case 5: 01936 #line 390 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01937 {struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL); 01938 struct expr_node *t; 01939 DESTROY((yyvsp[(2) - (3)].val)); 01940 for (t=(yyvsp[(1) - (3)].arglist);t->right;t=t->right) 01941 ; 01942 (yyval.arglist) = (yyvsp[(1) - (3)].arglist); t->right = x; x->val = (yyvsp[(3) - (3)].val);;} 01943 break; 01944 01945 case 6: 01946 #line 396 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01947 {struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL); 01948 struct expr_node *t; /* NULL args should OK */ 01949 DESTROY((yyvsp[(2) - (2)].val)); 01950 for (t=(yyvsp[(1) - (2)].arglist);t->right;t=t->right) 01951 ; 01952 (yyval.arglist) = (yyvsp[(1) - (2)].arglist); t->right = x; x->val = make_str("");;} 01953 break; 01954 01955 case 7: 01956 #line 405 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01957 { (yyval.val) = op_func((yyvsp[(1) - (4)].val),(yyvsp[(3) - (4)].arglist), ((struct parse_io *)parseio)->chan); 01958 DESTROY((yyvsp[(2) - (4)].val)); 01959 DESTROY((yyvsp[(4) - (4)].val)); 01960 DESTROY((yyvsp[(1) - (4)].val)); 01961 destroy_arglist((yyvsp[(3) - (4)].arglist)); 01962 ;} 01963 break; 01964 01965 case 8: 01966 #line 411 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01967 {(yyval.val) = (yyvsp[(1) - (1)].val);;} 01968 break; 01969 01970 case 9: 01971 #line 412 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01972 { (yyval.val) = (yyvsp[(2) - (3)].val); 01973 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01974 (yyloc).first_line=0; (yyloc).last_line=0; 01975 DESTROY((yyvsp[(1) - (3)].val)); DESTROY((yyvsp[(3) - (3)].val)); ;} 01976 break; 01977 01978 case 10: 01979 #line 416 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01980 { (yyval.val) = op_or ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01981 DESTROY((yyvsp[(2) - (3)].val)); 01982 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01983 (yyloc).first_line=0; (yyloc).last_line=0;;} 01984 break; 01985 01986 case 11: 01987 #line 420 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01988 { (yyval.val) = op_and ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01989 DESTROY((yyvsp[(2) - (3)].val)); 01990 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01991 (yyloc).first_line=0; (yyloc).last_line=0;;} 01992 break; 01993 01994 case 12: 01995 #line 424 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 01996 { (yyval.val) = op_eq ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01997 DESTROY((yyvsp[(2) - (3)].val)); 01998 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01999 (yyloc).first_line=0; (yyloc).last_line=0;;} 02000 break; 02001 02002 case 13: 02003 #line 428 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02004 { (yyval.val) = op_gt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02005 DESTROY((yyvsp[(2) - (3)].val)); 02006 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02007 (yyloc).first_line=0; (yyloc).last_line=0;;} 02008 break; 02009 02010 case 14: 02011 #line 432 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02012 { (yyval.val) = op_lt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02013 DESTROY((yyvsp[(2) - (3)].val)); 02014 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02015 (yyloc).first_line=0; (yyloc).last_line=0;;} 02016 break; 02017 02018 case 15: 02019 #line 436 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02020 { (yyval.val) = op_ge ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02021 DESTROY((yyvsp[(2) - (3)].val)); 02022 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02023 (yyloc).first_line=0; (yyloc).last_line=0;;} 02024 break; 02025 02026 case 16: 02027 #line 440 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02028 { (yyval.val) = op_le ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02029 DESTROY((yyvsp[(2) - (3)].val)); 02030 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02031 (yyloc).first_line=0; (yyloc).last_line=0;;} 02032 break; 02033 02034 case 17: 02035 #line 444 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02036 { (yyval.val) = op_ne ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02037 DESTROY((yyvsp[(2) - (3)].val)); 02038 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02039 (yyloc).first_line=0; (yyloc).last_line=0;;} 02040 break; 02041 02042 case 18: 02043 #line 448 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02044 { (yyval.val) = op_plus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02045 DESTROY((yyvsp[(2) - (3)].val)); 02046 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02047 (yyloc).first_line=0; (yyloc).last_line=0;;} 02048 break; 02049 02050 case 19: 02051 #line 452 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02052 { (yyval.val) = op_minus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02053 DESTROY((yyvsp[(2) - (3)].val)); 02054 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02055 (yyloc).first_line=0; (yyloc).last_line=0;;} 02056 break; 02057 02058 case 20: 02059 #line 456 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02060 { (yyval.val) = op_negate ((yyvsp[(2) - (2)].val)); 02061 DESTROY((yyvsp[(1) - (2)].val)); 02062 (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column; 02063 (yyloc).first_line=0; (yyloc).last_line=0;;} 02064 break; 02065 02066 case 21: 02067 #line 460 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02068 { (yyval.val) = op_compl ((yyvsp[(2) - (2)].val)); 02069 DESTROY((yyvsp[(1) - (2)].val)); 02070 (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column; 02071 (yyloc).first_line=0; (yyloc).last_line=0;;} 02072 break; 02073 02074 case 22: 02075 #line 464 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02076 { (yyval.val) = op_times ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02077 DESTROY((yyvsp[(2) - (3)].val)); 02078 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02079 (yyloc).first_line=0; (yyloc).last_line=0;;} 02080 break; 02081 02082 case 23: 02083 #line 468 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02084 { (yyval.val) = op_div ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02085 DESTROY((yyvsp[(2) - (3)].val)); 02086 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02087 (yyloc).first_line=0; (yyloc).last_line=0;;} 02088 break; 02089 02090 case 24: 02091 #line 472 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02092 { (yyval.val) = op_rem ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02093 DESTROY((yyvsp[(2) - (3)].val)); 02094 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02095 (yyloc).first_line=0; (yyloc).last_line=0;;} 02096 break; 02097 02098 case 25: 02099 #line 476 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02100 { (yyval.val) = op_colon ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02101 DESTROY((yyvsp[(2) - (3)].val)); 02102 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02103 (yyloc).first_line=0; (yyloc).last_line=0;;} 02104 break; 02105 02106 case 26: 02107 #line 480 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02108 { (yyval.val) = op_eqtilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02109 DESTROY((yyvsp[(2) - (3)].val)); 02110 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02111 (yyloc).first_line=0; (yyloc).last_line=0;;} 02112 break; 02113 02114 case 27: 02115 #line 484 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02116 { (yyval.val) = op_cond ((yyvsp[(1) - (5)].val), (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val)); 02117 DESTROY((yyvsp[(2) - (5)].val)); 02118 DESTROY((yyvsp[(4) - (5)].val)); 02119 (yyloc).first_column = (yylsp[(1) - (5)]).first_column; (yyloc).last_column = (yylsp[(3) - (5)]).last_column; 02120 (yyloc).first_line=0; (yyloc).last_line=0;;} 02121 break; 02122 02123 case 28: 02124 #line 489 "/home/murf/asterisk/1.6.1/main/ast_expr2.y" 02125 { (yyval.val) = op_tildetilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 02126 DESTROY((yyvsp[(2) - (3)].val)); 02127 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 02128 (yyloc).first_line=0; (yyloc).last_line=0;;} 02129 break; 02130 02131 02132 /* Line 1267 of yacc.c. */ 02133 #line 2134 "/home/murf/asterisk/1.6.1/main/ast_expr2.c" 02134 default: break; 02135 } 02136 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 02137 02138 YYPOPSTACK (yylen); 02139 yylen = 0; 02140 YY_STACK_PRINT (yyss, yyssp); 02141 02142 *++yyvsp = yyval; 02143 *++yylsp = yyloc; 02144 02145 /* Now `shift' the result of the reduction. Determine what state 02146 that goes to, based on the state we popped back to and the rule 02147 number reduced by. */ 02148 02149 yyn = yyr1[yyn]; 02150 02151 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 02152 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 02153 yystate = yytable[yystate]; 02154 else 02155 yystate = yydefgoto[yyn - YYNTOKENS]; 02156 02157 goto yynewstate; 02158 02159 02160 /*------------------------------------. 02161 | yyerrlab -- here on detecting error | 02162 `------------------------------------*/ 02163 yyerrlab: 02164 /* If not already recovering from an error, report this error. */ 02165 if (!yyerrstatus) 02166 { 02167 ++yynerrs; 02168 #if ! YYERROR_VERBOSE 02169 yyerror (YY_("syntax error")); 02170 #else 02171 { 02172 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); 02173 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) 02174 { 02175 YYSIZE_T yyalloc = 2 * yysize; 02176 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) 02177 yyalloc = YYSTACK_ALLOC_MAXIMUM; 02178 if (yymsg != yymsgbuf) 02179 YYSTACK_FREE (yymsg); 02180 yymsg = (char *) YYSTACK_ALLOC (yyalloc); 02181 if (yymsg) 02182 yymsg_alloc = yyalloc; 02183 else 02184 { 02185 yymsg = yymsgbuf; 02186 yymsg_alloc = sizeof yymsgbuf; 02187 } 02188 } 02189 02190 if (0 < yysize && yysize <= yymsg_alloc) 02191 { 02192 (void) yysyntax_error (yymsg, yystate, yychar); 02193 yyerror (yymsg); 02194 } 02195 else 02196 { 02197 yyerror (YY_("syntax error")); 02198 if (yysize != 0) 02199 goto yyexhaustedlab; 02200 } 02201 } 02202 #endif 02203 } 02204 02205 yyerror_range[0] = yylloc; 02206 02207 if (yyerrstatus == 3) 02208 { 02209 /* If just tried and failed to reuse look-ahead token after an 02210 error, discard it. */ 02211 02212 if (yychar <= YYEOF) 02213 { 02214 /* Return failure if at end of input. */ 02215 if (yychar == YYEOF) 02216 YYABORT; 02217 } 02218 else 02219 { 02220 yydestruct ("Error: discarding", 02221 yytoken, &yylval, &yylloc); 02222 yychar = YYEMPTY; 02223 } 02224 } 02225 02226 /* Else will try to reuse look-ahead token after shifting the error 02227 token. */ 02228 goto yyerrlab1; 02229 02230 02231 /*---------------------------------------------------. 02232 | yyerrorlab -- error raised explicitly by YYERROR. | 02233 `---------------------------------------------------*/ 02234 yyerrorlab: 02235 02236 /* Pacify compilers like GCC when the user code never invokes 02237 YYERROR and the label yyerrorlab therefore never appears in user 02238 code. */ 02239 if (/*CONSTCOND*/ 0) 02240 goto yyerrorlab; 02241 02242 yyerror_range[0] = yylsp[1-yylen]; 02243 /* Do not reclaim the symbols of the rule which action triggered 02244 this YYERROR. */ 02245 YYPOPSTACK (yylen); 02246 yylen = 0; 02247 YY_STACK_PRINT (yyss, yyssp); 02248 yystate = *yyssp; 02249 goto yyerrlab1; 02250 02251 02252 /*-------------------------------------------------------------. 02253 | yyerrlab1 -- common code for both syntax error and YYERROR. | 02254 `-------------------------------------------------------------*/ 02255 yyerrlab1: 02256 yyerrstatus = 3; /* Each real token shifted decrements this. */ 02257 02258 for (;;) 02259 { 02260 yyn = yypact[yystate]; 02261 if (yyn != YYPACT_NINF) 02262 { 02263 yyn += YYTERROR; 02264 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 02265 { 02266 yyn = yytable[yyn]; 02267 if (0 < yyn) 02268 break; 02269 } 02270 } 02271 02272 /* Pop the current state because it cannot handle the error token. */ 02273 if (yyssp == yyss) 02274 YYABORT; 02275 02276 yyerror_range[0] = *yylsp; 02277 yydestruct ("Error: popping", 02278 yystos[yystate], yyvsp, yylsp); 02279 YYPOPSTACK (1); 02280 yystate = *yyssp; 02281 YY_STACK_PRINT (yyss, yyssp); 02282 } 02283 02284 if (yyn == YYFINAL) 02285 YYACCEPT; 02286 02287 *++yyvsp = yylval; 02288 02289 yyerror_range[1] = yylloc; 02290 /* Using YYLLOC is tempting, but would change the location of 02291 the look-ahead. YYLOC is available though. */ 02292 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); 02293 *++yylsp = yyloc; 02294 02295 /* Shift the error token. */ 02296 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); 02297 02298 yystate = yyn; 02299 goto yynewstate; 02300 02301 02302 /*-------------------------------------. 02303 | yyacceptlab -- YYACCEPT comes here. | 02304 `-------------------------------------*/ 02305 yyacceptlab: 02306 yyresult = 0; 02307 goto yyreturn; 02308 02309 /*-----------------------------------. 02310 | yyabortlab -- YYABORT comes here. | 02311 `-----------------------------------*/ 02312 yyabortlab: 02313 yyresult = 1; 02314 goto yyreturn; 02315 02316 #ifndef yyoverflow 02317 /*-------------------------------------------------. 02318 | yyexhaustedlab -- memory exhaustion comes here. | 02319 `-------------------------------------------------*/ 02320 yyexhaustedlab: 02321 yyerror (YY_("memory exhausted")); 02322 yyresult = 2; 02323 /* Fall through. */ 02324 #endif 02325 02326 yyreturn: 02327 if (yychar != YYEOF && yychar != YYEMPTY) 02328 yydestruct ("Cleanup: discarding lookahead", 02329 yytoken, &yylval, &yylloc); 02330 /* Do not reclaim the symbols of the rule which action triggered 02331 this YYABORT or YYACCEPT. */ 02332 YYPOPSTACK (yylen); 02333 YY_STACK_PRINT (yyss, yyssp); 02334 while (yyssp != yyss) 02335 { 02336 yydestruct ("Cleanup: popping", 02337 yystos[*yyssp], yyvsp, yylsp); 02338 YYPOPSTACK (1); 02339 } 02340 #ifndef yyoverflow 02341 if (yyss != yyssa) 02342 YYSTACK_FREE (yyss); 02343 #endif 02344 #if YYERROR_VERBOSE 02345 if (yymsg != yymsgbuf) 02346 YYSTACK_FREE (yymsg); 02347 #endif 02348 /* Make sure YYID is used. */ 02349 return YYID (yyresult); 02350 }
int yyparse | ( | ) |
static char* yystpcpy | ( | char * | yydest, | |
const char * | yysrc | |||
) | [static] |
Definition at line 1274 of file ast_expr2.c.
Referenced by yysyntax_error(), and yytnamerr().
01278 { 01279 char *yyd = yydest; 01280 const char *yys = yysrc; 01281 01282 while ((*yyd++ = *yys++) != '\0') 01283 continue; 01284 01285 return yyd - 1; 01286 }
static YYSIZE_T yystrlen | ( | char * | yystr | ) | const [static] |
Definition at line 1250 of file ast_expr2.c.
References YYSIZE_T.
Referenced by yysyntax_error(), and yytnamerr().
01253 { 01254 YYSIZE_T yylen; 01255 for (yylen = 0; yystr[yylen]; yylen++) 01256 continue; 01257 return yylen; 01258 }
static YYSIZE_T yysyntax_error | ( | char * | yyresult, | |
int | yystate, | |||
int | yychar | |||
) | [static] |
Definition at line 1346 of file ast_expr2.c.
References YY_, YYLAST, YYNTOKENS, YYPACT_NINF, YYSIZE_MAXIMUM, YYSIZE_T, yystpcpy(), yystrlen(), YYTERROR, yytnamerr(), and YYTRANSLATE.
Referenced by yyparse().
01347 { 01348 int yyn = yypact[yystate]; 01349 01350 if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) 01351 return 0; 01352 else 01353 { 01354 int yytype = YYTRANSLATE (yychar); 01355 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); 01356 YYSIZE_T yysize = yysize0; 01357 YYSIZE_T yysize1; 01358 int yysize_overflow = 0; 01359 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; 01360 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 01361 int yyx; 01362 01363 # if 0 01364 /* This is so xgettext sees the translatable formats that are 01365 constructed on the fly. */ 01366 YY_("syntax error, unexpected %s"); 01367 YY_("syntax error, unexpected %s, expecting %s"); 01368 YY_("syntax error, unexpected %s, expecting %s or %s"); 01369 YY_("syntax error, unexpected %s, expecting %s or %s or %s"); 01370 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); 01371 # endif 01372 char *yyfmt; 01373 char const *yyf; 01374 static char const yyunexpected[] = "syntax error, unexpected %s"; 01375 static char const yyexpecting[] = ", expecting %s"; 01376 static char const yyor[] = " or %s"; 01377 char yyformat[sizeof yyunexpected 01378 + sizeof yyexpecting - 1 01379 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) 01380 * (sizeof yyor - 1))]; 01381 char const *yyprefix = yyexpecting; 01382 01383 /* Start YYX at -YYN if negative to avoid negative indexes in 01384 YYCHECK. */ 01385 int yyxbegin = yyn < 0 ? -yyn : 0; 01386 01387 /* Stay within bounds of both yycheck and yytname. */ 01388 int yychecklim = YYLAST - yyn + 1; 01389 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; 01390 int yycount = 1; 01391 01392 yyarg[0] = yytname[yytype]; 01393 yyfmt = yystpcpy (yyformat, yyunexpected); 01394 01395 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 01396 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 01397 { 01398 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) 01399 { 01400 yycount = 1; 01401 yysize = yysize0; 01402 yyformat[sizeof yyunexpected - 1] = '\0'; 01403 break; 01404 } 01405 yyarg[yycount++] = yytname[yyx]; 01406 yysize1 = yysize + yytnamerr (0, yytname[yyx]); 01407 yysize_overflow |= (yysize1 < yysize); 01408 yysize = yysize1; 01409 yyfmt = yystpcpy (yyfmt, yyprefix); 01410 yyprefix = yyor; 01411 } 01412 01413 yyf = YY_(yyformat); 01414 yysize1 = yysize + yystrlen (yyf); 01415 yysize_overflow |= (yysize1 < yysize); 01416 yysize = yysize1; 01417 01418 if (yysize_overflow) 01419 return YYSIZE_MAXIMUM; 01420 01421 if (yyresult) 01422 { 01423 /* Avoid sprintf, as that infringes on the user's name space. 01424 Don't have undefined behavior even if the translation 01425 produced a string with the wrong number of "%s"s. */ 01426 char *yyp = yyresult; 01427 int yyi = 0; 01428 while ((*yyp = *yyf) != '\0') 01429 { 01430 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) 01431 { 01432 yyp += yytnamerr (yyp, yyarg[yyi++]); 01433 yyf += 2; 01434 } 01435 else 01436 { 01437 yyp++; 01438 yyf++; 01439 } 01440 } 01441 } 01442 return yysize; 01443 } 01444 }
static YYSIZE_T yytnamerr | ( | char * | yyres, | |
const char * | yystr | |||
) | [static] |
Definition at line 1299 of file ast_expr2.c.
References YYSIZE_T, yystpcpy(), and yystrlen().
Referenced by yysyntax_error().
01300 { 01301 if (*yystr == '"') 01302 { 01303 YYSIZE_T yyn = 0; 01304 char const *yyp = yystr; 01305 01306 for (;;) 01307 switch (*++yyp) 01308 { 01309 case '\'': 01310 case ',': 01311 goto do_not_strip_quotes; 01312 01313 case '\\': 01314 if (*++yyp != '\\') 01315 goto do_not_strip_quotes; 01316 /* Fall through. */ 01317 default: 01318 if (yyres) 01319 yyres[yyn] = *yyp; 01320 yyn++; 01321 break; 01322 01323 case '"': 01324 if (yyres) 01325 yyres[yyn] = '\0'; 01326 return yyn; 01327 } 01328 do_not_strip_quotes: ; 01329 } 01330 01331 if (! yyres) 01332 return yystrlen (yystr); 01333 01334 return yystpcpy (yyres, yystr) - yyres; 01335 }
char extra_error_message[4095] |
Definition at line 2435 of file ast_expr2f.c.
Definition at line 2436 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 870 of file ast_expr2.c.
const yytype_int8 yydefgoto[] [static] |
const yytype_int16 yypact[] [static] |
Definition at line 889 of file ast_expr2.c.
const yytype_int8 yypgoto[] [static] |
const yytype_uint8 yyr1[] [static] |
Definition at line 852 of file ast_expr2.c.
const yytype_uint8 yyr2[] [static] |
Definition at line 860 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 910 of file ast_expr2.c.
const char* const yytname[] [static] |
Definition at line 830 of file ast_expr2.c.
const yytype_uint8 yytranslate[] [static] |
Definition at line 759 of file ast_expr2.c.