#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.1a" |
#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, 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, 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 2292 of file ast_expr2.c.
#define ast_yyerror | ( | x | ) | ast_yyerror(x,&yyloc,parseio) |
Definition at line 2292 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 168 of file ast_expr2.c.
#define QUAD_MIN (-0x7fffffffffffffffLL-1) |
#define TOK_AND 261 |
Definition at line 94 of file ast_expr2.c.
#define TOK_COLON 275 |
Definition at line 108 of file ast_expr2.c.
#define TOK_COLONCOLON 258 |
Definition at line 91 of file ast_expr2.c.
#define TOK_COMPL 273 |
Definition at line 106 of file ast_expr2.c.
#define TOK_COND 259 |
Definition at line 92 of file ast_expr2.c.
#define TOK_DIV 271 |
Definition at line 104 of file ast_expr2.c.
#define TOK_EQ 267 |
Definition at line 100 of file ast_expr2.c.
#define TOK_EQTILDE 274 |
Definition at line 107 of file ast_expr2.c.
#define TOK_GE 264 |
Definition at line 97 of file ast_expr2.c.
#define TOK_GT 266 |
Definition at line 99 of file ast_expr2.c.
#define TOK_LE 263 |
Definition at line 96 of file ast_expr2.c.
#define TOK_LP 276 |
Definition at line 109 of file ast_expr2.c.
#define TOK_LT 265 |
Definition at line 98 of file ast_expr2.c.
#define TOK_MINUS 268 |
Definition at line 101 of file ast_expr2.c.
#define TOK_MOD 270 |
Definition at line 103 of file ast_expr2.c.
#define TOK_MULT 272 |
Definition at line 105 of file ast_expr2.c.
#define TOK_NE 262 |
Definition at line 95 of file ast_expr2.c.
#define TOK_OR 260 |
Definition at line 93 of file ast_expr2.c.
#define TOK_PLUS 269 |
Definition at line 102 of file ast_expr2.c.
#define TOK_RP 277 |
Definition at line 110 of file ast_expr2.c.
#define TOKEN 278 |
Definition at line 111 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 811 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 757 of file ast_expr2.c.
#define YYBISON 1 |
Definition at line 37 of file ast_expr2.c.
#define YYBISON_VERSION "2.1a" |
Definition at line 40 of file ast_expr2.c.
#define yychar ast_yychar |
#define yyclearin (yychar = YYEMPTY) |
Definition at line 740 of file ast_expr2.c.
#define YYCOPY | ( | To, | |||
From, | |||||
Count | ) |
Definition at line 493 of file ast_expr2.c.
#define YYDEBUG 0 |
Definition at line 259 of file ast_expr2.c.
#define yydebug ast_yydebug |
Definition at line 57 of file ast_expr2.c.
#define YYDPRINTF | ( | Args | ) |
#define YYEMPTY (-2) |
#define YYEOF 0 |
#define YYERRCODE 256 |
Definition at line 776 of file ast_expr2.c.
#define yyerrok (yyerrstatus = 0) |
Definition at line 739 of file ast_expr2.c.
#define YYERROR goto yyerrorlab |
Definition at line 746 of file ast_expr2.c.
#define yyerror ast_yyerror |
#define YYERROR_VERBOSE 1 |
Definition at line 265 of file ast_expr2.c.
#define YYERROR_VERBOSE 1 |
Definition at line 265 of file ast_expr2.c.
#define YYFAIL goto yyerrlab |
Definition at line 753 of file ast_expr2.c.
#define YYFINAL 10 |
#define YYFREE free |
Definition at line 451 of file ast_expr2.c.
#define YYID | ( | n | ) | (n) |
Definition at line 380 of file ast_expr2.c.
#define YYINITDEPTH 200 |
#define YYLAST 140 |
#define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) |
#define yylex ast_yylex |
Definition at line 53 of file ast_expr2.c.
#define YYLEX_PARAM ((struct parse_io *)parseio)->scanner |
Definition at line 172 of file ast_expr2.c.
#define yylloc ast_yylloc |
Definition at line 59 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 49 of file ast_expr2.c.
Definition at line 242 of file ast_expr2.c.
#define YYLTYPE_IS_TRIVIAL 1 |
Definition at line 243 of file ast_expr2.c.
#define yylval ast_yylval |
Definition at line 55 of file ast_expr2.c.
Referenced by ast_yyget_lval(), ast_yyset_lval(), and yyparse().
#define YYMALLOC malloc |
Definition at line 444 of file ast_expr2.c.
#define YYMAXDEPTH 10000 |
#define YYMAXUTOK 278 |
Definition at line 538 of file ast_expr2.c.
#define yynerrs ast_yynerrs |
#define YYNNTS 3 |
Definition at line 530 of file ast_expr2.c.
#define YYNRULES 23 |
Definition at line 532 of file ast_expr2.c.
#define YYNSTATES 46 |
Definition at line 534 of file ast_expr2.c.
#define YYNTOKENS 24 |
#define YYPACT_NINF -13 |
#define yyparse ast_yyparse |
Definition at line 52 of file ast_expr2.c.
#define YYPARSE_PARAM parseio |
Definition at line 171 of file ast_expr2.c.
#define YYPOPSTACK | ( | N | ) | (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) |
Referenced by yyparse().
#define YYPURE 1 |
Definition at line 46 of file ast_expr2.c.
#define YYRECOVERING | ( | ) | (!!yyerrstatus) |
Definition at line 755 of file ast_expr2.c.
#define YYRHSLOC | ( | Rhs, | |||
K | ) | ((Rhs)[K]) |
Definition at line 783 of file ast_expr2.c.
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
#define YYSIZE_T unsigned int |
Definition at line 353 of file ast_expr2.c.
Referenced by yyparse(), yystrlen(), and yysyntax_error().
#define YYSKELETON_NAME "yacc.c" |
Definition at line 43 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 482 of file ast_expr2.c.
Referenced by yyparse().
#define YYSTACK_FREE YYFREE |
#define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
Definition at line 478 of file ast_expr2.c.
#define YYSTACK_RELOCATE | ( | Stack | ) |
#define yystype YYSTYPE |
Definition at line 284 of file ast_expr2.c.
#define YYSTYPE_IS_DECLARED 1 |
Definition at line 285 of file ast_expr2.c.
#define YYSTYPE_IS_TRIVIAL 1 |
Definition at line 286 of file ast_expr2.c.
#define YYTABLE_NINF -1 |
#define YYTERROR 1 |
#define YYTOKEN_TABLE 0 |
Definition at line 272 of file ast_expr2.c.
#define YYTRANSLATE | ( | YYX | ) | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
#define YYUNDEFTOK 2 |
Definition at line 537 of file ast_expr2.c.
#define YYUSE | ( | e | ) | ((void) (e)) |
typedef void* yyscan_t |
Definition at line 193 of file ast_expr2.c.
typedef short int yytype_int16 |
Definition at line 340 of file ast_expr2.c.
typedef short int yytype_int8 |
Definition at line 328 of file ast_expr2.c.
typedef unsigned short int yytype_uint16 |
Definition at line 334 of file ast_expr2.c.
typedef unsigned char yytype_uint8 |
Definition at line 319 of file ast_expr2.c.
enum valtype |
AST_EXPR_integer | |
AST_EXPR_numeric_string | |
AST_EXPR_string | |
AST_EXPR_integer | |
AST_EXPR_numeric_string | |
AST_EXPR_string |
Definition at line 177 of file ast_expr2.c.
00177 { 00178 AST_EXPR_integer, AST_EXPR_numeric_string, AST_EXPR_string 00179 } ;
enum yytokentype |
Definition at line 66 of file ast_expr2.c.
00066 { 00067 TOK_COLONCOLON = 258, 00068 TOK_COND = 259, 00069 TOK_OR = 260, 00070 TOK_AND = 261, 00071 TOK_NE = 262, 00072 TOK_LE = 263, 00073 TOK_GE = 264, 00074 TOK_LT = 265, 00075 TOK_GT = 266, 00076 TOK_EQ = 267, 00077 TOK_MINUS = 268, 00078 TOK_PLUS = 269, 00079 TOK_MOD = 270, 00080 TOK_DIV = 271, 00081 TOK_MULT = 272, 00082 TOK_COMPL = 273, 00083 TOK_EQTILDE = 274, 00084 TOK_COLON = 275, 00085 TOK_LP = 276, 00086 TOK_RP = 277, 00087 TOKEN = 278 00088 };
static struct val* make_str __P | ( | (const char *) | ) | [static, read] |
static struct val* make_integer __P | ( | (quad_t) | ) | [static, read] |
static void to_string __P | ( | (struct val *) | ) | [static, read] |
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 2687 of file ast_expr2.c.
References QUAD_MIN.
Referenced by op_div().
02688 { 02689 /* div by zero has been taken care of before */ 02690 /* only QUAD_MIN / -1 causes overflow */ 02691 if (a == QUAD_MIN && b == -1) 02692 return 1; 02693 /* everything else is OK */ 02694 return 0; 02695 }
static int chk_minus | ( | quad_t | a, | |
quad_t | b, | |||
quad_t | r | |||
) | [static] |
Definition at line 2535 of file ast_expr2.c.
References chk_plus(), and QUAD_MIN.
Referenced by op_minus(), and op_negate().
02536 { 02537 /* special case subtraction of QUAD_MIN */ 02538 if (b == QUAD_MIN) { 02539 if (a >= 0) 02540 return 1; 02541 else 02542 return 0; 02543 } 02544 /* this is allowed for b != QUAD_MIN */ 02545 return chk_plus (a, -b, r); 02546 }
static int chk_plus | ( | quad_t | a, | |
quad_t | b, | |||
quad_t | r | |||
) | [static] |
Definition at line 2492 of file ast_expr2.c.
Referenced by chk_minus(), and op_plus().
02493 { 02494 /* sum of two positive numbers must be positive */ 02495 if (a > 0 && b > 0 && r <= 0) 02496 return 1; 02497 /* sum of two negative numbers must be negative */ 02498 if (a < 0 && b < 0 && r >= 0) 02499 return 1; 02500 /* all other cases are OK */ 02501 return 0; 02502 }
static int chk_times | ( | quad_t | a, | |
quad_t | b, | |||
quad_t | r | |||
) | [static] |
Definition at line 2653 of file ast_expr2.c.
Referenced by op_times().
02654 { 02655 /* special case: first operand is 0, no overflow possible */ 02656 if (a == 0) 02657 return 0; 02658 /* cerify that result of division matches second operand */ 02659 if (r / a != b) 02660 return 1; 02661 return 0; 02662 }
static void free_value | ( | struct val * | vp | ) | [static] |
Definition at line 2132 of file ast_expr2.c.
References AST_EXPR_numeric_string, AST_EXPR_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().
02133 { 02134 if (vp==NULL) { 02135 return; 02136 } 02137 if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string) 02138 free (vp->u.s); 02139 free(vp); 02140 }
static int is_zero_or_null | ( | struct val * | vp | ) | [static] |
Definition at line 2226 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().
02227 { 02228 if (vp->type == AST_EXPR_integer) { 02229 return (vp->u.i == 0); 02230 } else { 02231 return (*vp->u.s == 0 || (to_integer (vp) && vp->u.i == 0)); 02232 } 02233 /* NOTREACHED */ 02234 }
static int isstring | ( | struct val * | vp | ) | [static] |
Definition at line 2218 of file ast_expr2.c.
References AST_EXPR_string, and val::type.
Referenced by op_cond(), op_eq(), op_ge(), op_gt(), op_le(), op_lt(), and op_ne().
02219 { 02220 /* only TRUE if this string is not a valid integer */ 02221 return (vp->type == AST_EXPR_string); 02222 }
static struct val* make_integer | ( | quad_t | i | ) | [static, read] |
Definition at line 2086 of file ast_expr2.c.
References AST_EXPR_integer, ast_log(), val::i, LOG_WARNING, malloc, val::type, and val::u.
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().
02087 { 02088 struct val *vp; 02089 02090 vp = (struct val *) malloc (sizeof (*vp)); 02091 if (vp == NULL) { 02092 ast_log(LOG_WARNING, "malloc() failed\n"); 02093 return(NULL); 02094 } 02095 02096 vp->type = AST_EXPR_integer; 02097 vp->u.i = i; 02098 return vp; 02099 }
static struct val* make_str | ( | const char * | s | ) | [static, read] |
Definition at line 2102 of file ast_expr2.c.
References AST_EXPR_numeric_string, AST_EXPR_string, ast_log(), LOG_WARNING, malloc, val::s, strdup, val::type, and val::u.
Referenced by op_colon(), and op_eqtilde().
02103 { 02104 struct val *vp; 02105 size_t i; 02106 int isint; 02107 02108 vp = (struct val *) malloc (sizeof (*vp)); 02109 if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) { 02110 ast_log(LOG_WARNING,"malloc() failed\n"); 02111 return(NULL); 02112 } 02113 02114 for(i = 1, isint = isdigit(s[0]) || s[0] == '-'; 02115 isint && i < strlen(s); 02116 i++) 02117 { 02118 if(!isdigit(s[i])) 02119 isint = 0; 02120 } 02121 02122 if (isint) 02123 vp->type = AST_EXPR_numeric_string; 02124 else 02125 vp->type = AST_EXPR_string; 02126 02127 return vp; 02128 }
Definition at line 2313 of file ast_expr2.c.
References free_value(), is_zero_or_null(), and make_integer().
Referenced by yyparse().
02314 { 02315 if (is_zero_or_null (a) || is_zero_or_null (b)) { 02316 free_value (a); 02317 free_value (b); 02318 return (make_integer ((quad_t)0)); 02319 } else { 02320 free_value (b); 02321 return (a); 02322 } 02323 }
Definition at line 2760 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().
02761 { 02762 regex_t rp; 02763 regmatch_t rm[2]; 02764 char errbuf[256]; 02765 int eval; 02766 struct val *v; 02767 02768 /* coerce to both arguments to strings */ 02769 to_string(a); 02770 to_string(b); 02771 /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */ 02772 strip_quotes(a); 02773 strip_quotes(b); 02774 /* compile regular expression */ 02775 if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) { 02776 regerror (eval, &rp, errbuf, sizeof(errbuf)); 02777 ast_log(LOG_WARNING,"regcomp() error : %s",errbuf); 02778 free_value(a); 02779 free_value(b); 02780 return make_str(""); 02781 } 02782 02783 /* compare string against pattern */ 02784 /* remember that patterns are anchored to the beginning of the line */ 02785 if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 && rm[0].rm_so == 0) { 02786 if (rm[1].rm_so >= 0) { 02787 *(a->u.s + rm[1].rm_eo) = '\0'; 02788 v = make_str (a->u.s + rm[1].rm_so); 02789 02790 } else { 02791 v = make_integer ((quad_t)(rm[0].rm_eo - rm[0].rm_so)); 02792 } 02793 } else { 02794 if (rp.re_nsub == 0) { 02795 v = make_integer ((quad_t)0); 02796 } else { 02797 v = make_str (""); 02798 } 02799 } 02800 02801 /* free arguments and pattern buffer */ 02802 free_value (a); 02803 free_value (b); 02804 regfree (&rp); 02805 02806 return v; 02807 }
Definition at line 2603 of file ast_expr2.c.
References AST_EXPR_integer, AST_EXPR_numeric_string, AST_EXPR_string, free_value(), val::i, make_integer(), val::s, val::type, and val::u.
Referenced by yyparse().
02604 { 02605 int v1 = 1; 02606 struct val *r; 02607 02608 if( !a ) 02609 { 02610 v1 = 0; 02611 } 02612 else 02613 { 02614 switch( a->type ) 02615 { 02616 case AST_EXPR_integer: 02617 if( a->u.i == 0 ) 02618 v1 = 0; 02619 break; 02620 02621 case AST_EXPR_string: 02622 if( a->u.s == 0 ) 02623 v1 = 0; 02624 else 02625 { 02626 if( a->u.s[0] == 0 ) 02627 v1 = 0; 02628 else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' ) 02629 v1 = 0; 02630 } 02631 break; 02632 02633 case AST_EXPR_numeric_string: 02634 if( a->u.s == 0 ) 02635 v1 = 0; 02636 else 02637 { 02638 if( a->u.s[0] == 0 ) 02639 v1 = 0; 02640 else if (strlen(a->u.s) == 1 && a->u.s[0] == '0' ) 02641 v1 = 0; 02642 } 02643 break; 02644 } 02645 } 02646 02647 r = make_integer (!v1); 02648 free_value (a); 02649 return r; 02650 }
Definition at line 2433 of file ast_expr2.c.
References free_value(), val::i, isstring(), val::s, to_integer(), and val::u.
Referenced by yyparse().
02434 { 02435 struct val *r; 02436 02437 if( isstring(a) ) 02438 { 02439 if( strlen(a->u.s) && strcmp(a->u.s, "\"\"") != 0 && strcmp(a->u.s,"0") != 0 ) 02440 { 02441 free_value(a); 02442 free_value(c); 02443 r = b; 02444 } 02445 else 02446 { 02447 free_value(a); 02448 free_value(b); 02449 r = c; 02450 } 02451 } 02452 else 02453 { 02454 (void)to_integer(a); 02455 if( a->u.i ) 02456 { 02457 free_value(a); 02458 free_value(c); 02459 r = b; 02460 } 02461 else 02462 { 02463 free_value(a); 02464 free_value(b); 02465 r = c; 02466 } 02467 } 02468 return r; 02469 }
Definition at line 2698 of file ast_expr2.c.
References ast_log(), chk_div(), free_value(), val::i, LOG_WARNING, make_integer(), to_integer(), and val::u.
Referenced by yyparse().
02699 { 02700 struct val *r; 02701 02702 if (!to_integer (a)) { 02703 free_value(a); 02704 free_value(b); 02705 if( !extra_error_message_supplied ) 02706 ast_log(LOG_WARNING, "non-numeric argument\n"); 02707 return make_integer(0); 02708 } else if (!to_integer (b)) { 02709 free_value(a); 02710 free_value(b); 02711 if( !extra_error_message_supplied ) 02712 ast_log(LOG_WARNING, "non-numeric argument\n"); 02713 return make_integer(INT_MAX); 02714 } 02715 02716 if (b->u.i == 0) { 02717 ast_log(LOG_WARNING, "division by zero\n"); 02718 free_value(a); 02719 free_value(b); 02720 return make_integer(INT_MAX); 02721 } 02722 02723 r = make_integer (/*(quad_t)*/(a->u.i / b->u.i)); 02724 if (chk_div (a->u.i, b->u.i)) { 02725 ast_log(LOG_WARNING, "overflow\n"); 02726 } 02727 free_value (a); 02728 free_value (b); 02729 return r; 02730 }
Definition at line 2326 of file ast_expr2.c.
References ast_log(), free_value(), val::i, isstring(), LOG_WARNING, make_integer(), val::s, to_integer(), to_string(), and val::u.
Referenced by yyparse().
02327 { 02328 struct val *r; 02329 02330 if (isstring (a) || isstring (b)) { 02331 to_string (a); 02332 to_string (b); 02333 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) == 0)); 02334 } else { 02335 #ifdef DEBUG_FOR_CONVERSIONS 02336 char buffer[2000]; 02337 sprintf(buffer,"Converting '%s' and '%s' ", a->u.s, b->u.s); 02338 #endif 02339 (void)to_integer(a); 02340 (void)to_integer(b); 02341 #ifdef DEBUG_FOR_CONVERSIONS 02342 ast_log(LOG_WARNING,"%s to '%lld' and '%lld'\n", buffer, a->u.i, b->u.i); 02343 #endif 02344 r = make_integer ((quad_t)(a->u.i == b->u.i)); 02345 } 02346 02347 free_value (a); 02348 free_value (b); 02349 return r; 02350 }
Definition at line 2811 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().
02812 { 02813 regex_t rp; 02814 regmatch_t rm[2]; 02815 char errbuf[256]; 02816 int eval; 02817 struct val *v; 02818 02819 /* coerce to both arguments to strings */ 02820 to_string(a); 02821 to_string(b); 02822 /* strip double quotes from both -- they'll screw up the pattern, and the search string starting at ^ */ 02823 strip_quotes(a); 02824 strip_quotes(b); 02825 /* compile regular expression */ 02826 if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) { 02827 regerror (eval, &rp, errbuf, sizeof(errbuf)); 02828 ast_log(LOG_WARNING,"regcomp() error : %s",errbuf); 02829 free_value(a); 02830 free_value(b); 02831 return make_str(""); 02832 } 02833 02834 /* compare string against pattern */ 02835 /* remember that patterns are anchored to the beginning of the line */ 02836 if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 ) { 02837 if (rm[1].rm_so >= 0) { 02838 *(a->u.s + rm[1].rm_eo) = '\0'; 02839 v = make_str (a->u.s + rm[1].rm_so); 02840 02841 } else { 02842 v = make_integer ((quad_t)(rm[0].rm_eo - rm[0].rm_so)); 02843 } 02844 } else { 02845 if (rp.re_nsub == 0) { 02846 v = make_integer ((quad_t)0); 02847 } else { 02848 v = make_str (""); 02849 } 02850 } 02851 02852 /* free arguments and pattern buffer */ 02853 free_value (a); 02854 free_value (b); 02855 regfree (&rp); 02856 02857 return v; 02858 }
Definition at line 2393 of file ast_expr2.c.
References free_value(), val::i, isstring(), make_integer(), val::s, to_integer(), to_string(), and val::u.
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 2353 of file ast_expr2.c.
References free_value(), val::i, isstring(), make_integer(), val::s, to_integer(), to_string(), and val::u.
Referenced by yyparse().
02354 { 02355 struct val *r; 02356 02357 if (isstring (a) || isstring (b)) { 02358 to_string (a); 02359 to_string (b); 02360 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) > 0)); 02361 } else { 02362 (void)to_integer(a); 02363 (void)to_integer(b); 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 2413 of file ast_expr2.c.
References free_value(), val::i, isstring(), make_integer(), val::s, to_integer(), to_string(), and val::u.
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(), val::i, isstring(), make_integer(), val::s, to_integer(), to_string(), and val::u.
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 2549 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().
02550 { 02551 struct val *r; 02552 02553 if (!to_integer (a)) { 02554 if( !extra_error_message_supplied ) 02555 ast_log(LOG_WARNING, "non-numeric argument\n"); 02556 if (!to_integer (b)) { 02557 free_value(a); 02558 free_value(b); 02559 return make_integer(0); 02560 } else { 02561 r = make_integer(0 - b->u.i); 02562 free_value(a); 02563 free_value(b); 02564 return (r); 02565 } 02566 } else if (!to_integer(b)) { 02567 if( !extra_error_message_supplied ) 02568 ast_log(LOG_WARNING, "non-numeric argument\n"); 02569 free_value(b); 02570 return (a); 02571 } 02572 02573 r = make_integer (/*(quad_t)*/(a->u.i - b->u.i)); 02574 if (chk_minus (a->u.i, b->u.i, r->u.i)) { 02575 ast_log(LOG_WARNING, "overflow\n"); 02576 } 02577 free_value (a); 02578 free_value (b); 02579 return r; 02580 }
Definition at line 2472 of file ast_expr2.c.
References free_value(), val::i, isstring(), make_integer(), val::s, to_integer(), to_string(), and val::u.
Referenced by yyparse().
02473 { 02474 struct val *r; 02475 02476 if (isstring (a) || isstring (b)) { 02477 to_string (a); 02478 to_string (b); 02479 r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) != 0)); 02480 } else { 02481 (void)to_integer(a); 02482 (void)to_integer(b); 02483 r = make_integer ((quad_t)(a->u.i != b->u.i)); 02484 } 02485 02486 free_value (a); 02487 free_value (b); 02488 return r; 02489 }
Definition at line 2583 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().
02584 { 02585 struct val *r; 02586 02587 if (!to_integer (a) ) { 02588 free_value(a); 02589 if( !extra_error_message_supplied ) 02590 ast_log(LOG_WARNING, "non-numeric argument\n"); 02591 return make_integer(0); 02592 } 02593 02594 r = make_integer (/*(quad_t)*/(- a->u.i)); 02595 if (chk_minus (0, a->u.i, r->u.i)) { 02596 ast_log(LOG_WARNING, "overflow\n"); 02597 } 02598 free_value (a); 02599 return r; 02600 }
Definition at line 2301 of file ast_expr2.c.
References free_value(), and is_zero_or_null().
Referenced by yyparse().
02302 { 02303 if (is_zero_or_null (a)) { 02304 free_value (a); 02305 return (b); 02306 } else { 02307 free_value (b); 02308 return (a); 02309 } 02310 }
Definition at line 2505 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().
02506 { 02507 struct val *r; 02508 02509 if (!to_integer (a)) { 02510 if( !extra_error_message_supplied ) 02511 ast_log(LOG_WARNING,"non-numeric argument\n"); 02512 if (!to_integer (b)) { 02513 free_value(a); 02514 free_value(b); 02515 return make_integer(0); 02516 } else { 02517 free_value(a); 02518 return (b); 02519 } 02520 } else if (!to_integer(b)) { 02521 free_value(b); 02522 return (a); 02523 } 02524 02525 r = make_integer (/*(quad_t)*/(a->u.i + b->u.i)); 02526 if (chk_plus (a->u.i, b->u.i, r->u.i)) { 02527 ast_log(LOG_WARNING,"overflow\n"); 02528 } 02529 free_value (a); 02530 free_value (b); 02531 return r; 02532 }
Definition at line 2733 of file ast_expr2.c.
References ast_log(), free_value(), val::i, LOG_WARNING, make_integer(), to_integer(), and val::u.
Referenced by yyparse().
02734 { 02735 struct val *r; 02736 02737 if (!to_integer (a) || !to_integer (b)) { 02738 if( !extra_error_message_supplied ) 02739 ast_log(LOG_WARNING, "non-numeric argument\n"); 02740 free_value(a); 02741 free_value(b); 02742 return make_integer(0); 02743 } 02744 02745 if (b->u.i == 0) { 02746 ast_log(LOG_WARNING, "div by zero\n"); 02747 free_value(a); 02748 return(b); 02749 } 02750 02751 r = make_integer (/*(quad_t)*/(a->u.i % b->u.i)); 02752 /* chk_rem necessary ??? */ 02753 free_value (a); 02754 free_value (b); 02755 return r; 02756 }
Definition at line 2665 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().
02666 { 02667 struct val *r; 02668 02669 if (!to_integer (a) || !to_integer (b)) { 02670 free_value(a); 02671 free_value(b); 02672 if( !extra_error_message_supplied ) 02673 ast_log(LOG_WARNING, "non-numeric argument\n"); 02674 return(make_integer(0)); 02675 } 02676 02677 r = make_integer (/*(quad_t)*/(a->u.i * b->u.i)); 02678 if (chk_times (a->u.i, b->u.i, r->u.i)) { 02679 ast_log(LOG_WARNING, "overflow\n"); 02680 } 02681 free_value (a); 02682 free_value (b); 02683 return (r); 02684 }
static void strip_quotes | ( | struct val * | vp | ) | [static] |
Definition at line 2175 of file ast_expr2.c.
References AST_EXPR_numeric_string, AST_EXPR_string, f, val::s, t, val::type, and val::u.
Referenced by op_colon(), and op_eqtilde().
02176 { 02177 if (vp->type != AST_EXPR_string && vp->type != AST_EXPR_numeric_string) 02178 return; 02179 02180 if( vp->u.s[0] == '"' && vp->u.s[strlen(vp->u.s)-1] == '"' ) 02181 { 02182 char *f, *t; 02183 f = vp->u.s; 02184 t = vp->u.s; 02185 02186 while( *f ) 02187 { 02188 if( *f && *f != '"' ) 02189 *t++ = *f++; 02190 else 02191 f++; 02192 } 02193 *t = *f; 02194 } 02195 }
static quad_t to_integer | ( | struct val * | vp | ) | [static] |
Definition at line 2144 of file ast_expr2.c.
References AST_EXPR_integer, AST_EXPR_string, 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().
02145 { 02146 quad_t i; 02147 02148 if (vp == NULL) { 02149 ast_log(LOG_WARNING,"vp==NULL in to_integer()\n"); 02150 return(0); 02151 } 02152 02153 if (vp->type == AST_EXPR_integer) 02154 return 1; 02155 02156 if (vp->type == AST_EXPR_string) 02157 return 0; 02158 02159 /* vp->type == AST_EXPR_numeric_string, make it numeric */ 02160 errno = 0; 02161 i = strtoll(vp->u.s, (char**)NULL, 10); 02162 if (errno != 0) { 02163 ast_log(LOG_WARNING,"Conversion of %s to integer under/overflowed!\n", vp->u.s); 02164 free(vp->u.s); 02165 vp->u.s = 0; 02166 return(0); 02167 } 02168 free (vp->u.s); 02169 vp->u.i = i; 02170 vp->type = AST_EXPR_integer; 02171 return 1; 02172 }
static void to_string | ( | struct val * | vp | ) | [static] |
Definition at line 2198 of file ast_expr2.c.
References AST_EXPR_numeric_string, AST_EXPR_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().
02199 { 02200 char *tmp; 02201 02202 if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string) 02203 return; 02204 02205 tmp = malloc ((size_t)25); 02206 if (tmp == NULL) { 02207 ast_log(LOG_WARNING,"malloc() failed\n"); 02208 return; 02209 } 02210 02211 sprintf(tmp, "%ld", (long int) vp->u.i); 02212 vp->type = AST_EXPR_string; 02213 vp->u.s = tmp; 02214 }
static void yydestruct | ( | char * | yymsg, | |
int | yytype, | |||
YYSTYPE * | yyvaluep, | |||
YYLTYPE * | yylocationp | |||
) | const [static] |
Definition at line 1237 of file ast_expr2.c.
References free_value(), YYSTYPE::val, YY_SYMBOL_PRINT, and YYUSE.
Referenced by yyparse().
01243 { 01244 YYUSE (yyvaluep); 01245 YYUSE (yylocationp); 01246 01247 if (!yymsg) 01248 yymsg = "Deleting"; 01249 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 01250 01251 switch (yytype) 01252 { 01253 case 3: /* "TOK_COLONCOLON" */ 01254 #line 169 "ast_expr2.y" 01255 { free_value((yyvaluep->val)); }; 01256 #line 1257 "ast_expr2.c" 01257 break; 01258 case 4: /* "TOK_COND" */ 01259 #line 169 "ast_expr2.y" 01260 { free_value((yyvaluep->val)); }; 01261 #line 1262 "ast_expr2.c" 01262 break; 01263 case 5: /* "TOK_OR" */ 01264 #line 169 "ast_expr2.y" 01265 { free_value((yyvaluep->val)); }; 01266 #line 1267 "ast_expr2.c" 01267 break; 01268 case 6: /* "TOK_AND" */ 01269 #line 169 "ast_expr2.y" 01270 { free_value((yyvaluep->val)); }; 01271 #line 1272 "ast_expr2.c" 01272 break; 01273 case 7: /* "TOK_NE" */ 01274 #line 169 "ast_expr2.y" 01275 { free_value((yyvaluep->val)); }; 01276 #line 1277 "ast_expr2.c" 01277 break; 01278 case 8: /* "TOK_LE" */ 01279 #line 169 "ast_expr2.y" 01280 { free_value((yyvaluep->val)); }; 01281 #line 1282 "ast_expr2.c" 01282 break; 01283 case 9: /* "TOK_GE" */ 01284 #line 169 "ast_expr2.y" 01285 { free_value((yyvaluep->val)); }; 01286 #line 1287 "ast_expr2.c" 01287 break; 01288 case 10: /* "TOK_LT" */ 01289 #line 169 "ast_expr2.y" 01290 { free_value((yyvaluep->val)); }; 01291 #line 1292 "ast_expr2.c" 01292 break; 01293 case 11: /* "TOK_GT" */ 01294 #line 169 "ast_expr2.y" 01295 { free_value((yyvaluep->val)); }; 01296 #line 1297 "ast_expr2.c" 01297 break; 01298 case 12: /* "TOK_EQ" */ 01299 #line 169 "ast_expr2.y" 01300 { free_value((yyvaluep->val)); }; 01301 #line 1302 "ast_expr2.c" 01302 break; 01303 case 13: /* "TOK_MINUS" */ 01304 #line 169 "ast_expr2.y" 01305 { free_value((yyvaluep->val)); }; 01306 #line 1307 "ast_expr2.c" 01307 break; 01308 case 14: /* "TOK_PLUS" */ 01309 #line 169 "ast_expr2.y" 01310 { free_value((yyvaluep->val)); }; 01311 #line 1312 "ast_expr2.c" 01312 break; 01313 case 15: /* "TOK_MOD" */ 01314 #line 169 "ast_expr2.y" 01315 { free_value((yyvaluep->val)); }; 01316 #line 1317 "ast_expr2.c" 01317 break; 01318 case 16: /* "TOK_DIV" */ 01319 #line 169 "ast_expr2.y" 01320 { free_value((yyvaluep->val)); }; 01321 #line 1322 "ast_expr2.c" 01322 break; 01323 case 17: /* "TOK_MULT" */ 01324 #line 169 "ast_expr2.y" 01325 { free_value((yyvaluep->val)); }; 01326 #line 1327 "ast_expr2.c" 01327 break; 01328 case 18: /* "TOK_COMPL" */ 01329 #line 169 "ast_expr2.y" 01330 { free_value((yyvaluep->val)); }; 01331 #line 1332 "ast_expr2.c" 01332 break; 01333 case 19: /* "TOK_EQTILDE" */ 01334 #line 169 "ast_expr2.y" 01335 { free_value((yyvaluep->val)); }; 01336 #line 1337 "ast_expr2.c" 01337 break; 01338 case 20: /* "TOK_COLON" */ 01339 #line 169 "ast_expr2.y" 01340 { free_value((yyvaluep->val)); }; 01341 #line 1342 "ast_expr2.c" 01342 break; 01343 case 21: /* "TOK_LP" */ 01344 #line 169 "ast_expr2.y" 01345 { free_value((yyvaluep->val)); }; 01346 #line 1347 "ast_expr2.c" 01347 break; 01348 case 22: /* "TOK_RP" */ 01349 #line 169 "ast_expr2.y" 01350 { free_value((yyvaluep->val)); }; 01351 #line 1352 "ast_expr2.c" 01352 break; 01353 case 23: /* "TOKEN" */ 01354 #line 169 "ast_expr2.y" 01355 { free_value((yyvaluep->val)); }; 01356 #line 1357 "ast_expr2.c" 01357 break; 01358 case 26: /* "expr" */ 01359 #line 169 "ast_expr2.y" 01360 { free_value((yyvaluep->val)); }; 01361 #line 1362 "ast_expr2.c" 01362 break; 01363 01364 default: 01365 break; 01366 } 01367 }
int yyparse | ( | void * | YYPARSE_PARAM | ) |
Definition at line 1402 of file ast_expr2.c.
References AST_EXPR_integer, AST_EXPR_string, calloc, DESTROY, YYLTYPE::first_column, YYLTYPE::first_line, free, YYLTYPE::last_column, YYLTYPE::last_line, 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, YYINITDEPTH, YYLAST, YYLEX, yylloc, YYLLOC_DEFAULT, 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, and YYTRANSLATE.
01416 { 01417 /* The look-ahead symbol. */ 01418 int yychar; 01419 01420 /* The semantic value of the look-ahead symbol. */ 01421 YYSTYPE yylval; 01422 01423 /* Number of syntax errors so far. */ 01424 int yynerrs; 01425 /* Location data for the look-ahead symbol. */ 01426 YYLTYPE yylloc; 01427 01428 int yystate; 01429 int yyn; 01430 int yyresult; 01431 /* Number of tokens to shift before error messages enabled. */ 01432 int yyerrstatus; 01433 /* Look-ahead token as an internal (translated) token number. */ 01434 int yytoken = 0; 01435 #if YYERROR_VERBOSE 01436 /* Buffer for error messages, and its allocated size. */ 01437 char yymsgbuf[128]; 01438 char *yymsg = yymsgbuf; 01439 YYSIZE_T yymsg_alloc = sizeof yymsgbuf; 01440 #endif 01441 01442 /* Three stacks and their tools: 01443 `yyss': related to states, 01444 `yyvs': related to semantic values, 01445 `yyls': related to locations. 01446 01447 Refer to the stacks thru separate pointers, to allow yyoverflow 01448 to reallocate them elsewhere. */ 01449 01450 /* The state stack. */ 01451 yytype_int16 yyssa[YYINITDEPTH]; 01452 yytype_int16 *yyss = yyssa; 01453 yytype_int16 *yyssp; 01454 01455 /* The semantic value stack. */ 01456 YYSTYPE yyvsa[YYINITDEPTH]; 01457 YYSTYPE *yyvs = yyvsa; 01458 YYSTYPE *yyvsp; 01459 01460 /* The location stack. */ 01461 YYLTYPE yylsa[YYINITDEPTH]; 01462 YYLTYPE *yyls = yylsa; 01463 YYLTYPE *yylsp; 01464 /* The locations where the error started and ended. */ 01465 YYLTYPE yyerror_range[2]; 01466 01467 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) 01468 01469 YYSIZE_T yystacksize = YYINITDEPTH; 01470 01471 /* The variables used to return semantic value and location from the 01472 action routines. */ 01473 YYSTYPE yyval; 01474 YYLTYPE yyloc; 01475 01476 /* The number of symbols on the RHS of the reduced rule. 01477 Keep to zero when no symbol should be popped. */ 01478 int yylen = 0; 01479 01480 YYDPRINTF ((stderr, "Starting parse\n")); 01481 01482 yystate = 0; 01483 yyerrstatus = 0; 01484 yynerrs = 0; 01485 yychar = YYEMPTY; /* Cause a token to be read. */ 01486 01487 /* Initialize stack pointers. 01488 Waste one element of value and location stack 01489 so that they stay on the same level as the state stack. 01490 The wasted elements are never initialized. */ 01491 01492 yyssp = yyss; 01493 yyvsp = yyvs; 01494 yylsp = yyls; 01495 #if YYLTYPE_IS_TRIVIAL 01496 /* Initialize the default location before parsing starts. */ 01497 yylloc.first_line = yylloc.last_line = 1; 01498 yylloc.first_column = yylloc.last_column = 0; 01499 #endif 01500 01501 goto yysetstate; 01502 01503 /*------------------------------------------------------------. 01504 | yynewstate -- Push a new state, which is found in yystate. | 01505 `------------------------------------------------------------*/ 01506 yynewstate: 01507 /* In all cases, when you get here, the value and location stacks 01508 have just been pushed. So pushing a state here evens the stacks. */ 01509 yyssp++; 01510 01511 yysetstate: 01512 *yyssp = yystate; 01513 01514 if (yyss + yystacksize - 1 <= yyssp) 01515 { 01516 /* Get the current used size of the three stacks, in elements. */ 01517 YYSIZE_T yysize = yyssp - yyss + 1; 01518 01519 #ifdef yyoverflow 01520 { 01521 /* Give user a chance to reallocate the stack. Use copies of 01522 these so that the &'s don't force the real ones into 01523 memory. */ 01524 YYSTYPE *yyvs1 = yyvs; 01525 yytype_int16 *yyss1 = yyss; 01526 YYLTYPE *yyls1 = yyls; 01527 01528 /* Each stack pointer address is followed by the size of the 01529 data in use in that stack, in bytes. This used to be a 01530 conditional around just the two extra args, but that might 01531 be undefined if yyoverflow is a macro. */ 01532 yyoverflow (YY_("memory exhausted"), 01533 &yyss1, yysize * sizeof (*yyssp), 01534 &yyvs1, yysize * sizeof (*yyvsp), 01535 &yyls1, yysize * sizeof (*yylsp), 01536 &yystacksize); 01537 yyls = yyls1; 01538 yyss = yyss1; 01539 yyvs = yyvs1; 01540 } 01541 #else /* no yyoverflow */ 01542 # ifndef YYSTACK_RELOCATE 01543 goto yyexhaustedlab; 01544 # else 01545 /* Extend the stack our own way. */ 01546 if (YYMAXDEPTH <= yystacksize) 01547 goto yyexhaustedlab; 01548 yystacksize *= 2; 01549 if (YYMAXDEPTH < yystacksize) 01550 yystacksize = YYMAXDEPTH; 01551 01552 { 01553 yytype_int16 *yyss1 = yyss; 01554 union yyalloc *yyptr = 01555 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 01556 if (! yyptr) 01557 goto yyexhaustedlab; 01558 YYSTACK_RELOCATE (yyss); 01559 YYSTACK_RELOCATE (yyvs); 01560 YYSTACK_RELOCATE (yyls); 01561 # undef YYSTACK_RELOCATE 01562 if (yyss1 != yyssa) 01563 YYSTACK_FREE (yyss1); 01564 } 01565 # endif 01566 #endif /* no yyoverflow */ 01567 01568 yyssp = yyss + yysize - 1; 01569 yyvsp = yyvs + yysize - 1; 01570 yylsp = yyls + yysize - 1; 01571 01572 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 01573 (unsigned long int) yystacksize)); 01574 01575 if (yyss + yystacksize - 1 <= yyssp) 01576 YYABORT; 01577 } 01578 01579 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 01580 01581 goto yybackup; 01582 01583 /*-----------. 01584 | yybackup. | 01585 `-----------*/ 01586 yybackup: 01587 01588 /* Do appropriate processing given the current state. Read a 01589 look-ahead token if we need one and don't already have one. */ 01590 01591 /* First try to decide what to do without reference to look-ahead token. */ 01592 yyn = yypact[yystate]; 01593 if (yyn == YYPACT_NINF) 01594 goto yydefault; 01595 01596 /* Not known => get a look-ahead token if don't already have one. */ 01597 01598 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ 01599 if (yychar == YYEMPTY) 01600 { 01601 YYDPRINTF ((stderr, "Reading a token: ")); 01602 yychar = YYLEX; 01603 } 01604 01605 if (yychar <= YYEOF) 01606 { 01607 yychar = yytoken = YYEOF; 01608 YYDPRINTF ((stderr, "Now at end of input.\n")); 01609 } 01610 else 01611 { 01612 yytoken = YYTRANSLATE (yychar); 01613 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 01614 } 01615 01616 /* If the proper action on seeing token YYTOKEN is to reduce or to 01617 detect an error, take that action. */ 01618 yyn += yytoken; 01619 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 01620 goto yydefault; 01621 yyn = yytable[yyn]; 01622 if (yyn <= 0) 01623 { 01624 if (yyn == 0 || yyn == YYTABLE_NINF) 01625 goto yyerrlab; 01626 yyn = -yyn; 01627 goto yyreduce; 01628 } 01629 01630 if (yyn == YYFINAL) 01631 YYACCEPT; 01632 01633 /* Count tokens shifted since error; after three, turn off error 01634 status. */ 01635 if (yyerrstatus) 01636 yyerrstatus--; 01637 01638 /* Shift the look-ahead token. */ 01639 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 01640 01641 /* Discard the shifted token unless it is eof. */ 01642 if (yychar != YYEOF) 01643 yychar = YYEMPTY; 01644 01645 yystate = yyn; 01646 *++yyvsp = yylval; 01647 *++yylsp = yylloc; 01648 goto yynewstate; 01649 01650 01651 /*-----------------------------------------------------------. 01652 | yydefault -- do the default action for the current state. | 01653 `-----------------------------------------------------------*/ 01654 yydefault: 01655 yyn = yydefact[yystate]; 01656 if (yyn == 0) 01657 goto yyerrlab; 01658 goto yyreduce; 01659 01660 01661 /*-----------------------------. 01662 | yyreduce -- Do a reduction. | 01663 `-----------------------------*/ 01664 yyreduce: 01665 /* yyn is the number of a rule to reduce with. */ 01666 yylen = yyr2[yyn]; 01667 01668 /* If YYLEN is nonzero, implement the default value of the action: 01669 `$$ = $1'. 01670 01671 Otherwise, the following line sets YYVAL to garbage. 01672 This behavior is undocumented and Bison 01673 users should not rely upon it. Assigning to YYVAL 01674 unconditionally makes the parser a bit smaller, and it avoids a 01675 GCC warning that YYVAL may be used uninitialized. */ 01676 yyval = yyvsp[1-yylen]; 01677 01678 /* Default location. */ 01679 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); 01680 YY_REDUCE_PRINT (yyn); 01681 switch (yyn) 01682 { 01683 case 2: 01684 #line 175 "ast_expr2.y" 01685 { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1); 01686 ((struct parse_io *)parseio)->val->type = (yyvsp[(1) - (1)].val)->type; 01687 if( (yyvsp[(1) - (1)].val)->type == AST_EXPR_integer ) 01688 ((struct parse_io *)parseio)->val->u.i = (yyvsp[(1) - (1)].val)->u.i; 01689 else 01690 ((struct parse_io *)parseio)->val->u.s = (yyvsp[(1) - (1)].val)->u.s; 01691 free((yyvsp[(1) - (1)].val)); 01692 ;} 01693 break; 01694 01695 case 3: 01696 #line 183 "ast_expr2.y" 01697 {/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1); 01698 ((struct parse_io *)parseio)->val->type = AST_EXPR_string; 01699 ((struct parse_io *)parseio)->val->u.s = strdup(""); 01700 ;} 01701 break; 01702 01703 case 4: 01704 #line 190 "ast_expr2.y" 01705 { (yyval.val)= (yyvsp[(1) - (1)].val);;} 01706 break; 01707 01708 case 5: 01709 #line 191 "ast_expr2.y" 01710 { (yyval.val) = (yyvsp[(2) - (3)].val); 01711 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01712 (yyloc).first_line=0; (yyloc).last_line=0; 01713 DESTROY((yyvsp[(1) - (3)].val)); DESTROY((yyvsp[(3) - (3)].val)); ;} 01714 break; 01715 01716 case 6: 01717 #line 195 "ast_expr2.y" 01718 { (yyval.val) = op_or ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01719 DESTROY((yyvsp[(2) - (3)].val)); 01720 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01721 (yyloc).first_line=0; (yyloc).last_line=0;;} 01722 break; 01723 01724 case 7: 01725 #line 199 "ast_expr2.y" 01726 { (yyval.val) = op_and ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01727 DESTROY((yyvsp[(2) - (3)].val)); 01728 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01729 (yyloc).first_line=0; (yyloc).last_line=0;;} 01730 break; 01731 01732 case 8: 01733 #line 203 "ast_expr2.y" 01734 { (yyval.val) = op_eq ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01735 DESTROY((yyvsp[(2) - (3)].val)); 01736 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01737 (yyloc).first_line=0; (yyloc).last_line=0;;} 01738 break; 01739 01740 case 9: 01741 #line 207 "ast_expr2.y" 01742 { (yyval.val) = op_gt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01743 DESTROY((yyvsp[(2) - (3)].val)); 01744 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01745 (yyloc).first_line=0; (yyloc).last_line=0;;} 01746 break; 01747 01748 case 10: 01749 #line 211 "ast_expr2.y" 01750 { (yyval.val) = op_lt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01751 DESTROY((yyvsp[(2) - (3)].val)); 01752 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01753 (yyloc).first_line=0; (yyloc).last_line=0;;} 01754 break; 01755 01756 case 11: 01757 #line 215 "ast_expr2.y" 01758 { (yyval.val) = op_ge ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01759 DESTROY((yyvsp[(2) - (3)].val)); 01760 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01761 (yyloc).first_line=0; (yyloc).last_line=0;;} 01762 break; 01763 01764 case 12: 01765 #line 219 "ast_expr2.y" 01766 { (yyval.val) = op_le ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01767 DESTROY((yyvsp[(2) - (3)].val)); 01768 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01769 (yyloc).first_line=0; (yyloc).last_line=0;;} 01770 break; 01771 01772 case 13: 01773 #line 223 "ast_expr2.y" 01774 { (yyval.val) = op_ne ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01775 DESTROY((yyvsp[(2) - (3)].val)); 01776 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01777 (yyloc).first_line=0; (yyloc).last_line=0;;} 01778 break; 01779 01780 case 14: 01781 #line 227 "ast_expr2.y" 01782 { (yyval.val) = op_plus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01783 DESTROY((yyvsp[(2) - (3)].val)); 01784 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01785 (yyloc).first_line=0; (yyloc).last_line=0;;} 01786 break; 01787 01788 case 15: 01789 #line 231 "ast_expr2.y" 01790 { (yyval.val) = op_minus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01791 DESTROY((yyvsp[(2) - (3)].val)); 01792 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01793 (yyloc).first_line=0; (yyloc).last_line=0;;} 01794 break; 01795 01796 case 16: 01797 #line 235 "ast_expr2.y" 01798 { (yyval.val) = op_negate ((yyvsp[(2) - (2)].val)); 01799 DESTROY((yyvsp[(1) - (2)].val)); 01800 (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column; 01801 (yyloc).first_line=0; (yyloc).last_line=0;;} 01802 break; 01803 01804 case 17: 01805 #line 239 "ast_expr2.y" 01806 { (yyval.val) = op_compl ((yyvsp[(2) - (2)].val)); 01807 DESTROY((yyvsp[(1) - (2)].val)); 01808 (yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column; 01809 (yyloc).first_line=0; (yyloc).last_line=0;;} 01810 break; 01811 01812 case 18: 01813 #line 243 "ast_expr2.y" 01814 { (yyval.val) = op_times ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01815 DESTROY((yyvsp[(2) - (3)].val)); 01816 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01817 (yyloc).first_line=0; (yyloc).last_line=0;;} 01818 break; 01819 01820 case 19: 01821 #line 247 "ast_expr2.y" 01822 { (yyval.val) = op_div ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01823 DESTROY((yyvsp[(2) - (3)].val)); 01824 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01825 (yyloc).first_line=0; (yyloc).last_line=0;;} 01826 break; 01827 01828 case 20: 01829 #line 251 "ast_expr2.y" 01830 { (yyval.val) = op_rem ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01831 DESTROY((yyvsp[(2) - (3)].val)); 01832 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01833 (yyloc).first_line=0; (yyloc).last_line=0;;} 01834 break; 01835 01836 case 21: 01837 #line 255 "ast_expr2.y" 01838 { (yyval.val) = op_colon ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01839 DESTROY((yyvsp[(2) - (3)].val)); 01840 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01841 (yyloc).first_line=0; (yyloc).last_line=0;;} 01842 break; 01843 01844 case 22: 01845 #line 259 "ast_expr2.y" 01846 { (yyval.val) = op_eqtilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); 01847 DESTROY((yyvsp[(2) - (3)].val)); 01848 (yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column; 01849 (yyloc).first_line=0; (yyloc).last_line=0;;} 01850 break; 01851 01852 case 23: 01853 #line 263 "ast_expr2.y" 01854 { (yyval.val) = op_cond ((yyvsp[(1) - (5)].val), (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val)); 01855 DESTROY((yyvsp[(2) - (5)].val)); 01856 DESTROY((yyvsp[(4) - (5)].val)); 01857 (yyloc).first_column = (yylsp[(1) - (5)]).first_column; (yyloc).last_column = (yylsp[(3) - (5)]).last_column; 01858 (yyloc).first_line=0; (yyloc).last_line=0;;} 01859 break; 01860 01861 01862 /* Line 1270 of yacc.c. */ 01863 #line 1864 "ast_expr2.c" 01864 default: break; 01865 } 01866 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 01867 01868 YYPOPSTACK (yylen); 01869 yylen = 0; 01870 YY_STACK_PRINT (yyss, yyssp); 01871 01872 *++yyvsp = yyval; 01873 *++yylsp = yyloc; 01874 01875 /* Now `shift' the result of the reduction. Determine what state 01876 that goes to, based on the state we popped back to and the rule 01877 number reduced by. */ 01878 01879 yyn = yyr1[yyn]; 01880 01881 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 01882 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 01883 yystate = yytable[yystate]; 01884 else 01885 yystate = yydefgoto[yyn - YYNTOKENS]; 01886 01887 goto yynewstate; 01888 01889 01890 /*------------------------------------. 01891 | yyerrlab -- here on detecting error | 01892 `------------------------------------*/ 01893 yyerrlab: 01894 /* If not already recovering from an error, report this error. */ 01895 if (!yyerrstatus) 01896 { 01897 ++yynerrs; 01898 #if ! YYERROR_VERBOSE 01899 yyerror (YY_("syntax error")); 01900 #else 01901 { 01902 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); 01903 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) 01904 { 01905 YYSIZE_T yyalloc = 2 * yysize; 01906 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) 01907 yyalloc = YYSTACK_ALLOC_MAXIMUM; 01908 if (yymsg != yymsgbuf) 01909 YYSTACK_FREE (yymsg); 01910 yymsg = (char *) YYSTACK_ALLOC (yyalloc); 01911 if (yymsg) 01912 yymsg_alloc = yyalloc; 01913 else 01914 { 01915 yymsg = yymsgbuf; 01916 yymsg_alloc = sizeof yymsgbuf; 01917 } 01918 } 01919 01920 if (0 < yysize && yysize <= yymsg_alloc) 01921 { 01922 (void) yysyntax_error (yymsg, yystate, yychar); 01923 yyerror (yymsg); 01924 } 01925 else 01926 { 01927 yyerror (YY_("syntax error")); 01928 if (yysize != 0) 01929 goto yyexhaustedlab; 01930 } 01931 } 01932 #endif 01933 } 01934 01935 yyerror_range[0] = yylloc; 01936 01937 if (yyerrstatus == 3) 01938 { 01939 /* If just tried and failed to reuse look-ahead token after an 01940 error, discard it. */ 01941 01942 if (yychar <= YYEOF) 01943 { 01944 /* Return failure if at end of input. */ 01945 if (yychar == YYEOF) 01946 YYABORT; 01947 } 01948 else 01949 { 01950 yydestruct ("Error: discarding", 01951 yytoken, &yylval, &yylloc); 01952 yychar = YYEMPTY; 01953 } 01954 } 01955 01956 /* Else will try to reuse look-ahead token after shifting the error 01957 token. */ 01958 goto yyerrlab1; 01959 01960 01961 /*---------------------------------------------------. 01962 | yyerrorlab -- error raised explicitly by YYERROR. | 01963 `---------------------------------------------------*/ 01964 yyerrorlab: 01965 01966 /* Pacify compilers like GCC when the user code never invokes 01967 YYERROR and the label yyerrorlab therefore never appears in user 01968 code. */ 01969 if (/*CONSTCOND*/ 0) 01970 goto yyerrorlab; 01971 01972 yyerror_range[0] = yylsp[1-yylen]; 01973 /* Do not reclaim the symbols of the rule which action triggered 01974 this YYERROR. */ 01975 YYPOPSTACK (yylen); 01976 yylen = 0; 01977 YY_STACK_PRINT (yyss, yyssp); 01978 yystate = *yyssp; 01979 goto yyerrlab1; 01980 01981 01982 /*-------------------------------------------------------------. 01983 | yyerrlab1 -- common code for both syntax error and YYERROR. | 01984 `-------------------------------------------------------------*/ 01985 yyerrlab1: 01986 yyerrstatus = 3; /* Each real token shifted decrements this. */ 01987 01988 for (;;) 01989 { 01990 yyn = yypact[yystate]; 01991 if (yyn != YYPACT_NINF) 01992 { 01993 yyn += YYTERROR; 01994 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 01995 { 01996 yyn = yytable[yyn]; 01997 if (0 < yyn) 01998 break; 01999 } 02000 } 02001 02002 /* Pop the current state because it cannot handle the error token. */ 02003 if (yyssp == yyss) 02004 YYABORT; 02005 02006 yyerror_range[0] = *yylsp; 02007 yydestruct ("Error: popping", 02008 yystos[yystate], yyvsp, yylsp); 02009 YYPOPSTACK (1); 02010 yystate = *yyssp; 02011 YY_STACK_PRINT (yyss, yyssp); 02012 } 02013 02014 if (yyn == YYFINAL) 02015 YYACCEPT; 02016 02017 *++yyvsp = yylval; 02018 02019 yyerror_range[1] = yylloc; 02020 /* Using YYLLOC is tempting, but would change the location of 02021 the look-ahead. YYLOC is available though. */ 02022 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); 02023 *++yylsp = yyloc; 02024 02025 /* Shift the error token. */ 02026 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); 02027 02028 yystate = yyn; 02029 goto yynewstate; 02030 02031 02032 /*-------------------------------------. 02033 | yyacceptlab -- YYACCEPT comes here. | 02034 `-------------------------------------*/ 02035 yyacceptlab: 02036 yyresult = 0; 02037 goto yyreturn; 02038 02039 /*-----------------------------------. 02040 | yyabortlab -- YYABORT comes here. | 02041 `-----------------------------------*/ 02042 yyabortlab: 02043 yyresult = 1; 02044 goto yyreturn; 02045 02046 #ifndef yyoverflow 02047 /*-------------------------------------------------. 02048 | yyexhaustedlab -- memory exhaustion comes here. | 02049 `-------------------------------------------------*/ 02050 yyexhaustedlab: 02051 yyerror (YY_("memory exhausted")); 02052 yyresult = 2; 02053 /* Fall through. */ 02054 #endif 02055 02056 yyreturn: 02057 if (yychar != YYEOF && yychar != YYEMPTY) 02058 yydestruct ("Cleanup: discarding lookahead", 02059 yytoken, &yylval, &yylloc); 02060 /* Do not reclaim the symbols of the rule which action triggered 02061 this YYABORT or YYACCEPT. */ 02062 YYPOPSTACK (yylen); 02063 YY_STACK_PRINT (yyss, yyssp); 02064 while (yyssp != yyss) 02065 { 02066 yydestruct ("Cleanup: popping", 02067 yystos[*yyssp], yyvsp, yylsp); 02068 YYPOPSTACK (1); 02069 } 02070 #ifndef yyoverflow 02071 if (yyss != yyssa) 02072 YYSTACK_FREE (yyss); 02073 #endif 02074 #if YYERROR_VERBOSE 02075 if (yymsg != yymsgbuf) 02076 YYSTACK_FREE (yymsg); 02077 #endif 02078 return yyresult; 02079 }
int yyparse | ( | ) |
static char* yystpcpy | ( | char * | yydest, | |
const char * | yysrc | |||
) | [static] |
Definition at line 1052 of file ast_expr2.c.
Referenced by yysyntax_error(), and yytnamerr().
01056 { 01057 char *yyd = yydest; 01058 const char *yys = yysrc; 01059 01060 while ((*yyd++ = *yys++) != '\0') 01061 continue; 01062 01063 return yyd - 1; 01064 }
static YYSIZE_T yystrlen | ( | char * | yystr | ) | const [static] |
Definition at line 1028 of file ast_expr2.c.
References YYSIZE_T.
Referenced by yysyntax_error(), and yytnamerr().
01031 { 01032 YYSIZE_T yylen; 01033 for (yylen = 0; yystr[yylen]; yylen++) 01034 continue; 01035 return yylen; 01036 }
static YYSIZE_T yysyntax_error | ( | char * | yyresult, | |
int | yystate, | |||
int | yychar | |||
) | [static] |
Definition at line 1124 of file ast_expr2.c.
References YY_, YYLAST, YYNTOKENS, YYPACT_NINF, YYSIZE_MAXIMUM, YYSIZE_T, yystpcpy(), yystrlen(), YYTERROR, yytnamerr(), and YYTRANSLATE.
Referenced by yyparse().
01125 { 01126 int yyn = yypact[yystate]; 01127 01128 if (! (YYPACT_NINF < yyn && yyn < YYLAST)) 01129 return 0; 01130 else 01131 { 01132 int yytype = YYTRANSLATE (yychar); 01133 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); 01134 YYSIZE_T yysize = yysize0; 01135 YYSIZE_T yysize1; 01136 int yysize_overflow = 0; 01137 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; 01138 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 01139 int yyx; 01140 01141 # if 0 01142 /* This is so xgettext sees the translatable formats that are 01143 constructed on the fly. */ 01144 YY_("syntax error, unexpected %s"); 01145 YY_("syntax error, unexpected %s, expecting %s"); 01146 YY_("syntax error, unexpected %s, expecting %s or %s"); 01147 YY_("syntax error, unexpected %s, expecting %s or %s or %s"); 01148 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); 01149 # endif 01150 char *yyfmt; 01151 char const *yyf; 01152 static char const yyunexpected[] = "syntax error, unexpected %s"; 01153 static char const yyexpecting[] = ", expecting %s"; 01154 static char const yyor[] = " or %s"; 01155 char yyformat[sizeof yyunexpected 01156 + sizeof yyexpecting - 1 01157 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) 01158 * (sizeof yyor - 1))]; 01159 char const *yyprefix = yyexpecting; 01160 01161 /* Start YYX at -YYN if negative to avoid negative indexes in 01162 YYCHECK. */ 01163 int yyxbegin = yyn < 0 ? -yyn : 0; 01164 01165 /* Stay within bounds of both yycheck and yytname. */ 01166 int yychecklim = YYLAST - yyn; 01167 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; 01168 int yycount = 1; 01169 01170 yyarg[0] = yytname[yytype]; 01171 yyfmt = yystpcpy (yyformat, yyunexpected); 01172 01173 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 01174 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 01175 { 01176 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) 01177 { 01178 yycount = 1; 01179 yysize = yysize0; 01180 yyformat[sizeof yyunexpected - 1] = '\0'; 01181 break; 01182 } 01183 yyarg[yycount++] = yytname[yyx]; 01184 yysize1 = yysize + yytnamerr (0, yytname[yyx]); 01185 yysize_overflow |= (yysize1 < yysize); 01186 yysize = yysize1; 01187 yyfmt = yystpcpy (yyfmt, yyprefix); 01188 yyprefix = yyor; 01189 } 01190 01191 yyf = YY_(yyformat); 01192 yysize1 = yysize + yystrlen (yyf); 01193 yysize_overflow |= (yysize1 < yysize); 01194 yysize = yysize1; 01195 01196 if (yysize_overflow) 01197 return YYSIZE_MAXIMUM; 01198 01199 if (yyresult) 01200 { 01201 /* Avoid sprintf, as that infringes on the user's name space. 01202 Don't have undefined behavior even if the translation 01203 produced a string with the wrong number of "%s"s. */ 01204 char *yyp = yyresult; 01205 int yyi = 0; 01206 while ((*yyp = *yyf) != '\0') 01207 { 01208 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) 01209 { 01210 yyp += yytnamerr (yyp, yyarg[yyi++]); 01211 yyf += 2; 01212 } 01213 else 01214 { 01215 yyp++; 01216 yyf++; 01217 } 01218 } 01219 } 01220 return yysize; 01221 } 01222 }
static YYSIZE_T yytnamerr | ( | char * | yyres, | |
const char * | yystr | |||
) | [static] |
Definition at line 1077 of file ast_expr2.c.
References yystpcpy(), and yystrlen().
Referenced by yysyntax_error().
01078 { 01079 if (*yystr == '"') 01080 { 01081 size_t yyn = 0; 01082 char const *yyp = yystr; 01083 01084 for (;;) 01085 switch (*++yyp) 01086 { 01087 case '\'': 01088 case ',': 01089 goto do_not_strip_quotes; 01090 01091 case '\\': 01092 if (*++yyp != '\\') 01093 goto do_not_strip_quotes; 01094 /* Fall through. */ 01095 default: 01096 if (yyres) 01097 yyres[yyn] = *yyp; 01098 yyn++; 01099 break; 01100 01101 case '"': 01102 if (yyres) 01103 yyres[yyn] = '\0'; 01104 return yyn; 01105 } 01106 do_not_strip_quotes: ; 01107 } 01108 01109 if (! yyres) 01110 return yystrlen (yystr); 01111 01112 return yystpcpy (yyres, yystr) - yyres; 01113 }
char extra_error_message[4095] |
Definition at line 2330 of file ast_expr2f.c.
Definition at line 2331 of file ast_expr2f.c.
const yytype_int8 yycheck[] [static] |
Definition at line 709 of file ast_expr2.c.
const yytype_uint8 yydefact[] [static] |
Definition at line 652 of file ast_expr2.c.
const yytype_int8 yydefgoto[] [static] |
const yytype_int8 yypact[] [static] |
Definition at line 670 of file ast_expr2.c.
const yytype_int8 yypgoto[] [static] |
const yytype_uint8 yyr1[] [static] |
Definition at line 634 of file ast_expr2.c.
const yytype_uint8 yyr2[] [static] |
Definition at line 642 of file ast_expr2.c.
const yytype_uint8 yystos[] [static] |
Definition at line 730 of file ast_expr2.c.
const yytype_uint8 yytable[] [static] |
Definition at line 690 of file ast_expr2.c.
const char* const yytname[] [static] |
Definition at line 612 of file ast_expr2.c.
const yytype_uint8 yytranslate[] [static] |
Definition at line 544 of file ast_expr2.c.