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