#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 | TOK_AND 261 |
#define | TOK_COLON 275 |
#define | TOK_COLONCOLON 258 |
#define | TOK_COMPL 273 |
#define | TOK_COND 259 |
#define | TOK_DIV 271 |
#define | TOK_EQ 267 |
#define | TOK_EQTILDE 274 |
#define | TOK_GE 264 |
#define | TOK_GT 266 |
#define | TOK_LE 263 |
#define | TOK_LP 276 |
#define | TOK_LT 265 |
#define | TOK_MINUS 268 |
#define | TOK_MOD 270 |
#define | TOK_MULT 272 |
#define | TOK_NE 262 |
#define | TOK_OR 260 |
#define | TOK_PLUS 269 |
#define | TOK_RP 277 |
#define | TOKEN 278 |
#define | YY_(msgid) msgid |
#define | YY_LOCATION_PRINT(File, Loc) |
#define | YY_REDUCE_PRINT(Rule) |
#define | YY_STACK_PRINT(Bottom, Top) |
#define | YY_SYMBOL_PRINT(Title, Type, Value, Location) |
#define | YYABORT goto yyabortlab |
#define | YYACCEPT goto yyacceptlab |
#define | YYBACKUP(Token, Value) |
#define | YYBISON 1 |
#define | YYBISON_VERSION "2.3" |
#define | yychar ast_yychar |
#define | yyclearin (yychar = YYEMPTY) |
#define | YYCOPY(To, From, Count) |
#define | YYDEBUG 0 |
#define | yydebug ast_yydebug |
#define | YYDPRINTF(Args) |
#define | YYEMPTY (-2) |
#define | 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 | YYPURE 1 |
#define | YYRECOVERING() (!!yyerrstatus) |
#define | YYRHSLOC(Rhs, K) ((Rhs)[K]) |
#define | YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
#define | YYSIZE_T unsigned int |
#define | YYSKELETON_NAME "yacc.c" |
#define | YYSTACK_ALLOC YYMALLOC |
#define | YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
#define | YYSTACK_BYTES(N) |
#define | YYSTACK_FREE YYFREE |
#define | YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
#define | YYSTACK_RELOCATE(Stack) |
#define | yystype YYSTYPE |
#define | YYSTYPE_IS_DECLARED 1 |
#define | YYSTYPE_IS_TRIVIAL 1 |
#define | YYTABLE_NINF -1 |
#define | YYTERROR 1 |
#define | YYTOKEN_TABLE 0 |
#define | YYTRANSLATE(YYX) ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
#define | YYUNDEFTOK 2 |
#define | YYUSE(e) ((void) (e)) |
Typedefs | |
typedef void * | yyscan_t |
typedef short int | yytype_int16 |
typedef short int | yytype_int8 |
typedef unsigned short int | yytype_uint16 |
typedef unsigned char | yytype_uint8 |
Enumerations | |
enum | 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 2312 of file ast_expr2.c.
#define ast_yyerror | ( | x | ) | ast_yyerror(x,&yyloc,parseio) |
Definition at line 2312 of file ast_expr2.c.
#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) |
Definition at line 178 of file ast_expr2.c.
#define QUAD_MIN (-0x7fffffffffffffffLL-1) |
#define TOK_AND 261 |
Definition at line 104 of file ast_expr2.c.
#define TOK_COLON 275 |
Definition at line 118 of file ast_expr2.c.
#define TOK_COLONCOLON 258 |
Definition at line 101 of file ast_expr2.c.
#define TOK_COMPL 273 |
Definition at line 116 of file ast_expr2.c.
#define TOK_COND 259 |
Definition at line 102 of file ast_expr2.c.
#define TOK_DIV 271 |
Definition at line 114 of file ast_expr2.c.
#define TOK_EQ 267 |
Definition at line 110 of file ast_expr2.c.
#define TOK_EQTILDE 274 |
Definition at line 117 of file ast_expr2.c.
#define TOK_GE 264 |
Definition at line 107 of file ast_expr2.c.
#define TOK_GT 266 |
Definition at line 109 of file ast_expr2.c.
#define TOK_LE 263 |
Definition at line 106 of file ast_expr2.c.
#define TOK_LP 276 |
Definition at line 119 of file ast_expr2.c.
#define TOK_LT 265 |
Definition at line 108 of file ast_expr2.c.
#define TOK_MINUS 268 |
Definition at line 111 of file ast_expr2.c.
#define TOK_MOD 270 |
Definition at line 113 of file ast_expr2.c.
#define TOK_MULT 272 |
Definition at line 115 of file ast_expr2.c.
#define TOK_NE 262 |
Definition at line 105 of file ast_expr2.c.
#define TOK_OR 260 |
Definition at line 103 of file ast_expr2.c.
#define TOK_PLUS 269 |
Definition at line 112 of file ast_expr2.c.
#define TOK_RP 277 |
Definition at line 120 of file ast_expr2.c.
#define TOKEN 278 |
Definition at line 121 of file ast_expr2.c.
#define YY_ | ( | msgid | ) | msgid |
#define YY_LOCATION_PRINT | ( | File, | |||
Loc | ) |
Value:
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
(Loc).last_line, (Loc).last_column)
Definition at line 823 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 769 of file ast_expr2.c.
#define YYBISON 1 |
Definition at line 47 of file ast_expr2.c.
#define YYBISON_VERSION "2.3" |
Definition at line 50 of file ast_expr2.c.
#define yychar ast_yychar |
#define yyclearin (yychar = YYEMPTY) |
Definition at line 752 of file ast_expr2.c.
#define YYCOPY | ( | To, | |||
From, | |||||
Count | ) |
Definition at line 505 of file ast_expr2.c.
#define YYDEBUG 0 |
Definition at line 269 of file ast_expr2.c.
#define yydebug ast_yydebug |
Definition at line 67 of file ast_expr2.c.
#define YYDPRINTF | ( | Args | ) |
#define YYEMPTY (-2) |
#define YYEOF 0 |
#define YYERRCODE 256 |
Definition at line 788 of file ast_expr2.c.
#define yyerrok (yyerrstatus = 0) |
Definition at line 751 of file ast_expr2.c.
#define YYERROR goto yyerrorlab |
Definition at line 758 of file ast_expr2.c.
#define yyerror ast_yyerror |
#define YYERROR_VERBOSE 1 |
Definition at line 275 of file ast_expr2.c.
#define YYERROR_VERBOSE 1 |
Definition at line 275 of file ast_expr2.c.
#define YYFAIL goto yyerrlab |
Definition at line 765 of file ast_expr2.c.
#define YYFINAL 10 |
#define YYFREE free |
Definition at line 466 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 63 of file ast_expr2.c.
#define YYLEX_PARAM ((struct parse_io *)parseio)->scanner |
Definition at line 182 of file ast_expr2.c.
#define yylloc ast_yylloc |
Definition at line 69 of file ast_expr2.c.
Referenced by ast_yyget_lloc(), ast_yyset_lloc(), and yyparse().
#define YYLLOC_DEFAULT | ( | Current, | |||
Rhs, | |||||
N | ) |
#define YYLSP_NEEDED 1 |
Definition at line 59 of file ast_expr2.c.
Definition at line 252 of file ast_expr2.c.
#define YYLTYPE_IS_TRIVIAL 1 |
Definition at line 253 of file ast_expr2.c.
#define yylval ast_yylval |
Definition at line 65 of file ast_expr2.c.
Referenced by ast_yyget_lval(), ast_yyset_lval(), and yyparse().
#define YYMALLOC malloc |
Definition at line 459 of file ast_expr2.c.
#define YYMAXDEPTH 10000 |
#define YYMAXUTOK 278 |
Definition at line 550 of file ast_expr2.c.
#define yynerrs ast_yynerrs |
#define YYNNTS 3 |
Definition at line 542 of file ast_expr2.c.
#define YYNRULES 23 |
Definition at line 544 of file ast_expr2.c.
#define YYNSTATES 46 |
Definition at line 546 of file ast_expr2.c.
#define YYNTOKENS 24 |
#define YYPACT_NINF -13 |
#define yyparse ast_yyparse |
Definition at line 62 of file ast_expr2.c.
#define YYPARSE_PARAM parseio |
Definition at line 181 of file ast_expr2.c.
#define YYPOPSTACK | ( | N | ) | (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) |
Referenced by yyparse().
#define YYPURE 1 |
Definition at line 56 of file ast_expr2.c.
#define YYRECOVERING | ( | ) | (!!yyerrstatus) |
Definition at line 767 of file ast_expr2.c.
#define YYRHSLOC | ( | Rhs, | |||
K | ) | ((Rhs)[K]) |
Definition at line 795 of file ast_expr2.c.
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
#define YYSIZE_T unsigned int |
Definition at line 363 of file ast_expr2.c.
Referenced by yyparse(), yystrlen(), yysyntax_error(), and yytnamerr().
#define YYSKELETON_NAME "yacc.c" |
Definition at line 53 of file ast_expr2.c.
#define YYSTACK_ALLOC YYMALLOC |
#define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
#define YYSTACK_BYTES | ( | N | ) |
Value:
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM)
Definition at line 494 of file ast_expr2.c.
Referenced by yyparse().
#define YYSTACK_FREE YYFREE |
#define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
Definition at line 490 of file ast_expr2.c.
#define YYSTACK_RELOCATE | ( | Stack | ) |
#define yystype YYSTYPE |
Definition at line 294 of file ast_expr2.c.
#define YYSTYPE_IS_DECLARED 1 |
Definition at line 295 of file ast_expr2.c.
#define YYSTYPE_IS_TRIVIAL 1 |
Definition at line 296 of file ast_expr2.c.
#define YYTABLE_NINF -1 |
#define YYTERROR 1 |
#define YYTOKEN_TABLE 0 |
Definition at line 282 of file ast_expr2.c.
#define YYTRANSLATE | ( | YYX | ) | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
#define YYUNDEFTOK 2 |
Definition at line 549 of file ast_expr2.c.
#define YYUSE | ( | e | ) | ((void) (e)) |
typedef void* yyscan_t |
Definition at line 203 of file ast_expr2.c.
typedef short int yytype_int16 |
Definition at line 350 of file ast_expr2.c.
typedef short int yytype_int8 |
Definition at line 338 of file ast_expr2.c.
typedef unsigned short int yytype_uint16 |
Definition at line 344 of file ast_expr2.c.
typedef unsigned char yytype_uint8 |
Definition at line 329 of file ast_expr2.c.
enum valtype |
Definition at line 187 of file ast_expr2.c.
00187 { 00188 AST_EXPR_integer, AST_EXPR_numeric_string, AST_EXPR_string 00189 } ;
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 76 of file ast_expr2.c.
00076 { 00077 TOK_COLONCOLON = 258, 00078 TOK_COND = 259, 00079 TOK_OR = 260, 00080 TOK_AND = 261, 00081 TOK_NE = 262, 00082 TOK_LE = 263, 00083 TOK_GE = 264, 00084 TOK_LT = 265, 00085 TOK_GT = 266, 00086 TOK_EQ = 267, 00087 TOK_MINUS = 268, 00088 TOK_PLUS = 269, 00089 TOK_MOD = 270, 00090 TOK_DIV = 271, 00091 TOK_MULT = 272, 00092 TOK_COMPL = 273, 00093 TOK_EQTILDE = 274, 00094 TOK_COLON = 275, 00095 TOK_LP = 276, 00096 TOK_RP = 277, 00097 TOKEN = 278 00098 };
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 2707 of file ast_expr2.c.
References QUAD_MIN.
Referenced by op_div().
02708 { 02709 /* div by zero has been taken care of before */ 02710 /* only QUAD_MIN / -1 causes overflow */ 02711 if (a == QUAD_MIN && b == -1) 02712 return 1; 02713 /* everything else is OK */ 02714 return 0; 02715 }
static int chk_minus | ( | quad_t | a, | |
quad_t | b, | |||
quad_t | r | |||
) | [static] |
Definition at line 2555 of file ast_expr2.c.
References chk_plus(), and QUAD_MIN.
Referenced by op_minus(), and op_negate().
02556 { 02557 /* special case subtraction of QUAD_MIN */ 02558 if (b == QUAD_MIN) { 02559 if (a >= 0) 02560 return 1; 02561 else 02562 return 0; 02563 } 02564 /* this is allowed for b != QUAD_MIN */ 02565 return chk_plus (a, -b, r); 02566 }
static int chk_plus | ( | quad_t | a, | |
quad_t | b, | |||
quad_t | r | |||
) | [static] |
Definition at line 2512 of file ast_expr2.c.
Referenced by chk_minus(), and op_plus().
02513 { 02514 /* sum of two positive numbers must be positive */ 02515 if (a > 0 && b > 0 && r <= 0) 02516 return 1; 02517 /* sum of two negative numbers must be negative */ 02518 if (a < 0 && b < 0 && r >= 0) 02519 return 1; 02520 /* all other cases are OK */ 02521 return 0; 02522 }
static int chk_times | ( | quad_t | a, | |
quad_t | b, | |||
quad_t | r | |||
) | [static] |
Definition at line 2673 of file ast_expr2.c.
Referenced by op_times().
02674 { 02675 /* special case: first operand is 0, no overflow possible */ 02676 if (a == 0) 02677 return 0; 02678 /* cerify that result of division matches second operand */ 02679 if (r / a != b) 02680 return 1; 02681 return 0; 02682 }
static void free_value | ( | struct val * | vp | ) | [static] |
Definition at line 2144 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().
02145 { 02146 if (vp==NULL) { 02147 return; 02148 } 02149 if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string) 02150 free (vp->u.s); 02151 free(vp); 02152 }
static int is_zero_or_null | ( | struct val * | vp | ) | [static] |
Definition at line 2238 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().
02239 { 02240 if (vp->type == AST_EXPR_integer) { 02241 return (vp->u.i == 0); 02242 } else { 02243 return (*vp->u.s == 0 || (to_integer (vp) && vp->u.i == 0)); 02244 } 02245 /* NOTREACHED */ 02246 }
static int isstring | ( | struct val * | vp | ) | [static] |
static struct val* make_integer | ( | quad_t | i | ) | [static] |
Definition at line 2098 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().
02099 { 02100 struct val *vp; 02101 02102 vp = (struct val *) malloc (sizeof (*vp)); 02103 if (vp == NULL) { 02104 ast_log(LOG_WARNING, "malloc() failed\n"); 02105 return(NULL); 02106 } 02107 02108 vp->type = AST_EXPR_integer; 02109 vp->u.i = i; 02110 return vp; 02111 }
static struct val* make_str | ( | const char * | s | ) | [static] |
Definition at line 2114 of file ast_expr2.c.
References AST_EXPR_numeric_string, ast_log(), LOG_WARNING, malloc, and strdup.
Referenced by op_colon(), and op_eqtilde().
02115 { 02116 struct val *vp; 02117 size_t i; 02118 int isint; 02119 02120 vp = (struct val *) malloc (sizeof (*vp)); 02121 if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) { 02122 ast_log(LOG_WARNING,"malloc() failed\n"); 02123 return(NULL); 02124 } 02125 02126 for(i = 1, isint = isdigit(s[0]) || s[0] == '-'; 02127 isint && i < strlen(s); 02128 i++) 02129 { 02130 if(!isdigit(s[i])) 02131 isint = 0; 02132 } 02133 02134 if (isint) 02135 vp->type = AST_EXPR_numeric_string; 02136 else 02137 vp->type = AST_EXPR_string; 02138 02139 return vp; 02140 }
Definition at line 2333 of file ast_expr2.c.
References free_value(), is_zero_or_null(), and make_integer().
Referenced by yyparse().
02334 { 02335 if (is_zero_or_null (a) || is_zero_or_null (b)) { 02336 free_value (a); 02337 free_value (b); 02338 return (make_integer ((quad_t)0)); 02339 } else { 02340 free_value (b); 02341 return (a); 02342 } 02343 }
Definition at line 2780 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().
02781 { 02782 regex_t rp; 02783 regmatch_t rm[2]; 02784 char errbuf[256]; 02785 int eval; 02786 struct val *v; 02787 02788 /* coerce to both arguments to strings */ 02789 to_string(a); 02790 to_string(b); 02791 /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */ 02792 strip_quotes(a); 02793 strip_quotes(b); 02794 /* compile regular expression */ 02795 if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) { 02796 regerror (eval, &rp, errbuf, sizeof(errbuf)); 02797 ast_log(LOG_WARNING,"regcomp() error : %s",errbuf); 02798 free_value(a); 02799 free_value(b); 02800 return make_str(""); 02801 } 02802 02803 /* compare string against pattern */ 02804 /* remember that patterns are anchored to the beginning of the line */ 02805 if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 && rm[0].rm_so == 0) { 02806 if (rm[1].rm_so >= 0) { 02807 *(a->u.s + rm[1].rm_eo) = '\0'; 02808 v = make_str (a->u.s + rm[1].rm_so); 02809 02810 } else { 02811 v = make_integer ((quad_t)(rm[0].rm_eo - rm[0].rm_so)); 02812 } 02813 } else { 02814 if (rp.re_nsub == 0) { 02815 v = make_integer ((quad_t)0); 02816 } else { 02817 v = make_str (""); 02818 } 02819 } 02820 02821 /* free arguments and pattern buffer */ 02822 free_value (a); 02823 free_value (b); 02824 regfree (&rp); 02825 02826 return v; 02827 }
Definition at line 2623 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().
02624 { 02625 int v1 = 1; 02626 struct val *r; 02627 02628 if( !a ) 02629 { 02630 v1 = 0; 02631 } 02632 else 02633 { 02634 switch( a->type ) 02635 { 02636 case AST_EXPR_integer: 02637 if( a->u.i == 0 ) 02638 v1 = 0; 02639 break; 02640 02641 case AST_EXPR_string: 02642 if( a->u.s == 0 ) 02643 v1 = 0; 02644 else 02645 { 02646 if( a->u.s[0] == 0 ) 02647 v1 = 0; 02648 else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' ) 02649 v1 = 0; 02650 } 02651 break; 02652 02653 case AST_EXPR_numeric_string: 02654 if( a->u.s == 0 ) 02655 v1 = 0; 02656 else 02657 { 02658 if( a->u.s[0] == 0 ) 02659 v1 = 0; 02660 else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' ) 02661 v1 = 0; 02662 } 02663 break; 02664 } 02665 } 02666 02667 r = make_integer (!v1); 02668 free_value (a); 02669 return r; 02670 }
Definition at line 2453 of file ast_expr2.c.
References free_value(), val::i, isstring(), val::s, to_integer(), and val::u.
Referenced by yyparse().
02454 { 02455 struct val *r; 02456 02457 if( isstring(a) ) 02458 { 02459 if( strlen(a->u.s) && strcmp(a->u.s, "\"\"") != 0 && strcmp(a->u.s,"0") != 0 ) 02460 { 02461 free_value(a); 02462 free_value(c); 02463 r = b; 02464 } 02465 else 02466 { 02467 free_value(a); 02468 free_value(b); 02469 r = c; 02470 } 02471 } 02472 else 02473 { 02474 (void)to_integer(a); 02475 if( a->u.i ) 02476 { 02477 free_value(a); 02478 free_value(c); 02479 r = b; 02480 } 02481 else 02482 { 02483 free_value(a); 02484 free_value(b); 02485 r = c; 02486 } 02487 } 02488 return r; 02489 }
Definition at line 2718 of file ast_expr2.c.
References ast_log(), chk_div(), free_value(), LOG_WARNING, make_integer(), and to_integer().
Referenced by yyparse().
02719 { 02720 struct val *r; 02721 02722 if (!to_integer (a)) { 02723 free_value(a); 02724 free_value(b); 02725 if( !extra_error_message_supplied ) 02726 ast_log(LOG_WARNING, "non-numeric argument\n"); 02727 return make_integer(0); 02728 } else if (!to_integer (b)) { 02729 free_value(a); 02730 free_value(b); 02731 if( !extra_error_message_supplied ) 02732 ast_log(LOG_WARNING, "non-numeric argument\n"); 02733 return make_integer(INT_MAX); 02734 } 02735 02736 if (b->u.i == 0) { 02737 ast_log(LOG_WARNING, "division by zero\n"); 02738 free_value(a); 02739 free_value(b); 02740 return make_integer(INT_MAX); 02741 } 02742 02743 r = make_integer (/*(quad_t)*/(a->u.i / b->u.i)); 02744 if (chk_div (a->u.i, b->u.i)) { 02745 ast_log(LOG_WARNING, "overflow\n"); 02746 } 02747 free_value (a); 02748 free_value (b); 02749 return r; 02750 }
Definition at line 2346 of file ast_expr2.c.
References ast_log(), free_value(), isstring(), LOG_WARNING, make_integer(), to_integer(), and to_string().
Referenced by yyparse().
02347 { 02348 struct val *r; 02349 02350 if (isstring (a) || isstring (b)) { 02351 to_string (a); 02352 to_string (b); 02353 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) == 0)); 02354 } else { 02355 #ifdef DEBUG_FOR_CONVERSIONS 02356 char buffer[2000]; 02357 sprintf(buffer,"Converting '%s' and '%s' ", a->u.s, b->u.s); 02358 #endif 02359 (void)to_integer(a); 02360 (void)to_integer(b); 02361 #ifdef DEBUG_FOR_CONVERSIONS 02362 ast_log(LOG_WARNING,"%s to '%lld' and '%lld'\n", buffer, a->u.i, b->u.i); 02363 #endif 02364 r = make_integer ((quad_t)(a->u.i == b->u.i)); 02365 } 02366 02367 free_value (a); 02368 free_value (b); 02369 return r; 02370 }
Definition at line 2831 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().
02832 { 02833 regex_t rp; 02834 regmatch_t rm[2]; 02835 char errbuf[256]; 02836 int eval; 02837 struct val *v; 02838 02839 /* coerce to both arguments to strings */ 02840 to_string(a); 02841 to_string(b); 02842 /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */ 02843 strip_quotes(a); 02844 strip_quotes(b); 02845 /* compile regular expression */ 02846 if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) { 02847 regerror (eval, &rp, errbuf, sizeof(errbuf)); 02848 ast_log(LOG_WARNING,"regcomp() error : %s",errbuf); 02849 free_value(a); 02850 free_value(b); 02851 return make_str(""); 02852 } 02853 02854 /* compare string against pattern */ 02855 /* remember that patterns are anchored to the beginning of the line */ 02856 if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 ) { 02857 if (rm[1].rm_so >= 0) { 02858 *(a->u.s + rm[1].rm_eo) = '\0'; 02859 v = make_str (a->u.s + rm[1].rm_so); 02860 02861 } else { 02862 v = make_integer ((quad_t)(rm[0].rm_eo - rm[0].rm_so)); 02863 } 02864 } else { 02865 if (rp.re_nsub == 0) { 02866 v = make_integer ((quad_t)0); 02867 } else { 02868 v = make_str (""); 02869 } 02870 } 02871 02872 /* free arguments and pattern buffer */ 02873 free_value (a); 02874 free_value (b); 02875 regfree (&rp); 02876 02877 return v; 02878 }
Definition at line 2413 of file ast_expr2.c.
References free_value(), isstring(), make_integer(), to_integer(), and to_string().
Referenced by yyparse().
02414 { 02415 struct val *r; 02416 02417 if (isstring (a) || isstring (b)) { 02418 to_string (a); 02419 to_string (b); 02420 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) >= 0)); 02421 } else { 02422 (void)to_integer(a); 02423 (void)to_integer(b); 02424 r = make_integer ((quad_t)(a->u.i >= b->u.i)); 02425 } 02426 02427 free_value (a); 02428 free_value (b); 02429 return r; 02430 }
Definition at line 2373 of file ast_expr2.c.
References free_value(), isstring(), make_integer(), to_integer(), and to_string().
Referenced by yyparse().
02374 { 02375 struct val *r; 02376 02377 if (isstring (a) || isstring (b)) { 02378 to_string (a); 02379 to_string (b); 02380 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) > 0)); 02381 } else { 02382 (void)to_integer(a); 02383 (void)to_integer(b); 02384 r = make_integer ((quad_t)(a->u.i > b->u.i)); 02385 } 02386 02387 free_value (a); 02388 free_value (b); 02389 return r; 02390 }
Definition at line 2433 of file ast_expr2.c.
References free_value(), isstring(), make_integer(), to_integer(), and to_string().
Referenced by yyparse().
02434 { 02435 struct val *r; 02436 02437 if (isstring (a) || isstring (b)) { 02438 to_string (a); 02439 to_string (b); 02440 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) <= 0)); 02441 } else { 02442 (void)to_integer(a); 02443 (void)to_integer(b); 02444 r = make_integer ((quad_t)(a->u.i <= b->u.i)); 02445 } 02446 02447 free_value (a); 02448 free_value (b); 02449 return r; 02450 }
Definition at line 2393 of file ast_expr2.c.
References free_value(), isstring(), make_integer(), to_integer(), and to_string().
Referenced by yyparse().
02394 { 02395 struct val *r; 02396 02397 if (isstring (a) || isstring (b)) { 02398 to_string (a); 02399 to_string (b); 02400 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) < 0)); 02401 } else { 02402 (void)to_integer(a); 02403 (void)to_integer(b); 02404 r = make_integer ((quad_t)(a->u.i < b->u.i)); 02405 } 02406 02407 free_value (a); 02408 free_value (b); 02409 return r; 02410 }
Definition at line 2569 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().
02570 { 02571 struct val *r; 02572 02573 if (!to_integer (a)) { 02574 if( !extra_error_message_supplied ) 02575 ast_log(LOG_WARNING, "non-numeric argument\n"); 02576 if (!to_integer (b)) { 02577 free_value(a); 02578 free_value(b); 02579 return make_integer(0); 02580 } else { 02581 r = make_integer(0 - b->u.i); 02582 free_value(a); 02583 free_value(b); 02584 return (r); 02585 } 02586 } else if (!to_integer(b)) { 02587 if( !extra_error_message_supplied ) 02588 ast_log(LOG_WARNING, "non-numeric argument\n"); 02589 free_value(b); 02590 return (a); 02591 } 02592 02593 r = make_integer (/*(quad_t)*/(a->u.i - b->u.i)); 02594 if (chk_minus (a->u.i, b->u.i, r->u.i)) { 02595 ast_log(LOG_WARNING, "overflow\n"); 02596 } 02597 free_value (a); 02598 free_value (b); 02599 return r; 02600 }
Definition at line 2492 of file ast_expr2.c.
References free_value(), isstring(), make_integer(), to_integer(), and to_string().
Referenced by yyparse().
02493 { 02494 struct val *r; 02495 02496 if (isstring (a) || isstring (b)) { 02497 to_string (a); 02498 to_string (b); 02499 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) != 0)); 02500 } else { 02501 (void)to_integer(a); 02502 (void)to_integer(b); 02503 r = make_integer ((quad_t)(a->u.i != b->u.i)); 02504 } 02505 02506 free_value (a); 02507 free_value (b); 02508 return r; 02509 }
Definition at line 2603 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().
02604 { 02605 struct val *r; 02606 02607 if (!to_integer (a) ) { 02608 free_value(a); 02609 if( !extra_error_message_supplied ) 02610 ast_log(LOG_WARNING, "non-numeric argument\n"); 02611 return make_integer(0); 02612 } 02613 02614 r = make_integer (/*(quad_t)*/(- a->u.i)); 02615 if (chk_minus (0, a->u.i, r->u.i)) { 02616 ast_log(LOG_WARNING, "overflow\n"); 02617 } 02618 free_value (a); 02619 return r; 02620 }
Definition at line 2321 of file ast_expr2.c.
References free_value(), and is_zero_or_null().
Referenced by yyparse().
02322 { 02323 if (is_zero_or_null (a)) { 02324 free_value (a); 02325 return (b); 02326 } else { 02327 free_value (b); 02328 return (a); 02329 } 02330 }
Definition at line 2525 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().
02526 { 02527 struct val *r; 02528 02529 if (!to_integer (a)) { 02530 if( !extra_error_message_supplied ) 02531 ast_log(LOG_WARNING,"non-numeric argument\n"); 02532 if (!to_integer (b)) { 02533 free_value(a); 02534 free_value(b); 02535 return make_integer(0); 02536 } else { 02537 free_value(a); 02538 return (b); 02539 } 02540 } else if (!to_integer(b)) { 02541 free_value(b); 02542 return (a); 02543 } 02544 02545 r = make_integer (/*(quad_t)*/(a->u.i + b->u.i)); 02546 if (chk_plus (a->u.i, b->u.i, r->u.i)) { 02547 ast_log(LOG_WARNING,"overflow\n"); 02548 } 02549 free_value (a); 02550 free_value (b); 02551 return r; 02552 }
Definition at line 2753 of file ast_expr2.c.
References ast_log(), free_value(), LOG_WARNING, make_integer(), and to_integer().
Referenced by yyparse().
02754 { 02755 struct val *r; 02756 02757 if (!to_integer (a) || !to_integer (b)) { 02758 if( !extra_error_message_supplied ) 02759 ast_log(LOG_WARNING, "non-numeric argument\n"); 02760 free_value(a); 02761 free_value(b); 02762 return make_integer(0); 02763 } 02764 02765 if (b->u.i == 0) { 02766 ast_log(LOG_WARNING, "div by zero\n"); 02767 free_value(a); 02768 return(b); 02769 } 02770 02771 r = make_integer (/*(quad_t)*/(a->u.i % b->u.i)); 02772 /* chk_rem necessary ??? */ 02773 free_value (a); 02774 free_value (b); 02775 return r; 02776 }
Definition at line 2685 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().
02686 { 02687 struct val *r; 02688 02689 if (!to_integer (a) || !to_integer (b)) { 02690 free_value(a); 02691 free_value(b); 02692 if( !extra_error_message_supplied ) 02693 ast_log(LOG_WARNING, "non-numeric argument\n"); 02694 return(make_integer(0)); 02695 } 02696 02697 r = make_integer (/*(quad_t)*/(a->u.i * b->u.i)); 02698 if (chk_times (a->u.i, b->u.i, r->u.i)) { 02699 ast_log(LOG_WARNING, "overflow\n"); 02700 } 02701 free_value (a); 02702 free_value (b); 02703 return (r); 02704 }
static void strip_quotes | ( | struct val * | vp | ) | [static] |
Definition at line 2187 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().
02188 { 02189 if (vp->type != AST_EXPR_string && vp->type != AST_EXPR_numeric_string) 02190 return; 02191 02192 if( vp->u.s[0] == '"' && vp->u.s[strlen(vp->u.s)-1] == '"' ) 02193 { 02194 char *f, *t; 02195 f = vp->u.s; 02196 t = vp->u.s; 02197 02198 while( *f ) 02199 { 02200 if( *f && *f != '"' ) 02201 *t++ = *f++; 02202 else 02203 f++; 02204 } 02205 *t = *f; 02206 } 02207 }
static quad_t to_integer | ( | struct val * | vp | ) | [static] |
Definition at line 2156 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().
02157 { 02158 quad_t i; 02159 02160 if (vp == NULL) { 02161 ast_log(LOG_WARNING,"vp==NULL in to_integer()\n"); 02162 return(0); 02163 } 02164 02165 if (vp->type == AST_EXPR_integer) 02166 return 1; 02167 02168 if (vp->type == AST_EXPR_string) 02169 return 0; 02170 02171 /* vp->type == AST_EXPR_numeric_string, make it numeric */ 02172 errno = 0; 02173 i = strtoll(vp->u.s, (char**)NULL, 10); 02174 if (errno != 0) { 02175 ast_log(LOG_WARNING,"Conversion of %s to integer under/overflowed!\n", vp->u.s); 02176 free(vp->u.s); 02177 vp->u.s = 0; 02178 return(0); 02179 } 02180 free (vp->u.s); 02181 vp->u.i = i; 02182 vp->type = AST_EXPR_integer; 02183 return 1; 02184 }
static void to_string | ( | struct val * | vp | ) | [static] |
Definition at line 2210 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().
02211 { 02212 char *tmp; 02213 02214 if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string) 02215 return; 02216 02217 tmp = malloc ((size_t)25); 02218 if (tmp == NULL) { 02219 ast_log(LOG_WARNING,"malloc() failed\n"); 02220 return; 02221 } 02222 02223 sprintf(tmp, "%ld", (long int) vp->u.i); 02224 vp->type = AST_EXPR_string; 02225 vp->u.s = tmp; 02226 }
static void yydestruct | ( | char * | yymsg, | |
int | yytype, | |||
YYSTYPE * | yyvaluep, | |||
YYLTYPE * | yylocationp | |||
) | const [static] |
Definition at line 1248 of file ast_expr2.c.
References free_value(), YYSTYPE::val, YY_SYMBOL_PRINT, and YYUSE.
Referenced by yyparse().
01254 { 01255 YYUSE (yyvaluep); 01256 YYUSE (yylocationp); 01257 01258 if (!yymsg) 01259 yymsg = "Deleting"; 01260 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 01261 01262 switch (yytype) 01263 { 01264 case 3: /* "TOK_COLONCOLON" */ 01265 #line 169 "ast_expr2.y" 01266 { free_value((yyvaluep->val)); }; 01267 #line 1268 "ast_expr2.c" 01268 break; 01269 case 4: /* "TOK_COND" */ 01270 #line 169 "ast_expr2.y" 01271 { free_value((yyvaluep->val)); }; 01272 #line 1273 "ast_expr2.c" 01273 break; 01274 case 5: /* "TOK_OR" */ 01275 #line 169 "ast_expr2.y" 01276 { free_value((yyvaluep->val)); }; 01277 #line 1278 "ast_expr2.c" 01278 break; 01279 case 6: /* "TOK_AND" */ 01280 #line 169 "ast_expr2.y" 01281 { free_value((yyvaluep->val)); }; 01282 #line 1283 "ast_expr2.c" 01283 break; 01284 case 7: /* "TOK_NE" */ 01285 #line 169 "ast_expr2.y" 01286 { free_value((yyvaluep->val)); }; 01287 #line 1288 "ast_expr2.c" 01288 break; 01289 case 8: /* "TOK_LE" */ 01290 #line 169 "ast_expr2.y" 01291 { free_value((yyvaluep->val)); }; 01292 #line 1293 "ast_expr2.c" 01293 break; 01294 case 9: /* "TOK_GE" */ 01295 #line 169 "ast_expr2.y" 01296 { free_value((yyvaluep->val)); }; 01297 #line 1298 "ast_expr2.c" 01298 break; 01299 case 10: /* "TOK_LT" */ 01300 #line 169 "ast_expr2.y" 01301 { free_value((yyvaluep->val)); }; 01302 #line 1303 "ast_expr2.c" 01303 break; 01304 case 11: /* "TOK_GT" */ 01305 #line 169 "ast_expr2.y" 01306 { free_value((yyvaluep->val)); }; 01307 #line 1308 "ast_expr2.c" 01308 break; 01309 case 12: /* "TOK_EQ" */ 01310 #line 169 "ast_expr2.y" 01311 { free_value((yyvaluep->val)); }; 01312 #line 1313 "ast_expr2.c" 01313 break; 01314 case 13: /* "TOK_MINUS" */ 01315 #line 169 "ast_expr2.y" 01316 { free_value((yyvaluep->val)); }; 01317 #line 1318 "ast_expr2.c" 01318 break; 01319 case 14: /* "TOK_PLUS" */ 01320 #line 169 "ast_expr2.y" 01321 { free_value((yyvaluep->val)); }; 01322 #line 1323 "ast_expr2.c" 01323 break; 01324 case 15: /* "TOK_MOD" */ 01325 #line 169 "ast_expr2.y" 01326 { free_value((yyvaluep->val)); }; 01327 #line 1328 "ast_expr2.c" 01328 break; 01329 case 16: /* "TOK_DIV" */ 01330 #line 169 "ast_expr2.y" 01331 { free_value((yyvaluep->val)); }; 01332 #line 1333 "ast_expr2.c" 01333 break; 01334 case 17: /* "TOK_MULT" */ 01335 #line 169 "ast_expr2.y" 01336 { free_value((yyvaluep->val)); }; 01337 #line 1338 "ast_expr2.c" 01338 break; 01339 case 18: /* "TOK_COMPL" */ 01340 #line 169 "ast_expr2.y" 01341 { free_value((yyvaluep->val)); }; 01342 #line 1343 "ast_expr2.c" 01343 break; 01344 case 19: /* "TOK_EQTILDE" */ 01345 #line 169 "ast_expr2.y" 01346 { free_value((yyvaluep->val)); }; 01347 #line 1348 "ast_expr2.c" 01348 break; 01349 case 20: /* "TOK_COLON" */ 01350 #line 169 "ast_expr2.y" 01351 { free_value((yyvaluep->val)); }; 01352 #line 1353 "ast_expr2.c" 01353 break; 01354 case 21: /* "TOK_LP" */ 01355 #line 169 "ast_expr2.y" 01356 { free_value((yyvaluep->val)); }; 01357 #line 1358 "ast_expr2.c" 01358 break; 01359 case 22: /* "TOK_RP" */ 01360 #line 169 "ast_expr2.y" 01361 { free_value((yyvaluep->val)); }; 01362 #line 1363 "ast_expr2.c" 01363 break; 01364 case 23: /* "TOKEN" */ 01365 #line 169 "ast_expr2.y" 01366 { free_value((yyvaluep->val)); }; 01367 #line 1368 "ast_expr2.c" 01368 break; 01369 case 26: /* "expr" */ 01370 #line 169 "ast_expr2.y" 01371 { free_value((yyvaluep->val)); }; 01372 #line 1373 "ast_expr2.c" 01373 break; 01374 01375 default: 01376 break; 01377 } 01378 }
int yyparse | ( | void * | YYPARSE_PARAM | ) |
Definition at line 1413 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, yylval, YYMAXDEPTH, yynerrs, YYNTOKENS, YYPACT_NINF, YYPOPSTACK, YYSIZE_T, YYSTACK_ALLOC, YYSTACK_ALLOC_MAXIMUM, YYSTACK_BYTES, YYSTACK_FREE, YYSTACK_RELOCATE, yysyntax_error(), YYTABLE_NINF, YYTERROR, YYTRANSLATE, and yyalloc::yyvs.
01427 { 01428 /* The look-ahead symbol. */ 01429 int yychar; 01430 01431 /* The semantic value of the look-ahead symbol. */ 01432 YYSTYPE yylval; 01433 01434 /* Number of syntax errors so far. */ 01435 int yynerrs; 01436 /* Location data for the look-ahead symbol. */ 01437 YYLTYPE yylloc; 01438 01439 int yystate; 01440 int yyn; 01441 int yyresult; 01442 /* Number of tokens to shift before error messages enabled. */ 01443 int yyerrstatus; 01444 /* Look-ahead token as an internal (translated) token number. */ 01445 int yytoken = 0; 01446 #if YYERROR_VERBOSE 01447 /* Buffer for error messages, and its allocated size. */ 01448 char yymsgbuf[128]; 01449 char *yymsg = yymsgbuf; 01450 YYSIZE_T yymsg_alloc = sizeof yymsgbuf; 01451 #endif 01452 01453 /* Three stacks and their tools: 01454 `yyss': related to states, 01455 `yyvs': related to semantic values, 01456 `yyls': related to locations. 01457 01458 Refer to the stacks thru separate pointers, to allow yyoverflow 01459 to reallocate them elsewhere. */ 01460 01461 /* The state stack. */ 01462 yytype_int16 yyssa[YYINITDEPTH]; 01463 yytype_int16 *yyss = yyssa; 01464 yytype_int16 *yyssp; 01465 01466 /* The semantic value stack. */ 01467 YYSTYPE yyvsa[YYINITDEPTH]; 01468 YYSTYPE *yyvs = yyvsa; 01469 YYSTYPE *yyvsp; 01470 01471 /* The location stack. */ 01472 YYLTYPE yylsa[YYINITDEPTH]; 01473 YYLTYPE *yyls = yylsa; 01474 YYLTYPE *yylsp; 01475 /* The locations where the error started and ended. */ 01476 YYLTYPE yyerror_range[2]; 01477 01478 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) 01479 01480 YYSIZE_T yystacksize = YYINITDEPTH; 01481 01482 /* The variables used to return semantic value and location from the 01483 action routines. */ 01484 YYSTYPE yyval; 01485 YYLTYPE yyloc; 01486 01487 /* The number of symbols on the RHS of the reduced rule. 01488 Keep to zero when no symbol should be popped. */ 01489 int yylen = 0; 01490 01491 YYDPRINTF ((stderr, "Starting parse\n")); 01492 01493 yystate = 0; 01494 yyerrstatus = 0; 01495 yynerrs = 0; 01496 yychar = YYEMPTY; /* Cause a token to be read. */ 01497 01498 /* Initialize stack pointers. 01499 Waste one element of value and location stack 01500 so that they stay on the same level as the state stack. 01501 The wasted elements are never initialized. */ 01502 01503 yyssp = yyss; 01504 yyvsp = yyvs; 01505 yylsp = yyls; 01506 #if YYLTYPE_IS_TRIVIAL 01507 /* Initialize the default location before parsing starts. */ 01508 yylloc.first_line = yylloc.last_line = 1; 01509 yylloc.first_column = yylloc.last_column = 0; 01510 #endif 01511 01512 goto yysetstate; 01513 01514 /*------------------------------------------------------------. 01515 | yynewstate -- Push a new state, which is found in yystate. | 01516 `------------------------------------------------------------*/ 01517 yynewstate: 01518 /* In all cases, when you get here, the value and location stacks 01519 have just been pushed. So pushing a state here evens the stacks. */ 01520 yyssp++; 01521 01522 yysetstate: 01523 *yyssp = yystate; 01524 01525 if (yyss + yystacksize - 1 <= yyssp) 01526 { 01527 /* Get the current used size of the three stacks, in elements. */ 01528 YYSIZE_T yysize = yyssp - yyss + 1; 01529 01530 #ifdef yyoverflow 01531 { 01532 /* Give user a chance to reallocate the stack. Use copies of 01533 these so that the &'s don't force the real ones into 01534 memory. */ 01535 YYSTYPE *yyvs1 = yyvs; 01536 yytype_int16 *yyss1 = yyss; 01537 YYLTYPE *yyls1 = yyls; 01538 01539 /* Each stack pointer address is followed by the size of the 01540 data in use in that stack, in bytes. This used to be a 01541 conditional around just the two extra args, but that might 01542 be undefined if yyoverflow is a macro. */ 01543 yyoverflow (YY_("memory exhausted"), 01544 &yyss1, yysize * sizeof (*yyssp), 01545 &yyvs1, yysize * sizeof (*yyvsp), 01546 &yyls1, yysize * sizeof (*yylsp), 01547 &yystacksize); 01548 yyls = yyls1; 01549 yyss = yyss1; 01550 yyvs = yyvs1; 01551 } 01552 #else /* no yyoverflow */ 01553 # ifndef YYSTACK_RELOCATE 01554 goto yyexhaustedlab; 01555 # else 01556 /* Extend the stack our own way. */ 01557 if (YYMAXDEPTH <= yystacksize) 01558 goto yyexhaustedlab; 01559 yystacksize *= 2; 01560 if (YYMAXDEPTH < yystacksize) 01561 yystacksize = YYMAXDEPTH; 01562 01563 { 01564 yytype_int16 *yyss1 = yyss; 01565 union yyalloc *yyptr = 01566 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 01567 if (! yyptr) 01568 goto yyexhaustedlab; 01569 YYSTACK_RELOCATE (yyss); 01570 YYSTACK_RELOCATE (yyvs); 01571 YYSTACK_RELOCATE (yyls); 01572 # undef YYSTACK_RELOCATE 01573 if (yyss1 != yyssa) 01574 YYSTACK_FREE (yyss1); 01575 } 01576 # endif 01577 #endif /* no yyoverflow */ 01578 01579 yyssp = yyss + yysize - 1; 01580 yyvsp = yyvs + yysize - 1; 01581 yylsp = yyls + yysize - 1; 01582 01583 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 01584 (unsigned long int) yystacksize)); 01585 01586 if (yyss + yystacksize - 1 <= yyssp) 01587 YYABORT; 01588 } 01589 01590 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 01591 01592 goto yybackup; 01593 01594 /*-----------. 01595 | yybackup. | 01596 `-----------*/ 01597 yybackup: 01598 01599 /* Do appropriate processing given the current state. Read a 01600 look-ahead token if we need one and don't already have one. */ 01601 01602 /* First try to decide what to do without reference to look-ahead token. */ 01603 yyn = yypact[yystate]; 01604 if (yyn == YYPACT_NINF) 01605 goto yydefault; 01606 01607 /* Not known => get a look-ahead token if don't already have one. */ 01608 01609 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ 01610 if (yychar == YYEMPTY) 01611 { 01612 YYDPRINTF ((stderr, "Reading a token: ")); 01613 yychar = YYLEX; 01614 } 01615 01616 if (yychar <= YYEOF) 01617 { 01618 yychar = yytoken = YYEOF; 01619 YYDPRINTF ((stderr, "Now at end of input.\n")); 01620 } 01621 else 01622 { 01623 yytoken = YYTRANSLATE (yychar); 01624 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 01625 } 01626 01627 /* If the proper action on seeing token YYTOKEN is to reduce or to 01628 detect an error, take that action. */ 01629 yyn += yytoken; 01630 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 01631 goto yydefault; 01632 yyn = yytable[yyn]; 01633 if (yyn <= 0) 01634 { 01635 if (yyn == 0 || yyn == YYTABLE_NINF) 01636 goto yyerrlab; 01637 yyn = -yyn; 01638 goto yyreduce; 01639 } 01640 01641 if (yyn == YYFINAL) 01642 YYACCEPT; 01643 01644 /* Count tokens shifted since error; after three, turn off error 01645 status. */ 01646 if (yyerrstatus) 01647 yyerrstatus--; 01648 01649 /* Shift the look-ahead token. */ 01650 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 01651 01652 /* Discard the shifted token unless it is eof. */ 01653 if (yychar != YYEOF) 01654 yychar = YYEMPTY; 01655 01656 yystate = yyn; 01657 *++yyvsp = yylval; 01658 *++yylsp = yylloc; 01659 goto yynewstate; 01660 01661 01662 /*-----------------------------------------------------------. 01663 | yydefault -- do the default action for the current state. | 01664 `-----------------------------------------------------------*/ 01665 yydefault: 01666 yyn = yydefact[yystate]; 01667 if (yyn == 0) 01668 goto yyerrlab; 01669 goto yyreduce; 01670 01671 01672 /*-----------------------------. 01673 | yyreduce -- Do a reduction. | 01674 `-----------------------------*/ 01675 yyreduce: 01676 /* yyn is the number of a rule to reduce with. */ 01677 yylen = yyr2[yyn]; 01678 01679 /* If YYLEN is nonzero, implement the default value of the action: 01680 `$$ = $1'. 01681 01682 Otherwise, the following line sets YYVAL to garbage. 01683 This behavior is undocumented and Bison 01684 users should not rely upon it. Assigning to YYVAL 01685 unconditionally makes the parser a bit smaller, and it avoids a 01686 GCC warning that YYVAL may be used uninitialized. */ 01687 yyval = yyvsp[1-yylen]; 01688 01689 /* Default location. */ 01690 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); 01691 YY_REDUCE_PRINT (yyn); 01692 switch (yyn) 01693 { 01694 case 2: 01695 #line 175 "ast_expr2.y" 01696 { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1); 01697 ((struct parse_io *)parseio)->val->type = (yyvsp[(1) - (1)].val)->type; 01698 if( (yyvsp[(1) - (1)].val)->type == AST_EXPR_integer ) 01699 ((struct parse_io *)parseio)->val->u.i = (yyvsp[(1) - (1)].val)->u.i; 01700 else 01701 ((struct parse_io *)parseio)->val->u.s = (yyvsp[(1) - (1)].val)->u.s; 01702 free((yyvsp[(1) - (1)].val)); 01703 ;} 01704 break; 01705 01706 case 3: 01707 #line 183 "ast_expr2.y" 01708 {/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1); 01709 ((struct parse_io *)parseio)->val->type = AST_EXPR_string; 01710 ((struct parse_io *)parseio)->val->u.s = strdup(""); 01711 ;} 01712 break; 01713 01714 case 4: 01715 #line 190 "ast_expr2.y" 01716 { (yyval.val)= (yyvsp[(1) - (1)].val);;} 01717 break; 01718 01719 case 5: 01720 #line 191 "ast_expr2.y" 01721 { (yyval.val) = (yyvsp[(2) - (3)].val); 01722 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01723 (yyloc).first_line=0; (yyloc).last_line=0; 01724 DESTROY((yyvsp[(1) - (3)].val)); DESTROY((yyvsp[(3) - (3)].val)); ;} 01725 break; 01726 01727 case 6: 01728 #line 195 "ast_expr2.y" 01729 { (yyval.val) = op_or ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01730 DESTROY((yyvsp[(2) - (3)].val)); 01731 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01732 (yyloc).first_line=0; (yyloc).last_line=0;;} 01733 break; 01734 01735 case 7: 01736 #line 199 "ast_expr2.y" 01737 { (yyval.val) = op_and ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01738 DESTROY((yyvsp[(2) - (3)].val)); 01739 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01740 (yyloc).first_line=0; (yyloc).last_line=0;;} 01741 break; 01742 01743 case 8: 01744 #line 203 "ast_expr2.y" 01745 { (yyval.val) = op_eq ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01746 DESTROY((yyvsp[(2) - (3)].val)); 01747 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01748 (yyloc).first_line=0; (yyloc).last_line=0;;} 01749 break; 01750 01751 case 9: 01752 #line 207 "ast_expr2.y" 01753 { (yyval.val) = op_gt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01754 DESTROY((yyvsp[(2) - (3)].val)); 01755 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01756 (yyloc).first_line=0; (yyloc).last_line=0;;} 01757 break; 01758 01759 case 10: 01760 #line 211 "ast_expr2.y" 01761 { (yyval.val) = op_lt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01762 DESTROY((yyvsp[(2) - (3)].val)); 01763 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01764 (yyloc).first_line=0; (yyloc).last_line=0;;} 01765 break; 01766 01767 case 11: 01768 #line 215 "ast_expr2.y" 01769 { (yyval.val) = op_ge ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01770 DESTROY((yyvsp[(2) - (3)].val)); 01771 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01772 (yyloc).first_line=0; (yyloc).last_line=0;;} 01773 break; 01774 01775 case 12: 01776 #line 219 "ast_expr2.y" 01777 { (yyval.val) = op_le ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01778 DESTROY((yyvsp[(2) - (3)].val)); 01779 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01780 (yyloc).first_line=0; (yyloc).last_line=0;;} 01781 break; 01782 01783 case 13: 01784 #line 223 "ast_expr2.y" 01785 { (yyval.val) = op_ne ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01786 DESTROY((yyvsp[(2) - (3)].val)); 01787 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01788 (yyloc).first_line=0; (yyloc).last_line=0;;} 01789 break; 01790 01791 case 14: 01792 #line 227 "ast_expr2.y" 01793 { (yyval.val) = op_plus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01794 DESTROY((yyvsp[(2) - (3)].val)); 01795 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01796 (yyloc).first_line=0; (yyloc).last_line=0;;} 01797 break; 01798 01799 case 15: 01800 #line 231 "ast_expr2.y" 01801 { (yyval.val) = op_minus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01802 DESTROY((yyvsp[(2) - (3)].val)); 01803 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01804 (yyloc).first_line=0; (yyloc).last_line=0;;} 01805 break; 01806 01807 case 16: 01808 #line 235 "ast_expr2.y" 01809 { (yyval.val) = op_negate ((yyvsp[(2) - (2)].val)); 01810 DESTROY((yyvsp[(1) - (2)].val)); 01811 (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column; 01812 (yyloc).first_line=0; (yyloc).last_line=0;;} 01813 break; 01814 01815 case 17: 01816 #line 239 "ast_expr2.y" 01817 { (yyval.val) = op_compl ((yyvsp[(2) - (2)].val)); 01818 DESTROY((yyvsp[(1) - (2)].val)); 01819 (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column; 01820 (yyloc).first_line=0; (yyloc).last_line=0;;} 01821 break; 01822 01823 case 18: 01824 #line 243 "ast_expr2.y" 01825 { (yyval.val) = op_times ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01826 DESTROY((yyvsp[(2) - (3)].val)); 01827 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01828 (yyloc).first_line=0; (yyloc).last_line=0;;} 01829 break; 01830 01831 case 19: 01832 #line 247 "ast_expr2.y" 01833 { (yyval.val) = op_div ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01834 DESTROY((yyvsp[(2) - (3)].val)); 01835 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01836 (yyloc).first_line=0; (yyloc).last_line=0;;} 01837 break; 01838 01839 case 20: 01840 #line 251 "ast_expr2.y" 01841 { (yyval.val) = op_rem ((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 21: 01848 #line 255 "ast_expr2.y" 01849 { (yyval.val) = op_colon ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01850 DESTROY((yyvsp[(2) - (3)].val)); 01851 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01852 (yyloc).first_line=0; (yyloc).last_line=0;;} 01853 break; 01854 01855 case 22: 01856 #line 259 "ast_expr2.y" 01857 { (yyval.val) = op_eqtilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01858 DESTROY((yyvsp[(2) - (3)].val)); 01859 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01860 (yyloc).first_line=0; (yyloc).last_line=0;;} 01861 break; 01862 01863 case 23: 01864 #line 263 "ast_expr2.y" 01865 { (yyval.val) = op_cond ((yyvsp[(1) - (5)].val), (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val)); 01866 DESTROY((yyvsp[(2) - (5)].val)); 01867 DESTROY((yyvsp[(4) - (5)].val)); 01868 (yyloc).first_column = (yylsp[(1) - (5)]).first_column; (yyloc).last_column = (yylsp[(3) - (5)]).last_column; 01869 (yyloc).first_line=0; (yyloc).last_line=0;;} 01870 break; 01871 01872 01873 /* Line 1267 of yacc.c. */ 01874 #line 1875 "ast_expr2.c" 01875 default: break; 01876 } 01877 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 01878 01879 YYPOPSTACK (yylen); 01880 yylen = 0; 01881 YY_STACK_PRINT (yyss, yyssp); 01882 01883 *++yyvsp = yyval; 01884 *++yylsp = yyloc; 01885 01886 /* Now `shift' the result of the reduction. Determine what state 01887 that goes to, based on the state we popped back to and the rule 01888 number reduced by. */ 01889 01890 yyn = yyr1[yyn]; 01891 01892 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 01893 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 01894 yystate = yytable[yystate]; 01895 else 01896 yystate = yydefgoto[yyn - YYNTOKENS]; 01897 01898 goto yynewstate; 01899 01900 01901 /*------------------------------------. 01902 | yyerrlab -- here on detecting error | 01903 `------------------------------------*/ 01904 yyerrlab: 01905 /* If not already recovering from an error, report this error. */ 01906 if (!yyerrstatus) 01907 { 01908 ++yynerrs; 01909 #if ! YYERROR_VERBOSE 01910 yyerror (YY_("syntax error")); 01911 #else 01912 { 01913 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); 01914 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) 01915 { 01916 YYSIZE_T yyalloc = 2 * yysize; 01917 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) 01918 yyalloc = YYSTACK_ALLOC_MAXIMUM; 01919 if (yymsg != yymsgbuf) 01920 YYSTACK_FREE (yymsg); 01921 yymsg = (char *) YYSTACK_ALLOC (yyalloc); 01922 if (yymsg) 01923 yymsg_alloc = yyalloc; 01924 else 01925 { 01926 yymsg = yymsgbuf; 01927 yymsg_alloc = sizeof yymsgbuf; 01928 } 01929 } 01930 01931 if (0 < yysize && yysize <= yymsg_alloc) 01932 { 01933 (void) yysyntax_error (yymsg, yystate, yychar); 01934 yyerror (yymsg); 01935 } 01936 else 01937 { 01938 yyerror (YY_("syntax error")); 01939 if (yysize != 0) 01940 goto yyexhaustedlab; 01941 } 01942 } 01943 #endif 01944 } 01945 01946 yyerror_range[0] = yylloc; 01947 01948 if (yyerrstatus == 3) 01949 { 01950 /* If just tried and failed to reuse look-ahead token after an 01951 error, discard it. */ 01952 01953 if (yychar <= YYEOF) 01954 { 01955 /* Return failure if at end of input. */ 01956 if (yychar == YYEOF) 01957 YYABORT; 01958 } 01959 else 01960 { 01961 yydestruct ("Error: discarding", 01962 yytoken, &yylval, &yylloc); 01963 yychar = YYEMPTY; 01964 } 01965 } 01966 01967 /* Else will try to reuse look-ahead token after shifting the error 01968 token. */ 01969 goto yyerrlab1; 01970 01971 01972 /*---------------------------------------------------. 01973 | yyerrorlab -- error raised explicitly by YYERROR. | 01974 `---------------------------------------------------*/ 01975 yyerrorlab: 01976 01977 /* Pacify compilers like GCC when the user code never invokes 01978 YYERROR and the label yyerrorlab therefore never appears in user 01979 code. */ 01980 if (/*CONSTCOND*/ 0) 01981 goto yyerrorlab; 01982 01983 yyerror_range[0] = yylsp[1-yylen]; 01984 /* Do not reclaim the symbols of the rule which action triggered 01985 this YYERROR. */ 01986 YYPOPSTACK (yylen); 01987 yylen = 0; 01988 YY_STACK_PRINT (yyss, yyssp); 01989 yystate = *yyssp; 01990 goto yyerrlab1; 01991 01992 01993 /*-------------------------------------------------------------. 01994 | yyerrlab1 -- common code for both syntax error and YYERROR. | 01995 `-------------------------------------------------------------*/ 01996 yyerrlab1: 01997 yyerrstatus = 3; /* Each real token shifted decrements this. */ 01998 01999 for (;;) 02000 { 02001 yyn = yypact[yystate]; 02002 if (yyn != YYPACT_NINF) 02003 { 02004 yyn += YYTERROR; 02005 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 02006 { 02007 yyn = yytable[yyn]; 02008 if (0 < yyn) 02009 break; 02010 } 02011 } 02012 02013 /* Pop the current state because it cannot handle the error token. */ 02014 if (yyssp == yyss) 02015 YYABORT; 02016 02017 yyerror_range[0] = *yylsp; 02018 yydestruct ("Error: popping", 02019 yystos[yystate], yyvsp, yylsp); 02020 YYPOPSTACK (1); 02021 yystate = *yyssp; 02022 YY_STACK_PRINT (yyss, yyssp); 02023 } 02024 02025 if (yyn == YYFINAL) 02026 YYACCEPT; 02027 02028 *++yyvsp = yylval; 02029 02030 yyerror_range[1] = yylloc; 02031 /* Using YYLLOC is tempting, but would change the location of 02032 the look-ahead. YYLOC is available though. */ 02033 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); 02034 *++yylsp = yyloc; 02035 02036 /* Shift the error token. */ 02037 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); 02038 02039 yystate = yyn; 02040 goto yynewstate; 02041 02042 02043 /*-------------------------------------. 02044 | yyacceptlab -- YYACCEPT comes here. | 02045 `-------------------------------------*/ 02046 yyacceptlab: 02047 yyresult = 0; 02048 goto yyreturn; 02049 02050 /*-----------------------------------. 02051 | yyabortlab -- YYABORT comes here. | 02052 `-----------------------------------*/ 02053 yyabortlab: 02054 yyresult = 1; 02055 goto yyreturn; 02056 02057 #ifndef yyoverflow 02058 /*-------------------------------------------------. 02059 | yyexhaustedlab -- memory exhaustion comes here. | 02060 `-------------------------------------------------*/ 02061 yyexhaustedlab: 02062 yyerror (YY_("memory exhausted")); 02063 yyresult = 2; 02064 /* Fall through. */ 02065 #endif 02066 02067 yyreturn: 02068 if (yychar != YYEOF && yychar != YYEMPTY) 02069 yydestruct ("Cleanup: discarding lookahead", 02070 yytoken, &yylval, &yylloc); 02071 /* Do not reclaim the symbols of the rule which action triggered 02072 this YYABORT or YYACCEPT. */ 02073 YYPOPSTACK (yylen); 02074 YY_STACK_PRINT (yyss, yyssp); 02075 while (yyssp != yyss) 02076 { 02077 yydestruct ("Cleanup: popping", 02078 yystos[*yyssp], yyvsp, yylsp); 02079 YYPOPSTACK (1); 02080 } 02081 #ifndef yyoverflow 02082 if (yyss != yyssa) 02083 YYSTACK_FREE (yyss); 02084 #endif 02085 #if YYERROR_VERBOSE 02086 if (yymsg != yymsgbuf) 02087 YYSTACK_FREE (yymsg); 02088 #endif 02089 /* Make sure YYID is used. */ 02090 return YYID (yyresult); 02091 }
int yyparse | ( | ) |
static char* yystpcpy | ( | char * | yydest, | |
const char * | yysrc | |||
) | [static] |
Definition at line 1063 of file ast_expr2.c.
Referenced by yysyntax_error(), and yytnamerr().
01067 { 01068 char *yyd = yydest; 01069 const char *yys = yysrc; 01070 01071 while ((*yyd++ = *yys++) != '\0') 01072 continue; 01073 01074 return yyd - 1; 01075 }
static YYSIZE_T yystrlen | ( | char * | yystr | ) | const [static] |
Definition at line 1039 of file ast_expr2.c.
References YYSIZE_T.
Referenced by yysyntax_error(), and yytnamerr().
01042 { 01043 YYSIZE_T yylen; 01044 for (yylen = 0; yystr[yylen]; yylen++) 01045 continue; 01046 return yylen; 01047 }
static YYSIZE_T yysyntax_error | ( | char * | yyresult, | |
int | yystate, | |||
int | yychar | |||
) | [static] |
Definition at line 1135 of file ast_expr2.c.
References YY_, YYLAST, YYNTOKENS, YYPACT_NINF, YYSIZE_MAXIMUM, YYSIZE_T, yystpcpy(), yystrlen(), YYTERROR, yytnamerr(), and YYTRANSLATE.
Referenced by yyparse().
01136 { 01137 int yyn = yypact[yystate]; 01138 01139 if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) 01140 return 0; 01141 else 01142 { 01143 int yytype = YYTRANSLATE (yychar); 01144 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); 01145 YYSIZE_T yysize = yysize0; 01146 YYSIZE_T yysize1; 01147 int yysize_overflow = 0; 01148 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; 01149 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 01150 int yyx; 01151 01152 # if 0 01153 /* This is so xgettext sees the translatable formats that are 01154 constructed on the fly. */ 01155 YY_("syntax error, unexpected %s"); 01156 YY_("syntax error, unexpected %s, expecting %s"); 01157 YY_("syntax error, unexpected %s, expecting %s or %s"); 01158 YY_("syntax error, unexpected %s, expecting %s or %s or %s"); 01159 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); 01160 # endif 01161 char *yyfmt; 01162 char const *yyf; 01163 static char const yyunexpected[] = "syntax error, unexpected %s"; 01164 static char const yyexpecting[] = ", expecting %s"; 01165 static char const yyor[] = " or %s"; 01166 char yyformat[sizeof yyunexpected 01167 + sizeof yyexpecting - 1 01168 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) 01169 * (sizeof yyor - 1))]; 01170 char const *yyprefix = yyexpecting; 01171 01172 /* Start YYX at -YYN if negative to avoid negative indexes in 01173 YYCHECK. */ 01174 int yyxbegin = yyn < 0 ? -yyn : 0; 01175 01176 /* Stay within bounds of both yycheck and yytname. */ 01177 int yychecklim = YYLAST - yyn + 1; 01178 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; 01179 int yycount = 1; 01180 01181 yyarg[0] = yytname[yytype]; 01182 yyfmt = yystpcpy (yyformat, yyunexpected); 01183 01184 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 01185 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 01186 { 01187 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) 01188 { 01189 yycount = 1; 01190 yysize = yysize0; 01191 yyformat[sizeof yyunexpected - 1] = '\0'; 01192 break; 01193 } 01194 yyarg[yycount++] = yytname[yyx]; 01195 yysize1 = yysize + yytnamerr (0, yytname[yyx]); 01196 yysize_overflow |= (yysize1 < yysize); 01197 yysize = yysize1; 01198 yyfmt = yystpcpy (yyfmt, yyprefix); 01199 yyprefix = yyor; 01200 } 01201 01202 yyf = YY_(yyformat); 01203 yysize1 = yysize + yystrlen (yyf); 01204 yysize_overflow |= (yysize1 < yysize); 01205 yysize = yysize1; 01206 01207 if (yysize_overflow) 01208 return YYSIZE_MAXIMUM; 01209 01210 if (yyresult) 01211 { 01212 /* Avoid sprintf, as that infringes on the user's name space. 01213 Don't have undefined behavior even if the translation 01214 produced a string with the wrong number of "%s"s. */ 01215 char *yyp = yyresult; 01216 int yyi = 0; 01217 while ((*yyp = *yyf) != '\0') 01218 { 01219 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) 01220 { 01221 yyp += yytnamerr (yyp, yyarg[yyi++]); 01222 yyf += 2; 01223 } 01224 else 01225 { 01226 yyp++; 01227 yyf++; 01228 } 01229 } 01230 } 01231 return yysize; 01232 } 01233 }
static YYSIZE_T yytnamerr | ( | char * | yyres, | |
const char * | yystr | |||
) | [static] |
Definition at line 1088 of file ast_expr2.c.
References YYSIZE_T, yystpcpy(), and yystrlen().
Referenced by yysyntax_error().
01089 { 01090 if (*yystr == '"') 01091 { 01092 YYSIZE_T yyn = 0; 01093 char const *yyp = yystr; 01094 01095 for (;;) 01096 switch (*++yyp) 01097 { 01098 case '\'': 01099 case ',': 01100 goto do_not_strip_quotes; 01101 01102 case '\\': 01103 if (*++yyp != '\\') 01104 goto do_not_strip_quotes; 01105 /* Fall through. */ 01106 default: 01107 if (yyres) 01108 yyres[yyn] = *yyp; 01109 yyn++; 01110 break; 01111 01112 case '"': 01113 if (yyres) 01114 yyres[yyn] = '\0'; 01115 return yyn; 01116 } 01117 do_not_strip_quotes: ; 01118 } 01119 01120 if (! yyres) 01121 return yystrlen (yystr); 01122 01123 return yystpcpy (yyres, yystr) - yyres; 01124 }
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 721 of file ast_expr2.c.
const yytype_uint8 yydefact[] [static] |
Definition at line 664 of file ast_expr2.c.
const yytype_int8 yydefgoto[] [static] |
const yytype_int8 yypact[] [static] |
Definition at line 682 of file ast_expr2.c.
const yytype_int8 yypgoto[] [static] |
const yytype_uint8 yyr1[] [static] |
Definition at line 646 of file ast_expr2.c.
const yytype_uint8 yyr2[] [static] |
Definition at line 654 of file ast_expr2.c.
const yytype_uint8 yystos[] [static] |
Definition at line 742 of file ast_expr2.c.
const yytype_uint8 yytable[] [static] |
Definition at line 702 of file ast_expr2.c.
const char* const yytname[] [static] |
Definition at line 624 of file ast_expr2.c.
const yytype_uint8 yytranslate[] [static] |
Definition at line 556 of file ast_expr2.c.