[svn-commits] branch murf/AEL2 - r8253 in /team/murf/AEL2: ./
configs/ doc/ include/asteris...
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Wed Jan 18 22:26:10 MST 2006
Author: murf
Date: Wed Jan 18 23:25:20 2006
New Revision: 8253
URL: http://svn.digium.com/view/asterisk?rev=8253&view=rev
Log:
Committing all the current (0.12) files to SVN, even the flex/bison generated files, for those without the latest versions of these programs.
Added:
team/murf/AEL2/doc/README.ael2
team/murf/AEL2/include/asterisk/ael_structs.h
team/murf/AEL2/include/asterisk/argdesc.h
team/murf/AEL2/pbx/ael.flex
team/murf/AEL2/pbx/ael.tab.c
team/murf/AEL2/pbx/ael.tab.h
team/murf/AEL2/pbx/ael.y
team/murf/AEL2/pbx/ael_lex.c
team/murf/AEL2/pbx/applist
team/murf/AEL2/pbx/argdesc.l
team/murf/AEL2/pbx/argdesc.tab.c
team/murf/AEL2/pbx/argdesc.tab.h
team/murf/AEL2/pbx/argdesc.y
team/murf/AEL2/pbx/argdesc_lex.c
team/murf/AEL2/pbx/pbx_ael2.c
team/murf/AEL2/utils/ael_main.c
Modified:
team/murf/AEL2/CREDITS
team/murf/AEL2/ast_expr2.c
team/murf/AEL2/ast_expr2.fl
team/murf/AEL2/ast_expr2.h
team/murf/AEL2/ast_expr2.y
team/murf/AEL2/ast_expr2f.c
team/murf/AEL2/configs/extensions.ael.sample
team/murf/AEL2/doc/README.variables
team/murf/AEL2/pbx/Makefile
team/murf/AEL2/utils/Makefile
Modified: team/murf/AEL2/CREDITS
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2/CREDITS?rev=8253&r1=8252&r2=8253&view=diff
==============================================================================
--- team/murf/AEL2/CREDITS (original)
+++ team/murf/AEL2/CREDITS Wed Jan 18 23:25:20 2006
@@ -74,7 +74,7 @@
Steve Kann - new jitter buffer for IAX2
stevek at stevek.com
Constantine Filin - major contributions to the Asterisk Realtime Architecture
-Steve Murphy - privacy support
+Steve Murphy - privacy support, $[ ] parser upgrade, AEL2 parser upgrade
Claude Patry - bug fixes, feature enhancements, and bug marshalling
cpatry at gmail.com
Modified: team/murf/AEL2/ast_expr2.c
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2/ast_expr2.c?rev=8253&r1=8252&r2=8253&view=diff
==============================================================================
--- team/murf/AEL2/ast_expr2.c (original)
+++ team/murf/AEL2/ast_expr2.c Wed Jan 18 23:25:20 2006
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 1.875d. */
+/* A Bison parser, made by GNU Bison 2.0. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
@@ -45,8 +45,7 @@
/* Using locations. */
#define YYLSP_NEEDED 1
-/* If NAME_PREFIX is specified substitute the variables and functions
- names. */
+/* Substitute the variable and function names. */
#define yyparse ast_yyparse
#define yylex ast_yylex
#define yyerror ast_yyerror
@@ -160,6 +159,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
@@ -238,7 +239,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);}
/* Enabling traces. */
@@ -255,12 +256,12 @@
#endif
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 137 "ast_expr2.y"
+#line 139 "ast_expr2.y"
typedef union YYSTYPE {
struct val *val;
} YYSTYPE;
-/* Line 191 of yacc.c. */
-#line 264 "ast_expr2.c"
+/* Line 190 of yacc.c. */
+#line 265 "ast_expr2.c"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
@@ -281,13 +282,13 @@
/* Copy the second part of user declarations. */
-#line 141 "ast_expr2.y"
+#line 143 "ast_expr2.y"
extern int ast_yylex __P((YYSTYPE *, YYLTYPE *, yyscan_t));
-/* Line 214 of yacc.c. */
-#line 291 "ast_expr2.c"
+/* Line 213 of yacc.c. */
+#line 292 "ast_expr2.c"
#if ! defined (yyoverflow) || YYERROR_VERBOSE
@@ -302,14 +303,10 @@
# ifdef YYSTACK_USE_ALLOCA
# if YYSTACK_USE_ALLOCA
-# define YYSTACK_ALLOC alloca
-# endif
-# else
-# if defined (alloca) || defined (_ALLOCA_H)
-# define YYSTACK_ALLOC alloca
-# else
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
+# else
+# define YYSTACK_ALLOC alloca
# endif
# endif
# endif
@@ -402,7 +399,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
@@ -451,31 +448,31 @@
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, 160, 160, 168, 169, 172, 175, 178, 181, 184,
- 187, 190, 193, 196, 199, 202, 205, 208, 211, 214,
- 217, 220, 223
+ 0, 162, 162, 170, 177, 178, 182, 186, 190, 194,
+ 198, 202, 206, 210, 214, 218, 222, 226, 230, 234,
+ 238, 242, 246, 250
};
#endif
@@ -506,17 +503,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 +521,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]. */
@@ -660,19 +657,52 @@
} \
while (0)
+
#define YYTERROR 1
#define YYERRCODE 256
-/* YYLLOC_DEFAULT -- Compute the default location (before the actions
- are run). */
-
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- ((Current).first_line = (Rhs)[1].first_line, \
- (Current).first_column = (Rhs)[1].first_column, \
- (Current).last_line = (Rhs)[N].last_line, \
- (Current).last_column = (Rhs)[N].last_column)
-#endif
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (N) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (0)
+#endif
+
+
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+ This macro was not mandated originally: define only if we know
+ we won't break user code: when these are the locations we know. */
+
+#ifndef YY_LOCATION_PRINT
+# if YYLTYPE_IS_TRIVIAL
+# define YY_LOCATION_PRINT(File, Loc) \
+ fprintf (File, "%d.%d-%d.%d", \
+ (Loc).first_line, (Loc).first_column, \
+ (Loc).last_line, (Loc).last_column)
+# else
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
+#endif
+
/* YYLEX -- calling `yylex' with the right arguments. */
@@ -696,19 +726,13 @@
YYFPRINTF Args; \
} while (0)
-# define YYDSYMPRINT(Args) \
-do { \
- if (yydebug) \
- yysymprint Args; \
-} while (0)
-
-# define YYDSYMPRINTF(Title, Token, Value, Location) \
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yysymprint (stderr, \
- Token, Value, Location); \
+ Type, Value, Location); \
YYFPRINTF (stderr, "\n"); \
} \
} while (0)
@@ -775,8 +799,7 @@
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
-# define YYDSYMPRINT(Args)
-# define YYDSYMPRINTF(Title, Token, Value, Location)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
@@ -793,10 +816,6 @@
Do not make this value too large; the results are undefined if
SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
-
-#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
-# undef YYMAXDEPTH
-#endif
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
@@ -881,15 +900,17 @@
(void) yylocationp;
if (yytype < YYNTOKENS)
- {
- YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
-# ifdef YYPRINT
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# endif
- }
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
else
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+ YY_LOCATION_PRINT (yyoutput, *yylocationp);
+ fprintf (yyoutput, ": ");
+
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# endif
switch (yytype)
{
default:
@@ -905,10 +926,11 @@
#if defined (__STDC__) || defined (__cplusplus)
static void
-yydestruct (int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
#else
static void
-yydestruct (yytype, yyvaluep, yylocationp)
+yydestruct (yymsg, yytype, yyvaluep, yylocationp)
+ const char *yymsg;
int yytype;
YYSTYPE *yyvaluep;
YYLTYPE *yylocationp;
@@ -917,6 +939,10 @@
/* Pacify ``unused variable'' warnings. */
(void) yyvaluep;
(void) yylocationp;
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
switch (yytype)
{
@@ -970,15 +996,15 @@
#endif
#endif
{
- /* The lookahead symbol. */
+ /* The look-ahead symbol. */
int yychar;
-/* The semantic value of the lookahead symbol. */
+/* The semantic value of the look-ahead symbol. */
YYSTYPE yylval;
/* Number of syntax errors so far. */
int yynerrs;
-/* Location data for the lookahead symbol. */
+/* Location data for the look-ahead symbol. */
YYLTYPE yylloc;
register int yystate;
@@ -986,7 +1012,7 @@
int yyresult;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
- /* Lookahead token as an internal (translated) token number. */
+ /* Look-ahead token as an internal (translated) token number. */
int yytoken = 0;
/* Three stacks and their tools:
@@ -1011,7 +1037,8 @@
YYLTYPE yylsa[YYINITDEPTH];
YYLTYPE *yyls = yylsa;
YYLTYPE *yylsp;
- YYLTYPE *yylerrsp;
+ /* The locations where the error started and ended. */
+ YYLTYPE yyerror_range[2];
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
@@ -1041,6 +1068,15 @@
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
+#if YYLTYPE_IS_TRIVIAL
+ /* Initialize the default location before parsing starts. */
+ yylloc.first_line = yylloc.last_line = 1;
+ yylloc.first_column = yylloc.last_column = 0;
+#endif
+
+
+ yyvsp[0] = yylval;
+ yylsp[0] = yylloc;
goto yysetstate;
@@ -1131,18 +1167,18 @@
yybackup:
/* Do appropriate processing given the current state. */
-/* Read a lookahead token if we need one and don't already have one. */
+/* Read a look-ahead token if we need one and don't already have one. */
/* yyresume: */
- /* First try to decide what to do without reference to lookahead token. */
+ /* First try to decide what to do without reference to look-ahead token. */
yyn = yypact[yystate];
if (yyn == YYPACT_NINF)
goto yydefault;
- /* Not known => get a lookahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ /* Not known => get a look-ahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
@@ -1157,7 +1193,7 @@
else
{
yytoken = YYTRANSLATE (yychar);
- YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
@@ -1177,8 +1213,8 @@
if (yyn == YYFINAL)
YYACCEPT;
- /* Shift the lookahead token. */
- YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
+ /* Shift the look-ahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
@@ -1229,158 +1265,188 @@
switch (yyn)
{
case 2:
-#line 160 "ast_expr2.y"
+#line 162 "ast_expr2.y"
{ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
- ((struct parse_io *)parseio)->val->type = yyval.val->type;
- if( yyval.val->type == AST_EXPR_integer )
- ((struct parse_io *)parseio)->val->u.i = yyval.val->u.i;
+ ((struct parse_io *)parseio)->val->type = (yyvsp[0].val)->type;
+ if( (yyvsp[0].val)->type == AST_EXPR_integer )
+ ((struct parse_io *)parseio)->val->u.i = (yyvsp[0].val)->u.i;
else
- ((struct parse_io *)parseio)->val->u.s = yyval.val->u.s; ;}
+ ((struct parse_io *)parseio)->val->u.s = (yyvsp[0].val)->u.s;
+ free((yyvsp[0].val));
+ ;}
break;
case 3:
-#line 168 "ast_expr2.y"
- { yyval.val= yyvsp[0].val;;}
+#line 170 "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 169 "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;;}
+#line 177 "ast_expr2.y"
+ { (yyval.val)= (yyvsp[0].val);;}
break;
case 5:
-#line 172 "ast_expr2.y"
- { yyval.val = op_or (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 178 "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 6:
-#line 175 "ast_expr2.y"
- { yyval.val = op_and (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 182 "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 7:
-#line 178 "ast_expr2.y"
- { yyval.val = op_eq (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 186 "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 8:
-#line 181 "ast_expr2.y"
- { yyval.val = op_gt (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 190 "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 9:
-#line 184 "ast_expr2.y"
- { yyval.val = op_lt (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 194 "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 10:
-#line 187 "ast_expr2.y"
- { yyval.val = op_ge (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 198 "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 11:
-#line 190 "ast_expr2.y"
- { yyval.val = op_le (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 202 "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 12:
-#line 193 "ast_expr2.y"
- { yyval.val = op_ne (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 206 "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 13:
-#line 196 "ast_expr2.y"
- { yyval.val = op_plus (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 210 "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 14:
-#line 199 "ast_expr2.y"
- { yyval.val = op_minus (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 214 "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 15:
-#line 202 "ast_expr2.y"
- { yyval.val = op_negate (yyvsp[0].val);
- yyloc.first_column = yylsp[-1].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 218 "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 16:
-#line 205 "ast_expr2.y"
- { yyval.val = op_compl (yyvsp[0].val);
- yyloc.first_column = yylsp[-1].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 222 "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 17:
-#line 208 "ast_expr2.y"
- { yyval.val = op_times (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 226 "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 18:
-#line 211 "ast_expr2.y"
- { yyval.val = op_div (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 230 "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 19:
-#line 214 "ast_expr2.y"
- { yyval.val = op_rem (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 234 "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 20:
-#line 217 "ast_expr2.y"
- { yyval.val = op_colon (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 238 "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 21:
-#line 220 "ast_expr2.y"
- { yyval.val = op_eqtilde (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 242 "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 22:
-#line 223 "ast_expr2.y"
- { yyval.val = op_cond (yyvsp[-4].val, yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-4].first_column; yyloc.last_column = yylsp[-2].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 246 "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 23:
+#line 250 "ast_expr2.y"
+ { (yyval.val) = op_cond ((yyvsp[-4].val), (yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-3].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-4]).first_column; (yyloc).last_column = (yylsp[-2]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
+ break;
+
}
-/* Line 1010 of yacc.c. */
-#line 1384 "ast_expr2.c"
+/* Line 1037 of yacc.c. */
+#line 1450 "ast_expr2.c"
yyvsp -= yylen;
yyssp -= yylen;
@@ -1476,11 +1542,11 @@
yyerror ("syntax error");
}
- yylerrsp = yylsp;
+ yyerror_range[0] = yylloc;
if (yyerrstatus == 3)
{
- /* If just tried and failed to reuse lookahead token after an
+ /* If just tried and failed to reuse look-ahead token after an
error, discard it. */
if (yychar <= YYEOF)
@@ -1490,23 +1556,22 @@
if (yychar == YYEOF)
for (;;)
{
+ yyerror_range[0] = *yylsp;
YYPOPSTACK;
if (yyssp == yyss)
YYABORT;
- YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
- yydestruct (yystos[*yyssp], yyvsp, yylsp);
+ yydestruct ("Error: popping",
+ yystos[*yyssp], yyvsp, yylsp);
}
}
else
{
- YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
- yydestruct (yytoken, &yylval, &yylloc);
+ yydestruct ("Error: discarding", yytoken, &yylval, &yylloc);
yychar = YYEMPTY;
- *++yylerrsp = yylloc;
}
}
- /* Else will try to reuse lookahead token after shifting the error
+ /* Else will try to reuse look-ahead token after shifting the error
token. */
goto yyerrlab1;
@@ -1523,12 +1588,11 @@
goto yyerrorlab;
#endif
+ yyerror_range[0] = yylsp[1-yylen];
+ yylsp -= yylen;
yyvsp -= yylen;
yyssp -= yylen;
yystate = *yyssp;
- yylerrsp = yylsp;
- *++yylerrsp = yyloc;
- yylsp -= yylen;
goto yyerrlab1;
@@ -1556,8 +1620,8 @@
if (yyssp == yyss)
YYABORT;
- YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
- yydestruct (yystos[yystate], yyvsp, yylsp);
+ yyerror_range[0] = *yylsp;
+ yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp);
YYPOPSTACK;
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
@@ -1566,11 +1630,16 @@
if (yyn == YYFINAL)
YYACCEPT;
- YYDPRINTF ((stderr, "Shifting error token, "));
-
*++yyvsp = yylval;
- YYLLOC_DEFAULT (yyloc, yylsp, yylerrsp - yylsp);
+
+ yyerror_range[1] = yylloc;
+ /* Using YYLLOC is tempting, but would change the location of
+ the look-ahead. YYLOC is available though. */
+ YYLLOC_DEFAULT (yyloc, yyerror_range - 1, 2);
*++yylsp = yyloc;
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
@@ -1587,6 +1656,9 @@
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
+ yydestruct ("Error: discarding lookahead",
+ yytoken, &yylval, &yylloc);
+ yychar = YYEMPTY;
yyresult = 1;
goto yyreturn;
@@ -1609,7 +1681,7 @@
}
-#line 228 "ast_expr2.y"
+#line 257 "ast_expr2.y"
static struct val *
@@ -1666,6 +1738,7 @@
}
if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
free (vp->u.s);
+ free(vp);
}
@@ -2007,7 +2080,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);
@@ -2050,7 +2124,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);
@@ -2062,7 +2137,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);
}
@@ -2083,7 +2159,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);
}
@@ -2165,7 +2242,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));
}
@@ -2197,12 +2275,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);
}
@@ -2228,7 +2308,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/ast_expr2.fl
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2/ast_expr2.fl?rev=8253&r1=8252&r2=8253&view=diff
==============================================================================
--- team/murf/AEL2/ast_expr2.fl (original)
+++ team/murf/AEL2/ast_expr2.fl Wed Jan 18 23:25:20 2006
@@ -19,7 +19,7 @@
/*! \file
*
- * \brief Dialplan Expression Parser
+ * \brief Dialplan Expression Lexical Scanner
*/
#include <sys/types.h>
@@ -67,7 +67,8 @@
void ast_yyset_column(int column_no, yyscan_t yyscanner);
int ast_yyget_column(yyscan_t yyscanner);
-
+static int curlycount = 0;
+static char *expr2_token_subst(char *mess);
%}
%option prefix="ast_yy"
@@ -77,12 +78,17 @@
%option bison-bridge
%option bison-locations
%option noyywrap
+%x var trail
%%
\| { SET_COLUMNS; SET_STRING; return TOK_OR;}
\& { SET_COLUMNS; SET_STRING; return TOK_AND;}
\= { SET_COLUMNS; SET_STRING; return TOK_EQ;}
+\|\| { SET_COLUMNS; SET_STRING; return TOK_OR;}
+\&\& { SET_COLUMNS; SET_STRING; return TOK_AND;}
+\=\= { SET_COLUMNS; SET_STRING; return TOK_EQ;}
+\=~ { SET_COLUMNS; SET_STRING; return TOK_EQTILDE;}
\> { SET_COLUMNS; SET_STRING; return TOK_GT;}
\< { SET_COLUMNS; SET_STRING; return TOK_LT;}
\>\= { SET_COLUMNS; SET_STRING; return TOK_GE;}
@@ -98,6 +104,8 @@
\:\: { SET_COLUMNS; SET_STRING; return TOK_COLONCOLON;}
\( { SET_COLUMNS; SET_STRING; return TOK_LP;}
\) { SET_COLUMNS; SET_STRING; return TOK_RP;}
+\$\{ {/* gather the contents of ${} expressions, with trailing stuff, into a single TOKEN. They are much more complex now than they used to be */
+ curlycount = 0; BEGIN(var); yymore();}
[ \r] {}
\"[^"]*\" {SET_COLUMNS; SET_STRING; return TOKEN;}
@@ -106,7 +114,14 @@
[0-9]+ { SET_COLUMNS; /* the original behavior of the expression parser was to bring in numbers as a numeric string */
SET_NUMERIC_STRING;
return TOKEN;}
-[a-zA-Z0-9,.';{}\\_^%$#@!]+ {SET_COLUMNS; SET_STRING; return TOKEN;}
+[a-zA-Z0-9,.';\\_^%$#@!]+ {SET_COLUMNS; SET_STRING; return TOKEN;}
+
+<var>[^{}]*\} {curlycount--; if(curlycount < 0){ BEGIN(trail); yymore();} else { yymore();}}
+<var>[^{}]*\{ {curlycount++; yymore(); }
+<trail>[^-\t\r \n$():?%/+=*<>!|&]* {BEGIN(0); SET_COLUMNS; SET_STRING; return TOKEN;}
+<trail>[-\t\r \n$():?%/+=*<>!|&] {char c = yytext[yyleng-1]; BEGIN(0); unput(c); SET_COLUMNS; SET_STRING; return TOKEN;}
+<trail>\$\{ {curlycount = 0; BEGIN(var); yymore(); }
+<trail><<EOF>> {BEGIN(0); SET_COLUMNS; SET_STRING; return TOKEN; /*actually, if an expr is only a variable ref, this could happen a LOT */}
%%
@@ -153,10 +168,123 @@
ast_copy_string(buf, io.val->u.s, length);
#endif /* STANDALONE */
return_value = strlen(buf);
+ free(io.val->u.s);
}
free(io.val);
}
return return_value;
+}
+
+
+char extra_error_message[4095];
+int extra_error_message_supplied = 0;
+void ast_expr_register_extra_error_info(char *message);
+void ast_expr_clear_extra_error_info(void);
+
+void ast_expr_register_extra_error_info(char *message)
+{
+ extra_error_message_supplied=1;
+ strcpy(extra_error_message, message);
+}
+
+void ast_expr_clear_extra_error_info(void)
+{
+ extra_error_message_supplied=0;
+ extra_error_message[0] = 0;
+}
+
+static char *expr2_token_equivs1[] =
+{
+ "TOKEN",
+ "TOK_COND",
+ "TOK_COLONCOLON",
+ "TOK_OR",
+ "TOK_AND",
+ "TOK_EQ",
+ "TOK_GT",
+ "TOK_LT",
+ "TOK_GE",
+ "TOK_LE",
+ "TOK_NE",
+ "TOK_PLUS",
+ "TOK_MINUS",
+ "TOK_MULT",
+ "TOK_DIV",
+ "TOK_MOD",
+ "TOK_COMPL",
+ "TOK_COLON",
+ "TOK_EQTILDE",
+ "TOK_RP",
+ "TOK_LP"
+};
+
+static char *expr2_token_equivs2[] =
+{
+ "<token>",
+ "?",
+ "::",
+ "|",
+ "&",
+ "=",
+ ">",
+ "<",
+ ">=",
+ "<=",
+ "!=",
+ "+",
+ "-",
+ "*",
+ "/",
+ "%",
+ "~",
+ ":",
+ "=~",
+ ")",
+ "("
+};
+
+
+static char *expr2_token_subst(char *mess)
+{
+ /* calc a length, malloc, fill, and return; yyerror had better free it! */
+ int len=0,i;
+ char *p;
+ char *res, *s,*t;
+ int expr2_token_equivs_entries = sizeof(expr2_token_equivs1)/sizeof(char*);
+
+ for (p=mess; *p; p++) {
+ for (i=0; i<expr2_token_equivs_entries; i++) {
+ if ( strncmp(p,expr2_token_equivs1[i],strlen(expr2_token_equivs1[i])) == 0 )
+ {
+ len+=strlen(expr2_token_equivs2[i])+2;
+ p += strlen(expr2_token_equivs1[i])-1;
+ break;
+ }
+ }
+ len++;
+ }
+ res = (char*)malloc(len+1);
+ res[0] = 0;
+ s = res;
+ for (p=mess; *p;) {
+ int found = 0;
+ for (i=0; i<expr2_token_equivs_entries; i++) {
+ if ( strncmp(p,expr2_token_equivs1[i],strlen(expr2_token_equivs1[i])) == 0 ) {
+ *s++ = '\'';
+ for (t=expr2_token_equivs2[i]; *t;) {
+ *s++ = *t++;
+ }
+ *s++ = '\'';
+ p += strlen(expr2_token_equivs1[i]);
+ found = 1;
+ break;
+ }
+ }
+ if( !found )
+ *s++ = *p++;
+ }
+ *s++ = 0;
+ return res;
}
int ast_yyerror (const char *s, yyltype *loc, struct parse_io *parseio )
@@ -165,19 +293,10 @@
char spacebuf[8000]; /* best safe than sorry */
char spacebuf2[8000]; /* best safe than sorry */
int i=0;
+ char *s2 = expr2_token_subst((char *)s);
spacebuf[0] = 0;
-
-#ifdef WHEN_LOC_MEANS_SOMETHING
- if( loc->first_column > 7990 ) /* if things get out of whack, why crash? */
- loc->first_column = 7990;
- if( loc->last_column > 7990 )
- loc->last_column = 7990;
- for(i=0;i<loc->first_column;i++) spacebuf[i] = ' ';
- for( ;i<loc->last_column;i++) spacebuf[i] = '^';
- spacebuf[i] = 0;
-#endif
for(i=0;i< (int)(yytext - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf);i++) spacebuf2[i] = ' '; /* uh... assuming yyg is defined, then I can use the yycolumn macro,
- which is the same thing as... get this:
+ which is the same thing as... get this:
yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column
I was tempted to just use yy_buf_pos in the STATE, but..., well:
a. the yy_buf_pos is the current position in the buffer, which
@@ -192,14 +311,15 @@
#ifdef STANDALONE3
/* easier to read in the standalone version */
- printf("ast_yyerror(): syntax error: %s; Input:\n%s\n%s\n",
- s, parseio->string,spacebuf2);
+ printf("ast_yyerror(): %s syntax error: %s; Input:\n%s\n%s\n",
+ (extra_error_message_supplied?extra_error_message:""), s2, parseio->string,spacebuf2);
#else
- ast_log(LOG_WARNING,"ast_yyerror(): syntax error: %s; Input:\n%s\n%s\n",
- s, parseio->string,spacebuf2);
+ ast_log(LOG_WARNING,"ast_yyerror(): %s syntax error: %s; Input:\n%s\n%s\n",
+ (extra_error_message_supplied?extra_error_message:""), s2, parseio->string,spacebuf2);
#endif
#ifndef STANDALONE
ast_log(LOG_WARNING,"If you have questions, please refer to doc/README.variables in the asterisk source.\n");
#endif
+ free(s2);
return(0);
}
[... 19228 lines stripped ...]
More information about the svn-commits
mailing list