Mon Jun 27 16:51:02 2011

Asterisk developer's documentation


ast_expr2.c File Reference

#include "asterisk.h"
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <locale.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <regex.h>
#include <limits.h>
#include "asterisk/ast_expr.h"
#include "asterisk/logger.h"
#include "asterisk/pbx.h"

Go to the source code of this file.

Data Structures

struct  expr_node
struct  parse_io
struct  val
union  yyalloc
struct  yyltype
union  YYSTYPE

Defines

#define ast_yyerror(x)   ast_yyerror(x, YYLTYPE *yylloc, struct parse_io *parseio)
#define ast_yyerror(x)   ast_yyerror(x,&yyloc,parseio)
#define DESTROY(x)   {if((x)->type == AST_EXPR_numeric_string || (x)->type == AST_EXPR_string) free((x)->u.s); (x)->u.s = 0; free(x);}
#define FP___PRINTF   "%.16g"
#define FP___TYPE   double
#define FUNC_ACOS   acosl
#define FUNC_ASIN   asinl
#define FUNC_ATAN   atanl
#define FUNC_ATAN2   atan2l
#define FUNC_CEIL   ceill
#define FUNC_COS   cosl
#define FUNC_EXP   expl
#define FUNC_EXP10   exp10l
#define FUNC_EXP2   exp2l
#define FUNC_FLOOR   floorl
#define FUNC_FMOD   fmodl
#define FUNC_LOG   logl
#define FUNC_LOG10   log10l
#define FUNC_LOG2   log2l
#define FUNC_POW   powl
#define FUNC_REMAINDER   remainderl
#define FUNC_RINT   rintl
#define FUNC_ROUND   roundl
#define FUNC_SIN   sinl
#define FUNC_SQRT   sqrtl
#define FUNC_STRTOD   strtold
#define FUNC_TAN   tanl
#define FUNC_TRUNC   truncl
#define QUAD_MAX   (0x7fffffffffffffffLL)
#define QUAD_MIN   (-0x7fffffffffffffffLL-1)
#define YY_(msgid)   msgid
#define YY_LOCATION_PRINT(File, Loc)
#define YY_REDUCE_PRINT(Rule)
#define YY_STACK_PRINT(Bottom, Top)
#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
#define YYABORT   goto yyabortlab
#define YYACCEPT   goto yyacceptlab
#define YYBACKUP(Token, Value)
#define YYBISON   1
#define YYBISON_VERSION   "2.4.1"
#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 YYPULL   1
#define YYPURE   1
#define YYPUSH   0
#define YYRECOVERING()   (!!yyerrstatus)
#define YYRHSLOC(Rhs, K)   ((Rhs)[K])
#define YYSIZE_MAXIMUM   ((YYSIZE_T) -1)
#define YYSIZE_T   unsigned int
#define YYSKELETON_NAME   "yacc.c"
#define YYSTACK_ALLOC   YYMALLOC
#define YYSTACK_ALLOC_MAXIMUM   YYSIZE_MAXIMUM
#define YYSTACK_BYTES(N)
#define YYSTACK_FREE   YYFREE
#define YYSTACK_GAP_MAXIMUM   (sizeof (union yyalloc) - 1)
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
#define yystype   YYSTYPE
#define YYSTYPE_IS_DECLARED   1
#define YYSTYPE_IS_TRIVIAL   1
#define 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_nodealloc_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 valmake_number (FP___TYPE i)
static struct valmake_str (const char *s)
static struct valop_and (struct val *a, struct val *b)
static struct valop_colon (struct val *a, struct val *b)
static struct valop_compl (struct val *a)
static struct valop_cond (struct val *a, struct val *b, struct val *c)
static struct valop_div (struct val *a, struct val *b)
static struct valop_eq (struct val *a, struct val *b)
static struct valop_eqtilde (struct val *a, struct val *b)
static struct valop_func (struct val *funcname, struct expr_node *arglist, struct ast_channel *chan)
static struct valop_ge (struct val *a, struct val *b)
static struct valop_gt (struct val *a, struct val *b)
static struct valop_le (struct val *a, struct val *b)
static struct valop_lt (struct val *a, struct val *b)
static struct valop_minus (struct val *a, struct val *b)
static struct valop_ne (struct val *a, struct val *b)
static struct valop_negate (struct val *a)
static struct valop_or (struct val *a, struct val *b)
static struct valop_plus (struct val *a, struct val *b)
static struct valop_rem (struct val *a, struct val *b)
static struct valop_tildetilde (struct val *a, struct val *b)
static struct valop_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 []


Define Documentation

#define ast_yyerror (  )     ast_yyerror(x, YYLTYPE *yylloc, struct parse_io *parseio)

Definition at line 2724 of file ast_expr2.c.

#define ast_yyerror (  )     ast_yyerror(x,&yyloc,parseio)

Definition at line 2724 of file ast_expr2.c.

#define DESTROY (  )     {if((x)->type == AST_EXPR_numeric_string || (x)->type == AST_EXPR_string) free((x)->u.s); (x)->u.s = 0; free(x);}

Definition at line 414 of file ast_expr2.c.

Referenced by yyparse().

#define FP___PRINTF   "%.16g"

Definition at line 112 of file ast_expr2.c.

Referenced by ast_expr(), ast_str_expr(), compose_func_args(), and to_string().

#define FP___TYPE   double

Definition at line 113 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

Definition at line 135 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_ASIN   asinl

Definition at line 141 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_ATAN   atanl

Definition at line 147 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_ATAN2   atan2l

Definition at line 153 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_CEIL   ceill

Definition at line 213 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_COS   cosl

Definition at line 117 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_EXP   expl

Definition at line 177 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_EXP10   exp10l

Definition at line 243 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_EXP2   exp2l

Note:
Oddly enough, some platforms have some ISO C99 functions, but not others, so we define the missing functions in terms of their mathematical identities.

Definition at line 235 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_FLOOR   floorl

Definition at line 207 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_FMOD   fmodl

Definition at line 195 of file ast_expr2.c.

Referenced by op_rem().

#define FUNC_LOG   logl

Definition at line 183 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_LOG10   log10l

Definition at line 263 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_LOG2   log2l

Definition at line 251 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_POW   powl

Definition at line 159 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_REMAINDER   remainderl

Definition at line 189 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_RINT   rintl

Definition at line 171 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_ROUND   roundl

Definition at line 219 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_SIN   sinl

Definition at line 123 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_SQRT   sqrtl

Definition at line 165 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_STRTOD   strtold

Definition at line 201 of file ast_expr2.c.

Referenced by op_func(), and to_number().

#define FUNC_TAN   tanl

Definition at line 129 of file ast_expr2.c.

Referenced by op_func().

#define FUNC_TRUNC   truncl

Definition at line 225 of file ast_expr2.c.

Referenced by op_func().

#define QUAD_MAX   (0x7fffffffffffffffLL)

Definition at line 310 of file ast_expr2.c.

#define QUAD_MIN   (-0x7fffffffffffffffLL-1)

Definition at line 307 of file ast_expr2.c.

#define YY_ ( msgid   )     msgid

Definition at line 573 of file ast_expr2.c.

Referenced by yyparse(), and yysyntax_error().

#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 1027 of file ast_expr2.c.

#define YY_REDUCE_PRINT ( Rule   ) 

Definition at line 1211 of file ast_expr2.c.

Referenced by yyparse().

#define YY_STACK_PRINT ( Bottom,
Top   ) 

Definition at line 1210 of file ast_expr2.c.

Referenced by yyparse().

#define YY_SYMBOL_PRINT ( Title,
Type,
Value,
Location   ) 

Definition at line 1209 of file ast_expr2.c.

Referenced by yydestruct(), and yyparse().

#define YYABORT   goto yyabortlab

Definition at line 961 of file ast_expr2.c.

Referenced by yyparse().

#define YYACCEPT   goto yyacceptlab

Definition at line 960 of file ast_expr2.c.

Referenced by yyparse().

#define YYBACKUP ( Token,
Value   ) 

Definition at line 973 of file ast_expr2.c.

#define YYBISON   1

Definition at line 46 of file ast_expr2.c.

#define YYBISON_VERSION   "2.4.1"

Definition at line 49 of file ast_expr2.c.

#define yychar   ast_yychar

Definition at line 71 of file ast_expr2.c.

Referenced by yyparse().

#define yyclearin   (yychar = YYEMPTY)

Definition at line 956 of file ast_expr2.c.

#define YYCOPY ( To,
From,
Count   ) 

Definition at line 701 of file ast_expr2.c.

#define YYDEBUG   0

Definition at line 422 of file ast_expr2.c.

#define yydebug   ast_yydebug

Definition at line 72 of file ast_expr2.c.

#define YYDPRINTF ( Args   ) 

Definition at line 1208 of file ast_expr2.c.

Referenced by yyparse().

#define YYEMPTY   (-2)

Definition at line 957 of file ast_expr2.c.

Referenced by yyparse().

#define YYENABLE_NLS   0

Definition at line 312 of file ast_expr2.c.

#define YYEOF   0

Definition at line 958 of file ast_expr2.c.

Referenced by yyparse().

#define YYERRCODE   256

Definition at line 992 of file ast_expr2.c.

#define yyerrok   (yyerrstatus = 0)

Definition at line 955 of file ast_expr2.c.

#define YYERROR   goto yyerrorlab

Definition at line 962 of file ast_expr2.c.

#define yyerror   ast_yyerror

Definition at line 69 of file ast_expr2.c.

Referenced by yyparse().

#define YYERROR_VERBOSE   1

Definition at line 428 of file ast_expr2.c.

#define YYERROR_VERBOSE   1

Definition at line 428 of file ast_expr2.c.

#define YYFAIL   goto yyerrlab

Definition at line 969 of file ast_expr2.c.

#define YYFINAL   11

Definition at line 731 of file ast_expr2.c.

Referenced by yyparse().

#define YYFREE   free

Definition at line 662 of file ast_expr2.c.

#define YYID (  )     (n)

Definition at line 586 of file ast_expr2.c.

Referenced by yyparse().

#define YYINITDEPTH   200

Definition at line 1217 of file ast_expr2.c.

Referenced by yyparse().

#define YYLAST   159

Definition at line 733 of file ast_expr2.c.

Referenced by yyparse(), and yysyntax_error().

#define YYLEX   yylex (&yylval, &yylloc, YYLEX_PARAM)

Definition at line 1040 of file ast_expr2.c.

Referenced by yyparse().

#define yylex   ast_yylex

Definition at line 68 of file ast_expr2.c.

#define YYLEX_PARAM   ((struct parse_io *)parseio)->scanner

Definition at line 314 of file ast_expr2.c.

#define yylloc   ast_yylloc

Definition at line 74 of file ast_expr2.c.

Referenced by ast_yyget_lloc(), ast_yyset_lloc(), and yyparse().

#define YYLLOC_DEFAULT ( Current,
Rhs,
 ) 

Definition at line 1001 of file ast_expr2.c.

Referenced by yyparse().

#define YYLSP_NEEDED   1

Definition at line 64 of file ast_expr2.c.

#define YYLTYPE   yyltype

Definition at line 402 of file ast_expr2.c.

#define YYLTYPE_IS_TRIVIAL   1

Definition at line 403 of file ast_expr2.c.

#define yylval   ast_yylval

Definition at line 70 of file ast_expr2.c.

Referenced by ast_yyget_lval(), ast_yyset_lval(), and yyparse().

#define YYMALLOC   malloc

Definition at line 655 of file ast_expr2.c.

#define YYMAXDEPTH   10000

Definition at line 1228 of file ast_expr2.c.

Referenced by yyparse().

#define YYMAXUTOK   280

Definition at line 746 of file ast_expr2.c.

#define yynerrs   ast_yynerrs

Definition at line 73 of file ast_expr2.c.

Referenced by yyparse().

#define YYNNTS   4

Definition at line 738 of file ast_expr2.c.

#define YYNRULES   28

Definition at line 740 of file ast_expr2.c.

#define YYNSTATES   54

Definition at line 742 of file ast_expr2.c.

#define YYNTOKENS   26

Definition at line 736 of file ast_expr2.c.

Referenced by yyparse(), and yysyntax_error().

#define YYPACT_NINF   -18

Definition at line 881 of file ast_expr2.c.

Referenced by yyparse(), and yysyntax_error().

#define yyparse   ast_yyparse

Definition at line 67 of file ast_expr2.c.

#define YYPARSE_PARAM   parseio

Definition at line 313 of file ast_expr2.c.

#define YYPOPSTACK (  )     (yyvsp -= (N), yyssp -= (N), yylsp -= (N))

Referenced by yyparse().

#define YYPULL   1

Definition at line 61 of file ast_expr2.c.

#define YYPURE   1

Definition at line 55 of file ast_expr2.c.

#define YYPUSH   0

Definition at line 58 of file ast_expr2.c.

 
#define YYRECOVERING (  )     (!!yyerrstatus)

Definition at line 971 of file ast_expr2.c.

#define YYRHSLOC ( Rhs,
 )     ((Rhs)[K])

Definition at line 999 of file ast_expr2.c.

#define YYSIZE_MAXIMUM   ((YYSIZE_T) -1)

Definition at line 563 of file ast_expr2.c.

Referenced by yysyntax_error().

#define YYSIZE_T   unsigned int

Definition at line 559 of file ast_expr2.c.

Referenced by yyparse(), yystrlen(), yysyntax_error(), and yytnamerr().

#define YYSKELETON_NAME   "yacc.c"

Definition at line 52 of file ast_expr2.c.

#define YYSTACK_ALLOC   YYMALLOC

Definition at line 641 of file ast_expr2.c.

Referenced by yyparse().

#define YYSTACK_ALLOC_MAXIMUM   YYSIZE_MAXIMUM

Definition at line 644 of file ast_expr2.c.

Referenced by yyparse().

#define YYSTACK_BYTES (  ) 

Value:

((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
      + 2 * YYSTACK_GAP_MAXIMUM)

Definition at line 690 of file ast_expr2.c.

Referenced by yyparse().

#define YYSTACK_FREE   YYFREE

Definition at line 642 of file ast_expr2.c.

Referenced by yyparse().

#define YYSTACK_GAP_MAXIMUM   (sizeof (union yyalloc) - 1)

Definition at line 686 of file ast_expr2.c.

#define YYSTACK_RELOCATE ( Stack_alloc,
Stack   ) 

Definition at line 717 of file ast_expr2.c.

Referenced by yyparse().

#define yystype   YYSTYPE

Definition at line 489 of file ast_expr2.c.

#define YYSTYPE_IS_DECLARED   1

Definition at line 490 of file ast_expr2.c.

#define YYSTYPE_IS_TRIVIAL   1

Definition at line 488 of file ast_expr2.c.

#define YYTABLE_NINF   -1

Definition at line 902 of file ast_expr2.c.

Referenced by yyparse().

#define YYTERROR   1

Definition at line 991 of file ast_expr2.c.

Referenced by yyparse(), and yysyntax_error().

#define YYTOKEN_TABLE   0

Definition at line 435 of file ast_expr2.c.

#define YYTRANSLATE ( YYX   )     ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)

Definition at line 748 of file ast_expr2.c.

Referenced by yyparse(), and yysyntax_error().

#define YYUNDEFTOK   2

Definition at line 745 of file ast_expr2.c.

#define YYUSE (  )     ((void) (e))

Definition at line 579 of file ast_expr2.c.

Referenced by yydestruct().


Typedef Documentation

typedef void* yyscan_t

Definition at line 348 of file ast_expr2.c.

typedef short int yytype_int16

Definition at line 546 of file ast_expr2.c.

typedef short int yytype_int8

Definition at line 534 of file ast_expr2.c.

typedef unsigned short int yytype_uint16

Definition at line 540 of file ast_expr2.c.

typedef unsigned char yytype_uint8

Definition at line 525 of file ast_expr2.c.


Enumeration Type Documentation

enum node_type

Enumerator:
AST_EXPR_NODE_COMMA 
AST_EXPR_NODE_STRING 
AST_EXPR_NODE_VAL 

Definition at line 335 of file ast_expr2.c.

enum valtype

Enumerator:
AST_EXPR_number 
AST_EXPR_numeric_string 
AST_EXPR_string 

Definition at line 319 of file ast_expr2.c.

enum yytokentype

Enumerator:
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_TILDETILDE 
TOK_EQTILDE 
TOK_COLON 
TOK_LP 
TOK_RP 
TOKEN 

Definition at line 444 of file ast_expr2.c.

00444                     {
00445      TOK_COMMA = 258,
00446      TOK_COLONCOLON = 259,
00447      TOK_COND = 260,
00448      TOK_OR = 261,
00449      TOK_AND = 262,
00450      TOK_NE = 263,
00451      TOK_LE = 264,
00452      TOK_GE = 265,
00453      TOK_LT = 266,
00454      TOK_GT = 267,
00455      TOK_EQ = 268,
00456      TOK_MINUS = 269,
00457      TOK_PLUS = 270,
00458      TOK_MOD = 271,
00459      TOK_DIV = 272,
00460      TOK_MULT = 273,
00461      TOK_COMPL = 274,
00462      TOK_TILDETILDE = 275,
00463      TOK_EQTILDE = 276,
00464      TOK_COLON = 277,
00465      TOK_LP = 278,
00466      TOK_RP = 279,
00467      TOKEN = 280
00468    };


Function Documentation

int ast_yylex __P ( (YYSTYPE *, YYLTYPE *, yyscan_t  ) 

static struct val* op_cond __P ( (struct val *, struct val *, struct val *)   )  [static]

static struct val *op_times __P ( (struct val *, struct val *)   )  [static]

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 2504 of file ast_expr2.c.

References ast_log(), calloc, LOG_ERROR, and expr_node::type.

Referenced by yyparse().

02505 {
02506    struct expr_node *x = calloc(1,sizeof(struct expr_node));
02507    if (!x) {
02508       ast_log(LOG_ERROR, "Allocation for expr_node FAILED!!\n");
02509       return 0;
02510    }
02511    x->type = nt;
02512    return x;
02513 }

int ast_yyerror ( const char *  ,
YYLTYPE ,
struct parse_io  
)

static int chk_div ( FP___TYPE  a,
FP___TYPE  b 
) [static]

Definition at line 3473 of file ast_expr2.c.

References QUAD_MIN.

Referenced by op_div().

03474 {
03475    /* div by zero has been taken care of before */
03476    /* only QUAD_MIN / -1 causes overflow */
03477    if (a == QUAD_MIN && b == -1)
03478       return 1;
03479    /* everything else is OK */
03480    return 0;
03481 }

static int chk_minus ( FP___TYPE  a,
FP___TYPE  b,
FP___TYPE  r 
) [static]

Definition at line 3317 of file ast_expr2.c.

References chk_plus(), and QUAD_MIN.

Referenced by op_minus(), and op_negate().

03318 {
03319    /* special case subtraction of QUAD_MIN */
03320    if (b == QUAD_MIN) {
03321       if (a >= 0)
03322          return 1;
03323       else
03324          return 0;
03325    }
03326    /* this is allowed for b != QUAD_MIN */
03327    return chk_plus (a, -b, r);
03328 }

static int chk_plus ( FP___TYPE  a,
FP___TYPE  b,
FP___TYPE  r 
) [static]

Definition at line 3274 of file ast_expr2.c.

Referenced by chk_minus(), and op_plus().

03275 {
03276    /* sum of two positive numbers must be positive */
03277    if (a > 0 && b > 0 && r <= 0)
03278       return 1;
03279    /* sum of two negative numbers must be negative */
03280    if (a < 0 && b < 0 && r >= 0)
03281       return 1;
03282    /* all other cases are OK */
03283    return 0;
03284 }

static int chk_times ( FP___TYPE  a,
FP___TYPE  b,
FP___TYPE  r 
) [static]

Definition at line 3439 of file ast_expr2.c.

Referenced by op_times().

03440 {
03441    /* special case: first operand is 0, no overflow possible */
03442    if (a == 0)
03443       return 0;
03444    /* cerify that result of division matches second operand */
03445    if (r / a != b)
03446       return 1;
03447    return 0;
03448 }

static char* compose_func_args ( struct expr_node arglist  )  [static]

Definition at line 2748 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().

02749 {
02750    struct expr_node *t = arglist;
02751    char *argbuf;
02752    int total_len = 0;
02753    
02754    while (t) {
02755       if (t != arglist)
02756          total_len += 1; /* for the sep */
02757       if (t->val) {
02758          if (t->val->type == AST_EXPR_number)
02759             total_len += 25; /* worst case */
02760          else
02761             total_len += strlen(t->val->u.s);
02762       }
02763       
02764       t = t->right;
02765    }
02766    total_len++; /* for the null */
02767    ast_log(LOG_NOTICE,"argbuf allocated %d bytes;\n", total_len);
02768    argbuf = malloc(total_len);
02769    argbuf[0] = 0;
02770    t = arglist;
02771    while (t) {
02772       char numbuf[30];
02773       
02774       if (t != arglist)
02775          strcat(argbuf,",");
02776       
02777       if (t->val) {
02778          if (t->val->type == AST_EXPR_number) {
02779             sprintf(numbuf,FP___PRINTF,t->val->u.i);
02780             strcat(argbuf,numbuf);
02781          } else
02782             strcat(argbuf,t->val->u.s);
02783       }
02784       t = t->right;
02785    }
02786    ast_log(LOG_NOTICE,"argbuf uses %d bytes;\n", (int) strlen(argbuf));
02787    return argbuf;
02788 }

static void destroy_arglist ( struct expr_node arglist  )  [static]

Definition at line 2731 of file ast_expr2.c.

References free, free_value(), expr_node::right, and expr_node::val.

Referenced by yyparse().

02732 {
02733    struct expr_node *arglist_next;
02734    
02735    while (arglist)
02736    {
02737       arglist_next = arglist->right;
02738       if (arglist->val)
02739          free_value(arglist->val);
02740       arglist->val = 0;
02741       arglist->right = 0;
02742       free(arglist);
02743       arglist = arglist_next;
02744    }
02745 }

static void free_value ( struct val vp  )  [static]

Definition at line 2563 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().

02564 {  
02565    if (vp==NULL) {
02566       return;
02567    }
02568    if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
02569       free (vp->u.s);   
02570    free(vp);
02571 }

static int is_really_num ( char *  str  )  [static]

Definition at line 2790 of file ast_expr2.c.

Referenced by op_func().

02791 {
02792    if ( strspn(str,"-0123456789.    ") == strlen(str))
02793       return 1;
02794    else
02795       return 0;
02796 }

static int is_zero_or_null ( struct val vp  )  [static]

Definition at line 2657 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().

02658 {
02659    if (vp->type == AST_EXPR_number) {
02660       return (vp->u.i == 0);
02661    } else {
02662       return (*vp->u.s == 0 || (to_number(vp) && vp->u.i == 0));
02663    }
02664    /* NOTREACHED */
02665 }

static int isstring ( struct val vp  )  [static]

Definition at line 2649 of file ast_expr2.c.

References val::type.

Referenced by op_cond(), op_eq(), op_ge(), op_gt(), op_le(), op_lt(), and op_ne().

02650 {
02651    /* only TRUE if this string is not a valid number */
02652    return (vp->type == AST_EXPR_string);
02653 }

static struct val* make_number ( FP___TYPE  i  )  [static]

Definition at line 2518 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().

02519 {
02520    struct val *vp;
02521 
02522    vp = (struct val *) malloc (sizeof (*vp));
02523    if (vp == NULL) {
02524       ast_log(LOG_WARNING, "malloc() failed\n");
02525       return(NULL);
02526    }
02527 
02528    vp->type = AST_EXPR_number;
02529    vp->u.i  = i;
02530    return vp; 
02531 }

static struct val* make_str ( const char *  s  )  [static]

Definition at line 2534 of file ast_expr2.c.

References AST_EXPR_numeric_string, ast_log(), val::i, LOG_WARNING, malloc, and strdup.

Referenced by op_colon(), op_eqtilde(), op_func(), op_tildetilde(), and yyparse().

02535 {
02536    struct val *vp;
02537    size_t i;
02538    int isint; /* this started out being a test for an integer, but then ended up being a test for a float */
02539 
02540    vp = (struct val *) malloc (sizeof (*vp));
02541    if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) {
02542       ast_log(LOG_WARNING,"malloc() failed\n");
02543       return(NULL);
02544    }
02545 
02546    for (i = 0, isint = (isdigit(s[0]) || s[0] == '-' || s[0]=='.'); isint && i < strlen(s); i++)
02547    {
02548       if (!isdigit(s[i]) && s[i] != '.') {
02549          isint = 0;
02550          break;
02551       }
02552    }
02553    if (isint)
02554       vp->type = AST_EXPR_numeric_string;
02555    else  
02556       vp->type = AST_EXPR_string;
02557 
02558    return vp;
02559 }

static struct val* op_and ( struct val a,
struct val b 
) [static]

Definition at line 3095 of file ast_expr2.c.

References FP___TYPE, free_value(), is_zero_or_null(), and make_number().

Referenced by yyparse().

03096 {
03097    if (is_zero_or_null (a) || is_zero_or_null (b)) {
03098       free_value (a);
03099       free_value (b);
03100       return (make_number ((FP___TYPE)0.0));
03101    } else {
03102       free_value (b);
03103       return (a);
03104    }
03105 }

static struct val* op_colon ( struct val a,
struct val b 
) [static]

Definition at line 3546 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().

03547 {
03548    regex_t rp;
03549    regmatch_t rm[2];
03550    char errbuf[256];
03551    int eval;
03552    struct val *v;
03553 
03554    /* coerce to both arguments to strings */
03555    to_string(a);
03556    to_string(b);
03557    /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */
03558    strip_quotes(a);
03559    strip_quotes(b);
03560    /* compile regular expression */
03561    if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) {
03562       regerror (eval, &rp, errbuf, sizeof(errbuf));
03563       ast_log(LOG_WARNING, "regcomp() error : %s\n", errbuf);
03564       free_value(a);
03565       free_value(b);
03566       return make_str("");    
03567    }
03568 
03569    /* compare string against pattern */
03570    /* remember that patterns are anchored to the beginning of the line */
03571    if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 && rm[0].rm_so == 0) {
03572       if (rm[1].rm_so >= 0) {
03573          *(a->u.s + rm[1].rm_eo) = '\0';
03574          v = make_str (a->u.s + rm[1].rm_so);
03575 
03576       } else {
03577          v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so));
03578       }
03579    } else {
03580       if (rp.re_nsub == 0) {
03581          v = make_number ((FP___TYPE)0);
03582       } else {
03583          v = make_str ("");
03584       }
03585    }
03586 
03587    /* free arguments and pattern buffer */
03588    free_value (a);
03589    free_value (b);
03590    regfree (&rp);
03591 
03592    return v;
03593 }

static struct val* op_compl ( struct val a  )  [static]

Definition at line 3385 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().

03386 {
03387    int v1 = 1;
03388    struct val *r;
03389    
03390    if( !a )
03391    {
03392       v1 = 0;
03393    }
03394    else
03395    {
03396       switch( a->type )
03397       {
03398       case AST_EXPR_number:
03399          if( a->u.i == 0 )
03400             v1 = 0;
03401          break;
03402          
03403       case AST_EXPR_string:
03404          if( a->u.s == 0 )
03405             v1 = 0;
03406          else
03407          {
03408             if( a->u.s[0] == 0 )
03409                v1 = 0;
03410             else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' )
03411                v1 = 0;
03412             else
03413                v1 = atoi(a->u.s);
03414          }
03415          break;
03416          
03417       case AST_EXPR_numeric_string:
03418          if( a->u.s == 0 )
03419             v1 = 0;
03420          else
03421          {
03422             if( a->u.s[0] == 0 )
03423                v1 = 0;
03424             else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' )
03425                v1 = 0;
03426             else
03427                v1 = atoi(a->u.s);
03428          }
03429          break;
03430       }
03431    }
03432    
03433    r = make_number (!v1);
03434    free_value (a);
03435    return r;
03436 }

static struct val* op_cond ( struct val a,
struct val b,
struct val c 
) [static]

Definition at line 3215 of file ast_expr2.c.

References free_value(), val::i, isstring(), val::s, to_number(), and val::u.

Referenced by yyparse().

03216 {
03217    struct val *r;
03218 
03219    if( isstring(a) )
03220    {
03221       if( strlen(a->u.s) && strcmp(a->u.s, "\"\"") != 0 && strcmp(a->u.s,"0") != 0 )
03222       {
03223          free_value(a);
03224          free_value(c);
03225          r = b;
03226       }
03227       else
03228       {
03229          free_value(a);
03230          free_value(b);
03231          r = c;
03232       }
03233    }
03234    else
03235    {
03236       (void)to_number(a);
03237       if( a->u.i )
03238       {
03239          free_value(a);
03240          free_value(c);
03241          r = b;
03242       }
03243       else
03244       {
03245          free_value(a);
03246          free_value(b);
03247          r = c;
03248       }
03249    }
03250    return r;
03251 }

static struct val* op_div ( struct val a,
struct val b 
) [static]

Definition at line 3484 of file ast_expr2.c.

References ast_log(), chk_div(), free_value(), LOG_WARNING, make_number(), and to_number().

Referenced by yyparse().

03485 {
03486    struct val *r;
03487 
03488    if (!to_number (a)) {
03489       free_value(a);
03490       free_value(b);
03491       if( !extra_error_message_supplied )
03492          ast_log(LOG_WARNING, "non-numeric argument\n");
03493       return make_number(0);
03494    } else if (!to_number (b)) {
03495       free_value(a);
03496       free_value(b);
03497       if( !extra_error_message_supplied )
03498          ast_log(LOG_WARNING, "non-numeric argument\n");
03499       return make_number(INT_MAX);
03500    }
03501 
03502    if (b->u.i == 0) {
03503       ast_log(LOG_WARNING, "division by zero\n");     
03504       free_value(a);
03505       free_value(b);
03506       return make_number(INT_MAX);
03507    }
03508 
03509    r = make_number (a->u.i / b->u.i);
03510    if (chk_div (a->u.i, b->u.i)) {
03511       ast_log(LOG_WARNING, "overflow\n");
03512    }
03513    free_value (a);
03514    free_value (b);
03515    return r;
03516 }

static struct val* op_eq ( struct val a,
struct val b 
) [static]

Definition at line 3108 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().

03109 {
03110    struct val *r; 
03111 
03112    if (isstring (a) || isstring (b)) {
03113       to_string (a);
03114       to_string (b); 
03115       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) == 0));
03116    } else {
03117 #ifdef DEBUG_FOR_CONVERSIONS
03118       char buffer[2000];
03119       sprintf(buffer,"Converting '%s' and '%s' ", a->u.s, b->u.s);
03120 #endif
03121       (void)to_number(a);
03122       (void)to_number(b);
03123 #ifdef DEBUG_FOR_CONVERSIONS
03124       ast_log(LOG_WARNING,"%s to '%lld' and '%lld'\n", buffer, a->u.i, b->u.i);
03125 #endif
03126       r = make_number ((FP___TYPE)(a->u.i == b->u.i));
03127    }
03128 
03129    free_value (a);
03130    free_value (b);
03131    return r;
03132 }

static struct val* op_eqtilde ( struct val a,
struct val b 
) [static]

Definition at line 3597 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().

03598 {
03599    regex_t rp;
03600    regmatch_t rm[2];
03601    char errbuf[256];
03602    int eval;
03603    struct val *v;
03604 
03605    /* coerce to both arguments to strings */
03606    to_string(a);
03607    to_string(b);
03608    /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */
03609    strip_quotes(a);
03610    strip_quotes(b);
03611    /* compile regular expression */
03612    if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) {
03613       regerror (eval, &rp, errbuf, sizeof(errbuf));
03614       ast_log(LOG_WARNING, "regcomp() error : %s\n", errbuf);
03615       free_value(a);
03616       free_value(b);
03617       return make_str("");    
03618    }
03619 
03620    /* compare string against pattern */
03621    /* remember that patterns are anchored to the beginning of the line */
03622    if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 ) {
03623       if (rm[1].rm_so >= 0) {
03624          *(a->u.s + rm[1].rm_eo) = '\0';
03625          v = make_str (a->u.s + rm[1].rm_so);
03626 
03627       } else {
03628          v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so));
03629       }
03630    } else {
03631       if (rp.re_nsub == 0) {
03632          v = make_number ((FP___TYPE)0.0);
03633       } else {
03634          v = make_str ("");
03635       }
03636    }
03637 
03638    /* free arguments and pattern buffer */
03639    free_value (a);
03640    free_value (b);
03641    regfree (&rp);
03642 
03643    return v;
03644 }

static struct val * op_func ( struct val funcname,
struct expr_node arglist,
struct ast_channel chan 
) [static]

Definition at line 2799 of file ast_expr2.c.

References ast_custom_function_find(), ast_log(), compose_func_args(), f, FP___TYPE, free, FUNC_ACOS, FUNC_ASIN, FUNC_ATAN, FUNC_ATAN2, FUNC_CEIL, FUNC_COS, FUNC_EXP, FUNC_EXP10, FUNC_EXP2, FUNC_FLOOR, FUNC_LOG, FUNC_LOG10, FUNC_LOG2, FUNC_POW, FUNC_REMAINDER, FUNC_RINT, FUNC_ROUND, FUNC_SIN, FUNC_SQRT, FUNC_STRTOD, FUNC_TAN, FUNC_TRUNC, val::i, is_really_num(), LOG_ERROR, LOG_WARNING, make_number(), make_str(), ast_format::read, expr_node::right, val::s, to_number(), val::u, and expr_node::val.

Referenced by yyparse().

02800 {
02801    if (strspn(funcname->u.s,"ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789") == strlen(funcname->u.s))
02802    {
02803       struct val *result;
02804       if (0) {
02805 #ifdef FUNC_COS
02806       } else if (strcmp(funcname->u.s,"COS") == 0) {
02807          if (arglist && !arglist->right && arglist->val){
02808             to_number(arglist->val);
02809             result = make_number(FUNC_COS(arglist->val->u.i));
02810             return result;
02811          } else {
02812             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02813             return make_number(0.0);
02814          }
02815 #endif
02816 #ifdef FUNC_SIN
02817       } else if (strcmp(funcname->u.s,"SIN") == 0) {
02818          if (arglist && !arglist->right && arglist->val){
02819             to_number(arglist->val);
02820             result = make_number(FUNC_SIN(arglist->val->u.i));
02821             return result;
02822          } else {
02823             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02824             return make_number(0.0);
02825          }
02826 #endif
02827 #ifdef FUNC_TAN
02828       } else if (strcmp(funcname->u.s,"TAN") == 0) {
02829          if (arglist && !arglist->right && arglist->val){
02830             to_number(arglist->val);
02831             result = make_number(FUNC_TAN(arglist->val->u.i));
02832             return result;
02833          } else {
02834             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02835             return make_number(0.0);
02836          }
02837 #endif
02838 #ifdef FUNC_ACOS
02839       } else if (strcmp(funcname->u.s,"ACOS") == 0) {
02840          if (arglist && !arglist->right && arglist->val){
02841             to_number(arglist->val);
02842             result = make_number(FUNC_ACOS(arglist->val->u.i));
02843             return result;
02844          } else {
02845             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02846             return make_number(0.0);
02847          }
02848 #endif
02849 #ifdef FUNC_ASIN
02850       } else if (strcmp(funcname->u.s,"ASIN") == 0) {
02851          if (arglist && !arglist->right && arglist->val){
02852             to_number(arglist->val);
02853             result = make_number(FUNC_ASIN(arglist->val->u.i));
02854             return result;
02855          } else {
02856             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02857             return make_number(0.0);
02858          }
02859 #endif
02860 #ifdef FUNC_ATAN
02861       } else if (strcmp(funcname->u.s,"ATAN") == 0) {
02862          if (arglist && !arglist->right && arglist->val){
02863             to_number(arglist->val);
02864             result = make_number(FUNC_ATAN(arglist->val->u.i));
02865             return result;
02866          } else {
02867             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02868             return make_number(0.0);
02869          }
02870 #endif
02871 #ifdef FUNC_ATAN2
02872       } else if (strcmp(funcname->u.s,"ATAN2") == 0) {
02873          if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
02874             to_number(arglist->val);
02875             to_number(arglist->right->val);
02876             result = make_number(FUNC_ATAN2(arglist->val->u.i, arglist->right->val->u.i));
02877             return result;
02878          } else {
02879             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02880             return make_number(0.0);
02881          }
02882 #endif
02883 #ifdef FUNC_POW
02884       } else if (strcmp(funcname->u.s,"POW") == 0) {
02885          if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
02886             to_number(arglist->val);
02887             to_number(arglist->right->val);
02888             result = make_number(FUNC_POW(arglist->val->u.i, arglist->right->val->u.i));
02889             return result;
02890          } else {
02891             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02892             return make_number(0.0);
02893          }
02894 #endif
02895 #ifdef FUNC_SQRT
02896       } else if (strcmp(funcname->u.s,"SQRT") == 0) {
02897          if (arglist && !arglist->right && arglist->val){
02898             to_number(arglist->val);
02899             result = make_number(FUNC_SQRT(arglist->val->u.i));
02900             return result;
02901          } else {
02902             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02903             return make_number(0.0);
02904          }
02905 #endif
02906 #ifdef FUNC_FLOOR
02907       } else if (strcmp(funcname->u.s,"FLOOR") == 0) {
02908          if (arglist && !arglist->right && arglist->val){
02909             to_number(arglist->val);
02910             result = make_number(FUNC_FLOOR(arglist->val->u.i));
02911             return result;
02912          } else {
02913             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02914             return make_number(0.0);
02915          }
02916 #endif
02917 #ifdef FUNC_CEIL
02918       } else if (strcmp(funcname->u.s,"CEIL") == 0) {
02919          if (arglist && !arglist->right && arglist->val){
02920             to_number(arglist->val);
02921             result = make_number(FUNC_CEIL(arglist->val->u.i));
02922             return result;
02923          } else {
02924             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02925             return make_number(0.0);
02926          }
02927 #endif
02928 #ifdef FUNC_ROUND
02929       } else if (strcmp(funcname->u.s,"ROUND") == 0) {
02930          if (arglist && !arglist->right && arglist->val){
02931             to_number(arglist->val);
02932             result = make_number(FUNC_ROUND(arglist->val->u.i));
02933             return result;
02934          } else {
02935             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02936             return make_number(0.0);
02937          }
02938 #endif /* defined(FUNC_ROUND) */
02939 #ifdef FUNC_RINT
02940       } else if (strcmp(funcname->u.s,"RINT") == 0) {
02941          if (arglist && !arglist->right && arglist->val){
02942             to_number(arglist->val);
02943             result = make_number(FUNC_RINT(arglist->val->u.i));
02944             return result;
02945          } else {
02946             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02947             return make_number(0.0);
02948          }
02949 #endif
02950 #ifdef FUNC_TRUNC
02951       } else if (strcmp(funcname->u.s,"TRUNC") == 0) {
02952          if (arglist && !arglist->right && arglist->val){
02953             to_number(arglist->val);
02954             result = make_number(FUNC_TRUNC(arglist->val->u.i));
02955             return result;
02956          } else {
02957             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02958             return make_number(0.0);
02959          }
02960 #endif /* defined(FUNC_TRUNC) */
02961 #ifdef FUNC_EXP
02962       } else if (strcmp(funcname->u.s,"EXP") == 0) {
02963          if (arglist && !arglist->right && arglist->val){
02964             to_number(arglist->val);
02965             result = make_number(FUNC_EXP(arglist->val->u.i));
02966             return result;
02967          } else {
02968             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02969             return make_number(0.0);
02970          }
02971 #endif
02972 #ifdef FUNC_EXP2
02973       } else if (strcmp(funcname->u.s,"EXP2") == 0) {
02974          if (arglist && !arglist->right && arglist->val){
02975             to_number(arglist->val);
02976             result = make_number(FUNC_EXP2(arglist->val->u.i));
02977             return result;
02978          } else {
02979             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02980             return make_number(0.0);
02981          }
02982 #endif
02983 #ifdef FUNC_EXP10
02984       } else if (strcmp(funcname->u.s,"EXP10") == 0) {
02985          if (arglist && !arglist->right && arglist->val){
02986             to_number(arglist->val);
02987             result = make_number(FUNC_EXP10(arglist->val->u.i));
02988             return result;
02989          } else {
02990             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
02991             return make_number(0.0);
02992          }
02993 #endif
02994 #ifdef FUNC_LOG
02995       } else if (strcmp(funcname->u.s,"LOG") == 0) {
02996          if (arglist && !arglist->right && arglist->val){
02997             to_number(arglist->val);
02998             result = make_number(FUNC_LOG(arglist->val->u.i));
02999             return result;
03000          } else {
03001             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
03002             return make_number(0.0);
03003          }
03004 #endif
03005 #ifdef FUNC_LOG2
03006       } else if (strcmp(funcname->u.s,"LOG2") == 0) {
03007          if (arglist && !arglist->right && arglist->val){
03008             to_number(arglist->val);
03009             result = make_number(FUNC_LOG2(arglist->val->u.i));
03010             return result;
03011          } else {
03012             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
03013             return make_number(0.0);
03014          }
03015 #endif
03016 #ifdef FUNC_LOG10
03017       } else if (strcmp(funcname->u.s,"LOG10") == 0) {
03018          if (arglist && !arglist->right && arglist->val){
03019             to_number(arglist->val);
03020             result = make_number(FUNC_LOG10(arglist->val->u.i));
03021             return result;
03022          } else {
03023             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
03024             return make_number(0.0);
03025          }
03026 #endif
03027 #ifdef FUNC_REMAINDER
03028       } else if (strcmp(funcname->u.s,"REMAINDER") == 0) {
03029          if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
03030             to_number(arglist->val);
03031             to_number(arglist->right->val);
03032             result = make_number(FUNC_REMAINDER(arglist->val->u.i, arglist->right->val->u.i));
03033             return result;
03034          } else {
03035             ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
03036             return make_number(0.0);
03037          }
03038 #endif
03039       } else {
03040          /* is this a custom function we should execute and collect the results of? */
03041 #if !defined(STANDALONE) && !defined(STANDALONE2)
03042          struct ast_custom_function *f = ast_custom_function_find(funcname->u.s);
03043          if (!chan)
03044             ast_log(LOG_WARNING,"Hey! chan is NULL.\n");
03045          if (!f)
03046             ast_log(LOG_WARNING,"Hey! could not find func %s.\n", funcname->u.s);
03047          
03048          if (f && chan) {
03049             if (f->read) {
03050                char workspace[512];
03051                char *argbuf = compose_func_args(arglist);
03052                f->read(chan, funcname->u.s, argbuf, workspace, sizeof(workspace));
03053                free(argbuf);
03054                if (is_really_num(workspace))
03055                   return make_number(FUNC_STRTOD(workspace,(char **)NULL));
03056                else
03057                   return make_str(workspace);
03058             } else {
03059                ast_log(LOG_ERROR,"Error! Function '%s' cannot be read!\n", funcname->u.s);
03060                return (make_number ((FP___TYPE)0.0));
03061             }
03062             
03063          } else {
03064             ast_log(LOG_ERROR, "Error! '%s' doesn't appear to be an available function!\n", funcname->u.s);
03065             return (make_number ((FP___TYPE)0.0));
03066          }
03067 #else
03068          ast_log(LOG_ERROR, "Error! '%s' is not available in the standalone version!\n", funcname->u.s);
03069          return (make_number ((FP___TYPE)0.0));
03070 #endif
03071       }
03072    }
03073    else
03074    {
03075       ast_log(LOG_ERROR, "Error! '%s' is not possibly a function name!\n", funcname->u.s);
03076       return (make_number ((FP___TYPE)0.0));
03077    }
03078    return (make_number ((FP___TYPE)0.0));
03079 }

static struct val* op_ge ( struct val a,
struct val b 
) [static]

Definition at line 3175 of file ast_expr2.c.

References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().

Referenced by yyparse().

03176 {
03177    struct val *r;
03178 
03179    if (isstring (a) || isstring (b)) {
03180       to_string (a);
03181       to_string (b);
03182       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) >= 0));
03183    } else {
03184       (void)to_number(a);
03185       (void)to_number(b);
03186       r = make_number ((FP___TYPE)(a->u.i >= b->u.i));
03187    }
03188 
03189    free_value (a);
03190    free_value (b);
03191    return r;
03192 }

static struct val* op_gt ( struct val a,
struct val b 
) [static]

Definition at line 3135 of file ast_expr2.c.

References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().

Referenced by yyparse().

03136 {
03137    struct val *r;
03138 
03139    if (isstring (a) || isstring (b)) {
03140       to_string (a);
03141       to_string (b);
03142       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) > 0));
03143    } else {
03144       (void)to_number(a);
03145       (void)to_number(b);
03146       r = make_number ((FP___TYPE)(a->u.i > b->u.i));
03147    }
03148 
03149    free_value (a);
03150    free_value (b);
03151    return r;
03152 }

static struct val* op_le ( struct val a,
struct val b 
) [static]

Definition at line 3195 of file ast_expr2.c.

References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().

Referenced by yyparse().

03196 {
03197    struct val *r;
03198 
03199    if (isstring (a) || isstring (b)) {
03200       to_string (a);
03201       to_string (b);
03202       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) <= 0));
03203    } else {
03204       (void)to_number(a);
03205       (void)to_number(b);
03206       r = make_number ((FP___TYPE)(a->u.i <= b->u.i));
03207    }
03208 
03209    free_value (a);
03210    free_value (b);
03211    return r;
03212 }

static struct val* op_lt ( struct val a,
struct val b 
) [static]

Definition at line 3155 of file ast_expr2.c.

References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().

Referenced by yyparse().

03156 {
03157    struct val *r;
03158 
03159    if (isstring (a) || isstring (b)) {
03160       to_string (a);
03161       to_string (b);
03162       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) < 0));
03163    } else {
03164       (void)to_number(a);
03165       (void)to_number(b);
03166       r = make_number ((FP___TYPE)(a->u.i < b->u.i));
03167    }
03168 
03169    free_value (a);
03170    free_value (b);
03171    return r;
03172 }

static struct val* op_minus ( struct val a,
struct val b 
) [static]

Definition at line 3331 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().

03332 {
03333    struct val *r;
03334 
03335    if (!to_number (a)) {
03336       if( !extra_error_message_supplied )
03337          ast_log(LOG_WARNING, "non-numeric argument\n");
03338       if (!to_number (b)) {
03339          free_value(a);
03340          free_value(b);
03341          return make_number(0);
03342       } else {
03343          r = make_number(0 - b->u.i);
03344          free_value(a);
03345          free_value(b);
03346          return (r);
03347       }
03348    } else if (!to_number(b)) {
03349       if( !extra_error_message_supplied )
03350          ast_log(LOG_WARNING, "non-numeric argument\n");
03351       free_value(b);
03352       return (a);
03353    }
03354 
03355    r = make_number (a->u.i - b->u.i);
03356    if (chk_minus (a->u.i, b->u.i, r->u.i)) {
03357       ast_log(LOG_WARNING, "overflow\n");
03358    }
03359    free_value (a);
03360    free_value (b);
03361    return r;
03362 }

static struct val* op_ne ( struct val a,
struct val b 
) [static]

Definition at line 3254 of file ast_expr2.c.

References FP___TYPE, free_value(), isstring(), make_number(), to_number(), and to_string().

Referenced by yyparse().

03255 {
03256    struct val *r;
03257 
03258    if (isstring (a) || isstring (b)) {
03259       to_string (a);
03260       to_string (b);
03261       r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) != 0));
03262    } else {
03263       (void)to_number(a);
03264       (void)to_number(b);
03265       r = make_number ((FP___TYPE)(a->u.i != b->u.i));
03266    }
03267 
03268    free_value (a);
03269    free_value (b);
03270    return r;
03271 }

static struct val* op_negate ( struct val a  )  [static]

Definition at line 3365 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().

03366 {
03367    struct val *r;
03368 
03369    if (!to_number (a) ) {
03370       free_value(a);
03371       if( !extra_error_message_supplied )
03372          ast_log(LOG_WARNING, "non-numeric argument\n");
03373       return make_number(0);
03374    }
03375 
03376    r = make_number (- a->u.i);
03377    if (chk_minus (0, a->u.i, r->u.i)) {
03378       ast_log(LOG_WARNING, "overflow\n");
03379    }
03380    free_value (a);
03381    return r;
03382 }

static struct val* op_or ( struct val a,
struct val b 
) [static]

Definition at line 3083 of file ast_expr2.c.

References free_value(), and is_zero_or_null().

Referenced by yyparse().

03084 {
03085    if (is_zero_or_null (a)) {
03086       free_value (a);
03087       return (b);
03088    } else {
03089       free_value (b);
03090       return (a);
03091    }
03092 }

static struct val* op_plus ( struct val a,
struct val b 
) [static]

Definition at line 3287 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().

03288 {
03289    struct val *r;
03290 
03291    if (!to_number (a)) {
03292       if( !extra_error_message_supplied )
03293          ast_log(LOG_WARNING,"non-numeric argument\n");
03294       if (!to_number (b)) {
03295          free_value(a);
03296          free_value(b);
03297          return make_number(0);
03298       } else {
03299          free_value(a);
03300          return (b);
03301       }
03302    } else if (!to_number(b)) {
03303       free_value(b);
03304       return (a);
03305    }
03306 
03307    r = make_number (a->u.i + b->u.i);
03308    if (chk_plus (a->u.i, b->u.i, r->u.i)) {
03309       ast_log(LOG_WARNING,"overflow\n");
03310    }
03311    free_value (a);
03312    free_value (b);
03313    return r;
03314 }

static struct val* op_rem ( struct val a,
struct val b 
) [static]

Definition at line 3519 of file ast_expr2.c.

References ast_log(), free_value(), FUNC_FMOD, LOG_WARNING, make_number(), and to_number().

Referenced by yyparse().

03520 {
03521    struct val *r;
03522 
03523    if (!to_number (a) || !to_number (b)) {
03524       if( !extra_error_message_supplied )
03525          ast_log(LOG_WARNING, "non-numeric argument\n");
03526       free_value(a);
03527       free_value(b);
03528       return make_number(0);
03529    }
03530 
03531    if (b->u.i == 0) {
03532       ast_log(LOG_WARNING, "div by zero\n");
03533       free_value(a);
03534       return(b);
03535    }
03536 
03537    r = make_number (FUNC_FMOD(a->u.i, b->u.i)); /* either fmod or fmodl if FP___TYPE is available */
03538    /* chk_rem necessary ??? */
03539    free_value (a);
03540    free_value (b);
03541    return r;
03542 }

static struct val* op_tildetilde ( struct val a,
struct val b 
) [static]

Definition at line 3647 of file ast_expr2.c.

References free_value(), make_str(), malloc, val::s, strip_quotes(), to_string(), and val::u.

Referenced by yyparse().

03648 {
03649    struct val *v;
03650    char *vs;
03651 
03652    /* coerce to both arguments to strings */
03653    to_string(a);
03654    to_string(b);
03655    /* strip double quotes from both -- */
03656    strip_quotes(a);
03657    strip_quotes(b);
03658    
03659    vs = malloc(strlen(a->u.s)+strlen(b->u.s)+1);
03660    strcpy(vs,a->u.s);
03661    strcat(vs,b->u.s);
03662 
03663    v = make_str(vs);
03664 
03665    /* free arguments */
03666    free_value(a);
03667    free_value(b);
03668 
03669    return v;
03670 }

static struct val* op_times ( struct val a,
struct val b 
) [static]

Definition at line 3451 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().

03452 {
03453    struct val *r;
03454 
03455    if (!to_number (a) || !to_number (b)) {
03456       free_value(a);
03457       free_value(b);
03458       if( !extra_error_message_supplied )
03459          ast_log(LOG_WARNING, "non-numeric argument\n");
03460       return(make_number(0));
03461    }
03462 
03463    r = make_number (a->u.i * b->u.i);
03464    if (chk_times (a->u.i, b->u.i, r->u.i)) {
03465       ast_log(LOG_WARNING, "overflow\n");
03466    }
03467    free_value (a);
03468    free_value (b);
03469    return (r);
03470 }

static void strip_quotes ( struct val vp  )  [static]

Definition at line 2606 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().

02607 {
02608    if (vp->type != AST_EXPR_string && vp->type != AST_EXPR_numeric_string)
02609       return;
02610    
02611    if( vp->u.s[0] == '"' && vp->u.s[strlen(vp->u.s)-1] == '"' )
02612    {
02613       char *f, *t;
02614       f = vp->u.s;
02615       t = vp->u.s;
02616       
02617       while( *f )
02618       {
02619          if( *f  && *f != '"' )
02620             *t++ = *f++;
02621          else
02622             f++;
02623       }
02624       *t = *f;
02625    }
02626 }

static int to_number ( struct val vp  )  [static]

Definition at line 2575 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().

02576 {
02577    FP___TYPE i;
02578    
02579    if (vp == NULL) {
02580       ast_log(LOG_WARNING,"vp==NULL in to_number()\n");
02581       return(0);
02582    }
02583 
02584    if (vp->type == AST_EXPR_number)
02585       return 1;
02586 
02587    if (vp->type == AST_EXPR_string)
02588       return 0;
02589 
02590    /* vp->type == AST_EXPR_numeric_string, make it numeric */
02591    errno = 0;
02592    i  = FUNC_STRTOD(vp->u.s, (char**)0); /* either strtod, or strtold on a good day */
02593    if (errno != 0) {
02594       ast_log(LOG_WARNING,"Conversion of %s to number under/overflowed!\n", vp->u.s);
02595       free(vp->u.s);
02596       vp->u.s = 0;
02597       return(0);
02598    }
02599    free (vp->u.s);
02600    vp->u.i = i;
02601    vp->type = AST_EXPR_number;
02602    return 1;
02603 }

static void to_string ( struct val vp  )  [static]

Definition at line 2629 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().

02630 {
02631    char *tmp;
02632 
02633    if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
02634       return;
02635 
02636    tmp = malloc ((size_t)25);
02637    if (tmp == NULL) {
02638       ast_log(LOG_WARNING,"malloc() failed\n");
02639       return;
02640    }
02641 
02642    sprintf(tmp, FP___PRINTF, vp->u.i);
02643    vp->type = AST_EXPR_string;
02644    vp->u.s  = tmp;
02645 }

static void yydestruct ( char *  yymsg,
int  yytype,
YYSTYPE yyvaluep,
YYLTYPE yylocationp 
) const [static]

Definition at line 1455 of file ast_expr2.c.

References free_value(), YYSTYPE::val, YY_SYMBOL_PRINT, and YYUSE.

Referenced by yyparse().

01461 {
01462   YYUSE (yyvaluep);
01463   YYUSE (yylocationp);
01464 
01465   if (!yymsg)
01466     yymsg = "Deleting";
01467   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
01468 
01469   switch (yytype)
01470     {
01471       case 4: /* "TOK_COLONCOLON" */
01472 
01473 /* Line 1000 of yacc.c  */
01474 #line 368 "ast_expr2.y"
01475    {  free_value((yyvaluep->val)); };
01476 
01477 /* Line 1000 of yacc.c  */
01478 #line 1479 "ast_expr2.c"
01479    break;
01480       case 5: /* "TOK_COND" */
01481 
01482 /* Line 1000 of yacc.c  */
01483 #line 368 "ast_expr2.y"
01484    {  free_value((yyvaluep->val)); };
01485 
01486 /* Line 1000 of yacc.c  */
01487 #line 1488 "ast_expr2.c"
01488    break;
01489       case 6: /* "TOK_OR" */
01490 
01491 /* Line 1000 of yacc.c  */
01492 #line 368 "ast_expr2.y"
01493    {  free_value((yyvaluep->val)); };
01494 
01495 /* Line 1000 of yacc.c  */
01496 #line 1497 "ast_expr2.c"
01497    break;
01498       case 7: /* "TOK_AND" */
01499 
01500 /* Line 1000 of yacc.c  */
01501 #line 368 "ast_expr2.y"
01502    {  free_value((yyvaluep->val)); };
01503 
01504 /* Line 1000 of yacc.c  */
01505 #line 1506 "ast_expr2.c"
01506    break;
01507       case 8: /* "TOK_NE" */
01508 
01509 /* Line 1000 of yacc.c  */
01510 #line 368 "ast_expr2.y"
01511    {  free_value((yyvaluep->val)); };
01512 
01513 /* Line 1000 of yacc.c  */
01514 #line 1515 "ast_expr2.c"
01515    break;
01516       case 9: /* "TOK_LE" */
01517 
01518 /* Line 1000 of yacc.c  */
01519 #line 368 "ast_expr2.y"
01520    {  free_value((yyvaluep->val)); };
01521 
01522 /* Line 1000 of yacc.c  */
01523 #line 1524 "ast_expr2.c"
01524    break;
01525       case 10: /* "TOK_GE" */
01526 
01527 /* Line 1000 of yacc.c  */
01528 #line 368 "ast_expr2.y"
01529    {  free_value((yyvaluep->val)); };
01530 
01531 /* Line 1000 of yacc.c  */
01532 #line 1533 "ast_expr2.c"
01533    break;
01534       case 11: /* "TOK_LT" */
01535 
01536 /* Line 1000 of yacc.c  */
01537 #line 368 "ast_expr2.y"
01538    {  free_value((yyvaluep->val)); };
01539 
01540 /* Line 1000 of yacc.c  */
01541 #line 1542 "ast_expr2.c"
01542    break;
01543       case 12: /* "TOK_GT" */
01544 
01545 /* Line 1000 of yacc.c  */
01546 #line 368 "ast_expr2.y"
01547    {  free_value((yyvaluep->val)); };
01548 
01549 /* Line 1000 of yacc.c  */
01550 #line 1551 "ast_expr2.c"
01551    break;
01552       case 13: /* "TOK_EQ" */
01553 
01554 /* Line 1000 of yacc.c  */
01555 #line 368 "ast_expr2.y"
01556    {  free_value((yyvaluep->val)); };
01557 
01558 /* Line 1000 of yacc.c  */
01559 #line 1560 "ast_expr2.c"
01560    break;
01561       case 14: /* "TOK_MINUS" */
01562 
01563 /* Line 1000 of yacc.c  */
01564 #line 368 "ast_expr2.y"
01565    {  free_value((yyvaluep->val)); };
01566 
01567 /* Line 1000 of yacc.c  */
01568 #line 1569 "ast_expr2.c"
01569    break;
01570       case 15: /* "TOK_PLUS" */
01571 
01572 /* Line 1000 of yacc.c  */
01573 #line 368 "ast_expr2.y"
01574    {  free_value((yyvaluep->val)); };
01575 
01576 /* Line 1000 of yacc.c  */
01577 #line 1578 "ast_expr2.c"
01578    break;
01579       case 16: /* "TOK_MOD" */
01580 
01581 /* Line 1000 of yacc.c  */
01582 #line 368 "ast_expr2.y"
01583    {  free_value((yyvaluep->val)); };
01584 
01585 /* Line 1000 of yacc.c  */
01586 #line 1587 "ast_expr2.c"
01587    break;
01588       case 17: /* "TOK_DIV" */
01589 
01590 /* Line 1000 of yacc.c  */
01591 #line 368 "ast_expr2.y"
01592    {  free_value((yyvaluep->val)); };
01593 
01594 /* Line 1000 of yacc.c  */
01595 #line 1596 "ast_expr2.c"
01596    break;
01597       case 18: /* "TOK_MULT" */
01598 
01599 /* Line 1000 of yacc.c  */
01600 #line 368 "ast_expr2.y"
01601    {  free_value((yyvaluep->val)); };
01602 
01603 /* Line 1000 of yacc.c  */
01604 #line 1605 "ast_expr2.c"
01605    break;
01606       case 19: /* "TOK_COMPL" */
01607 
01608 /* Line 1000 of yacc.c  */
01609 #line 368 "ast_expr2.y"
01610    {  free_value((yyvaluep->val)); };
01611 
01612 /* Line 1000 of yacc.c  */
01613 #line 1614 "ast_expr2.c"
01614    break;
01615       case 20: /* "TOK_TILDETILDE" */
01616 
01617 /* Line 1000 of yacc.c  */
01618 #line 368 "ast_expr2.y"
01619    {  free_value((yyvaluep->val)); };
01620 
01621 /* Line 1000 of yacc.c  */
01622 #line 1623 "ast_expr2.c"
01623    break;
01624       case 21: /* "TOK_EQTILDE" */
01625 
01626 /* Line 1000 of yacc.c  */
01627 #line 368 "ast_expr2.y"
01628    {  free_value((yyvaluep->val)); };
01629 
01630 /* Line 1000 of yacc.c  */
01631 #line 1632 "ast_expr2.c"
01632    break;
01633       case 22: /* "TOK_COLON" */
01634 
01635 /* Line 1000 of yacc.c  */
01636 #line 368 "ast_expr2.y"
01637    {  free_value((yyvaluep->val)); };
01638 
01639 /* Line 1000 of yacc.c  */
01640 #line 1641 "ast_expr2.c"
01641    break;
01642       case 23: /* "TOK_LP" */
01643 
01644 /* Line 1000 of yacc.c  */
01645 #line 368 "ast_expr2.y"
01646    {  free_value((yyvaluep->val)); };
01647 
01648 /* Line 1000 of yacc.c  */
01649 #line 1650 "ast_expr2.c"
01650    break;
01651       case 24: /* "TOK_RP" */
01652 
01653 /* Line 1000 of yacc.c  */
01654 #line 368 "ast_expr2.y"
01655    {  free_value((yyvaluep->val)); };
01656 
01657 /* Line 1000 of yacc.c  */
01658 #line 1659 "ast_expr2.c"
01659    break;
01660       case 25: /* "TOKEN" */
01661 
01662 /* Line 1000 of yacc.c  */
01663 #line 368 "ast_expr2.y"
01664    {  free_value((yyvaluep->val)); };
01665 
01666 /* Line 1000 of yacc.c  */
01667 #line 1668 "ast_expr2.c"
01668    break;
01669       case 29: /* "expr" */
01670 
01671 /* Line 1000 of yacc.c  */
01672 #line 368 "ast_expr2.y"
01673    {  free_value((yyvaluep->val)); };
01674 
01675 /* Line 1000 of yacc.c  */
01676 #line 1677 "ast_expr2.c"
01677    break;
01678 
01679       default:
01680    break;
01681     }
01682 }

int yyparse ( void *  YYPARSE_PARAM  ) 

Definition at line 1714 of file ast_expr2.c.

References alloc_expr_node(), YYSTYPE::arglist, AST_EXPR_number, calloc, DESTROY, destroy_arglist(), free, make_str(), op_and(), op_colon(), op_compl(), op_cond(), op_div(), op_eq(), op_eqtilde(), op_func(), op_ge(), op_gt(), op_le(), op_lt(), op_minus(), op_ne(), op_negate(), op_or(), op_plus(), op_rem(), op_tildetilde(), op_times(), expr_node::right, strdup, type, expr_node::val, YYSTYPE::val, YY_, YY_REDUCE_PRINT, YY_STACK_PRINT, YY_SYMBOL_PRINT, YYABORT, YYACCEPT, yychar, yydestruct(), YYDPRINTF, YYEMPTY, YYEOF, yyerror, YYFINAL, YYID, YYINITDEPTH, YYLAST, YYLEX, yylloc, YYLLOC_DEFAULT, yyalloc::yyls_alloc, yylval, YYMAXDEPTH, yynerrs, YYNTOKENS, YYPACT_NINF, YYPOPSTACK, YYSIZE_T, yyalloc::yyss_alloc, YYSTACK_ALLOC, YYSTACK_ALLOC_MAXIMUM, YYSTACK_BYTES, YYSTACK_FREE, YYSTACK_RELOCATE, yysyntax_error(), YYTABLE_NINF, YYTERROR, YYTRANSLATE, and yyalloc::yyvs_alloc.

01728 {
01729 /* The lookahead symbol.  */
01730 int yychar;
01731 
01732 /* The semantic value of the lookahead symbol.  */
01733 YYSTYPE yylval;
01734 
01735 /* Location data for the lookahead symbol.  */
01736 YYLTYPE yylloc;
01737 
01738     /* Number of syntax errors so far.  */
01739     int yynerrs;
01740 
01741     int yystate;
01742     /* Number of tokens to shift before error messages enabled.  */
01743     int yyerrstatus;
01744 
01745     /* The stacks and their tools:
01746        `yyss': related to states.
01747        `yyvs': related to semantic values.
01748        `yyls': related to locations.
01749 
01750        Refer to the stacks thru separate pointers, to allow yyoverflow
01751        to reallocate them elsewhere.  */
01752 
01753     /* The state stack.  */
01754     yytype_int16 yyssa[YYINITDEPTH];
01755     yytype_int16 *yyss;
01756     yytype_int16 *yyssp;
01757 
01758     /* The semantic value stack.  */
01759     YYSTYPE yyvsa[YYINITDEPTH];
01760     YYSTYPE *yyvs;
01761     YYSTYPE *yyvsp;
01762 
01763     /* The location stack.  */
01764     YYLTYPE yylsa[YYINITDEPTH];
01765     YYLTYPE *yyls;
01766     YYLTYPE *yylsp;
01767 
01768     /* The locations where the error started and ended.  */
01769     YYLTYPE yyerror_range[2];
01770 
01771     YYSIZE_T yystacksize;
01772 
01773   int yyn;
01774   int yyresult;
01775   /* Lookahead token as an internal (translated) token number.  */
01776   int yytoken;
01777   /* The variables used to return semantic value and location from the
01778      action routines.  */
01779   YYSTYPE yyval;
01780   YYLTYPE yyloc;
01781 
01782 #if YYERROR_VERBOSE
01783   /* Buffer for error messages, and its allocated size.  */
01784   char yymsgbuf[128];
01785   char *yymsg = yymsgbuf;
01786   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
01787 #endif
01788 
01789 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
01790 
01791   /* The number of symbols on the RHS of the reduced rule.
01792      Keep to zero when no symbol should be popped.  */
01793   int yylen = 0;
01794 
01795   yytoken = 0;
01796   yyss = yyssa;
01797   yyvs = yyvsa;
01798   yyls = yylsa;
01799   yystacksize = YYINITDEPTH;
01800 
01801   YYDPRINTF ((stderr, "Starting parse\n"));
01802 
01803   yystate = 0;
01804   yyerrstatus = 0;
01805   yynerrs = 0;
01806   yychar = YYEMPTY; /* Cause a token to be read.  */
01807 
01808   /* Initialize stack pointers.
01809      Waste one element of value and location stack
01810      so that they stay on the same level as the state stack.
01811      The wasted elements are never initialized.  */
01812   yyssp = yyss;
01813   yyvsp = yyvs;
01814   yylsp = yyls;
01815 
01816 #if YYLTYPE_IS_TRIVIAL
01817   /* Initialize the default location before parsing starts.  */
01818   yylloc.first_line   = yylloc.last_line   = 1;
01819   yylloc.first_column = yylloc.last_column = 1;
01820 #endif
01821 
01822   goto yysetstate;
01823 
01824 /*------------------------------------------------------------.
01825 | yynewstate -- Push a new state, which is found in yystate.  |
01826 `------------------------------------------------------------*/
01827  yynewstate:
01828   /* In all cases, when you get here, the value and location stacks
01829      have just been pushed.  So pushing a state here evens the stacks.  */
01830   yyssp++;
01831 
01832  yysetstate:
01833   *yyssp = yystate;
01834 
01835   if (yyss + yystacksize - 1 <= yyssp)
01836     {
01837       /* Get the current used size of the three stacks, in elements.  */
01838       YYSIZE_T yysize = yyssp - yyss + 1;
01839 
01840 #ifdef yyoverflow
01841       {
01842    /* Give user a chance to reallocate the stack.  Use copies of
01843       these so that the &'s don't force the real ones into
01844       memory.  */
01845    YYSTYPE *yyvs1 = yyvs;
01846    yytype_int16 *yyss1 = yyss;
01847    YYLTYPE *yyls1 = yyls;
01848 
01849    /* Each stack pointer address is followed by the size of the
01850       data in use in that stack, in bytes.  This used to be a
01851       conditional around just the two extra args, but that might
01852       be undefined if yyoverflow is a macro.  */
01853    yyoverflow (YY_("memory exhausted"),
01854           &yyss1, yysize * sizeof (*yyssp),
01855           &yyvs1, yysize * sizeof (*yyvsp),
01856           &yyls1, yysize * sizeof (*yylsp),
01857           &yystacksize);
01858 
01859    yyls = yyls1;
01860    yyss = yyss1;
01861    yyvs = yyvs1;
01862       }
01863 #else /* no yyoverflow */
01864 # ifndef YYSTACK_RELOCATE
01865       goto yyexhaustedlab;
01866 # else
01867       /* Extend the stack our own way.  */
01868       if (YYMAXDEPTH <= yystacksize)
01869    goto yyexhaustedlab;
01870       yystacksize *= 2;
01871       if (YYMAXDEPTH < yystacksize)
01872    yystacksize = YYMAXDEPTH;
01873 
01874       {
01875    yytype_int16 *yyss1 = yyss;
01876    union yyalloc *yyptr =
01877      (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
01878    if (! yyptr)
01879      goto yyexhaustedlab;
01880    YYSTACK_RELOCATE (yyss_alloc, yyss);
01881    YYSTACK_RELOCATE (yyvs_alloc, yyvs);
01882    YYSTACK_RELOCATE (yyls_alloc, yyls);
01883 #  undef YYSTACK_RELOCATE
01884    if (yyss1 != yyssa)
01885      YYSTACK_FREE (yyss1);
01886       }
01887 # endif
01888 #endif /* no yyoverflow */
01889 
01890       yyssp = yyss + yysize - 1;
01891       yyvsp = yyvs + yysize - 1;
01892       yylsp = yyls + yysize - 1;
01893 
01894       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
01895         (unsigned long int) yystacksize));
01896 
01897       if (yyss + yystacksize - 1 <= yyssp)
01898    YYABORT;
01899     }
01900 
01901   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
01902 
01903   if (yystate == YYFINAL)
01904     YYACCEPT;
01905 
01906   goto yybackup;
01907 
01908 /*-----------.
01909 | yybackup.  |
01910 `-----------*/
01911 yybackup:
01912 
01913   /* Do appropriate processing given the current state.  Read a
01914      lookahead token if we need one and don't already have one.  */
01915 
01916   /* First try to decide what to do without reference to lookahead token.  */
01917   yyn = yypact[yystate];
01918   if (yyn == YYPACT_NINF)
01919     goto yydefault;
01920 
01921   /* Not known => get a lookahead token if don't already have one.  */
01922 
01923   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
01924   if (yychar == YYEMPTY)
01925     {
01926       YYDPRINTF ((stderr, "Reading a token: "));
01927       yychar = YYLEX;
01928     }
01929 
01930   if (yychar <= YYEOF)
01931     {
01932       yychar = yytoken = YYEOF;
01933       YYDPRINTF ((stderr, "Now at end of input.\n"));
01934     }
01935   else
01936     {
01937       yytoken = YYTRANSLATE (yychar);
01938       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
01939     }
01940 
01941   /* If the proper action on seeing token YYTOKEN is to reduce or to
01942      detect an error, take that action.  */
01943   yyn += yytoken;
01944   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
01945     goto yydefault;
01946   yyn = yytable[yyn];
01947   if (yyn <= 0)
01948     {
01949       if (yyn == 0 || yyn == YYTABLE_NINF)
01950    goto yyerrlab;
01951       yyn = -yyn;
01952       goto yyreduce;
01953     }
01954 
01955   /* Count tokens shifted since error; after three, turn off error
01956      status.  */
01957   if (yyerrstatus)
01958     yyerrstatus--;
01959 
01960   /* Shift the lookahead token.  */
01961   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
01962 
01963   /* Discard the shifted token.  */
01964   yychar = YYEMPTY;
01965 
01966   yystate = yyn;
01967   *++yyvsp = yylval;
01968   *++yylsp = yylloc;
01969   goto yynewstate;
01970 
01971 
01972 /*-----------------------------------------------------------.
01973 | yydefault -- do the default action for the current state.  |
01974 `-----------------------------------------------------------*/
01975 yydefault:
01976   yyn = yydefact[yystate];
01977   if (yyn == 0)
01978     goto yyerrlab;
01979   goto yyreduce;
01980 
01981 
01982 /*-----------------------------.
01983 | yyreduce -- Do a reduction.  |
01984 `-----------------------------*/
01985 yyreduce:
01986   /* yyn is the number of a rule to reduce with.  */
01987   yylen = yyr2[yyn];
01988 
01989   /* If YYLEN is nonzero, implement the default value of the action:
01990      `$$ = $1'.
01991 
01992      Otherwise, the following line sets YYVAL to garbage.
01993      This behavior is undocumented and Bison
01994      users should not rely upon it.  Assigning to YYVAL
01995      unconditionally makes the parser a bit smaller, and it avoids a
01996      GCC warning that YYVAL may be used uninitialized.  */
01997   yyval = yyvsp[1-yylen];
01998 
01999   /* Default location.  */
02000   YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
02001   YY_REDUCE_PRINT (yyn);
02002   switch (yyn)
02003     {
02004         case 2:
02005 
02006 /* Line 1455 of yacc.c  */
02007 #line 374 "ast_expr2.y"
02008     { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
02009               ((struct parse_io *)parseio)->val->type = (yyvsp[(1) - (1)].val)->type;
02010               if( (yyvsp[(1) - (1)].val)->type == AST_EXPR_number )
02011               ((struct parse_io *)parseio)->val->u.i = (yyvsp[(1) - (1)].val)->u.i;
02012               else
02013               ((struct parse_io *)parseio)->val->u.s = (yyvsp[(1) - (1)].val)->u.s; 
02014            free((yyvsp[(1) - (1)].val));
02015          ;}
02016     break;
02017 
02018   case 3:
02019 
02020 /* Line 1455 of yacc.c  */
02021 #line 382 "ast_expr2.y"
02022     {/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
02023               ((struct parse_io *)parseio)->val->type = AST_EXPR_string;
02024            ((struct parse_io *)parseio)->val->u.s = strdup(""); 
02025          ;}
02026     break;
02027 
02028   case 4:
02029 
02030 /* Line 1455 of yacc.c  */
02031 #line 389 "ast_expr2.y"
02032     { (yyval.arglist) = alloc_expr_node(AST_EXPR_NODE_VAL); (yyval.arglist)->val = (yyvsp[(1) - (1)].val);;}
02033     break;
02034 
02035   case 5:
02036 
02037 /* Line 1455 of yacc.c  */
02038 #line 390 "ast_expr2.y"
02039     {struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL);
02040                                  struct expr_node *t;
02041                          DESTROY((yyvsp[(2) - (3)].val));
02042                                  for (t=(yyvsp[(1) - (3)].arglist);t->right;t=t->right)
02043                                 ;
02044                                  (yyval.arglist) = (yyvsp[(1) - (3)].arglist); t->right = x; x->val = (yyvsp[(3) - (3)].val);;}
02045     break;
02046 
02047   case 6:
02048 
02049 /* Line 1455 of yacc.c  */
02050 #line 396 "ast_expr2.y"
02051     {struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL);
02052                                  struct expr_node *t;  /* NULL args should OK */
02053                          DESTROY((yyvsp[(2) - (2)].val));
02054                                  for (t=(yyvsp[(1) - (2)].arglist);t->right;t=t->right)
02055                                 ;
02056                                  (yyval.arglist) = (yyvsp[(1) - (2)].arglist); t->right = x; x->val = make_str("");;}
02057     break;
02058 
02059   case 7:
02060 
02061 /* Line 1455 of yacc.c  */
02062 #line 405 "ast_expr2.y"
02063     { (yyval.val) = op_func((yyvsp[(1) - (4)].val),(yyvsp[(3) - (4)].arglist), ((struct parse_io *)parseio)->chan);
02064                                   DESTROY((yyvsp[(2) - (4)].val));
02065                            DESTROY((yyvsp[(4) - (4)].val));
02066                            DESTROY((yyvsp[(1) - (4)].val));
02067                            destroy_arglist((yyvsp[(3) - (4)].arglist));
02068                                   ;}
02069     break;
02070 
02071   case 8:
02072 
02073 /* Line 1455 of yacc.c  */
02074 #line 411 "ast_expr2.y"
02075     {(yyval.val) = (yyvsp[(1) - (1)].val);;}
02076     break;
02077 
02078   case 9:
02079 
02080 /* Line 1455 of yacc.c  */
02081 #line 412 "ast_expr2.y"
02082     { (yyval.val) = (yyvsp[(2) - (3)].val);
02083                           (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02084                      (yyloc).first_line=0; (yyloc).last_line=0;
02085                      DESTROY((yyvsp[(1) - (3)].val)); DESTROY((yyvsp[(3) - (3)].val)); ;}
02086     break;
02087 
02088   case 10:
02089 
02090 /* Line 1455 of yacc.c  */
02091 #line 416 "ast_expr2.y"
02092     { (yyval.val) = op_or ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
02093                   DESTROY((yyvsp[(2) - (3)].val)); 
02094                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02095                    (yyloc).first_line=0; (yyloc).last_line=0;;}
02096     break;
02097 
02098   case 11:
02099 
02100 /* Line 1455 of yacc.c  */
02101 #line 420 "ast_expr2.y"
02102     { (yyval.val) = op_and ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02103                   DESTROY((yyvsp[(2) - (3)].val)); 
02104                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02105                           (yyloc).first_line=0; (yyloc).last_line=0;;}
02106     break;
02107 
02108   case 12:
02109 
02110 /* Line 1455 of yacc.c  */
02111 #line 424 "ast_expr2.y"
02112     { (yyval.val) = op_eq ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
02113                   DESTROY((yyvsp[(2) - (3)].val)); 
02114                         (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
02115                    (yyloc).first_line=0; (yyloc).last_line=0;;}
02116     break;
02117 
02118   case 13:
02119 
02120 /* Line 1455 of yacc.c  */
02121 #line 428 "ast_expr2.y"
02122     { (yyval.val) = op_gt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
02123                   DESTROY((yyvsp[(2) - (3)].val)); 
02124                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
02125                    (yyloc).first_line=0; (yyloc).last_line=0;;}
02126     break;
02127 
02128   case 14:
02129 
02130 /* Line 1455 of yacc.c  */
02131 #line 432 "ast_expr2.y"
02132     { (yyval.val) = op_lt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02133                   DESTROY((yyvsp[(2) - (3)].val)); 
02134                         (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02135                    (yyloc).first_line=0; (yyloc).last_line=0;;}
02136     break;
02137 
02138   case 15:
02139 
02140 /* Line 1455 of yacc.c  */
02141 #line 436 "ast_expr2.y"
02142     { (yyval.val) = op_ge ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02143                   DESTROY((yyvsp[(2) - (3)].val)); 
02144                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02145                     (yyloc).first_line=0; (yyloc).last_line=0;;}
02146     break;
02147 
02148   case 16:
02149 
02150 /* Line 1455 of yacc.c  */
02151 #line 440 "ast_expr2.y"
02152     { (yyval.val) = op_le ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02153                   DESTROY((yyvsp[(2) - (3)].val)); 
02154                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02155                     (yyloc).first_line=0; (yyloc).last_line=0;;}
02156     break;
02157 
02158   case 17:
02159 
02160 /* Line 1455 of yacc.c  */
02161 #line 444 "ast_expr2.y"
02162     { (yyval.val) = op_ne ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02163                   DESTROY((yyvsp[(2) - (3)].val)); 
02164                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02165                     (yyloc).first_line=0; (yyloc).last_line=0;;}
02166     break;
02167 
02168   case 18:
02169 
02170 /* Line 1455 of yacc.c  */
02171 #line 448 "ast_expr2.y"
02172     { (yyval.val) = op_plus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02173                   DESTROY((yyvsp[(2) - (3)].val)); 
02174                           (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02175                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02176     break;
02177 
02178   case 19:
02179 
02180 /* Line 1455 of yacc.c  */
02181 #line 452 "ast_expr2.y"
02182     { (yyval.val) = op_minus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02183                   DESTROY((yyvsp[(2) - (3)].val)); 
02184                            (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02185                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02186     break;
02187 
02188   case 20:
02189 
02190 /* Line 1455 of yacc.c  */
02191 #line 456 "ast_expr2.y"
02192     { (yyval.val) = op_negate ((yyvsp[(2) - (2)].val)); 
02193                   DESTROY((yyvsp[(1) - (2)].val)); 
02194                            (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column; 
02195                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02196     break;
02197 
02198   case 21:
02199 
02200 /* Line 1455 of yacc.c  */
02201 #line 460 "ast_expr2.y"
02202     { (yyval.val) = op_compl ((yyvsp[(2) - (2)].val)); 
02203                   DESTROY((yyvsp[(1) - (2)].val)); 
02204                            (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column; 
02205                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02206     break;
02207 
02208   case 22:
02209 
02210 /* Line 1455 of yacc.c  */
02211 #line 464 "ast_expr2.y"
02212     { (yyval.val) = op_times ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02213                   DESTROY((yyvsp[(2) - (3)].val)); 
02214                           (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02215                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02216     break;
02217 
02218   case 23:
02219 
02220 /* Line 1455 of yacc.c  */
02221 #line 468 "ast_expr2.y"
02222     { (yyval.val) = op_div ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02223                   DESTROY((yyvsp[(2) - (3)].val)); 
02224                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02225                     (yyloc).first_line=0; (yyloc).last_line=0;;}
02226     break;
02227 
02228   case 24:
02229 
02230 /* Line 1455 of yacc.c  */
02231 #line 472 "ast_expr2.y"
02232     { (yyval.val) = op_rem ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02233                   DESTROY((yyvsp[(2) - (3)].val)); 
02234                          (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02235                     (yyloc).first_line=0; (yyloc).last_line=0;;}
02236     break;
02237 
02238   case 25:
02239 
02240 /* Line 1455 of yacc.c  */
02241 #line 476 "ast_expr2.y"
02242     { (yyval.val) = op_colon ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02243                   DESTROY((yyvsp[(2) - (3)].val)); 
02244                            (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02245                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02246     break;
02247 
02248   case 26:
02249 
02250 /* Line 1455 of yacc.c  */
02251 #line 480 "ast_expr2.y"
02252     { (yyval.val) = op_eqtilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02253                   DESTROY((yyvsp[(2) - (3)].val)); 
02254                            (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02255                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02256     break;
02257 
02258   case 27:
02259 
02260 /* Line 1455 of yacc.c  */
02261 #line 484 "ast_expr2.y"
02262     { (yyval.val) = op_cond ((yyvsp[(1) - (5)].val), (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val)); 
02263                   DESTROY((yyvsp[(2) - (5)].val)); 
02264                   DESTROY((yyvsp[(4) - (5)].val)); 
02265                            (yyloc).first_column = (yylsp[(1) - (5)]).first_column; (yyloc).last_column = (yylsp[(3) - (5)]).last_column; 
02266                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02267     break;
02268 
02269   case 28:
02270 
02271 /* Line 1455 of yacc.c  */
02272 #line 489 "ast_expr2.y"
02273     { (yyval.val) = op_tildetilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 
02274                   DESTROY((yyvsp[(2) - (3)].val)); 
02275                            (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 
02276                      (yyloc).first_line=0; (yyloc).last_line=0;;}
02277     break;
02278 
02279 
02280 
02281 /* Line 1455 of yacc.c  */
02282 #line 2283 "ast_expr2.c"
02283       default: break;
02284     }
02285   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
02286 
02287   YYPOPSTACK (yylen);
02288   yylen = 0;
02289   YY_STACK_PRINT (yyss, yyssp);
02290 
02291   *++yyvsp = yyval;
02292   *++yylsp = yyloc;
02293 
02294   /* Now `shift' the result of the reduction.  Determine what state
02295      that goes to, based on the state we popped back to and the rule
02296      number reduced by.  */
02297 
02298   yyn = yyr1[yyn];
02299 
02300   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
02301   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
02302     yystate = yytable[yystate];
02303   else
02304     yystate = yydefgoto[yyn - YYNTOKENS];
02305 
02306   goto yynewstate;
02307 
02308 
02309 /*------------------------------------.
02310 | yyerrlab -- here on detecting error |
02311 `------------------------------------*/
02312 yyerrlab:
02313   /* If not already recovering from an error, report this error.  */
02314   if (!yyerrstatus)
02315     {
02316       ++yynerrs;
02317 #if ! YYERROR_VERBOSE
02318       yyerror (YY_("syntax error"));
02319 #else
02320       {
02321    YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
02322    if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
02323      {
02324        YYSIZE_T yyalloc = 2 * yysize;
02325        if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
02326          yyalloc = YYSTACK_ALLOC_MAXIMUM;
02327        if (yymsg != yymsgbuf)
02328          YYSTACK_FREE (yymsg);
02329        yymsg = (char *) YYSTACK_ALLOC (yyalloc);
02330        if (yymsg)
02331          yymsg_alloc = yyalloc;
02332        else
02333          {
02334       yymsg = yymsgbuf;
02335       yymsg_alloc = sizeof yymsgbuf;
02336          }
02337      }
02338 
02339    if (0 < yysize && yysize <= yymsg_alloc)
02340      {
02341        (void) yysyntax_error (yymsg, yystate, yychar);
02342        yyerror (yymsg);
02343      }
02344    else
02345      {
02346        yyerror (YY_("syntax error"));
02347        if (yysize != 0)
02348          goto yyexhaustedlab;
02349      }
02350       }
02351 #endif
02352     }
02353 
02354   yyerror_range[0] = yylloc;
02355 
02356   if (yyerrstatus == 3)
02357     {
02358       /* If just tried and failed to reuse lookahead token after an
02359     error, discard it.  */
02360 
02361       if (yychar <= YYEOF)
02362    {
02363      /* Return failure if at end of input.  */
02364      if (yychar == YYEOF)
02365        YYABORT;
02366    }
02367       else
02368    {
02369      yydestruct ("Error: discarding",
02370             yytoken, &yylval, &yylloc);
02371      yychar = YYEMPTY;
02372    }
02373     }
02374 
02375   /* Else will try to reuse lookahead token after shifting the error
02376      token.  */
02377   goto yyerrlab1;
02378 
02379 
02380 /*---------------------------------------------------.
02381 | yyerrorlab -- error raised explicitly by YYERROR.  |
02382 `---------------------------------------------------*/
02383 yyerrorlab:
02384 
02385   /* Pacify compilers like GCC when the user code never invokes
02386      YYERROR and the label yyerrorlab therefore never appears in user
02387      code.  */
02388   if (/*CONSTCOND*/ 0)
02389      goto yyerrorlab;
02390 
02391   yyerror_range[0] = yylsp[1-yylen];
02392   /* Do not reclaim the symbols of the rule which action triggered
02393      this YYERROR.  */
02394   YYPOPSTACK (yylen);
02395   yylen = 0;
02396   YY_STACK_PRINT (yyss, yyssp);
02397   yystate = *yyssp;
02398   goto yyerrlab1;
02399 
02400 
02401 /*-------------------------------------------------------------.
02402 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
02403 `-------------------------------------------------------------*/
02404 yyerrlab1:
02405   yyerrstatus = 3;   /* Each real token shifted decrements this.  */
02406 
02407   for (;;)
02408     {
02409       yyn = yypact[yystate];
02410       if (yyn != YYPACT_NINF)
02411    {
02412      yyn += YYTERROR;
02413      if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
02414        {
02415          yyn = yytable[yyn];
02416          if (0 < yyn)
02417       break;
02418        }
02419    }
02420 
02421       /* Pop the current state because it cannot handle the error token.  */
02422       if (yyssp == yyss)
02423    YYABORT;
02424 
02425       yyerror_range[0] = *yylsp;
02426       yydestruct ("Error: popping",
02427         yystos[yystate], yyvsp, yylsp);
02428       YYPOPSTACK (1);
02429       yystate = *yyssp;
02430       YY_STACK_PRINT (yyss, yyssp);
02431     }
02432 
02433   *++yyvsp = yylval;
02434 
02435   yyerror_range[1] = yylloc;
02436   /* Using YYLLOC is tempting, but would change the location of
02437      the lookahead.  YYLOC is available though.  */
02438   YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
02439   *++yylsp = yyloc;
02440 
02441   /* Shift the error token.  */
02442   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
02443 
02444   yystate = yyn;
02445   goto yynewstate;
02446 
02447 
02448 /*-------------------------------------.
02449 | yyacceptlab -- YYACCEPT comes here.  |
02450 `-------------------------------------*/
02451 yyacceptlab:
02452   yyresult = 0;
02453   goto yyreturn;
02454 
02455 /*-----------------------------------.
02456 | yyabortlab -- YYABORT comes here.  |
02457 `-----------------------------------*/
02458 yyabortlab:
02459   yyresult = 1;
02460   goto yyreturn;
02461 
02462 #if !defined(yyoverflow) || YYERROR_VERBOSE
02463 /*-------------------------------------------------.
02464 | yyexhaustedlab -- memory exhaustion comes here.  |
02465 `-------------------------------------------------*/
02466 yyexhaustedlab:
02467   yyerror (YY_("memory exhausted"));
02468   yyresult = 2;
02469   /* Fall through.  */
02470 #endif
02471 
02472 yyreturn:
02473   if (yychar != YYEMPTY)
02474      yydestruct ("Cleanup: discarding lookahead",
02475        yytoken, &yylval, &yylloc);
02476   /* Do not reclaim the symbols of the rule which action triggered
02477      this YYABORT or YYACCEPT.  */
02478   YYPOPSTACK (yylen);
02479   YY_STACK_PRINT (yyss, yyssp);
02480   while (yyssp != yyss)
02481     {
02482       yydestruct ("Cleanup: popping",
02483         yystos[*yyssp], yyvsp, yylsp);
02484       YYPOPSTACK (1);
02485     }
02486 #ifndef yyoverflow
02487   if (yyss != yyssa)
02488     YYSTACK_FREE (yyss);
02489 #endif
02490 #if YYERROR_VERBOSE
02491   if (yymsg != yymsgbuf)
02492     YYSTACK_FREE (yymsg);
02493 #endif
02494   /* Make sure YYID is used.  */
02495   return YYID (yyresult);
02496 }

int yyparse (  ) 

static char* yystpcpy ( char *  yydest,
const char *  yysrc 
) [static]

Definition at line 1270 of file ast_expr2.c.

Referenced by yysyntax_error(), and yytnamerr().

01274 {
01275   char *yyd = yydest;
01276   const char *yys = yysrc;
01277 
01278   while ((*yyd++ = *yys++) != '\0')
01279     continue;
01280 
01281   return yyd - 1;
01282 }

static YYSIZE_T yystrlen ( char *  yystr  )  const [static]

Definition at line 1246 of file ast_expr2.c.

References YYSIZE_T.

Referenced by yysyntax_error(), and yytnamerr().

01249 {
01250   YYSIZE_T yylen;
01251   for (yylen = 0; yystr[yylen]; yylen++)
01252     continue;
01253   return yylen;
01254 }

static YYSIZE_T yysyntax_error ( char *  yyresult,
int  yystate,
int  yychar 
) [static]

Definition at line 1342 of file ast_expr2.c.

References YY_, YYLAST, YYNTOKENS, YYPACT_NINF, YYSIZE_MAXIMUM, YYSIZE_T, yystpcpy(), yystrlen(), YYTERROR, yytnamerr(), and YYTRANSLATE.

Referenced by yyparse().

01343 {
01344   int yyn = yypact[yystate];
01345 
01346   if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
01347     return 0;
01348   else
01349     {
01350       int yytype = YYTRANSLATE (yychar);
01351       YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
01352       YYSIZE_T yysize = yysize0;
01353       YYSIZE_T yysize1;
01354       int yysize_overflow = 0;
01355       enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
01356       char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
01357       int yyx;
01358 
01359 # if 0
01360       /* This is so xgettext sees the translatable formats that are
01361     constructed on the fly.  */
01362       YY_("syntax error, unexpected %s");
01363       YY_("syntax error, unexpected %s, expecting %s");
01364       YY_("syntax error, unexpected %s, expecting %s or %s");
01365       YY_("syntax error, unexpected %s, expecting %s or %s or %s");
01366       YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
01367 # endif
01368       char *yyfmt;
01369       char const *yyf;
01370       static char const yyunexpected[] = "syntax error, unexpected %s";
01371       static char const yyexpecting[] = ", expecting %s";
01372       static char const yyor[] = " or %s";
01373       char yyformat[sizeof yyunexpected
01374           + sizeof yyexpecting - 1
01375           + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
01376              * (sizeof yyor - 1))];
01377       char const *yyprefix = yyexpecting;
01378 
01379       /* Start YYX at -YYN if negative to avoid negative indexes in
01380     YYCHECK.  */
01381       int yyxbegin = yyn < 0 ? -yyn : 0;
01382 
01383       /* Stay within bounds of both yycheck and yytname.  */
01384       int yychecklim = YYLAST - yyn + 1;
01385       int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
01386       int yycount = 1;
01387 
01388       yyarg[0] = yytname[yytype];
01389       yyfmt = yystpcpy (yyformat, yyunexpected);
01390 
01391       for (yyx = yyxbegin; yyx < yyxend; ++yyx)
01392    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
01393      {
01394        if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
01395          {
01396       yycount = 1;
01397       yysize = yysize0;
01398       yyformat[sizeof yyunexpected - 1] = '\0';
01399       break;
01400          }
01401        yyarg[yycount++] = yytname[yyx];
01402        yysize1 = yysize + yytnamerr (0, yytname[yyx]);
01403        yysize_overflow |= (yysize1 < yysize);
01404        yysize = yysize1;
01405        yyfmt = yystpcpy (yyfmt, yyprefix);
01406        yyprefix = yyor;
01407      }
01408 
01409       yyf = YY_(yyformat);
01410       yysize1 = yysize + yystrlen (yyf);
01411       yysize_overflow |= (yysize1 < yysize);
01412       yysize = yysize1;
01413 
01414       if (yysize_overflow)
01415    return YYSIZE_MAXIMUM;
01416 
01417       if (yyresult)
01418    {
01419      /* Avoid sprintf, as that infringes on the user's name space.
01420         Don't have undefined behavior even if the translation
01421         produced a string with the wrong number of "%s"s.  */
01422      char *yyp = yyresult;
01423      int yyi = 0;
01424      while ((*yyp = *yyf) != '\0')
01425        {
01426          if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
01427       {
01428         yyp += yytnamerr (yyp, yyarg[yyi++]);
01429         yyf += 2;
01430       }
01431          else
01432       {
01433         yyp++;
01434         yyf++;
01435       }
01436        }
01437    }
01438       return yysize;
01439     }
01440 }

static YYSIZE_T yytnamerr ( char *  yyres,
const char *  yystr 
) [static]

Definition at line 1295 of file ast_expr2.c.

References YYSIZE_T, yystpcpy(), and yystrlen().

Referenced by yysyntax_error().

01296 {
01297   if (*yystr == '"')
01298     {
01299       YYSIZE_T yyn = 0;
01300       char const *yyp = yystr;
01301 
01302       for (;;)
01303    switch (*++yyp)
01304      {
01305      case '\'':
01306      case ',':
01307        goto do_not_strip_quotes;
01308 
01309      case '\\':
01310        if (*++yyp != '\\')
01311          goto do_not_strip_quotes;
01312        /* Fall through.  */
01313      default:
01314        if (yyres)
01315          yyres[yyn] = *yyp;
01316        yyn++;
01317        break;
01318 
01319      case '"':
01320        if (yyres)
01321          yyres[yyn] = '\0';
01322        return yyn;
01323      }
01324     do_not_strip_quotes: ;
01325     }
01326 
01327   if (! yyres)
01328     return yystrlen (yystr);
01329 
01330   return yystpcpy (yyres, yystr) - yyres;
01331 }


Variable Documentation

char extra_error_message[4095]

Definition at line 2460 of file ast_expr2f.c.

int extra_error_message_supplied

Definition at line 2461 of file ast_expr2f.c.

const yytype_int8 yycheck[] [static]

Definition at line 923 of file ast_expr2.c.

const yytype_uint8 yydefact[] [static]

Definition at line 863 of file ast_expr2.c.

const yytype_int8 yydefgoto[] [static]

Initial value:

{
      -1,     5,    30,     6
}

Definition at line 874 of file ast_expr2.c.

const yytype_int16 yypact[] [static]

Definition at line 882 of file ast_expr2.c.

const yytype_int8 yypgoto[] [static]

Initial value:

{
     -18,   -18,   -18,    -1
}

Definition at line 893 of file ast_expr2.c.

const yytype_uint8 yyr1[] [static]

Definition at line 845 of file ast_expr2.c.

const yytype_uint8 yyr2[] [static]

Definition at line 853 of file ast_expr2.c.

const yytype_uint8 yystos[] [static]

Definition at line 945 of file ast_expr2.c.

const yytype_uint8 yytable[] [static]

Definition at line 903 of file ast_expr2.c.

const char* const yytname[] [static]

Definition at line 823 of file ast_expr2.c.

const yytype_uint8 yytranslate[] [static]

Definition at line 752 of file ast_expr2.c.


Generated on Mon Jun 27 16:51:02 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7