Asterisk - The Open Source Telephony Project GIT-master-d5a0626
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
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"
Include dependency graph for ast_expr2.c:

Go to the source code of this file.

Data Structures

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

Macros

#define ast_yyerror(x)   ast_yyerror(x,&yyloc,parseio)
 
#define ast_yyerror(x)   ast_yyerror(x, YYLTYPE *yylloc, struct parse_io *parseio)
 
#define ASTMM_LIBC   ASTMM_REDIRECT
 
#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   ast_yydebug
 
#define YYDEBUG   0
 
#define YYDPRINTF(Args)
 
#define YYEMPTY   (-2)
 
#define YYENABLE_NLS   0
 
#define YYEOF   0
 
#define YYERRCODE   256
 
#define yyerrok   (yyerrstatus = 0)
 
#define yyerror   ast_yyerror
 
#define YYERROR   goto yyerrorlab
 
#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   ast_yylex
 
#define YYLEX   yylex (&yylval, &yylloc, YYLEX_PARAM)
 
#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 /* obsolescent; will be withdrawn */
 
#define YYSTYPE_IS_DECLARED   1
 
#define YYSTYPE_IS_TRIVIAL   1
 
#define YYTABLE_NINF   -1
 
#define YYTERROR   1
 
#define YYTOKEN_TABLE   0
 
#define YYTOKENTYPE
 
#define YYTRANSLATE(YYX)    ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
 
#define YYUNDEFTOK   2
 
#define YYUSE(e)   ((void) (e))
 

Typedefs

typedef struct yyltype yyltype
 
typedef void * yyscan_t
 
typedef union YYSTYPE YYSTYPE
 
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 , 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 , 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 , KW_CONTEXT = 258 , LC = 259 ,
  RC = 260 , LP = 261 , RP = 262 , SEMI = 263 ,
  EQ = 264 , COMMA = 265 , COLON = 266 , AMPER = 267 ,
  BAR = 268 , AT = 269 , KW_MACRO = 270 , KW_GLOBALS = 271 ,
  KW_IGNOREPAT = 272 , KW_SWITCH = 273 , KW_IF = 274 , KW_IFTIME = 275 ,
  KW_ELSE = 276 , KW_RANDOM = 277 , KW_ABSTRACT = 278 , KW_EXTEND = 279 ,
  EXTENMARK = 280 , KW_GOTO = 281 , KW_JUMP = 282 , KW_RETURN = 283 ,
  KW_BREAK = 284 , KW_CONTINUE = 285 , KW_REGEXTEN = 286 , KW_HINT = 287 ,
  KW_FOR = 288 , KW_WHILE = 289 , KW_CASE = 290 , KW_PATTERN = 291 ,
  KW_DEFAULT = 292 , KW_CATCH = 293 , KW_SWITCHES = 294 , KW_ESWITCHES = 295 ,
  KW_INCLUDES = 296 , KW_LOCAL = 297 , word = 298 , KW_CONTEXT = 258 ,
  LC = 259 , RC = 260 , LP = 261 , RP = 262 ,
  SEMI = 263 , EQ = 264 , COMMA = 265 , COLON = 266 ,
  AMPER = 267 , BAR = 268 , AT = 269 , KW_MACRO = 270 ,
  KW_GLOBALS = 271 , KW_IGNOREPAT = 272 , KW_SWITCH = 273 , KW_IF = 274 ,
  KW_IFTIME = 275 , KW_ELSE = 276 , KW_RANDOM = 277 , KW_ABSTRACT = 278 ,
  KW_EXTEND = 279 , EXTENMARK = 280 , KW_GOTO = 281 , KW_JUMP = 282 ,
  KW_RETURN = 283 , KW_BREAK = 284 , KW_CONTINUE = 285 , KW_REGEXTEN = 286 ,
  KW_HINT = 287 , KW_FOR = 288 , KW_WHILE = 289 , KW_CASE = 290 ,
  KW_PATTERN = 291 , KW_DEFAULT = 292 , KW_CATCH = 293 , KW_SWITCHES = 294 ,
  KW_ESWITCHES = 295 , KW_INCLUDES = 296 , KW_LOCAL = 297 , word = 298
}
 

Functions

static struct val *make_str __P ((const char *))
 
static struct val *make_number __P ((FP___TYPE))
 
static int chk_div __P ((FP___TYPE, FP___TYPE))
 
static int chk_minus __P ((FP___TYPE, FP___TYPE, FP___TYPE))
 
static void free_value __P ((struct val *))
 
static struct val *op_and __P ((struct val *, struct val *))
 
static struct val *op_cond __P ((struct val *, struct val *, struct val *))
 
int ast_yylex __P ((YYSTYPE *, YYLTYPE *, yyscan_t))
 
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)
 
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 []
 

Macro Definition Documentation

◆ ast_yyerror [1/2]

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

Definition at line 2723 of file ast_expr2.c.

◆ ast_yyerror [2/2]

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

Definition at line 2723 of file ast_expr2.c.

◆ ASTMM_LIBC

#define ASTMM_LIBC   ASTMM_REDIRECT

Definition at line 94 of file ast_expr2.c.

◆ DESTROY

#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);}

Definition at line 412 of file ast_expr2.c.

◆ FP___PRINTF

#define FP___PRINTF   "%.16g"

Definition at line 110 of file ast_expr2.c.

◆ FP___TYPE

#define FP___TYPE   double

Definition at line 111 of file ast_expr2.c.

◆ FUNC_ACOS

#define FUNC_ACOS   acosl

Definition at line 133 of file ast_expr2.c.

◆ FUNC_ASIN

#define FUNC_ASIN   asinl

Definition at line 139 of file ast_expr2.c.

◆ FUNC_ATAN

#define FUNC_ATAN   atanl

Definition at line 145 of file ast_expr2.c.

◆ FUNC_ATAN2

#define FUNC_ATAN2   atan2l

Definition at line 151 of file ast_expr2.c.

◆ FUNC_CEIL

#define FUNC_CEIL   ceill

Definition at line 211 of file ast_expr2.c.

◆ FUNC_COS

#define FUNC_COS   cosl

Definition at line 115 of file ast_expr2.c.

◆ FUNC_EXP

#define FUNC_EXP   expl

Definition at line 175 of file ast_expr2.c.

◆ FUNC_EXP10

#define FUNC_EXP10   exp10l

Definition at line 241 of file ast_expr2.c.

◆ FUNC_EXP2

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

◆ FUNC_FLOOR

#define FUNC_FLOOR   floorl

Definition at line 205 of file ast_expr2.c.

◆ FUNC_FMOD

#define FUNC_FMOD   fmodl

Definition at line 193 of file ast_expr2.c.

◆ FUNC_LOG

#define FUNC_LOG   logl

Definition at line 181 of file ast_expr2.c.

◆ FUNC_LOG10

#define FUNC_LOG10   log10l

Definition at line 261 of file ast_expr2.c.

◆ FUNC_LOG2

#define FUNC_LOG2   log2l

Definition at line 249 of file ast_expr2.c.

◆ FUNC_POW

#define FUNC_POW   powl

Definition at line 157 of file ast_expr2.c.

◆ FUNC_REMAINDER

#define FUNC_REMAINDER   remainderl

Definition at line 187 of file ast_expr2.c.

◆ FUNC_RINT

#define FUNC_RINT   rintl

Definition at line 169 of file ast_expr2.c.

◆ FUNC_ROUND

#define FUNC_ROUND   roundl

Definition at line 217 of file ast_expr2.c.

◆ FUNC_SIN

#define FUNC_SIN   sinl

Definition at line 121 of file ast_expr2.c.

◆ FUNC_SQRT

#define FUNC_SQRT   sqrtl

Definition at line 163 of file ast_expr2.c.

◆ FUNC_STRTOD

#define FUNC_STRTOD   strtold

Definition at line 199 of file ast_expr2.c.

◆ FUNC_TAN

#define FUNC_TAN   tanl

Definition at line 127 of file ast_expr2.c.

◆ FUNC_TRUNC

#define FUNC_TRUNC   truncl

Definition at line 223 of file ast_expr2.c.

◆ QUAD_MAX

#define QUAD_MAX   (0x7fffffffffffffffLL)

Definition at line 308 of file ast_expr2.c.

◆ QUAD_MIN

#define QUAD_MIN   (-0x7fffffffffffffffLL-1)

Definition at line 305 of file ast_expr2.c.

◆ YY_

#define YY_ (   msgid)    msgid

Definition at line 571 of file ast_expr2.c.

◆ YY_LOCATION_PRINT

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

◆ YY_REDUCE_PRINT

#define YY_REDUCE_PRINT (   Rule)

Definition at line 1209 of file ast_expr2.c.

◆ YY_STACK_PRINT

#define YY_STACK_PRINT (   Bottom,
  Top 
)

Definition at line 1208 of file ast_expr2.c.

◆ YY_SYMBOL_PRINT

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

Definition at line 1207 of file ast_expr2.c.

◆ YYABORT

#define YYABORT   goto yyabortlab

Definition at line 959 of file ast_expr2.c.

◆ YYACCEPT

#define YYACCEPT   goto yyacceptlab

Definition at line 958 of file ast_expr2.c.

◆ YYBACKUP

#define YYBACKUP (   Token,
  Value 
)

Definition at line 971 of file ast_expr2.c.

◆ YYBISON

#define YYBISON   1

Definition at line 46 of file ast_expr2.c.

◆ YYBISON_VERSION

#define YYBISON_VERSION   "2.4.1"

Definition at line 49 of file ast_expr2.c.

◆ yychar

#define yychar   ast_yychar

Definition at line 71 of file ast_expr2.c.

◆ yyclearin

#define yyclearin   (yychar = YYEMPTY)

Definition at line 954 of file ast_expr2.c.

◆ YYCOPY

#define YYCOPY (   To,
  From,
  Count 
)

Definition at line 699 of file ast_expr2.c.

◆ yydebug

#define yydebug   ast_yydebug

Definition at line 72 of file ast_expr2.c.

◆ YYDEBUG

#define YYDEBUG   0

Definition at line 420 of file ast_expr2.c.

◆ YYDPRINTF

#define YYDPRINTF (   Args)

Definition at line 1206 of file ast_expr2.c.

◆ YYEMPTY

#define YYEMPTY   (-2)

Definition at line 955 of file ast_expr2.c.

◆ YYENABLE_NLS

#define YYENABLE_NLS   0

Definition at line 310 of file ast_expr2.c.

◆ YYEOF

#define YYEOF   0

Definition at line 956 of file ast_expr2.c.

◆ YYERRCODE

#define YYERRCODE   256

Definition at line 990 of file ast_expr2.c.

◆ yyerrok

#define yyerrok   (yyerrstatus = 0)

Definition at line 953 of file ast_expr2.c.

◆ yyerror

#define yyerror   ast_yyerror

Definition at line 69 of file ast_expr2.c.

◆ YYERROR

#define YYERROR   goto yyerrorlab

Definition at line 960 of file ast_expr2.c.

◆ YYERROR_VERBOSE [1/2]

#define YYERROR_VERBOSE   1

Definition at line 426 of file ast_expr2.c.

◆ YYERROR_VERBOSE [2/2]

#define YYERROR_VERBOSE   1

Definition at line 426 of file ast_expr2.c.

◆ YYFAIL

#define YYFAIL   goto yyerrlab

Definition at line 967 of file ast_expr2.c.

◆ YYFINAL

#define YYFINAL   11

Definition at line 729 of file ast_expr2.c.

◆ YYFREE

#define YYFREE   free

Definition at line 660 of file ast_expr2.c.

◆ YYID

#define YYID (   n)    (n)

Definition at line 584 of file ast_expr2.c.

◆ YYINITDEPTH

#define YYINITDEPTH   200

Definition at line 1215 of file ast_expr2.c.

◆ YYLAST

#define YYLAST   159

Definition at line 731 of file ast_expr2.c.

◆ yylex

#define yylex   ast_yylex

Definition at line 68 of file ast_expr2.c.

◆ YYLEX

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

Definition at line 1038 of file ast_expr2.c.

◆ YYLEX_PARAM

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

Definition at line 312 of file ast_expr2.c.

◆ yylloc

#define yylloc   ast_yylloc

Definition at line 74 of file ast_expr2.c.

◆ YYLLOC_DEFAULT

#define YYLLOC_DEFAULT (   Current,
  Rhs,
 
)

Definition at line 999 of file ast_expr2.c.

◆ YYLSP_NEEDED

#define YYLSP_NEEDED   1

Definition at line 64 of file ast_expr2.c.

◆ YYLTYPE

#define YYLTYPE   yyltype

Definition at line 400 of file ast_expr2.c.

◆ YYLTYPE_IS_TRIVIAL

#define YYLTYPE_IS_TRIVIAL   1

Definition at line 401 of file ast_expr2.c.

◆ yylval

#define yylval   ast_yylval

Definition at line 70 of file ast_expr2.c.

◆ YYMALLOC

#define YYMALLOC   malloc

Definition at line 653 of file ast_expr2.c.

◆ YYMAXDEPTH

#define YYMAXDEPTH   10000

Definition at line 1226 of file ast_expr2.c.

◆ YYMAXUTOK

#define YYMAXUTOK   280

Definition at line 744 of file ast_expr2.c.

◆ yynerrs

#define yynerrs   ast_yynerrs

Definition at line 73 of file ast_expr2.c.

◆ YYNNTS

#define YYNNTS   4

Definition at line 736 of file ast_expr2.c.

◆ YYNRULES

#define YYNRULES   28

Definition at line 738 of file ast_expr2.c.

◆ YYNSTATES

#define YYNSTATES   54

Definition at line 740 of file ast_expr2.c.

◆ YYNTOKENS

#define YYNTOKENS   26

Definition at line 734 of file ast_expr2.c.

◆ YYPACT_NINF

#define YYPACT_NINF   -18

Definition at line 879 of file ast_expr2.c.

◆ yyparse

int yyparse   ast_yyparse

Definition at line 67 of file ast_expr2.c.

◆ YYPARSE_PARAM

#define YYPARSE_PARAM   parseio

Definition at line 311 of file ast_expr2.c.

◆ YYPOPSTACK

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

◆ YYPULL

#define YYPULL   1

Definition at line 61 of file ast_expr2.c.

◆ YYPURE

#define YYPURE   1

Definition at line 55 of file ast_expr2.c.

◆ YYPUSH

#define YYPUSH   0

Definition at line 58 of file ast_expr2.c.

◆ YYRECOVERING

#define YYRECOVERING ( )    (!!yyerrstatus)

Definition at line 969 of file ast_expr2.c.

◆ YYRHSLOC

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

Definition at line 997 of file ast_expr2.c.

◆ YYSIZE_MAXIMUM

#define YYSIZE_MAXIMUM   ((YYSIZE_T) -1)

Definition at line 561 of file ast_expr2.c.

◆ YYSIZE_T

#define YYSIZE_T   unsigned int

Definition at line 557 of file ast_expr2.c.

◆ YYSKELETON_NAME

#define YYSKELETON_NAME   "yacc.c"

Definition at line 52 of file ast_expr2.c.

◆ YYSTACK_ALLOC

#define YYSTACK_ALLOC   YYMALLOC

Definition at line 639 of file ast_expr2.c.

◆ YYSTACK_ALLOC_MAXIMUM

#define YYSTACK_ALLOC_MAXIMUM   YYSIZE_MAXIMUM

Definition at line 642 of file ast_expr2.c.

◆ YYSTACK_BYTES

#define YYSTACK_BYTES (   N)
Value:
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
union YYSTYPE YYSTYPE
short int yytype_int16
Definition: ast_expr2.c:544
#define YYSTACK_GAP_MAXIMUM
Definition: ast_expr2.c:684

Definition at line 688 of file ast_expr2.c.

◆ YYSTACK_FREE

#define YYSTACK_FREE   YYFREE

Definition at line 640 of file ast_expr2.c.

◆ YYSTACK_GAP_MAXIMUM

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

Definition at line 684 of file ast_expr2.c.

◆ YYSTACK_RELOCATE

#define YYSTACK_RELOCATE (   Stack_alloc,
  Stack 
)

Definition at line 715 of file ast_expr2.c.

◆ yystype

#define yystype   YYSTYPE /* obsolescent; will be withdrawn */

Definition at line 487 of file ast_expr2.c.

◆ YYSTYPE_IS_DECLARED

#define YYSTYPE_IS_DECLARED   1

Definition at line 488 of file ast_expr2.c.

◆ YYSTYPE_IS_TRIVIAL

#define YYSTYPE_IS_TRIVIAL   1

Definition at line 486 of file ast_expr2.c.

◆ YYTABLE_NINF

#define YYTABLE_NINF   -1

Definition at line 900 of file ast_expr2.c.

◆ YYTERROR

#define YYTERROR   1

Definition at line 989 of file ast_expr2.c.

◆ YYTOKEN_TABLE

#define YYTOKEN_TABLE   0

Definition at line 433 of file ast_expr2.c.

◆ YYTOKENTYPE

#define YYTOKENTYPE

Definition at line 439 of file ast_expr2.c.

◆ YYTRANSLATE

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

Definition at line 746 of file ast_expr2.c.

◆ YYUNDEFTOK

#define YYUNDEFTOK   2

Definition at line 743 of file ast_expr2.c.

◆ YYUSE

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

Definition at line 577 of file ast_expr2.c.

Typedef Documentation

◆ yyltype

typedef struct yyltype yyltype

◆ yyscan_t

typedef void* yyscan_t

Definition at line 346 of file ast_expr2.c.

◆ YYSTYPE

typedef union YYSTYPE YYSTYPE

◆ yytype_int16

typedef short int yytype_int16

Definition at line 544 of file ast_expr2.c.

◆ yytype_int8

typedef short int yytype_int8

Definition at line 532 of file ast_expr2.c.

◆ yytype_uint16

typedef unsigned short int yytype_uint16

Definition at line 538 of file ast_expr2.c.

◆ yytype_uint8

typedef unsigned char yytype_uint8

Definition at line 523 of file ast_expr2.c.

Enumeration Type Documentation

◆ node_type

enum node_type
Enumerator
AST_EXPR_NODE_COMMA 
AST_EXPR_NODE_STRING 
AST_EXPR_NODE_VAL 

Definition at line 333 of file ast_expr2.c.

333 {
335} ;
@ AST_EXPR_NODE_STRING
Definition: ast_expr2.c:334
@ AST_EXPR_NODE_VAL
Definition: ast_expr2.c:334
@ AST_EXPR_NODE_COMMA
Definition: ast_expr2.c:334

◆ valtype

enum valtype
Enumerator
AST_EXPR_number 
AST_EXPR_numeric_string 
AST_EXPR_string 
AST_EXPR_number 
AST_EXPR_numeric_string 
AST_EXPR_string 

Definition at line 317 of file ast_expr2.c.

317 {
319} ;
@ AST_EXPR_string
Definition: ast_expr2.c:318
@ AST_EXPR_numeric_string
Definition: ast_expr2.c:318
@ AST_EXPR_number
Definition: ast_expr2.c:318

◆ 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 
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 
KW_CONTEXT 
LC 
RC 
LP 
RP 
SEMI 
EQ 
COMMA 
COLON 
AMPER 
BAR 
AT 
KW_MACRO 
KW_GLOBALS 
KW_IGNOREPAT 
KW_SWITCH 
KW_IF 
KW_IFTIME 
KW_ELSE 
KW_RANDOM 
KW_ABSTRACT 
KW_EXTEND 
EXTENMARK 
KW_GOTO 
KW_JUMP 
KW_RETURN 
KW_BREAK 
KW_CONTINUE 
KW_REGEXTEN 
KW_HINT 
KW_FOR 
KW_WHILE 
KW_CASE 
KW_PATTERN 
KW_DEFAULT 
KW_CATCH 
KW_SWITCHES 
KW_ESWITCHES 
KW_INCLUDES 
KW_LOCAL 
word 
KW_CONTEXT 
LC 
RC 
LP 
RP 
SEMI 
EQ 
COMMA 
COLON 
AMPER 
BAR 
AT 
KW_MACRO 
KW_GLOBALS 
KW_IGNOREPAT 
KW_SWITCH 
KW_IF 
KW_IFTIME 
KW_ELSE 
KW_RANDOM 
KW_ABSTRACT 
KW_EXTEND 
EXTENMARK 
KW_GOTO 
KW_JUMP 
KW_RETURN 
KW_BREAK 
KW_CONTINUE 
KW_REGEXTEN 
KW_HINT 
KW_FOR 
KW_WHILE 
KW_CASE 
KW_PATTERN 
KW_DEFAULT 
KW_CATCH 
KW_SWITCHES 
KW_ESWITCHES 
KW_INCLUDES 
KW_LOCAL 
word 

Definition at line 442 of file ast_expr2.c.

442 {
443 TOK_COMMA = 258,
444 TOK_COLONCOLON = 259,
445 TOK_COND = 260,
446 TOK_OR = 261,
447 TOK_AND = 262,
448 TOK_NE = 263,
449 TOK_LE = 264,
450 TOK_GE = 265,
451 TOK_LT = 266,
452 TOK_GT = 267,
453 TOK_EQ = 268,
454 TOK_MINUS = 269,
455 TOK_PLUS = 270,
456 TOK_MOD = 271,
457 TOK_DIV = 272,
458 TOK_MULT = 273,
459 TOK_COMPL = 274,
460 TOK_TILDETILDE = 275,
461 TOK_EQTILDE = 276,
462 TOK_COLON = 277,
463 TOK_LP = 278,
464 TOK_RP = 279,
465 TOKEN = 280
466 };
@ TOK_COLONCOLON
Definition: ast_expr2.c:444
@ TOK_TILDETILDE
Definition: ast_expr2.c:460
@ TOK_EQTILDE
Definition: ast_expr2.c:461
@ TOKEN
Definition: ast_expr2.c:465
@ TOK_LE
Definition: ast_expr2.c:449
@ TOK_COLON
Definition: ast_expr2.c:462
@ TOK_GT
Definition: ast_expr2.c:452
@ TOK_PLUS
Definition: ast_expr2.c:455
@ TOK_NE
Definition: ast_expr2.c:448
@ TOK_EQ
Definition: ast_expr2.c:453
@ TOK_LP
Definition: ast_expr2.c:463
@ TOK_COMMA
Definition: ast_expr2.c:443
@ TOK_DIV
Definition: ast_expr2.c:457
@ TOK_GE
Definition: ast_expr2.c:450
@ TOK_OR
Definition: ast_expr2.c:446
@ TOK_LT
Definition: ast_expr2.c:451
@ TOK_COND
Definition: ast_expr2.c:445
@ TOK_COMPL
Definition: ast_expr2.c:459
@ TOK_MINUS
Definition: ast_expr2.c:454
@ TOK_AND
Definition: ast_expr2.c:447
@ TOK_RP
Definition: ast_expr2.c:464
@ TOK_MOD
Definition: ast_expr2.c:456
@ TOK_MULT
Definition: ast_expr2.c:458

Function Documentation

◆ __P() [1/8]

static struct val *make_str __P ( (const char *)  )
static

◆ __P() [2/8]

static struct val *make_number __P ( (FP___TYPE )
static

◆ __P() [3/8]

static int chk_div __P ( (FP___TYPE, FP___TYPE )
static

◆ __P() [4/8]

static int chk_times __P ( (FP___TYPE, FP___TYPE, FP___TYPE )
static

◆ __P() [5/8]

static void to_string __P ( (struct val *)  )
static

◆ __P() [6/8]

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

◆ __P() [7/8]

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

◆ __P() [8/8]

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

◆ alloc_expr_node()

static struct expr_node * alloc_expr_node ( enum node_type  nt)
static

Definition at line 2502 of file ast_expr2.c.

2503{
2504 struct expr_node *x = calloc(1,sizeof(struct expr_node));
2505 if (!x) {
2506 ast_log(LOG_ERROR, "Allocation for expr_node FAILED!!\n");
2507 return 0;
2508 }
2509 x->type = nt;
2510 return x;
2511}
#define calloc(a, b)
Definition: astmm.h:155
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
enum node_type type
Definition: ast_expr2.c:339

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

Referenced by yyparse().

◆ ast_yyerror()

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

◆ chk_div()

static int chk_div ( FP___TYPE  a,
FP___TYPE  b 
)
static

Definition at line 3481 of file ast_expr2.c.

3482{
3483 /* div by zero has been taken care of before */
3484 /* only QUAD_MIN / -1 causes overflow */
3485 if (a == QUAD_MIN && b == -1)
3486 return 1;
3487 /* everything else is OK */
3488 return 0;
3489}
#define QUAD_MIN
Definition: ast_expr2.c:305
static struct test_val b
static struct test_val a

References a, b, and QUAD_MIN.

Referenced by op_div().

◆ chk_minus()

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

Definition at line 3325 of file ast_expr2.c.

3326{
3327 /* special case subtraction of QUAD_MIN */
3328 if (b == QUAD_MIN) {
3329 if (a >= 0)
3330 return 1;
3331 else
3332 return 0;
3333 }
3334 /* this is allowed for b != QUAD_MIN */
3335 return chk_plus (a, -b, r);
3336}
static int chk_plus(FP___TYPE a, FP___TYPE b, FP___TYPE r)
Definition: ast_expr2.c:3282

References a, b, chk_plus(), and QUAD_MIN.

Referenced by op_minus(), and op_negate().

◆ chk_plus()

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

Definition at line 3282 of file ast_expr2.c.

3283{
3284 /* sum of two positive numbers must be positive */
3285 if (a > 0 && b > 0 && r <= 0)
3286 return 1;
3287 /* sum of two negative numbers must be negative */
3288 if (a < 0 && b < 0 && r >= 0)
3289 return 1;
3290 /* all other cases are OK */
3291 return 0;
3292}

References a, and b.

Referenced by chk_minus(), and op_plus().

◆ chk_times()

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

Definition at line 3447 of file ast_expr2.c.

3448{
3449 /* special case: first operand is 0, no overflow possible */
3450 if (a == 0)
3451 return 0;
3452 /* cerify that result of division matches second operand */
3453 if (r / a != b)
3454 return 1;
3455 return 0;
3456}

References a, and b.

Referenced by op_times().

◆ compose_func_args()

static char * compose_func_args ( struct expr_node arglist)
static

Definition at line 2747 of file ast_expr2.c.

2748{
2749 struct expr_node *t = arglist;
2750 char *argbuf;
2751 int total_len = 0;
2752
2753 while (t) {
2754 if (t != arglist)
2755 total_len += 1; /* for the sep */
2756 if (t->val) {
2757 if (t->val->type == AST_EXPR_number)
2758 total_len += 25; /* worst case */
2759 else
2760 total_len += strlen(t->val->u.s);
2761 }
2762
2763 t = t->right;
2764 }
2765 total_len++; /* for the null */
2766 ast_log(LOG_NOTICE,"argbuf allocated %d bytes;\n", total_len);
2767 argbuf = malloc(total_len);
2768 argbuf[0] = 0;
2769 t = arglist;
2770 while (t) {
2771 char numbuf[30];
2772
2773 if (t != arglist)
2774 strcat(argbuf,",");
2775
2776 if (t->val) {
2777 if (t->val->type == AST_EXPR_number) {
2778 sprintf(numbuf,FP___PRINTF,t->val->u.i);
2779 strcat(argbuf,numbuf);
2780 } else
2781 strcat(argbuf,t->val->u.s);
2782 }
2783 t = t->right;
2784 }
2785 ast_log(LOG_NOTICE,"argbuf uses %d bytes;\n", (int) strlen(argbuf));
2786 return argbuf;
2787}
#define FP___PRINTF
Definition: ast_expr2.c:110
char * malloc()
#define LOG_NOTICE
struct expr_node * right
Definition: ast_expr2.c:342
struct val * val
Definition: ast_expr2.c:340
FP___TYPE i
Definition: ast_expr2.c:329
char * s
Definition: ast_expr2.c:328
enum valtype type
Definition: ast_expr2.c:326
union val::@295 u

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().

◆ destroy_arglist()

static void destroy_arglist ( struct expr_node arglist)
static

Definition at line 2730 of file ast_expr2.c.

2731{
2732 struct expr_node *arglist_next;
2733
2734 while (arglist)
2735 {
2736 arglist_next = arglist->right;
2737 if (arglist->val)
2738 free_value(arglist->val);
2739 arglist->val = 0;
2740 arglist->right = 0;
2741 free(arglist);
2742 arglist = arglist_next;
2743 }
2744}
static void free_value(struct val *vp)
Definition: ast_expr2.c:2564
void free()

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

Referenced by yyparse().

◆ free_value()

static void free_value ( struct val vp)
static

Definition at line 2564 of file ast_expr2.c.

2565{
2566 if (vp==NULL) {
2567 return;
2568 }
2569 if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
2570 free (vp->u.s);
2571 free(vp);
2572}
#define NULL
Definition: resample.c:96

References AST_EXPR_numeric_string, AST_EXPR_string, free(), NULL, 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().

◆ is_really_num()

static int is_really_num ( char *  str)
static

Definition at line 2789 of file ast_expr2.c.

2790{
2791 if ( strspn(str,"-0123456789. ") == strlen(str))
2792 return 1;
2793 else
2794 return 0;
2795}
const char * str
Definition: app_jack.c:147

References str.

Referenced by op_func().

◆ is_zero_or_null()

static int is_zero_or_null ( struct val vp)
static

Definition at line 2656 of file ast_expr2.c.

2657{
2658 if (vp->type == AST_EXPR_number) {
2659 return (vp->u.i == 0);
2660 } else {
2661 return (*vp->u.s == 0 || (to_number(vp) && vp->u.i == 0));
2662 }
2663 /* NOTREACHED */
2664}
static int to_number(struct val *vp)
Definition: ast_expr2.c:2576

References AST_EXPR_number, val::i, val::s, to_number(), val::type, and val::u.

Referenced by op_and(), and op_or().

◆ isstring()

static int isstring ( struct val vp)
static

Definition at line 2648 of file ast_expr2.c.

2649{
2650 /* only TRUE if this string is not a valid number */
2651 return (vp->type == AST_EXPR_string);
2652}

References AST_EXPR_string, and val::type.

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

◆ make_number()

static struct val * make_number ( FP___TYPE  i)
static

Definition at line 2516 of file ast_expr2.c.

2517{
2518 struct val *vp;
2519
2520 vp = (struct val *) malloc (sizeof (*vp));
2521 if (vp == NULL) {
2522 ast_log(LOG_WARNING, "malloc() failed\n");
2523 return(NULL);
2524 }
2525
2526 vp->type = AST_EXPR_number;
2527 vp->u.i = i;
2528 return vp;
2529}
#define LOG_WARNING
Definition: ast_expr2.c:325

References AST_EXPR_number, ast_log, val::i, LOG_WARNING, malloc(), NULL, val::type, and val::u.

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().

◆ make_str()

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

Definition at line 2532 of file ast_expr2.c.

2533{
2534 struct val *vp;
2535 size_t i;
2536 int isint; /* this started out being a test for an integer, but then ended up being a test for a float */
2537
2538 vp = (struct val *) malloc (sizeof (*vp));
2539 if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) {
2540 if (vp) {
2541 free(vp);
2542 }
2543 ast_log(LOG_WARNING,"malloc() failed\n");
2544 return(NULL);
2545 }
2546
2547 for (i = 0, isint = (isdigit(s[0]) || s[0] == '-' || s[0]=='.'); isint && i < strlen(s); i++)
2548 {
2549 if (!isdigit(s[i]) && s[i] != '.') {
2550 isint = 0;
2551 break;
2552 }
2553 }
2554 if (isint)
2556 else
2557 vp->type = AST_EXPR_string;
2558
2559 return vp;
2560}
#define strdup(a)
Definition: astmm.h:163

References AST_EXPR_numeric_string, AST_EXPR_string, ast_log, free(), val::i, LOG_WARNING, malloc(), NULL, val::s, strdup, val::type, and val::u.

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

◆ op_and()

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

Definition at line 3103 of file ast_expr2.c.

3104{
3105 if (is_zero_or_null (a) || is_zero_or_null (b)) {
3106 free_value (a);
3107 free_value (b);
3108 return (make_number ((FP___TYPE)0.0));
3109 } else {
3110 free_value (b);
3111 return (a);
3112 }
3113}
static int is_zero_or_null(struct val *vp)
Definition: ast_expr2.c:2656
static struct val * make_number(FP___TYPE i)
Definition: ast_expr2.c:2516
#define FP___TYPE
Definition: ast_expr2.c:111

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

Referenced by yyparse().

◆ op_colon()

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

Definition at line 3554 of file ast_expr2.c.

3555{
3556 regex_t rp;
3557 regmatch_t rm[2];
3558 char errbuf[256];
3559 int eval;
3560 struct val *v;
3561
3562 /* coerce to both arguments to strings */
3563 to_string(a);
3564 to_string(b);
3565 /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */
3566 strip_quotes(a);
3567 strip_quotes(b);
3568 /* compile regular expression */
3569 if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) {
3570 regerror (eval, &rp, errbuf, sizeof(errbuf));
3571 ast_log(LOG_WARNING, "regcomp() error : %s\n", errbuf);
3572 free_value(a);
3573 free_value(b);
3574 return make_str("");
3575 }
3576
3577 /* compare string against pattern */
3578 /* remember that patterns are anchored to the beginning of the line */
3579 if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 && rm[0].rm_so == 0) {
3580 if (rm[1].rm_so >= 0) {
3581 *(a->u.s + rm[1].rm_eo) = '\0';
3582 v = make_str (a->u.s + rm[1].rm_so);
3583
3584 } else {
3585 v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so));
3586 }
3587 } else {
3588 if (rp.re_nsub == 0) {
3589 v = make_number ((FP___TYPE)0);
3590 } else {
3591 v = make_str ("");
3592 }
3593 }
3594
3595 /* free arguments and pattern buffer */
3596 free_value (a);
3597 free_value (b);
3598 regfree (&rp);
3599
3600 return v;
3601}
static void to_string(struct val *vp)
Definition: ast_expr2.c:2630
static void strip_quotes(struct val *vp)
Definition: ast_expr2.c:2607
static struct val * make_str(const char *s)
Definition: ast_expr2.c:2532

References a, ast_log, b, FP___TYPE, free_value(), LOG_WARNING, make_number(), make_str(), strip_quotes(), and to_string().

Referenced by yyparse().

◆ op_compl()

static struct val * op_compl ( struct val a)
static

Definition at line 3393 of file ast_expr2.c.

3394{
3395 int v1 = 1;
3396 struct val *r;
3397
3398 if( !a )
3399 {
3400 v1 = 0;
3401 }
3402 else
3403 {
3404 switch( a->type )
3405 {
3406 case AST_EXPR_number:
3407 if( a->u.i == 0 )
3408 v1 = 0;
3409 break;
3410
3411 case AST_EXPR_string:
3412 if( a->u.s == 0 )
3413 v1 = 0;
3414 else
3415 {
3416 if( a->u.s[0] == 0 )
3417 v1 = 0;
3418 else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' )
3419 v1 = 0;
3420 else
3421 v1 = atoi(a->u.s);
3422 }
3423 break;
3424
3426 if( a->u.s == 0 )
3427 v1 = 0;
3428 else
3429 {
3430 if( a->u.s[0] == 0 )
3431 v1 = 0;
3432 else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' )
3433 v1 = 0;
3434 else
3435 v1 = atoi(a->u.s);
3436 }
3437 break;
3438 }
3439 }
3440
3441 r = make_number (!v1);
3442 free_value (a);
3443 return r;
3444}

References a, AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string, free_value(), and make_number().

Referenced by yyparse().

◆ op_cond()

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

Definition at line 3223 of file ast_expr2.c.

3224{
3225 struct val *r;
3226
3227 if( isstring(a) )
3228 {
3229 if( strlen(a->u.s) && strcmp(a->u.s, "\"\"") != 0 && strcmp(a->u.s,"0") != 0 )
3230 {
3231 free_value(a);
3232 free_value(c);
3233 r = b;
3234 }
3235 else
3236 {
3237 free_value(a);
3238 free_value(b);
3239 r = c;
3240 }
3241 }
3242 else
3243 {
3244 (void)to_number(a);
3245 if( a->u.i )
3246 {
3247 free_value(a);
3248 free_value(c);
3249 r = b;
3250 }
3251 else
3252 {
3253 free_value(a);
3254 free_value(b);
3255 r = c;
3256 }
3257 }
3258 return r;
3259}
static int isstring(struct val *vp)
Definition: ast_expr2.c:2648
static struct test_val c

References a, b, c, free_value(), isstring(), and to_number().

Referenced by yyparse().

◆ op_div()

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

Definition at line 3492 of file ast_expr2.c.

3493{
3494 struct val *r;
3495
3496 if (!to_number (a)) {
3497 free_value(a);
3498 free_value(b);
3500 ast_log(LOG_WARNING, "non-numeric argument\n");
3501 return make_number(0);
3502 } else if (!to_number (b)) {
3503 free_value(a);
3504 free_value(b);
3506 ast_log(LOG_WARNING, "non-numeric argument\n");
3507 return make_number(INT_MAX);
3508 }
3509
3510 if (b->u.i == 0) {
3511 ast_log(LOG_WARNING, "division by zero\n");
3512 free_value(a);
3513 free_value(b);
3514 return make_number(INT_MAX);
3515 }
3516
3517 r = make_number (a->u.i / b->u.i);
3518 if (chk_div (a->u.i, b->u.i)) {
3519 ast_log(LOG_WARNING, "overflow\n");
3520 }
3521 free_value (a);
3522 free_value (b);
3523 return r;
3524}
static int chk_div(FP___TYPE a, FP___TYPE b)
Definition: ast_expr2.c:3481
int extra_error_message_supplied
Definition: ast_expr2f.c:2459

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

Referenced by yyparse().

◆ op_eq()

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

Definition at line 3116 of file ast_expr2.c.

3117{
3118 struct val *r;
3119
3120 if (isstring (a) || isstring (b)) {
3121 to_string (a);
3122 to_string (b);
3123 r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) == 0));
3124 } else {
3125#ifdef DEBUG_FOR_CONVERSIONS
3126 char buffer[2000];
3127 sprintf(buffer,"Converting '%s' and '%s' ", a->u.s, b->u.s);
3128#endif
3129 (void)to_number(a);
3130 (void)to_number(b);
3131#ifdef DEBUG_FOR_CONVERSIONS
3132 ast_log(LOG_WARNING,"%s to '%lld' and '%lld'\n", buffer, a->u.i, b->u.i);
3133#endif
3134 r = make_number ((FP___TYPE)(a->u.i == b->u.i));
3135 }
3136
3137 free_value (a);
3138 free_value (b);
3139 return r;
3140}

References a, ast_log, b, FP___TYPE, free_value(), isstring(), LOG_WARNING, make_number(), to_number(), and to_string().

Referenced by yyparse().

◆ op_eqtilde()

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

Definition at line 3605 of file ast_expr2.c.

3606{
3607 regex_t rp;
3608 regmatch_t rm[2];
3609 char errbuf[256];
3610 int eval;
3611 struct val *v;
3612
3613 /* coerce to both arguments to strings */
3614 to_string(a);
3615 to_string(b);
3616 /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */
3617 strip_quotes(a);
3618 strip_quotes(b);
3619 /* compile regular expression */
3620 if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) {
3621 regerror (eval, &rp, errbuf, sizeof(errbuf));
3622 ast_log(LOG_WARNING, "regcomp() error : %s\n", errbuf);
3623 free_value(a);
3624 free_value(b);
3625 return make_str("");
3626 }
3627
3628 /* compare string against pattern */
3629 /* remember that patterns are anchored to the beginning of the line */
3630 if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 ) {
3631 if (rm[1].rm_so >= 0) {
3632 *(a->u.s + rm[1].rm_eo) = '\0';
3633 v = make_str (a->u.s + rm[1].rm_so);
3634
3635 } else {
3636 v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so));
3637 }
3638 } else {
3639 if (rp.re_nsub == 0) {
3640 v = make_number ((FP___TYPE)0.0);
3641 } else {
3642 v = make_str ("");
3643 }
3644 }
3645
3646 /* free arguments and pattern buffer */
3647 free_value (a);
3648 free_value (b);
3649 regfree (&rp);
3650
3651 return v;
3652}

References a, ast_log, b, FP___TYPE, free_value(), LOG_WARNING, make_number(), make_str(), strip_quotes(), and to_string().

Referenced by yyparse().

◆ op_func()

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

Definition at line 2798 of file ast_expr2.c.

2799{
2800 if (strspn(funcname->u.s,"ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789") == strlen(funcname->u.s))
2801 {
2802 struct val *result;
2803 if (0) {
2804#ifdef FUNC_COS
2805 } else if (strcmp(funcname->u.s,"COS") == 0) {
2806 if (arglist && !arglist->right && arglist->val){
2807 to_number(arglist->val);
2808 result = make_number(FUNC_COS(arglist->val->u.i));
2809 return result;
2810 } else {
2811 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2812 return make_number(0.0);
2813 }
2814#endif
2815#ifdef FUNC_SIN
2816 } else if (strcmp(funcname->u.s,"SIN") == 0) {
2817 if (arglist && !arglist->right && arglist->val){
2818 to_number(arglist->val);
2819 result = make_number(FUNC_SIN(arglist->val->u.i));
2820 return result;
2821 } else {
2822 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2823 return make_number(0.0);
2824 }
2825#endif
2826#ifdef FUNC_TAN
2827 } else if (strcmp(funcname->u.s,"TAN") == 0) {
2828 if (arglist && !arglist->right && arglist->val){
2829 to_number(arglist->val);
2830 result = make_number(FUNC_TAN(arglist->val->u.i));
2831 return result;
2832 } else {
2833 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2834 return make_number(0.0);
2835 }
2836#endif
2837#ifdef FUNC_ACOS
2838 } else if (strcmp(funcname->u.s,"ACOS") == 0) {
2839 if (arglist && !arglist->right && arglist->val){
2840 to_number(arglist->val);
2841 result = make_number(FUNC_ACOS(arglist->val->u.i));
2842 return result;
2843 } else {
2844 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2845 return make_number(0.0);
2846 }
2847#endif
2848#ifdef FUNC_ASIN
2849 } else if (strcmp(funcname->u.s,"ASIN") == 0) {
2850 if (arglist && !arglist->right && arglist->val){
2851 to_number(arglist->val);
2852 result = make_number(FUNC_ASIN(arglist->val->u.i));
2853 return result;
2854 } else {
2855 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2856 return make_number(0.0);
2857 }
2858#endif
2859#ifdef FUNC_ATAN
2860 } else if (strcmp(funcname->u.s,"ATAN") == 0) {
2861 if (arglist && !arglist->right && arglist->val){
2862 to_number(arglist->val);
2863 result = make_number(FUNC_ATAN(arglist->val->u.i));
2864 return result;
2865 } else {
2866 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2867 return make_number(0.0);
2868 }
2869#endif
2870#ifdef FUNC_ATAN2
2871 } else if (strcmp(funcname->u.s,"ATAN2") == 0) {
2872 if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
2873 to_number(arglist->val);
2874 to_number(arglist->right->val);
2875 result = make_number(FUNC_ATAN2(arglist->val->u.i, arglist->right->val->u.i));
2876 return result;
2877 } else {
2878 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2879 return make_number(0.0);
2880 }
2881#endif
2882#ifdef FUNC_POW
2883 } else if (strcmp(funcname->u.s,"POW") == 0) {
2884 if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
2885 to_number(arglist->val);
2886 to_number(arglist->right->val);
2887 result = make_number(FUNC_POW(arglist->val->u.i, arglist->right->val->u.i));
2888 return result;
2889 } else {
2890 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2891 return make_number(0.0);
2892 }
2893#endif
2894#ifdef FUNC_SQRT
2895 } else if (strcmp(funcname->u.s,"SQRT") == 0) {
2896 if (arglist && !arglist->right && arglist->val){
2897 to_number(arglist->val);
2898 result = make_number(FUNC_SQRT(arglist->val->u.i));
2899 return result;
2900 } else {
2901 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2902 return make_number(0.0);
2903 }
2904#endif
2905#ifdef FUNC_FLOOR
2906 } else if (strcmp(funcname->u.s,"FLOOR") == 0) {
2907 if (arglist && !arglist->right && arglist->val){
2908 to_number(arglist->val);
2909 result = make_number(FUNC_FLOOR(arglist->val->u.i));
2910 return result;
2911 } else {
2912 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2913 return make_number(0.0);
2914 }
2915#endif
2916#ifdef FUNC_CEIL
2917 } else if (strcmp(funcname->u.s,"CEIL") == 0) {
2918 if (arglist && !arglist->right && arglist->val){
2919 to_number(arglist->val);
2920 result = make_number(FUNC_CEIL(arglist->val->u.i));
2921 return result;
2922 } else {
2923 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2924 return make_number(0.0);
2925 }
2926#endif
2927#ifdef FUNC_ROUND
2928 } else if (strcmp(funcname->u.s,"ROUND") == 0) {
2929 if (arglist && !arglist->right && arglist->val){
2930 to_number(arglist->val);
2931 result = make_number(FUNC_ROUND(arglist->val->u.i));
2932 return result;
2933 } else {
2934 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2935 return make_number(0.0);
2936 }
2937#endif /* defined(FUNC_ROUND) */
2938#ifdef FUNC_RINT
2939 } else if (strcmp(funcname->u.s,"RINT") == 0) {
2940 if (arglist && !arglist->right && arglist->val){
2941 to_number(arglist->val);
2942 result = make_number(FUNC_RINT(arglist->val->u.i));
2943 return result;
2944 } else {
2945 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2946 return make_number(0.0);
2947 }
2948#endif
2949#ifdef FUNC_TRUNC
2950 } else if (strcmp(funcname->u.s,"TRUNC") == 0) {
2951 if (arglist && !arglist->right && arglist->val){
2952 to_number(arglist->val);
2953 result = make_number(FUNC_TRUNC(arglist->val->u.i));
2954 return result;
2955 } else {
2956 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2957 return make_number(0.0);
2958 }
2959#endif /* defined(FUNC_TRUNC) */
2960#ifdef FUNC_EXP
2961 } else if (strcmp(funcname->u.s,"EXP") == 0) {
2962 if (arglist && !arglist->right && arglist->val){
2963 to_number(arglist->val);
2964 result = make_number(FUNC_EXP(arglist->val->u.i));
2965 return result;
2966 } else {
2967 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2968 return make_number(0.0);
2969 }
2970#endif
2971#ifdef FUNC_EXP2
2972 } else if (strcmp(funcname->u.s,"EXP2") == 0) {
2973 if (arglist && !arglist->right && arglist->val){
2974 to_number(arglist->val);
2975 result = make_number(FUNC_EXP2(arglist->val->u.i));
2976 return result;
2977 } else {
2978 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2979 return make_number(0.0);
2980 }
2981#endif
2982#ifdef FUNC_EXP10
2983 } else if (strcmp(funcname->u.s,"EXP10") == 0) {
2984 if (arglist && !arglist->right && arglist->val){
2985 to_number(arglist->val);
2986 result = make_number(FUNC_EXP10(arglist->val->u.i));
2987 return result;
2988 } else {
2989 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
2990 return make_number(0.0);
2991 }
2992#endif
2993#ifdef FUNC_LOG
2994 } else if (strcmp(funcname->u.s,"LOG") == 0) {
2995 if (arglist && !arglist->right && arglist->val){
2996 to_number(arglist->val);
2997 result = make_number(FUNC_LOG(arglist->val->u.i));
2998 return result;
2999 } else {
3000 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3001 return make_number(0.0);
3002 }
3003#endif
3004#ifdef FUNC_LOG2
3005 } else if (strcmp(funcname->u.s,"LOG2") == 0) {
3006 if (arglist && !arglist->right && arglist->val){
3007 to_number(arglist->val);
3008 result = make_number(FUNC_LOG2(arglist->val->u.i));
3009 return result;
3010 } else {
3011 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3012 return make_number(0.0);
3013 }
3014#endif
3015#ifdef FUNC_LOG10
3016 } else if (strcmp(funcname->u.s,"LOG10") == 0) {
3017 if (arglist && !arglist->right && arglist->val){
3018 to_number(arglist->val);
3019 result = make_number(FUNC_LOG10(arglist->val->u.i));
3020 return result;
3021 } else {
3022 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3023 return make_number(0.0);
3024 }
3025#endif
3026#ifdef FUNC_REMAINDER
3027 } else if (strcmp(funcname->u.s,"REMAINDER") == 0) {
3028 if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
3029 to_number(arglist->val);
3030 to_number(arglist->right->val);
3031 result = make_number(FUNC_REMAINDER(arglist->val->u.i, arglist->right->val->u.i));
3032 return result;
3033 } else {
3034 ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
3035 return make_number(0.0);
3036 }
3037#endif
3038 } else if (strcmp(funcname->u.s, "ABS") == 0) {
3039 if (arglist && !arglist->right && arglist->val) {
3040 to_number(arglist->val);
3041 result = make_number(arglist->val->u.i < 0 ? arglist->val->u.i * -1 : arglist->val->u.i);
3042 return result;
3043 } else {
3044 ast_log(LOG_WARNING, "Wrong args to %s() function\n", funcname->u.s);
3045 return make_number(0.0);
3046 }
3047 } else {
3048 /* is this a custom function we should execute and collect the results of? */
3049#if !defined(STANDALONE) && !defined(STANDALONE2)
3050 struct ast_custom_function *f = ast_custom_function_find(funcname->u.s);
3051 if (!chan)
3052 ast_log(LOG_WARNING,"Hey! chan is NULL.\n");
3053 if (!f)
3054 ast_log(LOG_WARNING,"Hey! could not find func %s.\n", funcname->u.s);
3055
3056 if (f && chan) {
3057 if (f->read) {
3058 char workspace[512];
3059 char *argbuf = compose_func_args(arglist);
3060 f->read(chan, funcname->u.s, argbuf, workspace, sizeof(workspace));
3061 free(argbuf);
3062 if (is_really_num(workspace))
3063 return make_number(FUNC_STRTOD(workspace,(char **)NULL));
3064 else
3065 return make_str(workspace);
3066 } else {
3067 ast_log(LOG_ERROR,"Error! Function '%s' cannot be read!\n", funcname->u.s);
3068 return (make_number ((FP___TYPE)0.0));
3069 }
3070
3071 } else {
3072 ast_log(LOG_ERROR, "Error! '%s' doesn't appear to be an available function!\n", funcname->u.s);
3073 return (make_number ((FP___TYPE)0.0));
3074 }
3075#else
3076 ast_log(LOG_ERROR, "Error! '%s' is not available in the standalone version!\n", funcname->u.s);
3077 return (make_number ((FP___TYPE)0.0));
3078#endif
3079 }
3080 }
3081 else
3082 {
3083 ast_log(LOG_ERROR, "Error! '%s' is not possibly a function name!\n", funcname->u.s);
3084 return (make_number ((FP___TYPE)0.0));
3085 }
3086 return (make_number ((FP___TYPE)0.0));
3087}
#define FUNC_EXP2
Definition: ast_expr2.c:233
#define FUNC_STRTOD
Definition: ast_expr2.c:199
#define FUNC_ACOS
Definition: ast_expr2.c:133
#define FUNC_ATAN2
Definition: ast_expr2.c:151
#define FUNC_SQRT
Definition: ast_expr2.c:163
static char * compose_func_args(struct expr_node *arglist)
Definition: ast_expr2.c:2747
#define FUNC_ROUND
Definition: ast_expr2.c:217
#define FUNC_RINT
Definition: ast_expr2.c:169
#define FUNC_REMAINDER
Definition: ast_expr2.c:187
#define FUNC_CEIL
Definition: ast_expr2.c:211
#define FUNC_TAN
Definition: ast_expr2.c:127
#define FUNC_ATAN
Definition: ast_expr2.c:145
#define FUNC_FLOOR
Definition: ast_expr2.c:205
#define FUNC_LOG
Definition: ast_expr2.c:181
#define FUNC_TRUNC
Definition: ast_expr2.c:223
#define FUNC_EXP10
Definition: ast_expr2.c:241
#define FUNC_EXP
Definition: ast_expr2.c:175
#define FUNC_SIN
Definition: ast_expr2.c:121
#define FUNC_LOG2
Definition: ast_expr2.c:249
#define FUNC_ASIN
Definition: ast_expr2.c:139
#define FUNC_COS
Definition: ast_expr2.c:115
#define FUNC_LOG10
Definition: ast_expr2.c:261
#define FUNC_POW
Definition: ast_expr2.c:157
static int is_really_num(char *str)
Definition: ast_expr2.c:2789
static PGresult * result
Definition: cel_pgsql.c:84
struct ast_custom_function * ast_custom_function_find(const char *name)
Definition: ael_main.c:173
Data structure associated with a custom dialplan function.
Definition: pbx.h:118
ast_acf_read_fn_t read
Definition: pbx.h:129

References ast_custom_function_find(), ast_log, compose_func_args(), 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(), NULL, ast_custom_function::read, result, expr_node::right, val::s, to_number(), val::u, and expr_node::val.

Referenced by yyparse().

◆ op_ge()

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

Definition at line 3183 of file ast_expr2.c.

3184{
3185 struct val *r;
3186
3187 if (isstring (a) || isstring (b)) {
3188 to_string (a);
3189 to_string (b);
3190 r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) >= 0));
3191 } else {
3192 (void)to_number(a);
3193 (void)to_number(b);
3194 r = make_number ((FP___TYPE)(a->u.i >= b->u.i));
3195 }
3196
3197 free_value (a);
3198 free_value (b);
3199 return r;
3200}

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

Referenced by yyparse().

◆ op_gt()

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

Definition at line 3143 of file ast_expr2.c.

3144{
3145 struct val *r;
3146
3147 if (isstring (a) || isstring (b)) {
3148 to_string (a);
3149 to_string (b);
3150 r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) > 0));
3151 } else {
3152 (void)to_number(a);
3153 (void)to_number(b);
3154 r = make_number ((FP___TYPE)(a->u.i > b->u.i));
3155 }
3156
3157 free_value (a);
3158 free_value (b);
3159 return r;
3160}

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

Referenced by yyparse().

◆ op_le()

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

Definition at line 3203 of file ast_expr2.c.

3204{
3205 struct val *r;
3206
3207 if (isstring (a) || isstring (b)) {
3208 to_string (a);
3209 to_string (b);
3210 r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) <= 0));
3211 } else {
3212 (void)to_number(a);
3213 (void)to_number(b);
3214 r = make_number ((FP___TYPE)(a->u.i <= b->u.i));
3215 }
3216
3217 free_value (a);
3218 free_value (b);
3219 return r;
3220}

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

Referenced by yyparse().

◆ op_lt()

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

Definition at line 3163 of file ast_expr2.c.

3164{
3165 struct val *r;
3166
3167 if (isstring (a) || isstring (b)) {
3168 to_string (a);
3169 to_string (b);
3170 r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) < 0));
3171 } else {
3172 (void)to_number(a);
3173 (void)to_number(b);
3174 r = make_number ((FP___TYPE)(a->u.i < b->u.i));
3175 }
3176
3177 free_value (a);
3178 free_value (b);
3179 return r;
3180}

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

Referenced by yyparse().

◆ op_minus()

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

Definition at line 3339 of file ast_expr2.c.

3340{
3341 struct val *r;
3342
3343 if (!to_number (a)) {
3345 ast_log(LOG_WARNING, "non-numeric argument\n");
3346 if (!to_number (b)) {
3347 free_value(a);
3348 free_value(b);
3349 return make_number(0);
3350 } else {
3351 r = make_number(0 - b->u.i);
3352 free_value(a);
3353 free_value(b);
3354 return (r);
3355 }
3356 } else if (!to_number(b)) {
3358 ast_log(LOG_WARNING, "non-numeric argument\n");
3359 free_value(b);
3360 return (a);
3361 }
3362
3363 r = make_number (a->u.i - b->u.i);
3364 if (chk_minus (a->u.i, b->u.i, r->u.i)) {
3365 ast_log(LOG_WARNING, "overflow\n");
3366 }
3367 free_value (a);
3368 free_value (b);
3369 return r;
3370}
static int chk_minus(FP___TYPE a, FP___TYPE b, FP___TYPE r)
Definition: ast_expr2.c:3325

References a, ast_log, b, chk_minus(), extra_error_message_supplied, free_value(), val::i, LOG_WARNING, make_number(), to_number(), and val::u.

Referenced by yyparse().

◆ op_ne()

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

Definition at line 3262 of file ast_expr2.c.

3263{
3264 struct val *r;
3265
3266 if (isstring (a) || isstring (b)) {
3267 to_string (a);
3268 to_string (b);
3269 r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) != 0));
3270 } else {
3271 (void)to_number(a);
3272 (void)to_number(b);
3273 r = make_number ((FP___TYPE)(a->u.i != b->u.i));
3274 }
3275
3276 free_value (a);
3277 free_value (b);
3278 return r;
3279}

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

Referenced by yyparse().

◆ op_negate()

static struct val * op_negate ( struct val a)
static

Definition at line 3373 of file ast_expr2.c.

3374{
3375 struct val *r;
3376
3377 if (!to_number (a) ) {
3378 free_value(a);
3380 ast_log(LOG_WARNING, "non-numeric argument\n");
3381 return make_number(0);
3382 }
3383
3384 r = make_number (- a->u.i);
3385 if (chk_minus (0, a->u.i, r->u.i)) {
3386 ast_log(LOG_WARNING, "overflow\n");
3387 }
3388 free_value (a);
3389 return r;
3390}

References a, ast_log, chk_minus(), extra_error_message_supplied, free_value(), val::i, LOG_WARNING, make_number(), to_number(), and val::u.

Referenced by yyparse().

◆ op_or()

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

Definition at line 3091 of file ast_expr2.c.

3092{
3093 if (is_zero_or_null (a)) {
3094 free_value (a);
3095 return (b);
3096 } else {
3097 free_value (b);
3098 return (a);
3099 }
3100}

References a, b, free_value(), and is_zero_or_null().

Referenced by yyparse().

◆ op_plus()

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

Definition at line 3295 of file ast_expr2.c.

3296{
3297 struct val *r;
3298
3299 if (!to_number (a)) {
3301 ast_log(LOG_WARNING,"non-numeric argument\n");
3302 if (!to_number (b)) {
3303 free_value(a);
3304 free_value(b);
3305 return make_number(0);
3306 } else {
3307 free_value(a);
3308 return (b);
3309 }
3310 } else if (!to_number(b)) {
3311 free_value(b);
3312 return (a);
3313 }
3314
3315 r = make_number (a->u.i + b->u.i);
3316 if (chk_plus (a->u.i, b->u.i, r->u.i)) {
3317 ast_log(LOG_WARNING,"overflow\n");
3318 }
3319 free_value (a);
3320 free_value (b);
3321 return r;
3322}

References a, ast_log, b, chk_plus(), extra_error_message_supplied, free_value(), val::i, LOG_WARNING, make_number(), to_number(), and val::u.

Referenced by yyparse().

◆ op_rem()

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

Definition at line 3527 of file ast_expr2.c.

3528{
3529 struct val *r;
3530
3531 if (!to_number (a) || !to_number (b)) {
3533 ast_log(LOG_WARNING, "non-numeric argument\n");
3534 free_value(a);
3535 free_value(b);
3536 return make_number(0);
3537 }
3538
3539 if (b->u.i == 0) {
3540 ast_log(LOG_WARNING, "div by zero\n");
3541 free_value(a);
3542 return(b);
3543 }
3544
3545 r = make_number (FUNC_FMOD(a->u.i, b->u.i)); /* either fmod or fmodl if FP___TYPE is available */
3546 /* chk_rem necessary ??? */
3547 free_value (a);
3548 free_value (b);
3549 return r;
3550}
#define FUNC_FMOD
Definition: ast_expr2.c:193

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

Referenced by yyparse().

◆ op_tildetilde()

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

Definition at line 3655 of file ast_expr2.c.

3656{
3657 struct val *v;
3658 char *vs;
3659
3660 /* coerce to both arguments to strings */
3661 to_string(a);
3662 to_string(b);
3663 /* strip double quotes from both -- */
3664 strip_quotes(a);
3665 strip_quotes(b);
3666
3667 vs = malloc(strlen(a->u.s)+strlen(b->u.s)+1);
3668 if (vs == NULL) {
3669 ast_log(LOG_WARNING, "malloc() failed\n");
3670 free_value(a);
3671 free_value(b);
3672 return NULL;
3673 }
3674
3675 strcpy(vs,a->u.s);
3676 strcat(vs,b->u.s);
3677
3678 v = make_str(vs);
3679
3680 free(vs);
3681
3682 /* free arguments */
3683 free_value(a);
3684 free_value(b);
3685
3686 return v;
3687}

References a, ast_log, b, free(), free_value(), LOG_WARNING, make_str(), malloc(), NULL, strip_quotes(), and to_string().

Referenced by yyparse().

◆ op_times()

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

Definition at line 3459 of file ast_expr2.c.

3460{
3461 struct val *r;
3462
3463 if (!to_number (a) || !to_number (b)) {
3464 free_value(a);
3465 free_value(b);
3467 ast_log(LOG_WARNING, "non-numeric argument\n");
3468 return(make_number(0));
3469 }
3470
3471 r = make_number (a->u.i * b->u.i);
3472 if (chk_times (a->u.i, b->u.i, r->u.i)) {
3473 ast_log(LOG_WARNING, "overflow\n");
3474 }
3475 free_value (a);
3476 free_value (b);
3477 return (r);
3478}
static int chk_times(FP___TYPE a, FP___TYPE b, FP___TYPE r)
Definition: ast_expr2.c:3447

References a, ast_log, b, chk_times(), extra_error_message_supplied, free_value(), val::i, LOG_WARNING, make_number(), to_number(), and val::u.

Referenced by yyparse().

◆ strip_quotes()

static void strip_quotes ( struct val vp)
static

Definition at line 2607 of file ast_expr2.c.

2608{
2609 if (vp->type != AST_EXPR_string && vp->type != AST_EXPR_numeric_string)
2610 return;
2611
2612 if( vp->u.s[0] == '"' && vp->u.s[strlen(vp->u.s)-1] == '"' )
2613 {
2614 char *f, *t;
2615 f = vp->u.s;
2616 t = vp->u.s;
2617
2618 while( *f )
2619 {
2620 if( *f && *f != '"' )
2621 *t++ = *f++;
2622 else
2623 f++;
2624 }
2625 *t = *f;
2626 }
2627}

References AST_EXPR_numeric_string, AST_EXPR_string, val::s, val::type, and val::u.

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

◆ to_number()

static int to_number ( struct val vp)
static

Definition at line 2576 of file ast_expr2.c.

2577{
2578 FP___TYPE i;
2579
2580 if (vp == NULL) {
2581 ast_log(LOG_WARNING,"vp==NULL in to_number()\n");
2582 return(0);
2583 }
2584
2585 if (vp->type == AST_EXPR_number)
2586 return 1;
2587
2588 if (vp->type == AST_EXPR_string)
2589 return 0;
2590
2591 /* vp->type == AST_EXPR_numeric_string, make it numeric */
2592 errno = 0;
2593 i = FUNC_STRTOD(vp->u.s, (char**)0); /* either strtod, or strtold on a good day */
2594 if (errno != 0) {
2595 ast_log(LOG_WARNING,"Conversion of %s to number under/overflowed!\n", vp->u.s);
2596 free(vp->u.s);
2597 vp->u.s = 0;
2598 return(0);
2599 }
2600 free (vp->u.s);
2601 vp->u.i = i;
2602 vp->type = AST_EXPR_number;
2603 return 1;
2604}
int errno

References AST_EXPR_number, AST_EXPR_string, ast_log, errno, FP___TYPE, free(), FUNC_STRTOD, val::i, LOG_WARNING, NULL, 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().

◆ to_string()

static void to_string ( struct val vp)
static

Definition at line 2630 of file ast_expr2.c.

2631{
2632 char *tmp;
2633
2634 if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
2635 return;
2636
2637 if (asprintf(&tmp, FP___PRINTF, vp->u.i) == -1) {
2638 ast_log(LOG_WARNING, "asprintf() failed\n");
2639 return;
2640 }
2641
2642 vp->type = AST_EXPR_string;
2643 vp->u.s = tmp;
2644}
static int tmp()
Definition: bt_open.c:389
int asprintf(char **str, const char *fmt,...)

References asprintf(), AST_EXPR_numeric_string, AST_EXPR_string, ast_log, FP___PRINTF, val::i, LOG_WARNING, val::s, tmp(), 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().

◆ yydestruct()

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

Definition at line 1453 of file ast_expr2.c.

1459{
1460 YYUSE (yyvaluep);
1461 YYUSE (yylocationp);
1462
1463 if (!yymsg)
1464 yymsg = "Deleting";
1465 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1466
1467 switch (yytype)
1468 {
1469 case 4: /* "TOK_COLONCOLON" */
1470
1471/* Line 1000 of yacc.c */
1472#line 366 "ast_expr2.y"
1473 { free_value((yyvaluep->val)); };
1474
1475/* Line 1000 of yacc.c */
1476#line 1477 "ast_expr2.c"
1477 break;
1478 case 5: /* "TOK_COND" */
1479
1480/* Line 1000 of yacc.c */
1481#line 366 "ast_expr2.y"
1482 { free_value((yyvaluep->val)); };
1483
1484/* Line 1000 of yacc.c */
1485#line 1486 "ast_expr2.c"
1486 break;
1487 case 6: /* "TOK_OR" */
1488
1489/* Line 1000 of yacc.c */
1490#line 366 "ast_expr2.y"
1491 { free_value((yyvaluep->val)); };
1492
1493/* Line 1000 of yacc.c */
1494#line 1495 "ast_expr2.c"
1495 break;
1496 case 7: /* "TOK_AND" */
1497
1498/* Line 1000 of yacc.c */
1499#line 366 "ast_expr2.y"
1500 { free_value((yyvaluep->val)); };
1501
1502/* Line 1000 of yacc.c */
1503#line 1504 "ast_expr2.c"
1504 break;
1505 case 8: /* "TOK_NE" */
1506
1507/* Line 1000 of yacc.c */
1508#line 366 "ast_expr2.y"
1509 { free_value((yyvaluep->val)); };
1510
1511/* Line 1000 of yacc.c */
1512#line 1513 "ast_expr2.c"
1513 break;
1514 case 9: /* "TOK_LE" */
1515
1516/* Line 1000 of yacc.c */
1517#line 366 "ast_expr2.y"
1518 { free_value((yyvaluep->val)); };
1519
1520/* Line 1000 of yacc.c */
1521#line 1522 "ast_expr2.c"
1522 break;
1523 case 10: /* "TOK_GE" */
1524
1525/* Line 1000 of yacc.c */
1526#line 366 "ast_expr2.y"
1527 { free_value((yyvaluep->val)); };
1528
1529/* Line 1000 of yacc.c */
1530#line 1531 "ast_expr2.c"
1531 break;
1532 case 11: /* "TOK_LT" */
1533
1534/* Line 1000 of yacc.c */
1535#line 366 "ast_expr2.y"
1536 { free_value((yyvaluep->val)); };
1537
1538/* Line 1000 of yacc.c */
1539#line 1540 "ast_expr2.c"
1540 break;
1541 case 12: /* "TOK_GT" */
1542
1543/* Line 1000 of yacc.c */
1544#line 366 "ast_expr2.y"
1545 { free_value((yyvaluep->val)); };
1546
1547/* Line 1000 of yacc.c */
1548#line 1549 "ast_expr2.c"
1549 break;
1550 case 13: /* "TOK_EQ" */
1551
1552/* Line 1000 of yacc.c */
1553#line 366 "ast_expr2.y"
1554 { free_value((yyvaluep->val)); };
1555
1556/* Line 1000 of yacc.c */
1557#line 1558 "ast_expr2.c"
1558 break;
1559 case 14: /* "TOK_MINUS" */
1560
1561/* Line 1000 of yacc.c */
1562#line 366 "ast_expr2.y"
1563 { free_value((yyvaluep->val)); };
1564
1565/* Line 1000 of yacc.c */
1566#line 1567 "ast_expr2.c"
1567 break;
1568 case 15: /* "TOK_PLUS" */
1569
1570/* Line 1000 of yacc.c */
1571#line 366 "ast_expr2.y"
1572 { free_value((yyvaluep->val)); };
1573
1574/* Line 1000 of yacc.c */
1575#line 1576 "ast_expr2.c"
1576 break;
1577 case 16: /* "TOK_MOD" */
1578
1579/* Line 1000 of yacc.c */
1580#line 366 "ast_expr2.y"
1581 { free_value((yyvaluep->val)); };
1582
1583/* Line 1000 of yacc.c */
1584#line 1585 "ast_expr2.c"
1585 break;
1586 case 17: /* "TOK_DIV" */
1587
1588/* Line 1000 of yacc.c */
1589#line 366 "ast_expr2.y"
1590 { free_value((yyvaluep->val)); };
1591
1592/* Line 1000 of yacc.c */
1593#line 1594 "ast_expr2.c"
1594 break;
1595 case 18: /* "TOK_MULT" */
1596
1597/* Line 1000 of yacc.c */
1598#line 366 "ast_expr2.y"
1599 { free_value((yyvaluep->val)); };
1600
1601/* Line 1000 of yacc.c */
1602#line 1603 "ast_expr2.c"
1603 break;
1604 case 19: /* "TOK_COMPL" */
1605
1606/* Line 1000 of yacc.c */
1607#line 366 "ast_expr2.y"
1608 { free_value((yyvaluep->val)); };
1609
1610/* Line 1000 of yacc.c */
1611#line 1612 "ast_expr2.c"
1612 break;
1613 case 20: /* "TOK_TILDETILDE" */
1614
1615/* Line 1000 of yacc.c */
1616#line 366 "ast_expr2.y"
1617 { free_value((yyvaluep->val)); };
1618
1619/* Line 1000 of yacc.c */
1620#line 1621 "ast_expr2.c"
1621 break;
1622 case 21: /* "TOK_EQTILDE" */
1623
1624/* Line 1000 of yacc.c */
1625#line 366 "ast_expr2.y"
1626 { free_value((yyvaluep->val)); };
1627
1628/* Line 1000 of yacc.c */
1629#line 1630 "ast_expr2.c"
1630 break;
1631 case 22: /* "TOK_COLON" */
1632
1633/* Line 1000 of yacc.c */
1634#line 366 "ast_expr2.y"
1635 { free_value((yyvaluep->val)); };
1636
1637/* Line 1000 of yacc.c */
1638#line 1639 "ast_expr2.c"
1639 break;
1640 case 23: /* "TOK_LP" */
1641
1642/* Line 1000 of yacc.c */
1643#line 366 "ast_expr2.y"
1644 { free_value((yyvaluep->val)); };
1645
1646/* Line 1000 of yacc.c */
1647#line 1648 "ast_expr2.c"
1648 break;
1649 case 24: /* "TOK_RP" */
1650
1651/* Line 1000 of yacc.c */
1652#line 366 "ast_expr2.y"
1653 { free_value((yyvaluep->val)); };
1654
1655/* Line 1000 of yacc.c */
1656#line 1657 "ast_expr2.c"
1657 break;
1658 case 25: /* "TOKEN" */
1659
1660/* Line 1000 of yacc.c */
1661#line 366 "ast_expr2.y"
1662 { free_value((yyvaluep->val)); };
1663
1664/* Line 1000 of yacc.c */
1665#line 1666 "ast_expr2.c"
1666 break;
1667 case 29: /* "expr" */
1668
1669/* Line 1000 of yacc.c */
1670#line 366 "ast_expr2.y"
1671 { free_value((yyvaluep->val)); };
1672
1673/* Line 1000 of yacc.c */
1674#line 1675 "ast_expr2.c"
1675 break;
1676
1677 default:
1678 break;
1679 }
1680}
#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
Definition: ast_expr2.c:1207
#define YYUSE(e)
Definition: ast_expr2.c:577
struct val * val
Definition: ast_expr2.c:478

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

Referenced by yyparse().

◆ yyparse()

int yyparse ( void *  YYPARSE_PARAM)

Definition at line 1712 of file ast_expr2.c.

1726{
1727/* The lookahead symbol. */
1728int yychar;
1729
1730/* The semantic value of the lookahead symbol. */
1732
1733/* Location data for the lookahead symbol. */
1735
1736 /* Number of syntax errors so far. */
1737 int yynerrs;
1738
1739 int yystate;
1740 /* Number of tokens to shift before error messages enabled. */
1741 int yyerrstatus;
1742
1743 /* The stacks and their tools:
1744 `yyss': related to states.
1745 `yyvs': related to semantic values.
1746 `yyls': related to locations.
1747
1748 Refer to the stacks thru separate pointers, to allow yyoverflow
1749 to reallocate them elsewhere. */
1750
1751 /* The state stack. */
1753 yytype_int16 *yyss;
1754 yytype_int16 *yyssp;
1755
1756 /* The semantic value stack. */
1757 YYSTYPE yyvsa[YYINITDEPTH];
1758 YYSTYPE *yyvs;
1759 YYSTYPE *yyvsp;
1760
1761 /* The location stack. */
1762 YYLTYPE yylsa[YYINITDEPTH];
1763 YYLTYPE *yyls;
1764 YYLTYPE *yylsp;
1765
1766 /* The locations where the error started and ended. */
1767 YYLTYPE yyerror_range[2];
1768
1769 YYSIZE_T yystacksize;
1770
1771 int yyn;
1772 int yyresult;
1773 /* Lookahead token as an internal (translated) token number. */
1774 int yytoken;
1775 /* The variables used to return semantic value and location from the
1776 action routines. */
1777 YYSTYPE yyval;
1778 YYLTYPE yyloc;
1779
1780#if YYERROR_VERBOSE
1781 /* Buffer for error messages, and its allocated size. */
1782 char yymsgbuf[128];
1783 char *yymsg = yymsgbuf;
1784 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1785#endif
1786
1787#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1788
1789 /* The number of symbols on the RHS of the reduced rule.
1790 Keep to zero when no symbol should be popped. */
1791 int yylen = 0;
1792
1793 yytoken = 0;
1794 yyss = yyssa;
1795 yyvs = yyvsa;
1796 yyls = yylsa;
1797 yystacksize = YYINITDEPTH;
1798
1799 YYDPRINTF ((stderr, "Starting parse\n"));
1800
1801 yystate = 0;
1802 yyerrstatus = 0;
1803 yynerrs = 0;
1804 yychar = YYEMPTY; /* Cause a token to be read. */
1805
1806 /* Initialize stack pointers.
1807 Waste one element of value and location stack
1808 so that they stay on the same level as the state stack.
1809 The wasted elements are never initialized. */
1810 yyssp = yyss;
1811 yyvsp = yyvs;
1812 yylsp = yyls;
1813
1814#if YYLTYPE_IS_TRIVIAL
1815 /* Initialize the default location before parsing starts. */
1816 yylloc.first_line = yylloc.last_line = 1;
1817 yylloc.first_column = yylloc.last_column = 1;
1818#endif
1819
1820 goto yysetstate;
1821
1822/*------------------------------------------------------------.
1823| yynewstate -- Push a new state, which is found in yystate. |
1824`------------------------------------------------------------*/
1825 yynewstate:
1826 /* In all cases, when you get here, the value and location stacks
1827 have just been pushed. So pushing a state here evens the stacks. */
1828 yyssp++;
1829
1830 yysetstate:
1831 *yyssp = yystate;
1832
1833 if (yyss + yystacksize - 1 <= yyssp)
1834 {
1835 /* Get the current used size of the three stacks, in elements. */
1836 YYSIZE_T yysize = yyssp - yyss + 1;
1837
1838#ifdef yyoverflow
1839 {
1840 /* Give user a chance to reallocate the stack. Use copies of
1841 these so that the &'s don't force the real ones into
1842 memory. */
1843 YYSTYPE *yyvs1 = yyvs;
1844 yytype_int16 *yyss1 = yyss;
1845 YYLTYPE *yyls1 = yyls;
1846
1847 /* Each stack pointer address is followed by the size of the
1848 data in use in that stack, in bytes. This used to be a
1849 conditional around just the two extra args, but that might
1850 be undefined if yyoverflow is a macro. */
1851 yyoverflow (YY_("memory exhausted"),
1852 &yyss1, yysize * sizeof (*yyssp),
1853 &yyvs1, yysize * sizeof (*yyvsp),
1854 &yyls1, yysize * sizeof (*yylsp),
1855 &yystacksize);
1856
1857 yyls = yyls1;
1858 yyss = yyss1;
1859 yyvs = yyvs1;
1860 }
1861#else /* no yyoverflow */
1862# ifndef YYSTACK_RELOCATE
1863 goto yyexhaustedlab;
1864# else
1865 /* Extend the stack our own way. */
1866 if (YYMAXDEPTH <= yystacksize)
1867 goto yyexhaustedlab;
1868 yystacksize *= 2;
1869 if (YYMAXDEPTH < yystacksize)
1870 yystacksize = YYMAXDEPTH;
1871
1872 {
1873 yytype_int16 *yyss1 = yyss;
1874 union yyalloc *yyptr =
1875 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1876 if (! yyptr)
1877 goto yyexhaustedlab;
1881# undef YYSTACK_RELOCATE
1882 if (yyss1 != yyssa)
1883 YYSTACK_FREE (yyss1);
1884 }
1885# endif
1886#endif /* no yyoverflow */
1887
1888 yyssp = yyss + yysize - 1;
1889 yyvsp = yyvs + yysize - 1;
1890 yylsp = yyls + yysize - 1;
1891
1892 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1893 (unsigned long int) yystacksize));
1894
1895 if (yyss + yystacksize - 1 <= yyssp)
1896 YYABORT;
1897 }
1898
1899 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1900
1901 if (yystate == YYFINAL)
1902 YYACCEPT;
1903
1904 goto yybackup;
1905
1906/*-----------.
1907| yybackup. |
1908`-----------*/
1909yybackup:
1910
1911 /* Do appropriate processing given the current state. Read a
1912 lookahead token if we need one and don't already have one. */
1913
1914 /* First try to decide what to do without reference to lookahead token. */
1915 yyn = yypact[yystate];
1916 if (yyn == YYPACT_NINF)
1917 goto yydefault;
1918
1919 /* Not known => get a lookahead token if don't already have one. */
1920
1921 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1922 if (yychar == YYEMPTY)
1923 {
1924 YYDPRINTF ((stderr, "Reading a token: "));
1925 yychar = YYLEX;
1926 }
1927
1928 if (yychar <= YYEOF)
1929 {
1930 yychar = yytoken = YYEOF;
1931 YYDPRINTF ((stderr, "Now at end of input.\n"));
1932 }
1933 else
1934 {
1935 yytoken = YYTRANSLATE (yychar);
1936 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1937 }
1938
1939 /* If the proper action on seeing token YYTOKEN is to reduce or to
1940 detect an error, take that action. */
1941 yyn += yytoken;
1942 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1943 goto yydefault;
1944 yyn = yytable[yyn];
1945 if (yyn <= 0)
1946 {
1947 if (yyn == 0 || yyn == YYTABLE_NINF)
1948 goto yyerrlab;
1949 yyn = -yyn;
1950 goto yyreduce;
1951 }
1952
1953 /* Count tokens shifted since error; after three, turn off error
1954 status. */
1955 if (yyerrstatus)
1956 yyerrstatus--;
1957
1958 /* Shift the lookahead token. */
1959 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1960
1961 /* Discard the shifted token. */
1962 yychar = YYEMPTY;
1963
1964 yystate = yyn;
1965 *++yyvsp = yylval;
1966 *++yylsp = yylloc;
1967 goto yynewstate;
1968
1969
1970/*-----------------------------------------------------------.
1971| yydefault -- do the default action for the current state. |
1972`-----------------------------------------------------------*/
1973yydefault:
1974 yyn = yydefact[yystate];
1975 if (yyn == 0)
1976 goto yyerrlab;
1977 goto yyreduce;
1978
1979
1980/*-----------------------------.
1981| yyreduce -- Do a reduction. |
1982`-----------------------------*/
1983yyreduce:
1984 /* yyn is the number of a rule to reduce with. */
1985 yylen = yyr2[yyn];
1986
1987 /* If YYLEN is nonzero, implement the default value of the action:
1988 `$$ = $1'.
1989
1990 Otherwise, the following line sets YYVAL to garbage.
1991 This behavior is undocumented and Bison
1992 users should not rely upon it. Assigning to YYVAL
1993 unconditionally makes the parser a bit smaller, and it avoids a
1994 GCC warning that YYVAL may be used uninitialized. */
1995 yyval = yyvsp[1-yylen];
1996
1997 /* Default location. */
1998 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1999 YY_REDUCE_PRINT (yyn);
2000 switch (yyn)
2001 {
2002 case 2:
2003
2004/* Line 1455 of yacc.c */
2005#line 372 "ast_expr2.y"
2006 { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
2007 ((struct parse_io *)parseio)->val->type = (yyvsp[(1) - (1)].val)->type;
2008 if( (yyvsp[(1) - (1)].val)->type == AST_EXPR_number )
2009 ((struct parse_io *)parseio)->val->u.i = (yyvsp[(1) - (1)].val)->u.i;
2010 else
2011 ((struct parse_io *)parseio)->val->u.s = (yyvsp[(1) - (1)].val)->u.s;
2012 free((yyvsp[(1) - (1)].val));
2013 ;}
2014 break;
2015
2016 case 3:
2017
2018/* Line 1455 of yacc.c */
2019#line 380 "ast_expr2.y"
2020 {/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
2021 ((struct parse_io *)parseio)->val->type = AST_EXPR_string;
2022 ((struct parse_io *)parseio)->val->u.s = strdup("");
2023 ;}
2024 break;
2025
2026 case 4:
2027
2028/* Line 1455 of yacc.c */
2029#line 387 "ast_expr2.y"
2030 { (yyval.arglist) = alloc_expr_node(AST_EXPR_NODE_VAL); (yyval.arglist)->val = (yyvsp[(1) - (1)].val);;}
2031 break;
2032
2033 case 5:
2034
2035/* Line 1455 of yacc.c */
2036#line 388 "ast_expr2.y"
2038 struct expr_node *t;
2039 DESTROY((yyvsp[(2) - (3)].val));
2040 for (t=(yyvsp[(1) - (3)].arglist);t->right;t=t->right)
2041 ;
2042 (yyval.arglist) = (yyvsp[(1) - (3)].arglist); t->right = x; x->val = (yyvsp[(3) - (3)].val);;}
2043 break;
2044
2045 case 6:
2046
2047/* Line 1455 of yacc.c */
2048#line 394 "ast_expr2.y"
2050 struct expr_node *t; /* NULL args should OK */
2051 DESTROY((yyvsp[(2) - (2)].val));
2052 for (t=(yyvsp[(1) - (2)].arglist);t->right;t=t->right)
2053 ;
2054 (yyval.arglist) = (yyvsp[(1) - (2)].arglist); t->right = x; x->val = make_str("");;}
2055 break;
2056
2057 case 7:
2058
2059/* Line 1455 of yacc.c */
2060#line 403 "ast_expr2.y"
2061 { (yyval.val) = op_func((yyvsp[(1) - (4)].val),(yyvsp[(3) - (4)].arglist), ((struct parse_io *)parseio)->chan);
2062 DESTROY((yyvsp[(2) - (4)].val));
2063 DESTROY((yyvsp[(4) - (4)].val));
2064 DESTROY((yyvsp[(1) - (4)].val));
2065 destroy_arglist((yyvsp[(3) - (4)].arglist));
2066 ;}
2067 break;
2068
2069 case 8:
2070
2071/* Line 1455 of yacc.c */
2072#line 409 "ast_expr2.y"
2073 {(yyval.val) = (yyvsp[(1) - (1)].val);;}
2074 break;
2075
2076 case 9:
2077
2078/* Line 1455 of yacc.c */
2079#line 410 "ast_expr2.y"
2080 { (yyval.val) = (yyvsp[(2) - (3)].val);
2081 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2082 (yyloc).first_line=0; (yyloc).last_line=0;
2083 DESTROY((yyvsp[(1) - (3)].val)); DESTROY((yyvsp[(3) - (3)].val)); ;}
2084 break;
2085
2086 case 10:
2087
2088/* Line 1455 of yacc.c */
2089#line 414 "ast_expr2.y"
2090 { (yyval.val) = op_or ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2091 DESTROY((yyvsp[(2) - (3)].val));
2092 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2093 (yyloc).first_line=0; (yyloc).last_line=0;;}
2094 break;
2095
2096 case 11:
2097
2098/* Line 1455 of yacc.c */
2099#line 418 "ast_expr2.y"
2100 { (yyval.val) = op_and ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2101 DESTROY((yyvsp[(2) - (3)].val));
2102 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2103 (yyloc).first_line=0; (yyloc).last_line=0;;}
2104 break;
2105
2106 case 12:
2107
2108/* Line 1455 of yacc.c */
2109#line 422 "ast_expr2.y"
2110 { (yyval.val) = op_eq ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2111 DESTROY((yyvsp[(2) - (3)].val));
2112 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2113 (yyloc).first_line=0; (yyloc).last_line=0;;}
2114 break;
2115
2116 case 13:
2117
2118/* Line 1455 of yacc.c */
2119#line 426 "ast_expr2.y"
2120 { (yyval.val) = op_gt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2121 DESTROY((yyvsp[(2) - (3)].val));
2122 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2123 (yyloc).first_line=0; (yyloc).last_line=0;;}
2124 break;
2125
2126 case 14:
2127
2128/* Line 1455 of yacc.c */
2129#line 430 "ast_expr2.y"
2130 { (yyval.val) = op_lt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2131 DESTROY((yyvsp[(2) - (3)].val));
2132 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2133 (yyloc).first_line=0; (yyloc).last_line=0;;}
2134 break;
2135
2136 case 15:
2137
2138/* Line 1455 of yacc.c */
2139#line 434 "ast_expr2.y"
2140 { (yyval.val) = op_ge ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2141 DESTROY((yyvsp[(2) - (3)].val));
2142 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2143 (yyloc).first_line=0; (yyloc).last_line=0;;}
2144 break;
2145
2146 case 16:
2147
2148/* Line 1455 of yacc.c */
2149#line 438 "ast_expr2.y"
2150 { (yyval.val) = op_le ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2151 DESTROY((yyvsp[(2) - (3)].val));
2152 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2153 (yyloc).first_line=0; (yyloc).last_line=0;;}
2154 break;
2155
2156 case 17:
2157
2158/* Line 1455 of yacc.c */
2159#line 442 "ast_expr2.y"
2160 { (yyval.val) = op_ne ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2161 DESTROY((yyvsp[(2) - (3)].val));
2162 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2163 (yyloc).first_line=0; (yyloc).last_line=0;;}
2164 break;
2165
2166 case 18:
2167
2168/* Line 1455 of yacc.c */
2169#line 446 "ast_expr2.y"
2170 { (yyval.val) = op_plus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2171 DESTROY((yyvsp[(2) - (3)].val));
2172 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2173 (yyloc).first_line=0; (yyloc).last_line=0;;}
2174 break;
2175
2176 case 19:
2177
2178/* Line 1455 of yacc.c */
2179#line 450 "ast_expr2.y"
2180 { (yyval.val) = op_minus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2181 DESTROY((yyvsp[(2) - (3)].val));
2182 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2183 (yyloc).first_line=0; (yyloc).last_line=0;;}
2184 break;
2185
2186 case 20:
2187
2188/* Line 1455 of yacc.c */
2189#line 454 "ast_expr2.y"
2190 { (yyval.val) = op_negate ((yyvsp[(2) - (2)].val));
2191 DESTROY((yyvsp[(1) - (2)].val));
2192 (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column;
2193 (yyloc).first_line=0; (yyloc).last_line=0;;}
2194 break;
2195
2196 case 21:
2197
2198/* Line 1455 of yacc.c */
2199#line 458 "ast_expr2.y"
2200 { (yyval.val) = op_compl ((yyvsp[(2) - (2)].val));
2201 DESTROY((yyvsp[(1) - (2)].val));
2202 (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column;
2203 (yyloc).first_line=0; (yyloc).last_line=0;;}
2204 break;
2205
2206 case 22:
2207
2208/* Line 1455 of yacc.c */
2209#line 462 "ast_expr2.y"
2210 { (yyval.val) = op_times ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2211 DESTROY((yyvsp[(2) - (3)].val));
2212 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2213 (yyloc).first_line=0; (yyloc).last_line=0;;}
2214 break;
2215
2216 case 23:
2217
2218/* Line 1455 of yacc.c */
2219#line 466 "ast_expr2.y"
2220 { (yyval.val) = op_div ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2221 DESTROY((yyvsp[(2) - (3)].val));
2222 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2223 (yyloc).first_line=0; (yyloc).last_line=0;;}
2224 break;
2225
2226 case 24:
2227
2228/* Line 1455 of yacc.c */
2229#line 470 "ast_expr2.y"
2230 { (yyval.val) = op_rem ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2231 DESTROY((yyvsp[(2) - (3)].val));
2232 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2233 (yyloc).first_line=0; (yyloc).last_line=0;;}
2234 break;
2235
2236 case 25:
2237
2238/* Line 1455 of yacc.c */
2239#line 474 "ast_expr2.y"
2240 { (yyval.val) = op_colon ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2241 DESTROY((yyvsp[(2) - (3)].val));
2242 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2243 (yyloc).first_line=0; (yyloc).last_line=0;;}
2244 break;
2245
2246 case 26:
2247
2248/* Line 1455 of yacc.c */
2249#line 478 "ast_expr2.y"
2250 { (yyval.val) = op_eqtilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2251 DESTROY((yyvsp[(2) - (3)].val));
2252 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2253 (yyloc).first_line=0; (yyloc).last_line=0;;}
2254 break;
2255
2256 case 27:
2257
2258/* Line 1455 of yacc.c */
2259#line 482 "ast_expr2.y"
2260 { (yyval.val) = op_cond ((yyvsp[(1) - (5)].val), (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val));
2261 DESTROY((yyvsp[(2) - (5)].val));
2262 DESTROY((yyvsp[(4) - (5)].val));
2263 (yyloc).first_column = (yylsp[(1) - (5)]).first_column; (yyloc).last_column = (yylsp[(3) - (5)]).last_column;
2264 (yyloc).first_line=0; (yyloc).last_line=0;;}
2265 break;
2266
2267 case 28:
2268
2269/* Line 1455 of yacc.c */
2270#line 487 "ast_expr2.y"
2271 { (yyval.val) = op_tildetilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
2272 DESTROY((yyvsp[(2) - (3)].val));
2273 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
2274 (yyloc).first_line=0; (yyloc).last_line=0;;}
2275 break;
2276
2277
2278
2279/* Line 1455 of yacc.c */
2280#line 2281 "ast_expr2.c"
2281 default: break;
2282 }
2283 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2284
2285 YYPOPSTACK (yylen);
2286 yylen = 0;
2287 YY_STACK_PRINT (yyss, yyssp);
2288
2289 *++yyvsp = yyval;
2290 *++yylsp = yyloc;
2291
2292 /* Now `shift' the result of the reduction. Determine what state
2293 that goes to, based on the state we popped back to and the rule
2294 number reduced by. */
2295
2296 yyn = yyr1[yyn];
2297
2298 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2299 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2300 yystate = yytable[yystate];
2301 else
2302 yystate = yydefgoto[yyn - YYNTOKENS];
2303
2304 goto yynewstate;
2305
2306
2307/*------------------------------------.
2308| yyerrlab -- here on detecting error |
2309`------------------------------------*/
2310yyerrlab:
2311 /* If not already recovering from an error, report this error. */
2312 if (!yyerrstatus)
2313 {
2314 ++yynerrs;
2315#if ! YYERROR_VERBOSE
2316 yyerror (YY_("syntax error"));
2317#else
2318 {
2319 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2320 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2321 {
2322 YYSIZE_T yyalloc = 2 * yysize;
2323 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2325 if (yymsg != yymsgbuf)
2326 YYSTACK_FREE (yymsg);
2327 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2328 if (yymsg)
2329 yymsg_alloc = yyalloc;
2330 else
2331 {
2332 yymsg = yymsgbuf;
2333 yymsg_alloc = sizeof yymsgbuf;
2334 }
2335 }
2336
2337 if (0 < yysize && yysize <= yymsg_alloc)
2338 {
2339 (void) yysyntax_error (yymsg, yystate, yychar);
2340 yyerror (yymsg);
2341 }
2342 else
2343 {
2344 yyerror (YY_("syntax error"));
2345 if (yysize != 0)
2346 goto yyexhaustedlab;
2347 }
2348 }
2349#endif
2350 }
2351
2352 yyerror_range[0] = yylloc;
2353
2354 if (yyerrstatus == 3)
2355 {
2356 /* If just tried and failed to reuse lookahead token after an
2357 error, discard it. */
2358
2359 if (yychar <= YYEOF)
2360 {
2361 /* Return failure if at end of input. */
2362 if (yychar == YYEOF)
2363 YYABORT;
2364 }
2365 else
2366 {
2367 yydestruct ("Error: discarding",
2368 yytoken, &yylval, &yylloc);
2369 yychar = YYEMPTY;
2370 }
2371 }
2372
2373 /* Else will try to reuse lookahead token after shifting the error
2374 token. */
2375 goto yyerrlab1;
2376
2377
2378/*---------------------------------------------------.
2379| yyerrorlab -- error raised explicitly by YYERROR. |
2380`---------------------------------------------------*/
2381yyerrorlab:
2382
2383 /* Pacify compilers like GCC when the user code never invokes
2384 YYERROR and the label yyerrorlab therefore never appears in user
2385 code. */
2386 if (/*CONSTCOND*/ 0)
2387 goto yyerrorlab;
2388
2389 yyerror_range[0] = yylsp[1-yylen];
2390 /* Do not reclaim the symbols of the rule which action triggered
2391 this YYERROR. */
2392 YYPOPSTACK (yylen);
2393 yylen = 0;
2394 YY_STACK_PRINT (yyss, yyssp);
2395 yystate = *yyssp;
2396 goto yyerrlab1;
2397
2398
2399/*-------------------------------------------------------------.
2400| yyerrlab1 -- common code for both syntax error and YYERROR. |
2401`-------------------------------------------------------------*/
2402yyerrlab1:
2403 yyerrstatus = 3; /* Each real token shifted decrements this. */
2404
2405 for (;;)
2406 {
2407 yyn = yypact[yystate];
2408 if (yyn != YYPACT_NINF)
2409 {
2410 yyn += YYTERROR;
2411 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2412 {
2413 yyn = yytable[yyn];
2414 if (0 < yyn)
2415 break;
2416 }
2417 }
2418
2419 /* Pop the current state because it cannot handle the error token. */
2420 if (yyssp == yyss)
2421 YYABORT;
2422
2423 yyerror_range[0] = *yylsp;
2424 yydestruct ("Error: popping",
2425 yystos[yystate], yyvsp, yylsp);
2426 YYPOPSTACK (1);
2427 yystate = *yyssp;
2428 YY_STACK_PRINT (yyss, yyssp);
2429 }
2430
2431 *++yyvsp = yylval;
2432
2433 yyerror_range[1] = yylloc;
2434 /* Using YYLLOC is tempting, but would change the location of
2435 the lookahead. YYLOC is available though. */
2436 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
2437 *++yylsp = yyloc;
2438
2439 /* Shift the error token. */
2440 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2441
2442 yystate = yyn;
2443 goto yynewstate;
2444
2445
2446/*-------------------------------------.
2447| yyacceptlab -- YYACCEPT comes here. |
2448`-------------------------------------*/
2449yyacceptlab:
2450 yyresult = 0;
2451 goto yyreturn;
2452
2453/*-----------------------------------.
2454| yyabortlab -- YYABORT comes here. |
2455`-----------------------------------*/
2456yyabortlab:
2457 yyresult = 1;
2458 goto yyreturn;
2459
2460#if !defined(yyoverflow) || YYERROR_VERBOSE
2461/*-------------------------------------------------.
2462| yyexhaustedlab -- memory exhaustion comes here. |
2463`-------------------------------------------------*/
2464yyexhaustedlab:
2465 yyerror (YY_("memory exhausted"));
2466 yyresult = 2;
2467 /* Fall through. */
2468#endif
2469
2470yyreturn:
2471 if (yychar != YYEMPTY)
2472 yydestruct ("Cleanup: discarding lookahead",
2473 yytoken, &yylval, &yylloc);
2474 /* Do not reclaim the symbols of the rule which action triggered
2475 this YYABORT or YYACCEPT. */
2476 YYPOPSTACK (yylen);
2477 YY_STACK_PRINT (yyss, yyssp);
2478 while (yyssp != yyss)
2479 {
2480 yydestruct ("Cleanup: popping",
2481 yystos[*yyssp], yyvsp, yylsp);
2482 YYPOPSTACK (1);
2483 }
2484#ifndef yyoverflow
2485 if (yyss != yyssa)
2486 YYSTACK_FREE (yyss);
2487#endif
2488#if YYERROR_VERBOSE
2489 if (yymsg != yymsgbuf)
2490 YYSTACK_FREE (yymsg);
2491#endif
2492 /* Make sure YYID is used. */
2493 return YYID (yyresult);
2494}
static struct val * op_gt(struct val *a, struct val *b)
Definition: ast_expr2.c:3143
#define YYID(n)
Definition: ast_expr2.c:584
static void destroy_arglist(struct expr_node *arglist)
Definition: ast_expr2.c:2730
static const yytype_uint8 yyr1[]
Definition: ast_expr2.c:843
#define yylloc
Definition: ast_expr2.c:74
#define YYLEX
Definition: ast_expr2.c:1038
#define YYMAXDEPTH
Definition: ast_expr2.c:1226
#define YYSTACK_FREE
Definition: ast_expr2.c:640
static struct val * op_or(struct val *a, struct val *b)
Definition: ast_expr2.c:3091
static struct val * op_ne(struct val *a, struct val *b)
Definition: ast_expr2.c:3262
#define yychar
Definition: ast_expr2.c:71
static void yydestruct(char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) const
Definition: ast_expr2.c:1453
#define YYEOF
Definition: ast_expr2.c:956
#define YYABORT
Definition: ast_expr2.c:959
#define YYSTACK_BYTES(N)
Definition: ast_expr2.c:688
static const yytype_int8 yycheck[]
Definition: ast_expr2.c:921
#define YYLLOC_DEFAULT(Current, Rhs, N)
Definition: ast_expr2.c:999
#define YY_REDUCE_PRINT(Rule)
Definition: ast_expr2.c:1209
static struct val * op_tildetilde(struct val *a, struct val *b)
Definition: ast_expr2.c:3655
#define YYTABLE_NINF
Definition: ast_expr2.c:900
static const yytype_int16 yypact[]
Definition: ast_expr2.c:880
static struct val * op_colon(struct val *a, struct val *b)
Definition: ast_expr2.c:3554
#define YYPACT_NINF
Definition: ast_expr2.c:879
#define YYFINAL
Definition: ast_expr2.c:729
static YYSIZE_T yysyntax_error(char *yyresult, int yystate, int yychar)
Definition: ast_expr2.c:1340
#define yylval
Definition: ast_expr2.c:70
#define YYNTOKENS
Definition: ast_expr2.c:734
#define YY_STACK_PRINT(Bottom, Top)
Definition: ast_expr2.c:1208
#define YYSIZE_T
Definition: ast_expr2.c:557
#define YYSTACK_ALLOC_MAXIMUM
Definition: ast_expr2.c:642
static struct val * op_minus(struct val *a, struct val *b)
Definition: ast_expr2.c:3339
#define YY_(msgid)
Definition: ast_expr2.c:571
static struct val * op_compl(struct val *a)
Definition: ast_expr2.c:3393
#define yynerrs
Definition: ast_expr2.c:73
static struct val * op_div(struct val *a, struct val *b)
Definition: ast_expr2.c:3492
static struct val * op_times(struct val *a, struct val *b)
Definition: ast_expr2.c:3459
static struct val * op_lt(struct val *a, struct val *b)
Definition: ast_expr2.c:3163
static const yytype_uint8 yyr2[]
Definition: ast_expr2.c:851
#define YYACCEPT
Definition: ast_expr2.c:958
static struct val * op_eqtilde(struct val *a, struct val *b)
Definition: ast_expr2.c:3605
#define YYTRANSLATE(YYX)
Definition: ast_expr2.c:746
static struct val * op_plus(struct val *a, struct val *b)
Definition: ast_expr2.c:3295
static const yytype_int8 yypgoto[]
Definition: ast_expr2.c:891
static const yytype_uint8 yystos[]
Definition: ast_expr2.c:943
static struct val * op_rem(struct val *a, struct val *b)
Definition: ast_expr2.c:3527
static struct val * op_func(struct val *funcname, struct expr_node *arglist, struct ast_channel *chan)
Definition: ast_expr2.c:2798
static struct val * op_negate(struct val *a)
Definition: ast_expr2.c:3373
static struct expr_node * alloc_expr_node(enum node_type)
Definition: ast_expr2.c:2502
static struct val * op_eq(struct val *a, struct val *b)
Definition: ast_expr2.c:3116
#define DESTROY(x)
Definition: ast_expr2.c:412
#define YYTERROR
Definition: ast_expr2.c:989
#define YYPOPSTACK(N)
static struct val * op_le(struct val *a, struct val *b)
Definition: ast_expr2.c:3203
static struct val * op_ge(struct val *a, struct val *b)
Definition: ast_expr2.c:3183
static struct val * op_and(struct val *a, struct val *b)
Definition: ast_expr2.c:3103
static const yytype_int8 yydefgoto[]
Definition: ast_expr2.c:872
#define YYEMPTY
Definition: ast_expr2.c:955
#define YYLAST
Definition: ast_expr2.c:731
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
Definition: ast_expr2.c:715
#define YYINITDEPTH
Definition: ast_expr2.c:1215
static const yytype_uint8 yytable[]
Definition: ast_expr2.c:901
#define YYSTACK_ALLOC
Definition: ast_expr2.c:639
#define YYDPRINTF(Args)
Definition: ast_expr2.c:1206
static const yytype_uint8 yydefact[]
Definition: ast_expr2.c:861
static struct val * op_cond(struct val *a, struct val *b, struct val *c)
Definition: ast_expr2.c:3223
#define yyerror
Definition: ast_expr2.c:69
static const char type[]
Definition: chan_ooh323.c:109
struct expr_node * arglist
Definition: ast_expr2.c:479
yytype_int16 yyss_alloc
Definition: ast_expr2.c:678
YYLTYPE yyls_alloc
Definition: ast_expr2.c:680
YYSTYPE yyvs_alloc
Definition: ast_expr2.c:679

References alloc_expr_node(), YYSTYPE::arglist, AST_EXPR_NODE_VAL, AST_EXPR_number, AST_EXPR_string, calloc, DESTROY, destroy_arglist(), free(), val::i, 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, val::s, strdup, type, val::u, expr_node::val, YYSTYPE::val, YY_, YY_REDUCE_PRINT, YY_STACK_PRINT, YY_SYMBOL_PRINT, YYABORT, YYACCEPT, yychar, yycheck, yydefact, yydefgoto, yydestruct(), YYDPRINTF, YYEMPTY, YYEOF, yyerror, YYFINAL, YYID, YYINITDEPTH, YYLAST, YYLEX, yylloc, YYLLOC_DEFAULT, yyalloc::yyls_alloc, yylval, YYMAXDEPTH, yynerrs, YYNTOKENS, yypact, YYPACT_NINF, yypgoto, YYPOPSTACK, yyr1, yyr2, YYSIZE_T, yyalloc::yyss_alloc, YYSTACK_ALLOC, YYSTACK_ALLOC_MAXIMUM, YYSTACK_BYTES, YYSTACK_FREE, YYSTACK_RELOCATE, yystos, yysyntax_error(), yytable, YYTABLE_NINF, YYTERROR, YYTRANSLATE, and yyalloc::yyvs_alloc.

◆ yystpcpy()

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

Definition at line 1268 of file ast_expr2.c.

1272{
1273 char *yyd = yydest;
1274 const char *yys = yysrc;
1275
1276 while ((*yyd++ = *yys++) != '\0')
1277 continue;
1278
1279 return yyd - 1;
1280}

Referenced by yysyntax_error(), and yytnamerr().

◆ yystrlen()

static YYSIZE_T yystrlen ( char *  yystr) const
static

Definition at line 1244 of file ast_expr2.c.

1247{
1248 YYSIZE_T yylen;
1249 for (yylen = 0; yystr[yylen]; yylen++)
1250 continue;
1251 return yylen;
1252}

References YYSIZE_T.

Referenced by yysyntax_error(), and yytnamerr().

◆ yysyntax_error()

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

Definition at line 1340 of file ast_expr2.c.

1341{
1342 int yyn = yypact[yystate];
1343
1344 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1345 return 0;
1346 else
1347 {
1348 int yytype = YYTRANSLATE (yychar);
1349 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1350 YYSIZE_T yysize = yysize0;
1351 YYSIZE_T yysize1;
1352 int yysize_overflow = 0;
1353 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1354 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1355 int yyx;
1356
1357# if 0
1358 /* This is so xgettext sees the translatable formats that are
1359 constructed on the fly. */
1360 YY_("syntax error, unexpected %s");
1361 YY_("syntax error, unexpected %s, expecting %s");
1362 YY_("syntax error, unexpected %s, expecting %s or %s");
1363 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1364 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1365# endif
1366 char *yyfmt;
1367 char const *yyf;
1368 static char const yyunexpected[] = "syntax error, unexpected %s";
1369 static char const yyexpecting[] = ", expecting %s";
1370 static char const yyor[] = " or %s";
1371 char yyformat[sizeof yyunexpected
1372 + sizeof yyexpecting - 1
1373 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1374 * (sizeof yyor - 1))];
1375 char const *yyprefix = yyexpecting;
1376
1377 /* Start YYX at -YYN if negative to avoid negative indexes in
1378 YYCHECK. */
1379 int yyxbegin = yyn < 0 ? -yyn : 0;
1380
1381 /* Stay within bounds of both yycheck and yytname. */
1382 int yychecklim = YYLAST - yyn + 1;
1383 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1384 int yycount = 1;
1385
1386 yyarg[0] = yytname[yytype];
1387 yyfmt = yystpcpy (yyformat, yyunexpected);
1388
1389 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1390 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1391 {
1392 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1393 {
1394 yycount = 1;
1395 yysize = yysize0;
1396 yyformat[sizeof yyunexpected - 1] = '\0';
1397 break;
1398 }
1399 yyarg[yycount++] = yytname[yyx];
1400 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1401 yysize_overflow |= (yysize1 < yysize);
1402 yysize = yysize1;
1403 yyfmt = yystpcpy (yyfmt, yyprefix);
1404 yyprefix = yyor;
1405 }
1406
1407 yyf = YY_(yyformat);
1408 yysize1 = yysize + yystrlen (yyf);
1409 yysize_overflow |= (yysize1 < yysize);
1410 yysize = yysize1;
1411
1412 if (yysize_overflow)
1413 return YYSIZE_MAXIMUM;
1414
1415 if (yyresult)
1416 {
1417 /* Avoid sprintf, as that infringes on the user's name space.
1418 Don't have undefined behavior even if the translation
1419 produced a string with the wrong number of "%s"s. */
1420 char *yyp = yyresult;
1421 int yyi = 0;
1422 while ((*yyp = *yyf) != '\0')
1423 {
1424 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1425 {
1426 yyp += yytnamerr (yyp, yyarg[yyi++]);
1427 yyf += 2;
1428 }
1429 else
1430 {
1431 yyp++;
1432 yyf++;
1433 }
1434 }
1435 }
1436 return yysize;
1437 }
1438}
static YYSIZE_T yystrlen(char *yystr) const
Definition: ast_expr2.c:1244
#define YYSIZE_MAXIMUM
Definition: ast_expr2.c:561
static const char *const yytname[]
Definition: ast_expr2.c:821
static YYSIZE_T yytnamerr(char *yyres, const char *yystr)
Definition: ast_expr2.c:1293
static char * yystpcpy(char *yydest, const char *yysrc)
Definition: ast_expr2.c:1268

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

Referenced by yyparse().

◆ yytnamerr()

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

Definition at line 1293 of file ast_expr2.c.

1294{
1295 if (*yystr == '"')
1296 {
1297 YYSIZE_T yyn = 0;
1298 char const *yyp = yystr;
1299
1300 for (;;)
1301 switch (*++yyp)
1302 {
1303 case '\'':
1304 case ',':
1305 goto do_not_strip_quotes;
1306
1307 case '\\':
1308 if (*++yyp != '\\')
1309 goto do_not_strip_quotes;
1310 /* Fall through. */
1311 default:
1312 if (yyres)
1313 yyres[yyn] = *yyp;
1314 yyn++;
1315 break;
1316
1317 case '"':
1318 if (yyres)
1319 yyres[yyn] = '\0';
1320 return yyn;
1321 }
1322 do_not_strip_quotes: ;
1323 }
1324
1325 if (! yyres)
1326 return yystrlen (yystr);
1327
1328 return yystpcpy (yyres, yystr) - yyres;
1329}

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

Referenced by yysyntax_error().

Variable Documentation

◆ extra_error_message

char extra_error_message[4095]
extern

◆ extra_error_message_supplied

int extra_error_message_supplied
extern

◆ yycheck

const yytype_int8 yycheck[]
static

Definition at line 921 of file ast_expr2.c.

Referenced by yyparse(), and yysyntax_error().

◆ yydefact

const yytype_uint8 yydefact[]
static

Definition at line 861 of file ast_expr2.c.

Referenced by yyparse().

◆ yydefgoto

const yytype_int8 yydefgoto[]
static
Initial value:
=
{
-1, 5, 30, 6
}

Definition at line 872 of file ast_expr2.c.

Referenced by yyparse().

◆ yypact

const yytype_int16 yypact[]
static

Definition at line 880 of file ast_expr2.c.

Referenced by yyparse(), and yysyntax_error().

◆ yypgoto

const yytype_int8 yypgoto[]
static
Initial value:
=
{
-18, -18, -18, -1
}

Definition at line 891 of file ast_expr2.c.

Referenced by yyparse().

◆ yyr1

const yytype_uint8 yyr1[]
static

Definition at line 843 of file ast_expr2.c.

Referenced by yyparse().

◆ yyr2

const yytype_uint8 yyr2[]
static

Definition at line 851 of file ast_expr2.c.

Referenced by yyparse().

◆ yystos

const yytype_uint8 yystos[]
static

Definition at line 943 of file ast_expr2.c.

Referenced by yyparse().

◆ yytable

const yytype_uint8 yytable[]
static

Definition at line 901 of file ast_expr2.c.

Referenced by yyparse().

◆ yytname

const char* const yytname[]
static

Definition at line 821 of file ast_expr2.c.

Referenced by yysyntax_error().

◆ yytranslate

const yytype_uint8 yytranslate[]
static

Definition at line 750 of file ast_expr2.c.