#include "asterisk.h"
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.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"
Go to the source code of this file.
Data Structures | |
struct | parse_io |
struct | val |
union | yyalloc |
struct | yyltype |
union | YYSTYPE |
Defines | |
#define | ast_yyerror(x) ast_yyerror(x, YYLTYPE *yylloc, struct parse_io *parseio) |
#define | ast_yyerror(x) ast_yyerror(x,&yyloc,parseio) |
#define | DESTROY(x) {if((x)->type == AST_EXPR_numeric_string || (x)->type == AST_EXPR_string) free((x)->u.s); (x)->u.s = 0; free(x);} |
#define | QUAD_MAX (0x7fffffffffffffffLL) |
#define | QUAD_MIN (-0x7fffffffffffffffLL-1) |
#define | YY_(msgid) msgid |
#define | YY_LOCATION_PRINT(File, Loc) |
#define | YY_REDUCE_PRINT(Rule) |
#define | YY_STACK_PRINT(Bottom, Top) |
#define | YY_SYMBOL_PRINT(Title, Type, Value, Location) |
#define | YYABORT goto yyabortlab |
#define | YYACCEPT goto yyacceptlab |
#define | YYBACKUP(Token, Value) |
#define | YYBISON 1 |
#define | YYBISON_VERSION "2.4.1" |
#define | yychar ast_yychar |
#define | yyclearin (yychar = YYEMPTY) |
#define | YYCOPY(To, From, Count) |
#define | YYDEBUG 0 |
#define | yydebug ast_yydebug |
#define | YYDPRINTF(Args) |
#define | YYEMPTY (-2) |
#define | YYEOF 0 |
#define | YYERRCODE 256 |
#define | yyerrok (yyerrstatus = 0) |
#define | YYERROR goto yyerrorlab |
#define | yyerror ast_yyerror |
#define | YYERROR_VERBOSE 1 |
#define | YYERROR_VERBOSE 1 |
#define | YYFAIL goto yyerrlab |
#define | YYFINAL 10 |
#define | YYFREE free |
#define | YYID(n) (n) |
#define | YYINITDEPTH 200 |
#define | YYLAST 140 |
#define | YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) |
#define | yylex ast_yylex |
#define | YYLEX_PARAM ((struct parse_io *)parseio)->scanner |
#define | yylloc ast_yylloc |
#define | YYLLOC_DEFAULT(Current, Rhs, N) |
#define | YYLSP_NEEDED 1 |
#define | YYLTYPE yyltype |
#define | YYLTYPE_IS_TRIVIAL 1 |
#define | yylval ast_yylval |
#define | YYMALLOC malloc |
#define | YYMAXDEPTH 10000 |
#define | YYMAXUTOK 278 |
#define | yynerrs ast_yynerrs |
#define | YYNNTS 3 |
#define | YYNRULES 23 |
#define | YYNSTATES 46 |
#define | YYNTOKENS 24 |
#define | YYPACT_NINF -13 |
#define | yyparse ast_yyparse |
#define | YYPARSE_PARAM parseio |
#define | YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) |
#define | YYPULL 1 |
#define | YYPURE 1 |
#define | YYPUSH 0 |
#define | YYRECOVERING() (!!yyerrstatus) |
#define | YYRHSLOC(Rhs, K) ((Rhs)[K]) |
#define | YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
#define | YYSIZE_T unsigned int |
#define | YYSKELETON_NAME "yacc.c" |
#define | YYSTACK_ALLOC YYMALLOC |
#define | YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
#define | YYSTACK_BYTES(N) |
#define | YYSTACK_FREE YYFREE |
#define | YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
#define | YYSTACK_RELOCATE(Stack_alloc, Stack) |
#define | yystype YYSTYPE |
#define | YYSTYPE_IS_DECLARED 1 |
#define | YYSTYPE_IS_TRIVIAL 1 |
#define | YYTABLE_NINF -1 |
#define | YYTERROR 1 |
#define | YYTOKEN_TABLE 0 |
#define | YYTRANSLATE(YYX) ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
#define | YYUNDEFTOK 2 |
#define | YYUSE(e) ((void) (e)) |
Typedefs | |
typedef void * | yyscan_t |
typedef short int | yytype_int16 |
typedef short int | yytype_int8 |
typedef unsigned short int | yytype_uint16 |
typedef unsigned char | yytype_uint8 |
Enumerations | |
enum | valtype { AST_EXPR_integer, AST_EXPR_numeric_string, AST_EXPR_string } |
enum | yytokentype { TOK_COLONCOLON = 258, TOK_COND = 259, TOK_OR = 260, TOK_AND = 261, TOK_NE = 262, TOK_LE = 263, TOK_GE = 264, TOK_LT = 265, TOK_GT = 266, TOK_EQ = 267, TOK_MINUS = 268, TOK_PLUS = 269, TOK_MOD = 270, TOK_DIV = 271, TOK_MULT = 272, TOK_COMPL = 273, TOK_EQTILDE = 274, TOK_COLON = 275, TOK_LP = 276, TOK_RP = 277, TOKEN = 278 } |
Functions | |
int ast_yylex | __P ((YYSTYPE *, YYLTYPE *, yyscan_t)) |
static struct val *op_cond | __P ((struct val *, struct val *, struct val *)) |
static struct val *op_and | __P ((struct val *, struct val *)) |
static struct val *make_str | __P ((const char *)) |
static struct val *make_integer | __P ((quad_t)) |
static void free_value | __P ((struct val *)) |
static int chk_minus | __P ((quad_t, quad_t, quad_t)) |
static int chk_div | __P ((quad_t, quad_t)) |
int | ast_yyerror (const char *, YYLTYPE *, struct parse_io *) |
static int | chk_div (quad_t a, quad_t b) |
static int | chk_minus (quad_t a, quad_t b, quad_t r) |
static int | chk_plus (quad_t a, quad_t b, quad_t r) |
static int | chk_times (quad_t a, quad_t b, quad_t r) |
static void | free_value (struct val *vp) |
static int | is_zero_or_null (struct val *vp) |
static int | isstring (struct val *vp) |
static struct val * | make_integer (quad_t i) |
static struct val * | make_str (const char *s) |
static struct val * | op_and (struct val *a, struct val *b) |
static struct val * | op_colon (struct val *a, struct val *b) |
static struct val * | op_compl (struct val *a) |
static struct val * | op_cond (struct val *a, struct val *b, struct val *c) |
static struct val * | op_div (struct val *a, struct val *b) |
static struct val * | op_eq (struct val *a, struct val *b) |
static struct val * | op_eqtilde (struct val *a, struct val *b) |
static struct val * | op_ge (struct val *a, struct val *b) |
static struct val * | op_gt (struct val *a, struct val *b) |
static struct val * | op_le (struct val *a, struct val *b) |
static struct val * | op_lt (struct val *a, struct val *b) |
static struct val * | op_minus (struct val *a, struct val *b) |
static struct val * | op_ne (struct val *a, struct val *b) |
static struct val * | op_negate (struct val *a) |
static struct val * | op_or (struct val *a, struct val *b) |
static struct val * | op_plus (struct val *a, struct val *b) |
static struct val * | op_rem (struct val *a, struct val *b) |
static struct val * | op_times (struct val *a, struct val *b) |
static void | strip_quotes (struct val *vp) |
static quad_t | to_integer (struct val *vp) |
static void | to_string (struct val *vp) |
static void | yydestruct (char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) const |
int | yyparse (void *YYPARSE_PARAM) |
int | yyparse () |
static char * | yystpcpy (char *yydest, const char *yysrc) |
static YYSIZE_T | yystrlen (char *yystr) const |
static YYSIZE_T | yysyntax_error (char *yyresult, int yystate, int yychar) |
static YYSIZE_T | yytnamerr (char *yyres, const char *yystr) |
Variables | |
char | extra_error_message [4095] |
int | extra_error_message_supplied |
static const yytype_int8 | yycheck [] |
static const yytype_uint8 | yydefact [] |
static const yytype_int8 | yydefgoto [] |
static const yytype_int8 | yypact [] |
static const yytype_int8 | yypgoto [] |
static const yytype_uint8 | yyr1 [] |
static const yytype_uint8 | yyr2 [] |
static const yytype_uint8 | yystos [] |
static const yytype_uint8 | yytable [] |
static const char *const | yytname [] |
static const yytype_uint8 | yytranslate [] |
Definition at line 2448 of file ast_expr2.c.
#define ast_yyerror | ( | x | ) | ast_yyerror(x,&yyloc,parseio) |
Definition at line 2448 of file ast_expr2.c.
#define QUAD_MAX (0x7fffffffffffffffLL) |
Definition at line 130 of file ast_expr2.c.
#define QUAD_MIN (-0x7fffffffffffffffLL-1) |
#define YY_ | ( | msgid | ) | msgid |
#define YY_LOCATION_PRINT | ( | File, | |||
Loc | ) |
Value:
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
(Loc).last_line, (Loc).last_column)
Definition at line 818 of file ast_expr2.c.
#define YY_REDUCE_PRINT | ( | Rule | ) |
#define YY_STACK_PRINT | ( | Bottom, | |||
Top | ) |
#define YY_SYMBOL_PRINT | ( | Title, | |||
Type, | |||||
Value, | |||||
Location | ) |
#define YYABORT goto yyabortlab |
#define YYACCEPT goto yyacceptlab |
#define YYBACKUP | ( | Token, | |||
Value | ) |
Definition at line 764 of file ast_expr2.c.
#define YYBISON 1 |
Definition at line 46 of file ast_expr2.c.
#define YYBISON_VERSION "2.4.1" |
Definition at line 49 of file ast_expr2.c.
#define yychar ast_yychar |
#define yyclearin (yychar = YYEMPTY) |
Definition at line 747 of file ast_expr2.c.
#define YYCOPY | ( | To, | |||
From, | |||||
Count | ) |
Definition at line 500 of file ast_expr2.c.
#define YYDEBUG 0 |
Definition at line 224 of file ast_expr2.c.
#define yydebug ast_yydebug |
Definition at line 72 of file ast_expr2.c.
#define YYDPRINTF | ( | Args | ) |
#define YYEMPTY (-2) |
#define YYEOF 0 |
#define YYERRCODE 256 |
Definition at line 783 of file ast_expr2.c.
#define yyerrok (yyerrstatus = 0) |
Definition at line 746 of file ast_expr2.c.
#define YYERROR goto yyerrorlab |
Definition at line 753 of file ast_expr2.c.
#define yyerror ast_yyerror |
#define YYERROR_VERBOSE 1 |
Definition at line 230 of file ast_expr2.c.
#define YYERROR_VERBOSE 1 |
Definition at line 230 of file ast_expr2.c.
#define YYFAIL goto yyerrlab |
Definition at line 760 of file ast_expr2.c.
#define YYFINAL 10 |
#define YYFREE free |
Definition at line 461 of file ast_expr2.c.
#define YYID | ( | n | ) | (n) |
#define YYINITDEPTH 200 |
#define YYLAST 140 |
#define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) |
#define yylex ast_yylex |
Definition at line 68 of file ast_expr2.c.
#define YYLEX_PARAM ((struct parse_io *)parseio)->scanner |
Definition at line 134 of file ast_expr2.c.
#define yylloc ast_yylloc |
Definition at line 74 of file ast_expr2.c.
Referenced by ast_yyget_lloc(), ast_yyset_lloc(), and yyparse().
#define YYLLOC_DEFAULT | ( | Current, | |||
Rhs, | |||||
N | ) |
#define YYLSP_NEEDED 1 |
Definition at line 64 of file ast_expr2.c.
Definition at line 204 of file ast_expr2.c.
#define YYLTYPE_IS_TRIVIAL 1 |
Definition at line 205 of file ast_expr2.c.
#define yylval ast_yylval |
Definition at line 70 of file ast_expr2.c.
Referenced by ast_yyget_lval(), ast_yyset_lval(), and yyparse().
#define YYMALLOC malloc |
Definition at line 454 of file ast_expr2.c.
#define YYMAXDEPTH 10000 |
#define YYMAXUTOK 278 |
Definition at line 545 of file ast_expr2.c.
#define yynerrs ast_yynerrs |
#define YYNNTS 3 |
Definition at line 537 of file ast_expr2.c.
#define YYNRULES 23 |
Definition at line 539 of file ast_expr2.c.
#define YYNSTATES 46 |
Definition at line 541 of file ast_expr2.c.
#define YYNTOKENS 24 |
#define YYPACT_NINF -13 |
#define yyparse ast_yyparse |
Definition at line 67 of file ast_expr2.c.
#define YYPARSE_PARAM parseio |
Definition at line 133 of file ast_expr2.c.
#define YYPOPSTACK | ( | N | ) | (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) |
Referenced by yyparse().
#define YYPULL 1 |
Definition at line 61 of file ast_expr2.c.
#define YYPURE 1 |
Definition at line 55 of file ast_expr2.c.
#define YYPUSH 0 |
Definition at line 58 of file ast_expr2.c.
#define YYRECOVERING | ( | ) | (!!yyerrstatus) |
Definition at line 762 of file ast_expr2.c.
#define YYRHSLOC | ( | Rhs, | |||
K | ) | ((Rhs)[K]) |
Definition at line 790 of file ast_expr2.c.
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
#define YYSIZE_T unsigned int |
Definition at line 358 of file ast_expr2.c.
Referenced by yyparse(), yystrlen(), yysyntax_error(), and yytnamerr().
#define YYSKELETON_NAME "yacc.c" |
Definition at line 52 of file ast_expr2.c.
#define YYSTACK_ALLOC YYMALLOC |
#define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
#define YYSTACK_BYTES | ( | N | ) |
Value:
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM)
Definition at line 489 of file ast_expr2.c.
Referenced by yyparse().
#define YYSTACK_FREE YYFREE |
#define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
Definition at line 485 of file ast_expr2.c.
#define YYSTACK_RELOCATE | ( | Stack_alloc, | |||
Stack | ) |
#define yystype YYSTYPE |
Definition at line 288 of file ast_expr2.c.
#define YYSTYPE_IS_DECLARED 1 |
Definition at line 289 of file ast_expr2.c.
#define YYSTYPE_IS_TRIVIAL 1 |
Definition at line 287 of file ast_expr2.c.
#define YYTABLE_NINF -1 |
#define YYTERROR 1 |
#define YYTOKEN_TABLE 0 |
Definition at line 237 of file ast_expr2.c.
#define YYTRANSLATE | ( | YYX | ) | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
#define YYUNDEFTOK 2 |
Definition at line 544 of file ast_expr2.c.
#define YYUSE | ( | e | ) | ((void) (e)) |
typedef void* yyscan_t |
Definition at line 155 of file ast_expr2.c.
typedef short int yytype_int16 |
Definition at line 345 of file ast_expr2.c.
typedef short int yytype_int8 |
Definition at line 333 of file ast_expr2.c.
typedef unsigned short int yytype_uint16 |
Definition at line 339 of file ast_expr2.c.
typedef unsigned char yytype_uint8 |
Definition at line 324 of file ast_expr2.c.
enum valtype |
Definition at line 139 of file ast_expr2.c.
00139 { 00140 AST_EXPR_integer, AST_EXPR_numeric_string, AST_EXPR_string 00141 } ;
enum yytokentype |
TOK_COLONCOLON | |
TOK_COND | |
TOK_OR | |
TOK_AND | |
TOK_NE | |
TOK_LE | |
TOK_GE | |
TOK_LT | |
TOK_GT | |
TOK_EQ | |
TOK_MINUS | |
TOK_PLUS | |
TOK_MOD | |
TOK_DIV | |
TOK_MULT | |
TOK_COMPL | |
TOK_EQTILDE | |
TOK_COLON | |
TOK_LP | |
TOK_RP | |
TOKEN |
Definition at line 246 of file ast_expr2.c.
00246 { 00247 TOK_COLONCOLON = 258, 00248 TOK_COND = 259, 00249 TOK_OR = 260, 00250 TOK_AND = 261, 00251 TOK_NE = 262, 00252 TOK_LE = 263, 00253 TOK_GE = 264, 00254 TOK_LT = 265, 00255 TOK_GT = 266, 00256 TOK_EQ = 267, 00257 TOK_MINUS = 268, 00258 TOK_PLUS = 269, 00259 TOK_MOD = 270, 00260 TOK_DIV = 271, 00261 TOK_MULT = 272, 00262 TOK_COMPL = 273, 00263 TOK_EQTILDE = 274, 00264 TOK_COLON = 275, 00265 TOK_LP = 276, 00266 TOK_RP = 277, 00267 TOKEN = 278 00268 };
static struct val* make_str __P | ( | (const char *) | ) | [static] |
static struct val* make_integer __P | ( | (quad_t) | ) | [static] |
static void to_string __P | ( | (struct val *) | ) | [static] |
static int chk_times __P | ( | (quad_t, quad_t, quad_t) | ) | [static] |
static int chk_div __P | ( | (quad_t, quad_t) | ) | [static] |
static int chk_div | ( | quad_t | a, | |
quad_t | b | |||
) | [static] |
Definition at line 2847 of file ast_expr2.c.
References QUAD_MIN.
Referenced by op_div().
02848 { 02849 /* div by zero has been taken care of before */ 02850 /* only QUAD_MIN / -1 causes overflow */ 02851 if (a == QUAD_MIN && b == -1) 02852 return 1; 02853 /* everything else is OK */ 02854 return 0; 02855 }
static int chk_minus | ( | quad_t | a, | |
quad_t | b, | |||
quad_t | r | |||
) | [static] |
Definition at line 2691 of file ast_expr2.c.
References chk_plus(), and QUAD_MIN.
Referenced by op_minus(), and op_negate().
02692 { 02693 /* special case subtraction of QUAD_MIN */ 02694 if (b == QUAD_MIN) { 02695 if (a >= 0) 02696 return 1; 02697 else 02698 return 0; 02699 } 02700 /* this is allowed for b != QUAD_MIN */ 02701 return chk_plus (a, -b, r); 02702 }
static int chk_plus | ( | quad_t | a, | |
quad_t | b, | |||
quad_t | r | |||
) | [static] |
Definition at line 2648 of file ast_expr2.c.
Referenced by chk_minus(), and op_plus().
02649 { 02650 /* sum of two positive numbers must be positive */ 02651 if (a > 0 && b > 0 && r <= 0) 02652 return 1; 02653 /* sum of two negative numbers must be negative */ 02654 if (a < 0 && b < 0 && r >= 0) 02655 return 1; 02656 /* all other cases are OK */ 02657 return 0; 02658 }
static int chk_times | ( | quad_t | a, | |
quad_t | b, | |||
quad_t | r | |||
) | [static] |
Definition at line 2813 of file ast_expr2.c.
Referenced by op_times().
02814 { 02815 /* special case: first operand is 0, no overflow possible */ 02816 if (a == 0) 02817 return 0; 02818 /* cerify that result of division matches second operand */ 02819 if (r / a != b) 02820 return 1; 02821 return 0; 02822 }
static void free_value | ( | struct val * | vp | ) | [static] |
Definition at line 2280 of file ast_expr2.c.
References AST_EXPR_numeric_string, free, val::s, val::type, and val::u.
Referenced by op_and(), op_colon(), op_compl(), op_cond(), op_div(), op_eq(), op_eqtilde(), op_ge(), op_gt(), op_le(), op_lt(), op_minus(), op_ne(), op_negate(), op_or(), op_plus(), op_rem(), op_times(), and yydestruct().
02281 { 02282 if (vp==NULL) { 02283 return; 02284 } 02285 if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string) 02286 free (vp->u.s); 02287 free(vp); 02288 }
static int is_zero_or_null | ( | struct val * | vp | ) | [static] |
Definition at line 2374 of file ast_expr2.c.
References AST_EXPR_integer, val::i, val::s, to_integer(), val::type, and val::u.
Referenced by op_and(), and op_or().
02375 { 02376 if (vp->type == AST_EXPR_integer) { 02377 return (vp->u.i == 0); 02378 } else { 02379 return (*vp->u.s == 0 || (to_integer (vp) && vp->u.i == 0)); 02380 } 02381 /* NOTREACHED */ 02382 }
static int isstring | ( | struct val * | vp | ) | [static] |
static struct val* make_integer | ( | quad_t | i | ) | [static] |
Definition at line 2234 of file ast_expr2.c.
References AST_EXPR_integer, ast_log(), LOG_WARNING, and malloc.
Referenced by op_and(), op_colon(), op_compl(), op_div(), op_eq(), op_eqtilde(), op_ge(), op_gt(), op_le(), op_lt(), op_minus(), op_ne(), op_negate(), op_plus(), op_rem(), and op_times().
02235 { 02236 struct val *vp; 02237 02238 vp = (struct val *) malloc (sizeof (*vp)); 02239 if (vp == NULL) { 02240 ast_log(LOG_WARNING, "malloc() failed\n"); 02241 return(NULL); 02242 } 02243 02244 vp->type = AST_EXPR_integer; 02245 vp->u.i = i; 02246 return vp; 02247 }
static struct val* make_str | ( | const char * | s | ) | [static] |
Definition at line 2250 of file ast_expr2.c.
References AST_EXPR_numeric_string, ast_log(), val::i, LOG_WARNING, malloc, and strdup.
Referenced by op_colon(), and op_eqtilde().
02251 { 02252 struct val *vp; 02253 size_t i; 02254 int isint; 02255 02256 vp = (struct val *) malloc (sizeof (*vp)); 02257 if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) { 02258 ast_log(LOG_WARNING,"malloc() failed\n"); 02259 return(NULL); 02260 } 02261 02262 for(i = 1, isint = isdigit(s[0]) || s[0] == '-'; 02263 isint && i < strlen(s); 02264 i++) 02265 { 02266 if(!isdigit(s[i])) 02267 isint = 0; 02268 } 02269 02270 if (isint) 02271 vp->type = AST_EXPR_numeric_string; 02272 else 02273 vp->type = AST_EXPR_string; 02274 02275 return vp; 02276 }
Definition at line 2469 of file ast_expr2.c.
References free_value(), is_zero_or_null(), and make_integer().
Referenced by yyparse().
02470 { 02471 if (is_zero_or_null (a) || is_zero_or_null (b)) { 02472 free_value (a); 02473 free_value (b); 02474 return (make_integer ((quad_t)0)); 02475 } else { 02476 free_value (b); 02477 return (a); 02478 } 02479 }
Definition at line 2920 of file ast_expr2.c.
References ast_log(), free_value(), LOG_WARNING, make_integer(), make_str(), val::s, strip_quotes(), to_string(), and val::u.
Referenced by yyparse().
02921 { 02922 regex_t rp; 02923 regmatch_t rm[2]; 02924 char errbuf[256]; 02925 int eval; 02926 struct val *v; 02927 02928 /* coerce to both arguments to strings */ 02929 to_string(a); 02930 to_string(b); 02931 /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */ 02932 strip_quotes(a); 02933 strip_quotes(b); 02934 /* compile regular expression */ 02935 if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) { 02936 regerror (eval, &rp, errbuf, sizeof(errbuf)); 02937 ast_log(LOG_WARNING, "regcomp() error : %s\n", errbuf); 02938 free_value(a); 02939 free_value(b); 02940 return make_str(""); 02941 } 02942 02943 /* compare string against pattern */ 02944 /* remember that patterns are anchored to the beginning of the line */ 02945 if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 && rm[0].rm_so == 0) { 02946 if (rm[1].rm_so >= 0) { 02947 *(a->u.s + rm[1].rm_eo) = '\0'; 02948 v = make_str (a->u.s + rm[1].rm_so); 02949 02950 } else { 02951 v = make_integer ((quad_t)(rm[0].rm_eo - rm[0].rm_so)); 02952 } 02953 } else { 02954 if (rp.re_nsub == 0) { 02955 v = make_integer ((quad_t)0); 02956 } else { 02957 v = make_str (""); 02958 } 02959 } 02960 02961 /* free arguments and pattern buffer */ 02962 free_value (a); 02963 free_value (b); 02964 regfree (&rp); 02965 02966 return v; 02967 }
Definition at line 2759 of file ast_expr2.c.
References AST_EXPR_integer, AST_EXPR_numeric_string, free_value(), val::i, make_integer(), val::s, val::type, and val::u.
Referenced by yyparse().
02760 { 02761 int v1 = 1; 02762 struct val *r; 02763 02764 if( !a ) 02765 { 02766 v1 = 0; 02767 } 02768 else 02769 { 02770 switch( a->type ) 02771 { 02772 case AST_EXPR_integer: 02773 if( a->u.i == 0 ) 02774 v1 = 0; 02775 break; 02776 02777 case AST_EXPR_string: 02778 if( a->u.s == 0 ) 02779 v1 = 0; 02780 else 02781 { 02782 if( a->u.s[0] == 0 ) 02783 v1 = 0; 02784 else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' ) 02785 v1 = 0; 02786 else 02787 v1 = atoi(a->u.s); 02788 } 02789 break; 02790 02791 case AST_EXPR_numeric_string: 02792 if( a->u.s == 0 ) 02793 v1 = 0; 02794 else 02795 { 02796 if( a->u.s[0] == 0 ) 02797 v1 = 0; 02798 else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' ) 02799 v1 = 0; 02800 else 02801 v1 = atoi(a->u.s); 02802 } 02803 break; 02804 } 02805 } 02806 02807 r = make_integer (!v1); 02808 free_value (a); 02809 return r; 02810 }
Definition at line 2589 of file ast_expr2.c.
References free_value(), val::i, isstring(), val::s, to_integer(), and val::u.
Referenced by yyparse().
02590 { 02591 struct val *r; 02592 02593 if( isstring(a) ) 02594 { 02595 if( strlen(a->u.s) && strcmp(a->u.s, "\"\"") != 0 && strcmp(a->u.s,"0") != 0 ) 02596 { 02597 free_value(a); 02598 free_value(c); 02599 r = b; 02600 } 02601 else 02602 { 02603 free_value(a); 02604 free_value(b); 02605 r = c; 02606 } 02607 } 02608 else 02609 { 02610 (void)to_integer(a); 02611 if( a->u.i ) 02612 { 02613 free_value(a); 02614 free_value(c); 02615 r = b; 02616 } 02617 else 02618 { 02619 free_value(a); 02620 free_value(b); 02621 r = c; 02622 } 02623 } 02624 return r; 02625 }
Definition at line 2858 of file ast_expr2.c.
References ast_log(), chk_div(), free_value(), LOG_WARNING, make_integer(), and to_integer().
Referenced by yyparse().
02859 { 02860 struct val *r; 02861 02862 if (!to_integer (a)) { 02863 free_value(a); 02864 free_value(b); 02865 if( !extra_error_message_supplied ) 02866 ast_log(LOG_WARNING, "non-numeric argument\n"); 02867 return make_integer(0); 02868 } else if (!to_integer (b)) { 02869 free_value(a); 02870 free_value(b); 02871 if( !extra_error_message_supplied ) 02872 ast_log(LOG_WARNING, "non-numeric argument\n"); 02873 return make_integer(INT_MAX); 02874 } 02875 02876 if (b->u.i == 0) { 02877 ast_log(LOG_WARNING, "division by zero\n"); 02878 free_value(a); 02879 free_value(b); 02880 return make_integer(INT_MAX); 02881 } 02882 02883 r = make_integer (/*(quad_t)*/(a->u.i / b->u.i)); 02884 if (chk_div (a->u.i, b->u.i)) { 02885 ast_log(LOG_WARNING, "overflow\n"); 02886 } 02887 free_value (a); 02888 free_value (b); 02889 return r; 02890 }
Definition at line 2482 of file ast_expr2.c.
References ast_log(), free_value(), isstring(), LOG_WARNING, make_integer(), to_integer(), and to_string().
Referenced by yyparse().
02483 { 02484 struct val *r; 02485 02486 if (isstring (a) || isstring (b)) { 02487 to_string (a); 02488 to_string (b); 02489 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) == 0)); 02490 } else { 02491 #ifdef DEBUG_FOR_CONVERSIONS 02492 char buffer[2000]; 02493 sprintf(buffer,"Converting '%s' and '%s' ", a->u.s, b->u.s); 02494 #endif 02495 (void)to_integer(a); 02496 (void)to_integer(b); 02497 #ifdef DEBUG_FOR_CONVERSIONS 02498 ast_log(LOG_WARNING,"%s to '%lld' and '%lld'\n", buffer, a->u.i, b->u.i); 02499 #endif 02500 r = make_integer ((quad_t)(a->u.i == b->u.i)); 02501 } 02502 02503 free_value (a); 02504 free_value (b); 02505 return r; 02506 }
Definition at line 2971 of file ast_expr2.c.
References ast_log(), free_value(), LOG_WARNING, make_integer(), make_str(), val::s, strip_quotes(), to_string(), and val::u.
Referenced by yyparse().
02972 { 02973 regex_t rp; 02974 regmatch_t rm[2]; 02975 char errbuf[256]; 02976 int eval; 02977 struct val *v; 02978 02979 /* coerce to both arguments to strings */ 02980 to_string(a); 02981 to_string(b); 02982 /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */ 02983 strip_quotes(a); 02984 strip_quotes(b); 02985 /* compile regular expression */ 02986 if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) { 02987 regerror (eval, &rp, errbuf, sizeof(errbuf)); 02988 ast_log(LOG_WARNING, "regcomp() error : %s\n", errbuf); 02989 free_value(a); 02990 free_value(b); 02991 return make_str(""); 02992 } 02993 02994 /* compare string against pattern */ 02995 /* remember that patterns are anchored to the beginning of the line */ 02996 if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 ) { 02997 if (rm[1].rm_so >= 0) { 02998 *(a->u.s + rm[1].rm_eo) = '\0'; 02999 v = make_str (a->u.s + rm[1].rm_so); 03000 03001 } else { 03002 v = make_integer ((quad_t)(rm[0].rm_eo - rm[0].rm_so)); 03003 } 03004 } else { 03005 if (rp.re_nsub == 0) { 03006 v = make_integer ((quad_t)0); 03007 } else { 03008 v = make_str (""); 03009 } 03010 } 03011 03012 /* free arguments and pattern buffer */ 03013 free_value (a); 03014 free_value (b); 03015 regfree (&rp); 03016 03017 return v; 03018 }
Definition at line 2549 of file ast_expr2.c.
References free_value(), isstring(), make_integer(), to_integer(), and to_string().
Referenced by yyparse().
02550 { 02551 struct val *r; 02552 02553 if (isstring (a) || isstring (b)) { 02554 to_string (a); 02555 to_string (b); 02556 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) >= 0)); 02557 } else { 02558 (void)to_integer(a); 02559 (void)to_integer(b); 02560 r = make_integer ((quad_t)(a->u.i >= b->u.i)); 02561 } 02562 02563 free_value (a); 02564 free_value (b); 02565 return r; 02566 }
Definition at line 2509 of file ast_expr2.c.
References free_value(), isstring(), make_integer(), to_integer(), and to_string().
Referenced by yyparse().
02510 { 02511 struct val *r; 02512 02513 if (isstring (a) || isstring (b)) { 02514 to_string (a); 02515 to_string (b); 02516 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) > 0)); 02517 } else { 02518 (void)to_integer(a); 02519 (void)to_integer(b); 02520 r = make_integer ((quad_t)(a->u.i > b->u.i)); 02521 } 02522 02523 free_value (a); 02524 free_value (b); 02525 return r; 02526 }
Definition at line 2569 of file ast_expr2.c.
References free_value(), isstring(), make_integer(), to_integer(), and to_string().
Referenced by yyparse().
02570 { 02571 struct val *r; 02572 02573 if (isstring (a) || isstring (b)) { 02574 to_string (a); 02575 to_string (b); 02576 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) <= 0)); 02577 } else { 02578 (void)to_integer(a); 02579 (void)to_integer(b); 02580 r = make_integer ((quad_t)(a->u.i <= b->u.i)); 02581 } 02582 02583 free_value (a); 02584 free_value (b); 02585 return r; 02586 }
Definition at line 2529 of file ast_expr2.c.
References free_value(), isstring(), make_integer(), to_integer(), and to_string().
Referenced by yyparse().
02530 { 02531 struct val *r; 02532 02533 if (isstring (a) || isstring (b)) { 02534 to_string (a); 02535 to_string (b); 02536 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) < 0)); 02537 } else { 02538 (void)to_integer(a); 02539 (void)to_integer(b); 02540 r = make_integer ((quad_t)(a->u.i < b->u.i)); 02541 } 02542 02543 free_value (a); 02544 free_value (b); 02545 return r; 02546 }
Definition at line 2705 of file ast_expr2.c.
References ast_log(), chk_minus(), free_value(), val::i, LOG_WARNING, make_integer(), to_integer(), and val::u.
Referenced by yyparse().
02706 { 02707 struct val *r; 02708 02709 if (!to_integer (a)) { 02710 if( !extra_error_message_supplied ) 02711 ast_log(LOG_WARNING, "non-numeric argument\n"); 02712 if (!to_integer (b)) { 02713 free_value(a); 02714 free_value(b); 02715 return make_integer(0); 02716 } else { 02717 r = make_integer(0 - b->u.i); 02718 free_value(a); 02719 free_value(b); 02720 return (r); 02721 } 02722 } else if (!to_integer(b)) { 02723 if( !extra_error_message_supplied ) 02724 ast_log(LOG_WARNING, "non-numeric argument\n"); 02725 free_value(b); 02726 return (a); 02727 } 02728 02729 r = make_integer (/*(quad_t)*/(a->u.i - b->u.i)); 02730 if (chk_minus (a->u.i, b->u.i, r->u.i)) { 02731 ast_log(LOG_WARNING, "overflow\n"); 02732 } 02733 free_value (a); 02734 free_value (b); 02735 return r; 02736 }
Definition at line 2628 of file ast_expr2.c.
References free_value(), isstring(), make_integer(), to_integer(), and to_string().
Referenced by yyparse().
02629 { 02630 struct val *r; 02631 02632 if (isstring (a) || isstring (b)) { 02633 to_string (a); 02634 to_string (b); 02635 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) != 0)); 02636 } else { 02637 (void)to_integer(a); 02638 (void)to_integer(b); 02639 r = make_integer ((quad_t)(a->u.i != b->u.i)); 02640 } 02641 02642 free_value (a); 02643 free_value (b); 02644 return r; 02645 }
Definition at line 2739 of file ast_expr2.c.
References ast_log(), chk_minus(), free_value(), val::i, LOG_WARNING, make_integer(), to_integer(), and val::u.
Referenced by yyparse().
02740 { 02741 struct val *r; 02742 02743 if (!to_integer (a) ) { 02744 free_value(a); 02745 if( !extra_error_message_supplied ) 02746 ast_log(LOG_WARNING, "non-numeric argument\n"); 02747 return make_integer(0); 02748 } 02749 02750 r = make_integer (/*(quad_t)*/(- a->u.i)); 02751 if (chk_minus (0, a->u.i, r->u.i)) { 02752 ast_log(LOG_WARNING, "overflow\n"); 02753 } 02754 free_value (a); 02755 return r; 02756 }
Definition at line 2457 of file ast_expr2.c.
References free_value(), and is_zero_or_null().
Referenced by yyparse().
02458 { 02459 if (is_zero_or_null (a)) { 02460 free_value (a); 02461 return (b); 02462 } else { 02463 free_value (b); 02464 return (a); 02465 } 02466 }
Definition at line 2661 of file ast_expr2.c.
References ast_log(), chk_plus(), free_value(), val::i, LOG_WARNING, make_integer(), to_integer(), and val::u.
Referenced by yyparse().
02662 { 02663 struct val *r; 02664 02665 if (!to_integer (a)) { 02666 if( !extra_error_message_supplied ) 02667 ast_log(LOG_WARNING,"non-numeric argument\n"); 02668 if (!to_integer (b)) { 02669 free_value(a); 02670 free_value(b); 02671 return make_integer(0); 02672 } else { 02673 free_value(a); 02674 return (b); 02675 } 02676 } else if (!to_integer(b)) { 02677 free_value(b); 02678 return (a); 02679 } 02680 02681 r = make_integer (/*(quad_t)*/(a->u.i + b->u.i)); 02682 if (chk_plus (a->u.i, b->u.i, r->u.i)) { 02683 ast_log(LOG_WARNING,"overflow\n"); 02684 } 02685 free_value (a); 02686 free_value (b); 02687 return r; 02688 }
Definition at line 2893 of file ast_expr2.c.
References ast_log(), free_value(), LOG_WARNING, make_integer(), and to_integer().
Referenced by yyparse().
02894 { 02895 struct val *r; 02896 02897 if (!to_integer (a) || !to_integer (b)) { 02898 if( !extra_error_message_supplied ) 02899 ast_log(LOG_WARNING, "non-numeric argument\n"); 02900 free_value(a); 02901 free_value(b); 02902 return make_integer(0); 02903 } 02904 02905 if (b->u.i == 0) { 02906 ast_log(LOG_WARNING, "div by zero\n"); 02907 free_value(a); 02908 return(b); 02909 } 02910 02911 r = make_integer (/*(quad_t)*/(a->u.i % b->u.i)); 02912 /* chk_rem necessary ??? */ 02913 free_value (a); 02914 free_value (b); 02915 return r; 02916 }
Definition at line 2825 of file ast_expr2.c.
References ast_log(), chk_times(), free_value(), val::i, LOG_WARNING, make_integer(), to_integer(), and val::u.
Referenced by yyparse().
02826 { 02827 struct val *r; 02828 02829 if (!to_integer (a) || !to_integer (b)) { 02830 free_value(a); 02831 free_value(b); 02832 if( !extra_error_message_supplied ) 02833 ast_log(LOG_WARNING, "non-numeric argument\n"); 02834 return(make_integer(0)); 02835 } 02836 02837 r = make_integer (/*(quad_t)*/(a->u.i * b->u.i)); 02838 if (chk_times (a->u.i, b->u.i, r->u.i)) { 02839 ast_log(LOG_WARNING, "overflow\n"); 02840 } 02841 free_value (a); 02842 free_value (b); 02843 return (r); 02844 }
static void strip_quotes | ( | struct val * | vp | ) | [static] |
Definition at line 2323 of file ast_expr2.c.
References AST_EXPR_numeric_string, f, val::s, t, val::type, and val::u.
Referenced by op_colon(), and op_eqtilde().
02324 { 02325 if (vp->type != AST_EXPR_string && vp->type != AST_EXPR_numeric_string) 02326 return; 02327 02328 if( vp->u.s[0] == '"' && vp->u.s[strlen(vp->u.s)-1] == '"' ) 02329 { 02330 char *f, *t; 02331 f = vp->u.s; 02332 t = vp->u.s; 02333 02334 while( *f ) 02335 { 02336 if( *f && *f != '"' ) 02337 *t++ = *f++; 02338 else 02339 f++; 02340 } 02341 *t = *f; 02342 } 02343 }
static quad_t to_integer | ( | struct val * | vp | ) | [static] |
Definition at line 2292 of file ast_expr2.c.
References AST_EXPR_integer, ast_log(), errno, free, val::i, LOG_WARNING, val::s, val::type, and val::u.
Referenced by is_zero_or_null(), op_cond(), op_div(), op_eq(), op_ge(), op_gt(), op_le(), op_lt(), op_minus(), op_ne(), op_negate(), op_plus(), op_rem(), and op_times().
02293 { 02294 quad_t i; 02295 02296 if (vp == NULL) { 02297 ast_log(LOG_WARNING,"vp==NULL in to_integer()\n"); 02298 return(0); 02299 } 02300 02301 if (vp->type == AST_EXPR_integer) 02302 return 1; 02303 02304 if (vp->type == AST_EXPR_string) 02305 return 0; 02306 02307 /* vp->type == AST_EXPR_numeric_string, make it numeric */ 02308 errno = 0; 02309 i = strtoll(vp->u.s, (char**)NULL, 10); 02310 if (errno != 0) { 02311 ast_log(LOG_WARNING,"Conversion of %s to integer under/overflowed!\n", vp->u.s); 02312 free(vp->u.s); 02313 vp->u.s = 0; 02314 return(0); 02315 } 02316 free (vp->u.s); 02317 vp->u.i = i; 02318 vp->type = AST_EXPR_integer; 02319 return 1; 02320 }
static void to_string | ( | struct val * | vp | ) | [static] |
Definition at line 2346 of file ast_expr2.c.
References AST_EXPR_numeric_string, ast_log(), val::i, LOG_WARNING, malloc, val::s, val::type, and val::u.
Referenced by op_colon(), op_eq(), op_eqtilde(), op_ge(), op_gt(), op_le(), op_lt(), and op_ne().
02347 { 02348 char *tmp; 02349 02350 if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string) 02351 return; 02352 02353 tmp = malloc ((size_t)25); 02354 if (tmp == NULL) { 02355 ast_log(LOG_WARNING,"malloc() failed\n"); 02356 return; 02357 } 02358 02359 sprintf(tmp, "%ld", (long int) vp->u.i); 02360 vp->type = AST_EXPR_string; 02361 vp->u.s = tmp; 02362 }
static void yydestruct | ( | char * | yymsg, | |
int | yytype, | |||
YYSTYPE * | yyvaluep, | |||
YYLTYPE * | yylocationp | |||
) | const [static] |
Definition at line 1246 of file ast_expr2.c.
References free_value(), YYSTYPE::val, YY_SYMBOL_PRINT, and YYUSE.
Referenced by yyparse().
01252 { 01253 YYUSE (yyvaluep); 01254 YYUSE (yylocationp); 01255 01256 if (!yymsg) 01257 yymsg = "Deleting"; 01258 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 01259 01260 switch (yytype) 01261 { 01262 case 3: /* "TOK_COLONCOLON" */ 01263 01264 /* Line 1000 of yacc.c */ 01265 #line 169 "ast_expr2.y" 01266 { free_value((yyvaluep->val)); }; 01267 01268 /* Line 1000 of yacc.c */ 01269 #line 1270 "ast_expr2.c" 01270 break; 01271 case 4: /* "TOK_COND" */ 01272 01273 /* Line 1000 of yacc.c */ 01274 #line 169 "ast_expr2.y" 01275 { free_value((yyvaluep->val)); }; 01276 01277 /* Line 1000 of yacc.c */ 01278 #line 1279 "ast_expr2.c" 01279 break; 01280 case 5: /* "TOK_OR" */ 01281 01282 /* Line 1000 of yacc.c */ 01283 #line 169 "ast_expr2.y" 01284 { free_value((yyvaluep->val)); }; 01285 01286 /* Line 1000 of yacc.c */ 01287 #line 1288 "ast_expr2.c" 01288 break; 01289 case 6: /* "TOK_AND" */ 01290 01291 /* Line 1000 of yacc.c */ 01292 #line 169 "ast_expr2.y" 01293 { free_value((yyvaluep->val)); }; 01294 01295 /* Line 1000 of yacc.c */ 01296 #line 1297 "ast_expr2.c" 01297 break; 01298 case 7: /* "TOK_NE" */ 01299 01300 /* Line 1000 of yacc.c */ 01301 #line 169 "ast_expr2.y" 01302 { free_value((yyvaluep->val)); }; 01303 01304 /* Line 1000 of yacc.c */ 01305 #line 1306 "ast_expr2.c" 01306 break; 01307 case 8: /* "TOK_LE" */ 01308 01309 /* Line 1000 of yacc.c */ 01310 #line 169 "ast_expr2.y" 01311 { free_value((yyvaluep->val)); }; 01312 01313 /* Line 1000 of yacc.c */ 01314 #line 1315 "ast_expr2.c" 01315 break; 01316 case 9: /* "TOK_GE" */ 01317 01318 /* Line 1000 of yacc.c */ 01319 #line 169 "ast_expr2.y" 01320 { free_value((yyvaluep->val)); }; 01321 01322 /* Line 1000 of yacc.c */ 01323 #line 1324 "ast_expr2.c" 01324 break; 01325 case 10: /* "TOK_LT" */ 01326 01327 /* Line 1000 of yacc.c */ 01328 #line 169 "ast_expr2.y" 01329 { free_value((yyvaluep->val)); }; 01330 01331 /* Line 1000 of yacc.c */ 01332 #line 1333 "ast_expr2.c" 01333 break; 01334 case 11: /* "TOK_GT" */ 01335 01336 /* Line 1000 of yacc.c */ 01337 #line 169 "ast_expr2.y" 01338 { free_value((yyvaluep->val)); }; 01339 01340 /* Line 1000 of yacc.c */ 01341 #line 1342 "ast_expr2.c" 01342 break; 01343 case 12: /* "TOK_EQ" */ 01344 01345 /* Line 1000 of yacc.c */ 01346 #line 169 "ast_expr2.y" 01347 { free_value((yyvaluep->val)); }; 01348 01349 /* Line 1000 of yacc.c */ 01350 #line 1351 "ast_expr2.c" 01351 break; 01352 case 13: /* "TOK_MINUS" */ 01353 01354 /* Line 1000 of yacc.c */ 01355 #line 169 "ast_expr2.y" 01356 { free_value((yyvaluep->val)); }; 01357 01358 /* Line 1000 of yacc.c */ 01359 #line 1360 "ast_expr2.c" 01360 break; 01361 case 14: /* "TOK_PLUS" */ 01362 01363 /* Line 1000 of yacc.c */ 01364 #line 169 "ast_expr2.y" 01365 { free_value((yyvaluep->val)); }; 01366 01367 /* Line 1000 of yacc.c */ 01368 #line 1369 "ast_expr2.c" 01369 break; 01370 case 15: /* "TOK_MOD" */ 01371 01372 /* Line 1000 of yacc.c */ 01373 #line 169 "ast_expr2.y" 01374 { free_value((yyvaluep->val)); }; 01375 01376 /* Line 1000 of yacc.c */ 01377 #line 1378 "ast_expr2.c" 01378 break; 01379 case 16: /* "TOK_DIV" */ 01380 01381 /* Line 1000 of yacc.c */ 01382 #line 169 "ast_expr2.y" 01383 { free_value((yyvaluep->val)); }; 01384 01385 /* Line 1000 of yacc.c */ 01386 #line 1387 "ast_expr2.c" 01387 break; 01388 case 17: /* "TOK_MULT" */ 01389 01390 /* Line 1000 of yacc.c */ 01391 #line 169 "ast_expr2.y" 01392 { free_value((yyvaluep->val)); }; 01393 01394 /* Line 1000 of yacc.c */ 01395 #line 1396 "ast_expr2.c" 01396 break; 01397 case 18: /* "TOK_COMPL" */ 01398 01399 /* Line 1000 of yacc.c */ 01400 #line 169 "ast_expr2.y" 01401 { free_value((yyvaluep->val)); }; 01402 01403 /* Line 1000 of yacc.c */ 01404 #line 1405 "ast_expr2.c" 01405 break; 01406 case 19: /* "TOK_EQTILDE" */ 01407 01408 /* Line 1000 of yacc.c */ 01409 #line 169 "ast_expr2.y" 01410 { free_value((yyvaluep->val)); }; 01411 01412 /* Line 1000 of yacc.c */ 01413 #line 1414 "ast_expr2.c" 01414 break; 01415 case 20: /* "TOK_COLON" */ 01416 01417 /* Line 1000 of yacc.c */ 01418 #line 169 "ast_expr2.y" 01419 { free_value((yyvaluep->val)); }; 01420 01421 /* Line 1000 of yacc.c */ 01422 #line 1423 "ast_expr2.c" 01423 break; 01424 case 21: /* "TOK_LP" */ 01425 01426 /* Line 1000 of yacc.c */ 01427 #line 169 "ast_expr2.y" 01428 { free_value((yyvaluep->val)); }; 01429 01430 /* Line 1000 of yacc.c */ 01431 #line 1432 "ast_expr2.c" 01432 break; 01433 case 22: /* "TOK_RP" */ 01434 01435 /* Line 1000 of yacc.c */ 01436 #line 169 "ast_expr2.y" 01437 { free_value((yyvaluep->val)); }; 01438 01439 /* Line 1000 of yacc.c */ 01440 #line 1441 "ast_expr2.c" 01441 break; 01442 case 23: /* "TOKEN" */ 01443 01444 /* Line 1000 of yacc.c */ 01445 #line 169 "ast_expr2.y" 01446 { free_value((yyvaluep->val)); }; 01447 01448 /* Line 1000 of yacc.c */ 01449 #line 1450 "ast_expr2.c" 01450 break; 01451 case 26: /* "expr" */ 01452 01453 /* Line 1000 of yacc.c */ 01454 #line 169 "ast_expr2.y" 01455 { free_value((yyvaluep->val)); }; 01456 01457 /* Line 1000 of yacc.c */ 01458 #line 1459 "ast_expr2.c" 01459 break; 01460 01461 default: 01462 break; 01463 } 01464 }
int yyparse | ( | void * | YYPARSE_PARAM | ) |
Definition at line 1496 of file ast_expr2.c.
References AST_EXPR_integer, calloc, DESTROY, free, op_and(), op_colon(), op_compl(), op_cond(), op_div(), op_eq(), op_eqtilde(), op_ge(), op_gt(), op_le(), op_lt(), op_minus(), op_ne(), op_negate(), op_or(), op_plus(), op_rem(), op_times(), strdup, type, YYSTYPE::val, YY_, YY_REDUCE_PRINT, YY_STACK_PRINT, YY_SYMBOL_PRINT, YYABORT, YYACCEPT, yychar, yydestruct(), YYDPRINTF, YYEMPTY, YYEOF, yyerror, YYFINAL, YYID, YYINITDEPTH, YYLAST, YYLEX, yylloc, YYLLOC_DEFAULT, yyalloc::yyls_alloc, yylval, YYMAXDEPTH, yynerrs, YYNTOKENS, YYPACT_NINF, YYPOPSTACK, YYSIZE_T, yyalloc::yyss_alloc, YYSTACK_ALLOC, YYSTACK_ALLOC_MAXIMUM, YYSTACK_BYTES, YYSTACK_FREE, YYSTACK_RELOCATE, yysyntax_error(), YYTABLE_NINF, YYTERROR, YYTRANSLATE, and yyalloc::yyvs_alloc.
01510 { 01511 /* The lookahead symbol. */ 01512 int yychar; 01513 01514 /* The semantic value of the lookahead symbol. */ 01515 YYSTYPE yylval; 01516 01517 /* Location data for the lookahead symbol. */ 01518 YYLTYPE yylloc; 01519 01520 /* Number of syntax errors so far. */ 01521 int yynerrs; 01522 01523 int yystate; 01524 /* Number of tokens to shift before error messages enabled. */ 01525 int yyerrstatus; 01526 01527 /* The stacks and their tools: 01528 `yyss': related to states. 01529 `yyvs': related to semantic values. 01530 `yyls': related to locations. 01531 01532 Refer to the stacks thru separate pointers, to allow yyoverflow 01533 to reallocate them elsewhere. */ 01534 01535 /* The state stack. */ 01536 yytype_int16 yyssa[YYINITDEPTH]; 01537 yytype_int16 *yyss; 01538 yytype_int16 *yyssp; 01539 01540 /* The semantic value stack. */ 01541 YYSTYPE yyvsa[YYINITDEPTH]; 01542 YYSTYPE *yyvs; 01543 YYSTYPE *yyvsp; 01544 01545 /* The location stack. */ 01546 YYLTYPE yylsa[YYINITDEPTH]; 01547 YYLTYPE *yyls; 01548 YYLTYPE *yylsp; 01549 01550 /* The locations where the error started and ended. */ 01551 YYLTYPE yyerror_range[2]; 01552 01553 YYSIZE_T yystacksize; 01554 01555 int yyn; 01556 int yyresult; 01557 /* Lookahead token as an internal (translated) token number. */ 01558 int yytoken; 01559 /* The variables used to return semantic value and location from the 01560 action routines. */ 01561 YYSTYPE yyval; 01562 YYLTYPE yyloc; 01563 01564 #if YYERROR_VERBOSE 01565 /* Buffer for error messages, and its allocated size. */ 01566 char yymsgbuf[128]; 01567 char *yymsg = yymsgbuf; 01568 YYSIZE_T yymsg_alloc = sizeof yymsgbuf; 01569 #endif 01570 01571 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) 01572 01573 /* The number of symbols on the RHS of the reduced rule. 01574 Keep to zero when no symbol should be popped. */ 01575 int yylen = 0; 01576 01577 yytoken = 0; 01578 yyss = yyssa; 01579 yyvs = yyvsa; 01580 yyls = yylsa; 01581 yystacksize = YYINITDEPTH; 01582 01583 YYDPRINTF ((stderr, "Starting parse\n")); 01584 01585 yystate = 0; 01586 yyerrstatus = 0; 01587 yynerrs = 0; 01588 yychar = YYEMPTY; /* Cause a token to be read. */ 01589 01590 /* Initialize stack pointers. 01591 Waste one element of value and location stack 01592 so that they stay on the same level as the state stack. 01593 The wasted elements are never initialized. */ 01594 yyssp = yyss; 01595 yyvsp = yyvs; 01596 yylsp = yyls; 01597 01598 #if YYLTYPE_IS_TRIVIAL 01599 /* Initialize the default location before parsing starts. */ 01600 yylloc.first_line = yylloc.last_line = 1; 01601 yylloc.first_column = yylloc.last_column = 1; 01602 #endif 01603 01604 goto yysetstate; 01605 01606 /*------------------------------------------------------------. 01607 | yynewstate -- Push a new state, which is found in yystate. | 01608 `------------------------------------------------------------*/ 01609 yynewstate: 01610 /* In all cases, when you get here, the value and location stacks 01611 have just been pushed. So pushing a state here evens the stacks. */ 01612 yyssp++; 01613 01614 yysetstate: 01615 *yyssp = yystate; 01616 01617 if (yyss + yystacksize - 1 <= yyssp) 01618 { 01619 /* Get the current used size of the three stacks, in elements. */ 01620 YYSIZE_T yysize = yyssp - yyss + 1; 01621 01622 #ifdef yyoverflow 01623 { 01624 /* Give user a chance to reallocate the stack. Use copies of 01625 these so that the &'s don't force the real ones into 01626 memory. */ 01627 YYSTYPE *yyvs1 = yyvs; 01628 yytype_int16 *yyss1 = yyss; 01629 YYLTYPE *yyls1 = yyls; 01630 01631 /* Each stack pointer address is followed by the size of the 01632 data in use in that stack, in bytes. This used to be a 01633 conditional around just the two extra args, but that might 01634 be undefined if yyoverflow is a macro. */ 01635 yyoverflow (YY_("memory exhausted"), 01636 &yyss1, yysize * sizeof (*yyssp), 01637 &yyvs1, yysize * sizeof (*yyvsp), 01638 &yyls1, yysize * sizeof (*yylsp), 01639 &yystacksize); 01640 01641 yyls = yyls1; 01642 yyss = yyss1; 01643 yyvs = yyvs1; 01644 } 01645 #else /* no yyoverflow */ 01646 # ifndef YYSTACK_RELOCATE 01647 goto yyexhaustedlab; 01648 # else 01649 /* Extend the stack our own way. */ 01650 if (YYMAXDEPTH <= yystacksize) 01651 goto yyexhaustedlab; 01652 yystacksize *= 2; 01653 if (YYMAXDEPTH < yystacksize) 01654 yystacksize = YYMAXDEPTH; 01655 01656 { 01657 yytype_int16 *yyss1 = yyss; 01658 union yyalloc *yyptr = 01659 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 01660 if (! yyptr) 01661 goto yyexhaustedlab; 01662 YYSTACK_RELOCATE (yyss_alloc, yyss); 01663 YYSTACK_RELOCATE (yyvs_alloc, yyvs); 01664 YYSTACK_RELOCATE (yyls_alloc, yyls); 01665 # undef YYSTACK_RELOCATE 01666 if (yyss1 != yyssa) 01667 YYSTACK_FREE (yyss1); 01668 } 01669 # endif 01670 #endif /* no yyoverflow */ 01671 01672 yyssp = yyss + yysize - 1; 01673 yyvsp = yyvs + yysize - 1; 01674 yylsp = yyls + yysize - 1; 01675 01676 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 01677 (unsigned long int) yystacksize)); 01678 01679 if (yyss + yystacksize - 1 <= yyssp) 01680 YYABORT; 01681 } 01682 01683 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 01684 01685 if (yystate == YYFINAL) 01686 YYACCEPT; 01687 01688 goto yybackup; 01689 01690 /*-----------. 01691 | yybackup. | 01692 `-----------*/ 01693 yybackup: 01694 01695 /* Do appropriate processing given the current state. Read a 01696 lookahead token if we need one and don't already have one. */ 01697 01698 /* First try to decide what to do without reference to lookahead token. */ 01699 yyn = yypact[yystate]; 01700 if (yyn == YYPACT_NINF) 01701 goto yydefault; 01702 01703 /* Not known => get a lookahead token if don't already have one. */ 01704 01705 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ 01706 if (yychar == YYEMPTY) 01707 { 01708 YYDPRINTF ((stderr, "Reading a token: ")); 01709 yychar = YYLEX; 01710 } 01711 01712 if (yychar <= YYEOF) 01713 { 01714 yychar = yytoken = YYEOF; 01715 YYDPRINTF ((stderr, "Now at end of input.\n")); 01716 } 01717 else 01718 { 01719 yytoken = YYTRANSLATE (yychar); 01720 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 01721 } 01722 01723 /* If the proper action on seeing token YYTOKEN is to reduce or to 01724 detect an error, take that action. */ 01725 yyn += yytoken; 01726 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 01727 goto yydefault; 01728 yyn = yytable[yyn]; 01729 if (yyn <= 0) 01730 { 01731 if (yyn == 0 || yyn == YYTABLE_NINF) 01732 goto yyerrlab; 01733 yyn = -yyn; 01734 goto yyreduce; 01735 } 01736 01737 /* Count tokens shifted since error; after three, turn off error 01738 status. */ 01739 if (yyerrstatus) 01740 yyerrstatus--; 01741 01742 /* Shift the lookahead token. */ 01743 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 01744 01745 /* Discard the shifted token. */ 01746 yychar = YYEMPTY; 01747 01748 yystate = yyn; 01749 *++yyvsp = yylval; 01750 *++yylsp = yylloc; 01751 goto yynewstate; 01752 01753 01754 /*-----------------------------------------------------------. 01755 | yydefault -- do the default action for the current state. | 01756 `-----------------------------------------------------------*/ 01757 yydefault: 01758 yyn = yydefact[yystate]; 01759 if (yyn == 0) 01760 goto yyerrlab; 01761 goto yyreduce; 01762 01763 01764 /*-----------------------------. 01765 | yyreduce -- Do a reduction. | 01766 `-----------------------------*/ 01767 yyreduce: 01768 /* yyn is the number of a rule to reduce with. */ 01769 yylen = yyr2[yyn]; 01770 01771 /* If YYLEN is nonzero, implement the default value of the action: 01772 `$$ = $1'. 01773 01774 Otherwise, the following line sets YYVAL to garbage. 01775 This behavior is undocumented and Bison 01776 users should not rely upon it. Assigning to YYVAL 01777 unconditionally makes the parser a bit smaller, and it avoids a 01778 GCC warning that YYVAL may be used uninitialized. */ 01779 yyval = yyvsp[1-yylen]; 01780 01781 /* Default location. */ 01782 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); 01783 YY_REDUCE_PRINT (yyn); 01784 switch (yyn) 01785 { 01786 case 2: 01787 01788 /* Line 1455 of yacc.c */ 01789 #line 175 "ast_expr2.y" 01790 { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1); 01791 ((struct parse_io *)parseio)->val->type = (yyvsp[(1) - (1)].val)->type; 01792 if( (yyvsp[(1) - (1)].val)->type == AST_EXPR_integer ) 01793 ((struct parse_io *)parseio)->val->u.i = (yyvsp[(1) - (1)].val)->u.i; 01794 else 01795 ((struct parse_io *)parseio)->val->u.s = (yyvsp[(1) - (1)].val)->u.s; 01796 free((yyvsp[(1) - (1)].val)); 01797 ;} 01798 break; 01799 01800 case 3: 01801 01802 /* Line 1455 of yacc.c */ 01803 #line 183 "ast_expr2.y" 01804 {/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1); 01805 ((struct parse_io *)parseio)->val->type = AST_EXPR_string; 01806 ((struct parse_io *)parseio)->val->u.s = strdup(""); 01807 ;} 01808 break; 01809 01810 case 4: 01811 01812 /* Line 1455 of yacc.c */ 01813 #line 190 "ast_expr2.y" 01814 { (yyval.val)= (yyvsp[(1) - (1)].val);;} 01815 break; 01816 01817 case 5: 01818 01819 /* Line 1455 of yacc.c */ 01820 #line 191 "ast_expr2.y" 01821 { (yyval.val) = (yyvsp[(2) - (3)].val); 01822 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01823 (yyloc).first_line=0; (yyloc).last_line=0; 01824 DESTROY((yyvsp[(1) - (3)].val)); DESTROY((yyvsp[(3) - (3)].val)); ;} 01825 break; 01826 01827 case 6: 01828 01829 /* Line 1455 of yacc.c */ 01830 #line 195 "ast_expr2.y" 01831 { (yyval.val) = op_or ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01832 DESTROY((yyvsp[(2) - (3)].val)); 01833 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01834 (yyloc).first_line=0; (yyloc).last_line=0;;} 01835 break; 01836 01837 case 7: 01838 01839 /* Line 1455 of yacc.c */ 01840 #line 199 "ast_expr2.y" 01841 { (yyval.val) = op_and ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01842 DESTROY((yyvsp[(2) - (3)].val)); 01843 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01844 (yyloc).first_line=0; (yyloc).last_line=0;;} 01845 break; 01846 01847 case 8: 01848 01849 /* Line 1455 of yacc.c */ 01850 #line 203 "ast_expr2.y" 01851 { (yyval.val) = op_eq ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01852 DESTROY((yyvsp[(2) - (3)].val)); 01853 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01854 (yyloc).first_line=0; (yyloc).last_line=0;;} 01855 break; 01856 01857 case 9: 01858 01859 /* Line 1455 of yacc.c */ 01860 #line 207 "ast_expr2.y" 01861 { (yyval.val) = op_gt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01862 DESTROY((yyvsp[(2) - (3)].val)); 01863 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01864 (yyloc).first_line=0; (yyloc).last_line=0;;} 01865 break; 01866 01867 case 10: 01868 01869 /* Line 1455 of yacc.c */ 01870 #line 211 "ast_expr2.y" 01871 { (yyval.val) = op_lt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01872 DESTROY((yyvsp[(2) - (3)].val)); 01873 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01874 (yyloc).first_line=0; (yyloc).last_line=0;;} 01875 break; 01876 01877 case 11: 01878 01879 /* Line 1455 of yacc.c */ 01880 #line 215 "ast_expr2.y" 01881 { (yyval.val) = op_ge ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01882 DESTROY((yyvsp[(2) - (3)].val)); 01883 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01884 (yyloc).first_line=0; (yyloc).last_line=0;;} 01885 break; 01886 01887 case 12: 01888 01889 /* Line 1455 of yacc.c */ 01890 #line 219 "ast_expr2.y" 01891 { (yyval.val) = op_le ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01892 DESTROY((yyvsp[(2) - (3)].val)); 01893 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01894 (yyloc).first_line=0; (yyloc).last_line=0;;} 01895 break; 01896 01897 case 13: 01898 01899 /* Line 1455 of yacc.c */ 01900 #line 223 "ast_expr2.y" 01901 { (yyval.val) = op_ne ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01902 DESTROY((yyvsp[(2) - (3)].val)); 01903 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01904 (yyloc).first_line=0; (yyloc).last_line=0;;} 01905 break; 01906 01907 case 14: 01908 01909 /* Line 1455 of yacc.c */ 01910 #line 227 "ast_expr2.y" 01911 { (yyval.val) = op_plus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01912 DESTROY((yyvsp[(2) - (3)].val)); 01913 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01914 (yyloc).first_line=0; (yyloc).last_line=0;;} 01915 break; 01916 01917 case 15: 01918 01919 /* Line 1455 of yacc.c */ 01920 #line 231 "ast_expr2.y" 01921 { (yyval.val) = op_minus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01922 DESTROY((yyvsp[(2) - (3)].val)); 01923 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01924 (yyloc).first_line=0; (yyloc).last_line=0;;} 01925 break; 01926 01927 case 16: 01928 01929 /* Line 1455 of yacc.c */ 01930 #line 235 "ast_expr2.y" 01931 { (yyval.val) = op_negate ((yyvsp[(2) - (2)].val)); 01932 DESTROY((yyvsp[(1) - (2)].val)); 01933 (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column; 01934 (yyloc).first_line=0; (yyloc).last_line=0;;} 01935 break; 01936 01937 case 17: 01938 01939 /* Line 1455 of yacc.c */ 01940 #line 239 "ast_expr2.y" 01941 { (yyval.val) = op_compl ((yyvsp[(2) - (2)].val)); 01942 DESTROY((yyvsp[(1) - (2)].val)); 01943 (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column; 01944 (yyloc).first_line=0; (yyloc).last_line=0;;} 01945 break; 01946 01947 case 18: 01948 01949 /* Line 1455 of yacc.c */ 01950 #line 243 "ast_expr2.y" 01951 { (yyval.val) = op_times ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01952 DESTROY((yyvsp[(2) - (3)].val)); 01953 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01954 (yyloc).first_line=0; (yyloc).last_line=0;;} 01955 break; 01956 01957 case 19: 01958 01959 /* Line 1455 of yacc.c */ 01960 #line 247 "ast_expr2.y" 01961 { (yyval.val) = op_div ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01962 DESTROY((yyvsp[(2) - (3)].val)); 01963 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01964 (yyloc).first_line=0; (yyloc).last_line=0;;} 01965 break; 01966 01967 case 20: 01968 01969 /* Line 1455 of yacc.c */ 01970 #line 251 "ast_expr2.y" 01971 { (yyval.val) = op_rem ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01972 DESTROY((yyvsp[(2) - (3)].val)); 01973 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01974 (yyloc).first_line=0; (yyloc).last_line=0;;} 01975 break; 01976 01977 case 21: 01978 01979 /* Line 1455 of yacc.c */ 01980 #line 255 "ast_expr2.y" 01981 { (yyval.val) = op_colon ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01982 DESTROY((yyvsp[(2) - (3)].val)); 01983 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01984 (yyloc).first_line=0; (yyloc).last_line=0;;} 01985 break; 01986 01987 case 22: 01988 01989 /* Line 1455 of yacc.c */ 01990 #line 259 "ast_expr2.y" 01991 { (yyval.val) = op_eqtilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01992 DESTROY((yyvsp[(2) - (3)].val)); 01993 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01994 (yyloc).first_line=0; (yyloc).last_line=0;;} 01995 break; 01996 01997 case 23: 01998 01999 /* Line 1455 of yacc.c */ 02000 #line 263 "ast_expr2.y" 02001 { (yyval.val) = op_cond ((yyvsp[(1) - (5)].val), (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val)); 02002 DESTROY((yyvsp[(2) - (5)].val)); 02003 DESTROY((yyvsp[(4) - (5)].val)); 02004 (yyloc).first_column = (yylsp[(1) - (5)]).first_column; (yyloc).last_column = (yylsp[(3) - (5)]).last_column; 02005 (yyloc).first_line=0; (yyloc).last_line=0;;} 02006 break; 02007 02008 02009 02010 /* Line 1455 of yacc.c */ 02011 #line 2012 "ast_expr2.c" 02012 default: break; 02013 } 02014 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 02015 02016 YYPOPSTACK (yylen); 02017 yylen = 0; 02018 YY_STACK_PRINT (yyss, yyssp); 02019 02020 *++yyvsp = yyval; 02021 *++yylsp = yyloc; 02022 02023 /* Now `shift' the result of the reduction. Determine what state 02024 that goes to, based on the state we popped back to and the rule 02025 number reduced by. */ 02026 02027 yyn = yyr1[yyn]; 02028 02029 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 02030 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 02031 yystate = yytable[yystate]; 02032 else 02033 yystate = yydefgoto[yyn - YYNTOKENS]; 02034 02035 goto yynewstate; 02036 02037 02038 /*------------------------------------. 02039 | yyerrlab -- here on detecting error | 02040 `------------------------------------*/ 02041 yyerrlab: 02042 /* If not already recovering from an error, report this error. */ 02043 if (!yyerrstatus) 02044 { 02045 ++yynerrs; 02046 #if ! YYERROR_VERBOSE 02047 yyerror (YY_("syntax error")); 02048 #else 02049 { 02050 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); 02051 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) 02052 { 02053 YYSIZE_T yyalloc = 2 * yysize; 02054 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) 02055 yyalloc = YYSTACK_ALLOC_MAXIMUM; 02056 if (yymsg != yymsgbuf) 02057 YYSTACK_FREE (yymsg); 02058 yymsg = (char *) YYSTACK_ALLOC (yyalloc); 02059 if (yymsg) 02060 yymsg_alloc = yyalloc; 02061 else 02062 { 02063 yymsg = yymsgbuf; 02064 yymsg_alloc = sizeof yymsgbuf; 02065 } 02066 } 02067 02068 if (0 < yysize && yysize <= yymsg_alloc) 02069 { 02070 (void) yysyntax_error (yymsg, yystate, yychar); 02071 yyerror (yymsg); 02072 } 02073 else 02074 { 02075 yyerror (YY_("syntax error")); 02076 if (yysize != 0) 02077 goto yyexhaustedlab; 02078 } 02079 } 02080 #endif 02081 } 02082 02083 yyerror_range[0] = yylloc; 02084 02085 if (yyerrstatus == 3) 02086 { 02087 /* If just tried and failed to reuse lookahead token after an 02088 error, discard it. */ 02089 02090 if (yychar <= YYEOF) 02091 { 02092 /* Return failure if at end of input. */ 02093 if (yychar == YYEOF) 02094 YYABORT; 02095 } 02096 else 02097 { 02098 yydestruct ("Error: discarding", 02099 yytoken, &yylval, &yylloc); 02100 yychar = YYEMPTY; 02101 } 02102 } 02103 02104 /* Else will try to reuse lookahead token after shifting the error 02105 token. */ 02106 goto yyerrlab1; 02107 02108 02109 /*---------------------------------------------------. 02110 | yyerrorlab -- error raised explicitly by YYERROR. | 02111 `---------------------------------------------------*/ 02112 yyerrorlab: 02113 02114 /* Pacify compilers like GCC when the user code never invokes 02115 YYERROR and the label yyerrorlab therefore never appears in user 02116 code. */ 02117 if (/*CONSTCOND*/ 0) 02118 goto yyerrorlab; 02119 02120 yyerror_range[0] = yylsp[1-yylen]; 02121 /* Do not reclaim the symbols of the rule which action triggered 02122 this YYERROR. */ 02123 YYPOPSTACK (yylen); 02124 yylen = 0; 02125 YY_STACK_PRINT (yyss, yyssp); 02126 yystate = *yyssp; 02127 goto yyerrlab1; 02128 02129 02130 /*-------------------------------------------------------------. 02131 | yyerrlab1 -- common code for both syntax error and YYERROR. | 02132 `-------------------------------------------------------------*/ 02133 yyerrlab1: 02134 yyerrstatus = 3; /* Each real token shifted decrements this. */ 02135 02136 for (;;) 02137 { 02138 yyn = yypact[yystate]; 02139 if (yyn != YYPACT_NINF) 02140 { 02141 yyn += YYTERROR; 02142 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 02143 { 02144 yyn = yytable[yyn]; 02145 if (0 < yyn) 02146 break; 02147 } 02148 } 02149 02150 /* Pop the current state because it cannot handle the error token. */ 02151 if (yyssp == yyss) 02152 YYABORT; 02153 02154 yyerror_range[0] = *yylsp; 02155 yydestruct ("Error: popping", 02156 yystos[yystate], yyvsp, yylsp); 02157 YYPOPSTACK (1); 02158 yystate = *yyssp; 02159 YY_STACK_PRINT (yyss, yyssp); 02160 } 02161 02162 *++yyvsp = yylval; 02163 02164 yyerror_range[1] = yylloc; 02165 /* Using YYLLOC is tempting, but would change the location of 02166 the lookahead. YYLOC is available though. */ 02167 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); 02168 *++yylsp = yyloc; 02169 02170 /* Shift the error token. */ 02171 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); 02172 02173 yystate = yyn; 02174 goto yynewstate; 02175 02176 02177 /*-------------------------------------. 02178 | yyacceptlab -- YYACCEPT comes here. | 02179 `-------------------------------------*/ 02180 yyacceptlab: 02181 yyresult = 0; 02182 goto yyreturn; 02183 02184 /*-----------------------------------. 02185 | yyabortlab -- YYABORT comes here. | 02186 `-----------------------------------*/ 02187 yyabortlab: 02188 yyresult = 1; 02189 goto yyreturn; 02190 02191 #if !defined(yyoverflow) || YYERROR_VERBOSE 02192 /*-------------------------------------------------. 02193 | yyexhaustedlab -- memory exhaustion comes here. | 02194 `-------------------------------------------------*/ 02195 yyexhaustedlab: 02196 yyerror (YY_("memory exhausted")); 02197 yyresult = 2; 02198 /* Fall through. */ 02199 #endif 02200 02201 yyreturn: 02202 if (yychar != YYEMPTY) 02203 yydestruct ("Cleanup: discarding lookahead", 02204 yytoken, &yylval, &yylloc); 02205 /* Do not reclaim the symbols of the rule which action triggered 02206 this YYABORT or YYACCEPT. */ 02207 YYPOPSTACK (yylen); 02208 YY_STACK_PRINT (yyss, yyssp); 02209 while (yyssp != yyss) 02210 { 02211 yydestruct ("Cleanup: popping", 02212 yystos[*yyssp], yyvsp, yylsp); 02213 YYPOPSTACK (1); 02214 } 02215 #ifndef yyoverflow 02216 if (yyss != yyssa) 02217 YYSTACK_FREE (yyss); 02218 #endif 02219 #if YYERROR_VERBOSE 02220 if (yymsg != yymsgbuf) 02221 YYSTACK_FREE (yymsg); 02222 #endif 02223 /* Make sure YYID is used. */ 02224 return YYID (yyresult); 02225 }
int yyparse | ( | ) |
static char* yystpcpy | ( | char * | yydest, | |
const char * | yysrc | |||
) | [static] |
Definition at line 1061 of file ast_expr2.c.
Referenced by yysyntax_error(), and yytnamerr().
01065 { 01066 char *yyd = yydest; 01067 const char *yys = yysrc; 01068 01069 while ((*yyd++ = *yys++) != '\0') 01070 continue; 01071 01072 return yyd - 1; 01073 }
static YYSIZE_T yystrlen | ( | char * | yystr | ) | const [static] |
Definition at line 1037 of file ast_expr2.c.
References YYSIZE_T.
Referenced by yysyntax_error(), and yytnamerr().
01040 { 01041 YYSIZE_T yylen; 01042 for (yylen = 0; yystr[yylen]; yylen++) 01043 continue; 01044 return yylen; 01045 }
static YYSIZE_T yysyntax_error | ( | char * | yyresult, | |
int | yystate, | |||
int | yychar | |||
) | [static] |
Definition at line 1133 of file ast_expr2.c.
References YY_, YYLAST, YYNTOKENS, YYPACT_NINF, YYSIZE_MAXIMUM, YYSIZE_T, yystpcpy(), yystrlen(), YYTERROR, yytnamerr(), and YYTRANSLATE.
Referenced by yyparse().
01134 { 01135 int yyn = yypact[yystate]; 01136 01137 if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) 01138 return 0; 01139 else 01140 { 01141 int yytype = YYTRANSLATE (yychar); 01142 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); 01143 YYSIZE_T yysize = yysize0; 01144 YYSIZE_T yysize1; 01145 int yysize_overflow = 0; 01146 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; 01147 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 01148 int yyx; 01149 01150 # if 0 01151 /* This is so xgettext sees the translatable formats that are 01152 constructed on the fly. */ 01153 YY_("syntax error, unexpected %s"); 01154 YY_("syntax error, unexpected %s, expecting %s"); 01155 YY_("syntax error, unexpected %s, expecting %s or %s"); 01156 YY_("syntax error, unexpected %s, expecting %s or %s or %s"); 01157 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); 01158 # endif 01159 char *yyfmt; 01160 char const *yyf; 01161 static char const yyunexpected[] = "syntax error, unexpected %s"; 01162 static char const yyexpecting[] = ", expecting %s"; 01163 static char const yyor[] = " or %s"; 01164 char yyformat[sizeof yyunexpected 01165 + sizeof yyexpecting - 1 01166 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) 01167 * (sizeof yyor - 1))]; 01168 char const *yyprefix = yyexpecting; 01169 01170 /* Start YYX at -YYN if negative to avoid negative indexes in 01171 YYCHECK. */ 01172 int yyxbegin = yyn < 0 ? -yyn : 0; 01173 01174 /* Stay within bounds of both yycheck and yytname. */ 01175 int yychecklim = YYLAST - yyn + 1; 01176 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; 01177 int yycount = 1; 01178 01179 yyarg[0] = yytname[yytype]; 01180 yyfmt = yystpcpy (yyformat, yyunexpected); 01181 01182 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 01183 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 01184 { 01185 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) 01186 { 01187 yycount = 1; 01188 yysize = yysize0; 01189 yyformat[sizeof yyunexpected - 1] = '\0'; 01190 break; 01191 } 01192 yyarg[yycount++] = yytname[yyx]; 01193 yysize1 = yysize + yytnamerr (0, yytname[yyx]); 01194 yysize_overflow |= (yysize1 < yysize); 01195 yysize = yysize1; 01196 yyfmt = yystpcpy (yyfmt, yyprefix); 01197 yyprefix = yyor; 01198 } 01199 01200 yyf = YY_(yyformat); 01201 yysize1 = yysize + yystrlen (yyf); 01202 yysize_overflow |= (yysize1 < yysize); 01203 yysize = yysize1; 01204 01205 if (yysize_overflow) 01206 return YYSIZE_MAXIMUM; 01207 01208 if (yyresult) 01209 { 01210 /* Avoid sprintf, as that infringes on the user's name space. 01211 Don't have undefined behavior even if the translation 01212 produced a string with the wrong number of "%s"s. */ 01213 char *yyp = yyresult; 01214 int yyi = 0; 01215 while ((*yyp = *yyf) != '\0') 01216 { 01217 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) 01218 { 01219 yyp += yytnamerr (yyp, yyarg[yyi++]); 01220 yyf += 2; 01221 } 01222 else 01223 { 01224 yyp++; 01225 yyf++; 01226 } 01227 } 01228 } 01229 return yysize; 01230 } 01231 }
static YYSIZE_T yytnamerr | ( | char * | yyres, | |
const char * | yystr | |||
) | [static] |
Definition at line 1086 of file ast_expr2.c.
References YYSIZE_T, yystpcpy(), and yystrlen().
Referenced by yysyntax_error().
01087 { 01088 if (*yystr == '"') 01089 { 01090 YYSIZE_T yyn = 0; 01091 char const *yyp = yystr; 01092 01093 for (;;) 01094 switch (*++yyp) 01095 { 01096 case '\'': 01097 case ',': 01098 goto do_not_strip_quotes; 01099 01100 case '\\': 01101 if (*++yyp != '\\') 01102 goto do_not_strip_quotes; 01103 /* Fall through. */ 01104 default: 01105 if (yyres) 01106 yyres[yyn] = *yyp; 01107 yyn++; 01108 break; 01109 01110 case '"': 01111 if (yyres) 01112 yyres[yyn] = '\0'; 01113 return yyn; 01114 } 01115 do_not_strip_quotes: ; 01116 } 01117 01118 if (! yyres) 01119 return yystrlen (yystr); 01120 01121 return yystpcpy (yyres, yystr) - yyres; 01122 }
char extra_error_message[4095] |
Definition at line 2394 of file ast_expr2f.c.
Definition at line 2395 of file ast_expr2f.c.
const yytype_int8 yycheck[] [static] |
Definition at line 716 of file ast_expr2.c.
const yytype_uint8 yydefact[] [static] |
Definition at line 659 of file ast_expr2.c.
const yytype_int8 yydefgoto[] [static] |
const yytype_int8 yypact[] [static] |
Definition at line 677 of file ast_expr2.c.
const yytype_int8 yypgoto[] [static] |
const yytype_uint8 yyr1[] [static] |
Definition at line 641 of file ast_expr2.c.
const yytype_uint8 yyr2[] [static] |
Definition at line 649 of file ast_expr2.c.
const yytype_uint8 yystos[] [static] |
Definition at line 737 of file ast_expr2.c.
const yytype_uint8 yytable[] [static] |
Definition at line 697 of file ast_expr2.c.
const char* const yytname[] [static] |
Definition at line 619 of file ast_expr2.c.
const yytype_uint8 yytranslate[] [static] |
Definition at line 551 of file ast_expr2.c.