[asterisk-commits] branch murf/AEL2-1.2 r19501 - in
/team/murf/AEL2-1.2: ./ pbx/ utils/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Apr 11 19:21:54 MST 2006
Author: murf
Date: Tue Apr 11 21:21:49 2006
New Revision: 19501
URL: http://svn.digium.com/view/asterisk?rev=19501&view=rev
Log:
These changes correspond to those made for the trunk version of
AEL2. Error handling for the parser upgraded. Added the -d option
to aelparse. Made fixes to syntax error counting, but it is not complete.
Modified:
team/murf/AEL2-1.2/ast_expr2.c
team/murf/AEL2-1.2/ast_expr2.h
team/murf/AEL2-1.2/ast_expr2f.c
team/murf/AEL2-1.2/pbx/ael.flex
team/murf/AEL2-1.2/pbx/ael.tab.c
team/murf/AEL2-1.2/pbx/ael.tab.h
team/murf/AEL2-1.2/pbx/ael.y
team/murf/AEL2-1.2/pbx/ael_lex.c
team/murf/AEL2-1.2/utils/ael_main.c
Modified: team/murf/AEL2-1.2/ast_expr2.c
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2-1.2/ast_expr2.c?rev=19501&r1=19500&r2=19501&view=diff
==============================================================================
--- team/murf/AEL2-1.2/ast_expr2.c (original)
+++ team/murf/AEL2-1.2/ast_expr2.c Tue Apr 11 21:21:49 2006
@@ -1,7 +1,7 @@
-/* A Bison parser, made by GNU Bison 2.0. */
+/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton parser for Yacc-like parsing with Bison,
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,8 +15,8 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
@@ -35,6 +35,9 @@
/* Identify Bison output. */
#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.1"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -84,6 +87,7 @@
TOKEN = 278
};
#endif
+/* Tokens. */
#define TOK_COLONCOLON 258
#define TOK_COND 259
#define TOK_OR 260
@@ -130,6 +134,7 @@
#include <stdlib.h>
#include <string.h>
#include <locale.h>
+#include <unistd.h>
#include <ctype.h>
#if !defined(SOLARIS) && !defined(__CYGWIN__)
#include <err.h>
@@ -159,6 +164,8 @@
#define YYPARSE_PARAM parseio
#define YYLEX_PARAM ((struct parse_io *)parseio)->scanner
#define YYERROR_VERBOSE 1
+extern char extra_error_message[4095];
+extern int extra_error_message_supplied;
enum valtype {
AST_EXPR_integer, AST_EXPR_numeric_string, AST_EXPR_string
@@ -237,12 +244,7 @@
some useful info about the error. Not as easy as it looks, but it
is possible. */
#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 DESTROY(x) {if((x)->type == AST_EXPR_numeric_string || (x)->type == AST_EXPR_string) free((x)->u.s); (x)->u.s = 0; free(x);}
/* Enabling traces. */
@@ -258,13 +260,18 @@
# define YYERROR_VERBOSE 0
#endif
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 142 "ast_expr2.y"
+#line 140 "ast_expr2.y"
typedef union YYSTYPE {
struct val *val;
} YYSTYPE;
-/* Line 190 of yacc.c. */
-#line 268 "ast_expr2.c"
+/* Line 196 of yacc.c. */
+#line 275 "ast_expr2.c"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
@@ -285,22 +292,41 @@
/* Copy the second part of user declarations. */
-#line 146 "ast_expr2.y"
+#line 144 "ast_expr2.y"
extern int ast_yylex __P((YYSTYPE *, YYLTYPE *, yyscan_t));
-/* Line 213 of yacc.c. */
-#line 295 "ast_expr2.c"
+/* Line 219 of yacc.c. */
+#line 302 "ast_expr2.c"
+
+#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
+# define YYSIZE_T __SIZE_TYPE__
+#endif
+#if ! defined (YYSIZE_T) && defined (size_t)
+# define YYSIZE_T size_t
+#endif
+#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+#endif
+#if ! defined (YYSIZE_T)
+# define YYSIZE_T unsigned int
+#endif
+
+#ifndef YY_
+# if YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
#if ! defined (yyoverflow) || YYERROR_VERBOSE
-
-# ifndef YYFREE
-# define YYFREE free
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# endif
/* The parser invokes alloca or malloc; define the necessary symbols. */
@@ -310,6 +336,10 @@
# define YYSTACK_ALLOC __builtin_alloca
# else
# define YYSTACK_ALLOC alloca
+# if defined (__STDC__) || defined (__cplusplus)
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# define YYINCLUDED_STDLIB_H
+# endif
# endif
# endif
# endif
@@ -317,13 +347,39 @@
# ifdef YYSTACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
+# endif
# else
-# if defined (__STDC__) || defined (__cplusplus)
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# endif
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
+# endif
+# ifdef __cplusplus
+extern "C" {
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
+ && (defined (__STDC__) || defined (__cplusplus)))
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
+ && (defined (__STDC__) || defined (__cplusplus)))
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifdef __cplusplus
+}
+# endif
# endif
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
@@ -360,7 +416,7 @@
# define YYCOPY(To, From, Count) \
do \
{ \
- register YYSIZE_T yyi; \
+ YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
@@ -402,7 +458,7 @@
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 3
/* YYNRULES -- Number of rules. */
-#define YYNRULES 22
+#define YYNRULES 23
/* YYNRULES -- Number of states. */
#define YYNSTATES 46
@@ -410,7 +466,7 @@
#define YYUNDEFTOK 2
#define YYMAXUTOK 278
-#define YYTRANSLATE(YYX) \
+#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
@@ -451,36 +507,36 @@
YYRHS. */
static const unsigned char yyprhs[] =
{
- 0, 0, 3, 5, 7, 11, 15, 19, 23, 27,
- 31, 35, 39, 43, 47, 51, 54, 57, 61, 65,
- 69, 73, 77
+ 0, 0, 3, 5, 6, 8, 12, 16, 20, 24,
+ 28, 32, 36, 40, 44, 48, 52, 55, 58, 62,
+ 66, 70, 74, 78
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yysigned_char yyrhs[] =
{
- 25, 0, -1, 26, -1, 23, -1, 21, 26, 22,
- -1, 26, 5, 26, -1, 26, 6, 26, -1, 26,
- 12, 26, -1, 26, 11, 26, -1, 26, 10, 26,
- -1, 26, 9, 26, -1, 26, 8, 26, -1, 26,
- 7, 26, -1, 26, 14, 26, -1, 26, 13, 26,
- -1, 13, 26, -1, 18, 26, -1, 26, 17, 26,
- -1, 26, 16, 26, -1, 26, 15, 26, -1, 26,
- 20, 26, -1, 26, 19, 26, -1, 26, 4, 26,
- 3, 26, -1
+ 25, 0, -1, 26, -1, -1, 23, -1, 21, 26,
+ 22, -1, 26, 5, 26, -1, 26, 6, 26, -1,
+ 26, 12, 26, -1, 26, 11, 26, -1, 26, 10,
+ 26, -1, 26, 9, 26, -1, 26, 8, 26, -1,
+ 26, 7, 26, -1, 26, 14, 26, -1, 26, 13,
+ 26, -1, 13, 26, -1, 18, 26, -1, 26, 17,
+ 26, -1, 26, 16, 26, -1, 26, 15, 26, -1,
+ 26, 20, 26, -1, 26, 19, 26, -1, 26, 4,
+ 26, 3, 26, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const unsigned char yyrline[] =
{
- 0, 165, 165, 175, 176, 180, 184, 188, 192, 196,
- 200, 204, 208, 212, 216, 220, 224, 228, 232, 236,
- 240, 244, 248
+ 0, 163, 163, 171, 178, 179, 183, 187, 191, 195,
+ 199, 203, 207, 211, 215, 219, 223, 227, 231, 235,
+ 239, 243, 247, 251
};
#endif
-#if YYDEBUG || YYERROR_VERBOSE
-/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
@@ -506,17 +562,17 @@
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const unsigned char yyr1[] =
{
- 0, 24, 25, 26, 26, 26, 26, 26, 26, 26,
+ 0, 24, 25, 25, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 26
+ 26, 26, 26, 26
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const unsigned char yyr2[] =
{
- 0, 2, 1, 1, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 2, 2, 3, 3, 3,
- 3, 3, 5
+ 0, 2, 1, 0, 1, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 2, 2, 3, 3,
+ 3, 3, 3, 5
};
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -524,11 +580,11 @@
means the default is an error. */
static const unsigned char yydefact[] =
{
- 0, 0, 0, 0, 3, 0, 2, 15, 16, 0,
+ 3, 0, 0, 0, 4, 0, 2, 16, 17, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 4, 0, 5,
- 6, 12, 11, 10, 9, 8, 7, 14, 13, 19,
- 18, 17, 21, 20, 0, 22
+ 0, 0, 0, 0, 0, 0, 0, 5, 0, 6,
+ 7, 13, 12, 11, 10, 9, 8, 15, 14, 20,
+ 19, 18, 22, 21, 0, 23
};
/* YYDEFGOTO[NTERM-NUM]. */
@@ -609,22 +665,6 @@
26, 26, 26, 26, 3, 26
};
-#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
-# define YYSIZE_T __SIZE_TYPE__
-#endif
-#if ! defined (YYSIZE_T) && defined (size_t)
-# define YYSIZE_T size_t
-#endif
-#if ! defined (YYSIZE_T)
-# if defined (__STDC__) || defined (__cplusplus)
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# endif
-#endif
-#if ! defined (YYSIZE_T)
-# define YYSIZE_T unsigned int
-#endif
-
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
@@ -654,8 +694,8 @@
goto yybackup; \
} \
else \
- { \
- yyerror ("syntax error: cannot back up");\
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (0)
@@ -734,7 +774,7 @@
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
- yysymprint (stderr, \
+ yysymprint (stderr, \
Type, Value, Location); \
YYFPRINTF (stderr, "\n"); \
} \
@@ -782,13 +822,13 @@
#endif
{
int yyi;
- unsigned int yylno = yyrline[yyrule];
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
+ unsigned long int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
yyrule - 1, yylno);
/* Print the symbols being reduced, and their result. */
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
- YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
- YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
+ YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
+ YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
}
# define YY_REDUCE_PRINT(Rule) \
@@ -817,7 +857,7 @@
if the built-in stack extension method is used).
Do not make this value too large; the results are undefined if
- SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
#ifndef YYMAXDEPTH
@@ -841,7 +881,7 @@
const char *yystr;
# endif
{
- register const char *yys = yystr;
+ const char *yys = yystr;
while (*yys++ != '\0')
continue;
@@ -866,8 +906,8 @@
const char *yysrc;
# endif
{
- register char *yyd = yydest;
- register const char *yys = yysrc;
+ char *yyd = yydest;
+ const char *yys = yysrc;
while ((*yyd++ = *yys++) != '\0')
continue;
@@ -877,7 +917,55 @@
# endif
# endif
-#endif /* !YYERROR_VERBOSE */
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ size_t yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return yystrlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+#endif /* YYERROR_VERBOSE */
@@ -908,7 +996,7 @@
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
YY_LOCATION_PRINT (yyoutput, *yylocationp);
- fprintf (yyoutput, ": ");
+ YYFPRINTF (yyoutput, ": ");
# ifdef YYPRINT
if (yytype < YYNTOKENS)
@@ -995,7 +1083,7 @@
#else
int
yyparse ()
-
+ ;
#endif
#endif
{
@@ -1010,8 +1098,8 @@
/* Location data for the look-ahead symbol. */
YYLTYPE yylloc;
- register int yystate;
- register int yyn;
+ int yystate;
+ int yyn;
int yyresult;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
@@ -1029,12 +1117,12 @@
/* The state stack. */
short int yyssa[YYINITDEPTH];
short int *yyss = yyssa;
- register short int *yyssp;
+ short int *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs = yyvsa;
- register YYSTYPE *yyvsp;
+ YYSTYPE *yyvsp;
/* The location stack. */
YYLTYPE yylsa[YYINITDEPTH];
@@ -1076,10 +1164,6 @@
yylloc.first_line = yylloc.last_line = 1;
yylloc.first_column = yylloc.last_column = 0;
#endif
-
-
- yyvsp[0] = yylval;
- yylsp[0] = yylloc;
goto yysetstate;
@@ -1113,7 +1197,7 @@
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
- yyoverflow ("parser stack overflow",
+ yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
@@ -1124,11 +1208,11 @@
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
- goto yyoverflowlab;
+ goto yyexhaustedlab;
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
- goto yyoverflowlab;
+ goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
@@ -1138,7 +1222,7 @@
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
- goto yyoverflowlab;
+ goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss);
YYSTACK_RELOCATE (yyvs);
YYSTACK_RELOCATE (yyls);
@@ -1268,7 +1352,7 @@
switch (yyn)
{
case 2:
-#line 165 "ast_expr2.y"
+#line 163 "ast_expr2.y"
{ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
((struct parse_io *)parseio)->val->type = (yyvsp[0].val)->type;
if( (yyvsp[0].val)->type == AST_EXPR_integer )
@@ -1280,156 +1364,164 @@
break;
case 3:
-#line 175 "ast_expr2.y"
+#line 171 "ast_expr2.y"
+ {/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
+ ((struct parse_io *)parseio)->val->type = AST_EXPR_string;
+ ((struct parse_io *)parseio)->val->u.s = strdup("");
+ ;}
+ break;
+
+ case 4:
+#line 178 "ast_expr2.y"
{ (yyval.val)= (yyvsp[0].val);;}
break;
- case 4:
-#line 176 "ast_expr2.y"
+ case 5:
+#line 179 "ast_expr2.y"
{ (yyval.val) = (yyvsp[-1].val);
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;
DESTROY((yyvsp[-2].val)); DESTROY((yyvsp[0].val)); ;}
break;
- case 5:
-#line 180 "ast_expr2.y"
+ case 6:
+#line 183 "ast_expr2.y"
{ (yyval.val) = op_or ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 6:
-#line 184 "ast_expr2.y"
+ case 7:
+#line 187 "ast_expr2.y"
{ (yyval.val) = op_and ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 7:
-#line 188 "ast_expr2.y"
+ case 8:
+#line 191 "ast_expr2.y"
{ (yyval.val) = op_eq ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 8:
-#line 192 "ast_expr2.y"
+ case 9:
+#line 195 "ast_expr2.y"
{ (yyval.val) = op_gt ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 9:
-#line 196 "ast_expr2.y"
+ case 10:
+#line 199 "ast_expr2.y"
{ (yyval.val) = op_lt ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 10:
-#line 200 "ast_expr2.y"
+ case 11:
+#line 203 "ast_expr2.y"
{ (yyval.val) = op_ge ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 11:
-#line 204 "ast_expr2.y"
+ case 12:
+#line 207 "ast_expr2.y"
{ (yyval.val) = op_le ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 12:
-#line 208 "ast_expr2.y"
+ case 13:
+#line 211 "ast_expr2.y"
{ (yyval.val) = op_ne ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 13:
-#line 212 "ast_expr2.y"
+ case 14:
+#line 215 "ast_expr2.y"
{ (yyval.val) = op_plus ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 14:
-#line 216 "ast_expr2.y"
+ case 15:
+#line 219 "ast_expr2.y"
{ (yyval.val) = op_minus ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 15:
-#line 220 "ast_expr2.y"
+ case 16:
+#line 223 "ast_expr2.y"
{ (yyval.val) = op_negate ((yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-1]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 16:
-#line 224 "ast_expr2.y"
+ case 17:
+#line 227 "ast_expr2.y"
{ (yyval.val) = op_compl ((yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-1]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 17:
-#line 228 "ast_expr2.y"
+ case 18:
+#line 231 "ast_expr2.y"
{ (yyval.val) = op_times ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 18:
-#line 232 "ast_expr2.y"
+ case 19:
+#line 235 "ast_expr2.y"
{ (yyval.val) = op_div ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 19:
-#line 236 "ast_expr2.y"
+ case 20:
+#line 239 "ast_expr2.y"
{ (yyval.val) = op_rem ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 20:
-#line 240 "ast_expr2.y"
+ case 21:
+#line 243 "ast_expr2.y"
{ (yyval.val) = op_colon ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 21:
-#line 244 "ast_expr2.y"
+ case 22:
+#line 247 "ast_expr2.y"
{ (yyval.val) = op_eqtilde ((yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-1].val));
(yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;;}
break;
- case 22:
-#line 248 "ast_expr2.y"
+ case 23:
+#line 251 "ast_expr2.y"
{ (yyval.val) = op_cond ((yyvsp[-4].val), (yyvsp[-2].val), (yyvsp[0].val));
DESTROY((yyvsp[-3].val));
DESTROY((yyvsp[-1].val));
@@ -1438,10 +1530,11 @@
break;
+ default: break;
}
-/* Line 1037 of yacc.c. */
-#line 1445 "ast_expr2.c"
+/* Line 1126 of yacc.c. */
+#line 1538 "ast_expr2.c"
yyvsp -= yylen;
yyssp -= yylen;
@@ -1480,11 +1573,35 @@
if (YYPACT_NINF < yyn && yyn < YYLAST)
{
- YYSIZE_T yysize = 0;
int yytype = YYTRANSLATE (yychar);
- const char* yyprefix;
- char *yymsg;
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+ YYSIZE_T yysize = yysize0;
+ YYSIZE_T yysize1;
+ int yysize_overflow = 0;
+ char *yymsg = 0;
+# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
int yyx;
+
+#if 0
+ /* This is so xgettext sees the translatable formats that are
+ constructed on the fly. */
+ YY_("syntax error, unexpected %s");
+ YY_("syntax error, unexpected %s, expecting %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
+#endif
+ char *yyfmt;
+ char const *yyf;
+ static char const yyunexpected[] = "syntax error, unexpected %s";
+ static char const yyexpecting[] = ", expecting %s";
+ static char const yyor[] = " or %s";
+ char yyformat[sizeof yyunexpected
+ + sizeof yyexpecting - 1
+ + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
+ * (sizeof yyor - 1))];
+ char const *yyprefix = yyexpecting;
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. */
@@ -1493,48 +1610,68 @@
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yycount = 0;
-
- yyprefix = ", expecting ";
+ int yycount = 1;
+
+ yyarg[0] = yytname[yytype];
+ yyfmt = yystpcpy (yyformat, yyunexpected);
+
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
{
- yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
- yycount += 1;
- if (yycount == 5)
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
- yysize = 0;
+ yycount = 1;
+ yysize = yysize0;
+ yyformat[sizeof yyunexpected - 1] = '\0';
break;
}
+ yyarg[yycount++] = yytname[yyx];
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ yysize_overflow |= yysize1 < yysize;
+ yysize = yysize1;
+ yyfmt = yystpcpy (yyfmt, yyprefix);
+ yyprefix = yyor;
}
- yysize += (sizeof ("syntax error, unexpected ")
- + yystrlen (yytname[yytype]));
- yymsg = (char *) YYSTACK_ALLOC (yysize);
- if (yymsg != 0)
+
+ yyf = YY_(yyformat);
+ yysize1 = yysize + yystrlen (yyf);
+ yysize_overflow |= yysize1 < yysize;
+ yysize = yysize1;
+
+ if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
+ yymsg = (char *) YYSTACK_ALLOC (yysize);
+ if (yymsg)
{
- char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
- yyp = yystpcpy (yyp, yytname[yytype]);
-
- if (yycount < 5)
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ char *yyp = yymsg;
+ int yyi = 0;
+ while ((*yyp = *yyf))
{
- yyprefix = ", expecting ";
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- {
- yyp = yystpcpy (yyp, yyprefix);
- yyp = yystpcpy (yyp, yytname[yyx]);
- yyprefix = " or ";
- }
+ if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyf += 2;
+ }
+ else
+ {
+ yyp++;
+ yyf++;
+ }
}
yyerror (yymsg);
YYSTACK_FREE (yymsg);
}
else
- yyerror ("syntax error; also virtual memory exhausted");
+ {
+ yyerror (YY_("syntax error"));
+ goto yyexhaustedlab;
+ }
}
else
#endif /* YYERROR_VERBOSE */
- yyerror ("syntax error");
+ yyerror (YY_("syntax error"));
}
yyerror_range[0] = yylloc;
@@ -1546,18 +1683,9 @@
if (yychar <= YYEOF)
{
- /* If at end of input, pop the error token,
- then the rest of the stack, then return failure. */
+ /* Return failure if at end of input. */
if (yychar == YYEOF)
- for (;;)
- {
- yyerror_range[0] = *yylsp;
- YYPOPSTACK;
- if (yyssp == yyss)
- YYABORT;
- yydestruct ("Error: popping",
- yystos[*yyssp], yyvsp, yylsp);
- }
+ YYABORT;
}
else
{
@@ -1576,12 +1704,11 @@
`---------------------------------------------------*/
yyerrorlab:
-#ifdef __GNUC__
- /* Pacify GCC when the user code never invokes YYERROR and the label
- yyerrorlab therefore never appears in user code. */
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
if (0)
goto yyerrorlab;
-#endif
yyerror_range[0] = yylsp[1-yylen];
yylsp -= yylen;
@@ -1651,23 +1778,29 @@
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
- yydestruct ("Error: discarding lookahead",
- yytoken, &yylval, &yylloc);
- yychar = YYEMPTY;
yyresult = 1;
goto yyreturn;
#ifndef yyoverflow
-/*----------------------------------------------.
-| yyoverflowlab -- parser overflow comes here. |
-`----------------------------------------------*/
-yyoverflowlab:
- yyerror ("parser stack overflow");
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (YY_("memory exhausted"));
yyresult = 2;
/* Fall through. */
#endif
yyreturn:
+ if (yychar != YYEOF && yychar != YYEMPTY)
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval, &yylloc);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp, yylsp);
+ YYPOPSTACK;
+ }
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
@@ -1676,7 +1809,7 @@
}
-#line 255 "ast_expr2.y"
+#line 258 "ast_expr2.y"
static struct val *
@@ -1847,11 +1980,40 @@
int main(int argc,char **argv) {
char s[4096];
+ char out[4096];
+ FILE *infile;
- if (ast_expr(argv[1], s, sizeof(s)))
- printf("=====%s======\n",s);
+ if( !argv[1] )
+ exit(20);
+
+ if( access(argv[1],F_OK)== 0 )
+ {
+ int ret;
+
+ infile = fopen(argv[1],"r");
+ if( !infile )
+ {
+ printf("Sorry, couldn't open %s for reading!\n", argv[1]);
+ exit(10);
+ }
+ while( fgets(s,sizeof(s),infile) )
+ {
+ if( s[strlen(s)-1] == '\n' )
+ s[strlen(s)-1] = 0;
+
+ ret = ast_expr(s, out, sizeof(out));
+ printf("Expression: %s Result: [%d] '%s'\n",
+ s, ret, out);
+ }
+ fclose(infile);
+ }
else
- printf("No result\n");
+ {
+ if (ast_expr(argv[1], s, sizeof(s)))
+ printf("=====%s======\n",s);
+ else
+ printf("No result\n");
+ }
}
#endif
@@ -2075,7 +2237,8 @@
struct val *r;
if (!to_integer (a)) {
- ast_log(LOG_WARNING,"non-numeric argument\n");
+ if( !extra_error_message_supplied )
+ ast_log(LOG_WARNING,"non-numeric argument\n");
if (!to_integer (b)) {
free_value(a);
free_value(b);
@@ -2118,7 +2281,8 @@
struct val *r;
if (!to_integer (a)) {
- ast_log(LOG_WARNING, "non-numeric argument\n");
+ if( !extra_error_message_supplied )
+ ast_log(LOG_WARNING, "non-numeric argument\n");
if (!to_integer (b)) {
free_value(a);
free_value(b);
@@ -2130,7 +2294,8 @@
return (r);
}
} else if (!to_integer(b)) {
- ast_log(LOG_WARNING, "non-numeric argument\n");
+ if( !extra_error_message_supplied )
+ ast_log(LOG_WARNING, "non-numeric argument\n");
free_value(b);
return (a);
}
@@ -2151,7 +2316,8 @@
if (!to_integer (a) ) {
free_value(a);
- ast_log(LOG_WARNING, "non-numeric argument\n");
+ if( !extra_error_message_supplied )
+ ast_log(LOG_WARNING, "non-numeric argument\n");
return make_integer(0);
}
@@ -2233,7 +2399,8 @@
if (!to_integer (a) || !to_integer (b)) {
free_value(a);
free_value(b);
- ast_log(LOG_WARNING, "non-numeric argument\n");
+ if( !extra_error_message_supplied )
+ ast_log(LOG_WARNING, "non-numeric argument\n");
return(make_integer(0));
}
@@ -2265,12 +2432,14 @@
if (!to_integer (a)) {
free_value(a);
free_value(b);
- ast_log(LOG_WARNING, "non-numeric argument\n");
+ if( !extra_error_message_supplied )
+ ast_log(LOG_WARNING, "non-numeric argument\n");
return make_integer(0);
} else if (!to_integer (b)) {
free_value(a);
free_value(b);
- ast_log(LOG_WARNING, "non-numeric argument\n");
+ if( !extra_error_message_supplied )
+ ast_log(LOG_WARNING, "non-numeric argument\n");
return make_integer(INT_MAX);
}
@@ -2296,7 +2465,8 @@
struct val *r;
if (!to_integer (a) || !to_integer (b)) {
- ast_log(LOG_WARNING, "non-numeric argument\n");
+ if( !extra_error_message_supplied )
+ ast_log(LOG_WARNING, "non-numeric argument\n");
free_value(a);
free_value(b);
return make_integer(0);
Modified: team/murf/AEL2-1.2/ast_expr2.h
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2-1.2/ast_expr2.h?rev=19501&r1=19500&r2=19501&view=diff
==============================================================================
--- team/murf/AEL2-1.2/ast_expr2.h (original)
+++ team/murf/AEL2-1.2/ast_expr2.h Tue Apr 11 21:21:49 2006
@@ -1,7 +1,7 @@
-/* A Bison parser, made by GNU Bison 2.0. */
+/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton parser for Yacc-like parsing with Bison,
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,8 +15,8 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
@@ -52,6 +52,7 @@
TOKEN = 278
};
#endif
+/* Tokens. */
#define TOK_COLONCOLON 258
#define TOK_COND 259
#define TOK_OR 260
@@ -82,8 +83,8 @@
typedef union YYSTYPE {
struct val *val;
} YYSTYPE;
-/* Line 1318 of yacc.c. */
-#line 87 "ast_expr2.h"
+/* Line 1447 of yacc.c. */
+#line 88 "ast_expr2.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
Modified: team/murf/AEL2-1.2/ast_expr2f.c
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2-1.2/ast_expr2f.c?rev=19501&r1=19500&r2=19501&view=diff
==============================================================================
--- team/murf/AEL2-1.2/ast_expr2f.c (original)
+++ team/murf/AEL2-1.2/ast_expr2f.c Tue Apr 11 21:21:49 2006
@@ -523,34 +523,34 @@
7, -11, -11, -11, -11, -11, -11, -11, -11, -11,
-11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
-11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
- -11, -11, -11, 36, -11, 36, 36, 36, -11, 36,
- -11, -11, -11, -11, 36, -11, 36, -11, 36, 36,
- 36, 36, 36, 36, 36, 36, 36, 36, -11, 36,
- -11, 37, -11, -11, 36, 36, 36, 36, 36, 36,
-
- 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
- 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
- 36, -11, 36, -11, 36, 36, -11, 36, 36, 36,
- 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
- 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
- 36, 36, 36, -11, -11, -11, -11, -11
- },
-
- {
- 7, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 38, 38, 38, 38, 39, 38, 38, 38, 38, 38,
-
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
- 38, 38, 38, 38, 38, 38, 38, 38
+ -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
+ -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
+ -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
+ -11, 36, -11, -11, -11, -11, -11, -11, -11, -11,
+
+ -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
+ -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
+ -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
+ -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
+ -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
+ -11, -11, -11, -11, -11, -11, -11, -11
+ },
+
+ {
+ 7, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 38, 37, 37, 37, 37, 37,
+
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 37, 37, 37, 37
},
{
@@ -558,51 +558,51 @@
[... 4560 lines stripped ...]
More information about the asterisk-commits
mailing list