2006-04-24 17:41:27 +00:00
%{
/*
2006-04-26 18:43:29 +00:00
* Asterisk -- An open source telephony toolkit.
2006-04-24 17:41:27 +00:00
*
* Copyright (C) 2006, Digium, Inc.
*
* Steve Murphy <murf@parsetree.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*! \file
*
* \brief Bison Grammar description of AEL2.
2006-04-26 18:43:29 +00:00
*
2006-04-24 17:41:27 +00:00
*/
2006-06-07 18:54:56 +00:00
#include "asterisk.h"
2008-09-27 15:00:48 +00:00
#if !defined(STANDALONE_AEL)
2006-06-07 18:54:56 +00:00
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
2008-09-27 15:00:48 +00:00
#endif
2006-06-07 18:54:56 +00:00
2006-04-24 17:41:27 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
2006-06-07 18:54:56 +00:00
2006-04-24 17:41:27 +00:00
#include "asterisk/logger.h"
#include "asterisk/ael_structs.h"
2006-04-28 14:17:03 +00:00
static pval * linku1(pval *head, pval *tail);
2006-08-07 12:59:47 +00:00
static void set_dads(pval *dad, pval *child_list);
2006-04-26 22:41:16 +00:00
void reset_parencount(yyscan_t yyscanner);
void reset_semicount(yyscan_t yyscanner);
void reset_argcount(yyscan_t yyscanner );
2006-04-24 17:41:27 +00:00
#define YYLEX_PARAM ((struct parse_io *)parseio)->scanner
#define YYERROR_VERBOSE 1
extern char *my_file;
#ifdef AAL_ARGCHECK
int ael_is_funcname(char *name);
#endif
2007-09-21 14:37:20 +00:00
static char *ael_token_subst(const char *mess);
2006-04-26 18:43:29 +00:00
2006-04-24 17:41:27 +00:00
%}
%union {
2006-04-30 12:44:54 +00:00
int intval; /* integer value, typically flags */
char *str; /* strings */
struct pval *pval; /* full objects */
2006-04-24 17:41:27 +00:00
}
%{
/* declaring these AFTER the union makes things a lot simpler! */
void yyerror(YYLTYPE *locp, struct parse_io *parseio, char const *s);
int ael_yylex (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , void * yyscanner);
2006-04-26 18:43:29 +00:00
2006-04-30 13:57:08 +00:00
/* create a new object with start-end marker */
static pval *npval(pvaltype type, int first_line, int last_line,
int first_column, int last_column);
2006-04-27 18:09:20 +00:00
/* create a new object with start-end marker, simplified interface.
* Must be declared here because YYLTYPE is not known before
*/
static pval *npval2(pvaltype type, YYLTYPE *first, YYLTYPE *last);
2006-04-30 12:12:39 +00:00
2006-04-30 13:57:08 +00:00
/* another frontend for npval, this time for a string */
static pval *nword(char *string, YYLTYPE *pos);
2006-04-30 12:12:39 +00:00
/* update end position of an object, return the object */
static pval *update_last(pval *, YYLTYPE *);
2006-04-24 17:41:27 +00:00
%}
2006-04-26 18:43:29 +00:00
2006-04-24 17:41:27 +00:00
%token KW_CONTEXT LC RC LP RP SEMI EQ COMMA COLON AMPER BAR AT
closes issue #11086 where a user complains that references to following contexts report a problem; The problem was REALLy that he was referring to empty contexts, which were being ignored. Reporter stated that empty contexts should be OK. I checked it out against extensions.conf, and sure enough, empty contexts ARE ok. So, I removed the restriction from AEL. This, though, highlighted a problem with multiple contexts of the same name. This should be OK, also. So, I added the extend keyword to AEL, and it can preceed the 'context' keyword (mixed with 'abstract', if nec.). This will turn off the warnings in AEL if the same context name is used 2 or more times. Also, I now call ast_context_find_or_create for contexts now, instead of just ast_context_create; I did this because pbx_config does this. The 'extend' keyword thus becomes a statement of intent. AEL can now duplicate the behavior of pbx_config,
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@87168 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-10-26 16:34:02 +00:00
%token KW_MACRO KW_GLOBALS KW_IGNOREPAT KW_SWITCH KW_IF KW_IFTIME KW_ELSE KW_RANDOM KW_ABSTRACT KW_EXTEND
2006-04-24 17:41:27 +00:00
%token EXTENMARK KW_GOTO KW_JUMP KW_RETURN KW_BREAK KW_CONTINUE KW_REGEXTEN KW_HINT
%token KW_FOR KW_WHILE KW_CASE KW_PATTERN KW_DEFAULT KW_CATCH KW_SWITCHES KW_ESWITCHES
%token KW_INCLUDES
2006-04-30 08:21:46 +00:00
%right BAR COMMA
2006-04-24 17:41:27 +00:00
%token <str> word
%type <pval>includes
%type <pval>includeslist
%type <pval>switchlist
%type <pval>eswitches
%type <pval>switches
%type <pval>macro_statement
%type <pval>macro_statements
%type <pval>case_statement
%type <pval>case_statements
%type <pval>eval_arglist
%type <pval>application_call
%type <pval>application_call_head
%type <pval>macro_call
%type <pval>target jumptarget
%type <pval>statement
2006-05-03 16:08:35 +00:00
%type <pval>switch_statement
2006-04-27 19:51:59 +00:00
2006-05-02 18:08:27 +00:00
%type <pval>if_like_head
2006-04-24 17:41:27 +00:00
%type <pval>statements
%type <pval>extension
%type <pval>ignorepat
%type <pval>element
%type <pval>elements
%type <pval>arglist
2006-05-02 20:11:24 +00:00
%type <pval>assignment
2006-04-24 17:41:27 +00:00
%type <pval>global_statements
%type <pval>globals
%type <pval>macro
%type <pval>context
%type <pval>object
2006-04-26 18:43:29 +00:00
%type <pval>objects
%type <pval>file
2006-04-30 08:21:46 +00:00
/* XXX lr changes */
%type <pval>opt_else
2006-05-02 18:33:15 +00:00
%type <pval>timespec
2006-05-02 18:41:57 +00:00
%type <pval>included_entry
2006-04-30 08:21:46 +00:00
%type <str>opt_word
2006-05-02 18:45:18 +00:00
%type <str>context_name
2006-05-02 18:23:41 +00:00
%type <str>timerange
2006-04-24 17:41:27 +00:00
2006-04-27 19:51:59 +00:00
%type <str>goto_word
%type <str>word_list
2006-08-12 19:28:33 +00:00
%type <str>word3_list hint_word
2006-05-02 19:17:49 +00:00
%type <str>test_expr
2006-05-03 17:07:56 +00:00
%type <str>opt_pri
2006-04-27 19:51:59 +00:00
2006-04-30 12:44:54 +00:00
%type <intval>opt_abstract
2006-04-27 19:51:59 +00:00
/*
* OPTIONS
*/
%locations /* track source location using @n variables (yylloc in flex) */
%pure-parser /* pass yylval and yylloc as arguments to yylex(). */
2006-04-24 17:41:27 +00:00
%name-prefix="ael_yy"
2006-04-27 19:51:59 +00:00
/*
* add an additional argument, parseio, to yyparse(),
* which is then accessible in the grammar actions
*/
2006-04-24 17:41:27 +00:00
%parse-param {struct parse_io *parseio}
2006-04-27 19:51:59 +00:00
2006-04-26 18:43:29 +00:00
/* there will be two shift/reduce conflicts, they involve the if statement, where a single statement occurs not wrapped in curlies in the "true" section
2006-04-24 17:41:27 +00:00
the default action to shift will attach the else to the preceeding if. */
This patch fixes a regression of sorts that was introduced in
rev 24425.
It basically fixes AST-190/ABE-1782.
What was wrong: the user has 6000 extensions in one context; and
then 6000 contexts, one per extension. The parser could only handle
about 4893 of the 6000 extens in the single context.
This was due to the regression I mentioned. To get rid of
shift/reduce conflicts, Luigi set up right-recursive lists
for globals, context elements, switch lists, and statements.
Right recursive lists got rid of the warnings, but instead, they
use up a tremendous amount of stack space when the lists are long.
I saw this a few years back, and resolved not to fix it until
someone complained. That day has arrived!
After the changes were made, I ran the regression test suite,
and there were no problems.
I took the test case the user provided, and added 100,000
extensions to the single context, that already had 6,000 extens
in it. (I'll see your 6, and raise you 100!) It takes a few minutes
to read it all in, check it and generate code for it, but no
problems.
So, I think I can say that fundamentally, there are no longer
any limits on the number of items you can place in contexts,
statement blocks, switches, or globals, beyond your virt mem
constraints.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@177225 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-18 22:43:14 +00:00
%expect 28
2006-04-24 17:41:27 +00:00
%error-verbose
2006-04-27 19:51:59 +00:00
/*
* declare destructors for objects.
* The former is for pval, the latter for strings.
2006-04-27 21:09:52 +00:00
* NOTE: we must not have a destructor for a 'file' object.
2006-04-27 19:51:59 +00:00
*/
%destructor {
2006-04-27 21:09:52 +00:00
destroy_pval($$);
prev_word=0;
2006-04-27 19:51:59 +00:00
} includes includeslist switchlist eswitches switches
macro_statement macro_statements case_statement case_statements
eval_arglist application_call application_call_head
2006-05-03 16:08:35 +00:00
macro_call target jumptarget statement switch_statement
2006-05-02 18:08:27 +00:00
if_like_head statements extension
2006-05-02 20:11:24 +00:00
ignorepat element elements arglist assignment
2006-04-27 19:51:59 +00:00
global_statements globals macro context object objects
2006-04-30 08:21:46 +00:00
opt_else
2006-05-02 18:41:57 +00:00
timespec included_entry
2006-04-27 19:51:59 +00:00
2006-05-02 18:45:18 +00:00
%destructor { free($$);} word word_list goto_word word3_list opt_word context_name
2006-05-02 18:23:41 +00:00
timerange
2006-05-02 19:17:49 +00:00
test_expr
2006-05-03 17:07:56 +00:00
opt_pri
2006-04-24 17:41:27 +00:00
%%
file : objects { $$ = parseio->pval = $1; }
;
objects : object {$$=$1;}
2006-05-02 14:12:01 +00:00
| objects object { $$ = linku1($1, $2); }
2006-04-24 17:41:27 +00:00
| objects error {$$=$1;}
;
object : context {$$=$1;}
| macro {$$=$1;}
| globals {$$=$1;}
| SEMI {$$=0;/* allow older docs to be read */}
;
2006-05-02 18:45:18 +00:00
context_name : word { $$ = $1; }
2006-04-30 08:21:46 +00:00
| KW_DEFAULT { $$ = strdup("default"); }
;
2006-05-03 16:46:55 +00:00
context : opt_abstract KW_CONTEXT context_name LC elements RC {
closes issue #11086 where a user complains that references to following contexts report a problem; The problem was REALLy that he was referring to empty contexts, which were being ignored. Reporter stated that empty contexts should be OK. I checked it out against extensions.conf, and sure enough, empty contexts ARE ok. So, I removed the restriction from AEL. This, though, highlighted a problem with multiple contexts of the same name. This should be OK, also. So, I added the extend keyword to AEL, and it can preceed the 'context' keyword (mixed with 'abstract', if nec.). This will turn off the warnings in AEL if the same context name is used 2 or more times. Also, I now call ast_context_find_or_create for contexts now, instead of just ast_context_create; I did this because pbx_config does this. The 'extend' keyword thus becomes a statement of intent. AEL can now duplicate the behavior of pbx_config,
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@87168 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-10-26 16:34:02 +00:00
$$ = npval2(PV_CONTEXT, &@1, &@6);
$$->u1.str = $3;
$$->u2.statements = $5;
set_dads($$,$5);
$$->u3.abstract = $1;}
2006-04-30 12:44:54 +00:00
;
2006-05-02 17:58:57 +00:00
/* optional "abstract" keyword XXX there is no regression test for this */
2006-04-30 12:44:54 +00:00
opt_abstract: KW_ABSTRACT { $$ = 1; }
| /* nothing */ { $$ = 0; }
closes issue #11086 where a user complains that references to following contexts report a problem; The problem was REALLy that he was referring to empty contexts, which were being ignored. Reporter stated that empty contexts should be OK. I checked it out against extensions.conf, and sure enough, empty contexts ARE ok. So, I removed the restriction from AEL. This, though, highlighted a problem with multiple contexts of the same name. This should be OK, also. So, I added the extend keyword to AEL, and it can preceed the 'context' keyword (mixed with 'abstract', if nec.). This will turn off the warnings in AEL if the same context name is used 2 or more times. Also, I now call ast_context_find_or_create for contexts now, instead of just ast_context_create; I did this because pbx_config does this. The 'extend' keyword thus becomes a statement of intent. AEL can now duplicate the behavior of pbx_config,
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@87168 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-10-26 16:34:02 +00:00
| KW_EXTEND { $$ = 2; }
| KW_EXTEND KW_ABSTRACT { $$=3; }
| KW_ABSTRACT KW_EXTEND { $$=3; }
2006-04-24 17:41:27 +00:00
;
2006-04-27 02:29:32 +00:00
macro : KW_MACRO word LP arglist RP LC macro_statements RC {
2006-04-27 18:18:12 +00:00
$$ = npval2(PV_MACRO, &@1, &@8);
2006-08-07 12:59:47 +00:00
$$->u1.str = $2; $$->u2.arglist = $4; $$->u3.macro_statements = $7;
set_dads($$,$7);}
2006-04-24 17:41:27 +00:00
;
2006-04-27 02:29:32 +00:00
globals : KW_GLOBALS LC global_statements RC {
2006-04-28 10:06:10 +00:00
$$ = npval2(PV_GLOBALS, &@1, &@4);
2006-08-07 12:59:47 +00:00
$$->u1.statements = $3;
set_dads($$,$3);}
2006-04-24 17:41:27 +00:00
;
2006-05-03 16:28:48 +00:00
global_statements : { $$ = NULL; }
This patch fixes a regression of sorts that was introduced in
rev 24425.
It basically fixes AST-190/ABE-1782.
What was wrong: the user has 6000 extensions in one context; and
then 6000 contexts, one per extension. The parser could only handle
about 4893 of the 6000 extens in the single context.
This was due to the regression I mentioned. To get rid of
shift/reduce conflicts, Luigi set up right-recursive lists
for globals, context elements, switch lists, and statements.
Right recursive lists got rid of the warnings, but instead, they
use up a tremendous amount of stack space when the lists are long.
I saw this a few years back, and resolved not to fix it until
someone complained. That day has arrived!
After the changes were made, I ran the regression test suite,
and there were no problems.
I took the test case the user provided, and added 100,000
extensions to the single context, that already had 6,000 extens
in it. (I'll see your 6, and raise you 100!) It takes a few minutes
to read it all in, check it and generate code for it, but no
problems.
So, I think I can say that fundamentally, there are no longer
any limits on the number of items you can place in contexts,
statement blocks, switches, or globals, beyond your virt mem
constraints.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@177225 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-18 22:43:14 +00:00
| global_statements assignment {$$ = linku1($1, $2); }
2007-08-24 13:20:18 +00:00
| error global_statements {$$=$2;}
2006-04-24 17:41:27 +00:00
;
2006-05-02 20:11:24 +00:00
assignment : word EQ { reset_semicount(parseio->scanner); } word SEMI {
2006-04-28 10:06:10 +00:00
$$ = npval2(PV_VARDEC, &@1, &@5);
2006-04-27 02:29:32 +00:00
$$->u1.str = $1;
$$->u2.val = $4; }
2006-04-24 17:41:27 +00:00
;
2006-05-03 16:58:16 +00:00
/* XXX this matches missing arguments, is this desired ? */
2006-05-02 18:48:47 +00:00
arglist : /* empty */ { $$ = NULL; }
| word { $$ = nword($1, &@1); }
2006-05-02 14:27:19 +00:00
| arglist COMMA word { $$ = linku1($1, nword($3, &@3)); }
2006-04-24 17:41:27 +00:00
| arglist error {$$=$1;}
;
2006-05-03 16:28:48 +00:00
elements : {$$=0;}
This patch fixes a regression of sorts that was introduced in
rev 24425.
It basically fixes AST-190/ABE-1782.
What was wrong: the user has 6000 extensions in one context; and
then 6000 contexts, one per extension. The parser could only handle
about 4893 of the 6000 extens in the single context.
This was due to the regression I mentioned. To get rid of
shift/reduce conflicts, Luigi set up right-recursive lists
for globals, context elements, switch lists, and statements.
Right recursive lists got rid of the warnings, but instead, they
use up a tremendous amount of stack space when the lists are long.
I saw this a few years back, and resolved not to fix it until
someone complained. That day has arrived!
After the changes were made, I ran the regression test suite,
and there were no problems.
I took the test case the user provided, and added 100,000
extensions to the single context, that already had 6,000 extens
in it. (I'll see your 6, and raise you 100!) It takes a few minutes
to read it all in, check it and generate code for it, but no
problems.
So, I think I can say that fundamentally, there are no longer
any limits on the number of items you can place in contexts,
statement blocks, switches, or globals, beyond your virt mem
constraints.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@177225 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-18 22:43:14 +00:00
| elements element { $$ = linku1($1, $2); }
2007-08-24 13:20:18 +00:00
| error elements { $$=$2;}
2006-04-24 17:41:27 +00:00
;
element : extension {$$=$1;}
| includes {$$=$1;}
| switches {$$=$1;}
| eswitches {$$=$1;}
| ignorepat {$$=$1;}
2006-05-02 20:11:24 +00:00
| assignment {$$=$1;}
2006-04-26 18:43:29 +00:00
| word error {free($1); $$=0;}
2006-04-24 17:41:27 +00:00
| SEMI {$$=0;/* allow older docs to be read */}
;
2006-04-27 02:29:32 +00:00
ignorepat : KW_IGNOREPAT EXTENMARK word SEMI {
2006-04-27 18:26:37 +00:00
$$ = npval2(PV_IGNOREPAT, &@1, &@4);
2006-04-27 02:29:32 +00:00
$$->u1.str = $3;}
2006-04-24 17:41:27 +00:00
;
2006-04-27 02:29:32 +00:00
extension : word EXTENMARK statement {
2006-04-28 11:20:21 +00:00
$$ = npval2(PV_EXTENSION, &@1, &@3);
2006-04-27 02:29:32 +00:00
$$->u1.str = $1;
2006-08-07 12:59:47 +00:00
$$->u2.statements = $3; set_dads($$,$3);}
2006-04-27 02:29:32 +00:00
| KW_REGEXTEN word EXTENMARK statement {
2006-04-28 11:20:21 +00:00
$$ = npval2(PV_EXTENSION, &@1, &@4);
2006-04-27 02:29:32 +00:00
$$->u1.str = $2;
2006-08-07 12:59:47 +00:00
$$->u2.statements = $4; set_dads($$,$4);
2006-04-27 02:29:32 +00:00
$$->u4.regexten=1;}
2006-08-12 19:28:33 +00:00
| KW_HINT LP hint_word RP word EXTENMARK statement {
2006-04-28 11:20:21 +00:00
$$ = npval2(PV_EXTENSION, &@1, &@7);
2006-04-27 02:29:32 +00:00
$$->u1.str = $5;
2006-08-07 12:59:47 +00:00
$$->u2.statements = $7; set_dads($$,$7);
2006-04-27 02:29:32 +00:00
$$->u3.hints = $3;}
2006-08-12 19:28:33 +00:00
| KW_REGEXTEN KW_HINT LP hint_word RP word EXTENMARK statement {
2006-04-28 11:20:21 +00:00
$$ = npval2(PV_EXTENSION, &@1, &@8);
2006-04-27 02:29:32 +00:00
$$->u1.str = $6;
2006-08-07 12:59:47 +00:00
$$->u2.statements = $8; set_dads($$,$8);
2006-04-27 02:29:32 +00:00
$$->u4.regexten=1;
$$->u3.hints = $4;}
2006-04-24 17:41:27 +00:00
;
2006-05-03 16:33:00 +00:00
/* list of statements in a block or after a case label - can be empty */
statements : /* empty */ { $$ = NULL; }
This patch fixes a regression of sorts that was introduced in
rev 24425.
It basically fixes AST-190/ABE-1782.
What was wrong: the user has 6000 extensions in one context; and
then 6000 contexts, one per extension. The parser could only handle
about 4893 of the 6000 extens in the single context.
This was due to the regression I mentioned. To get rid of
shift/reduce conflicts, Luigi set up right-recursive lists
for globals, context elements, switch lists, and statements.
Right recursive lists got rid of the warnings, but instead, they
use up a tremendous amount of stack space when the lists are long.
I saw this a few years back, and resolved not to fix it until
someone complained. That day has arrived!
After the changes were made, I ran the regression test suite,
and there were no problems.
I took the test case the user provided, and added 100,000
extensions to the single context, that already had 6,000 extens
in it. (I'll see your 6, and raise you 100!) It takes a few minutes
to read it all in, check it and generate code for it, but no
problems.
So, I think I can say that fundamentally, there are no longer
any limits on the number of items you can place in contexts,
statement blocks, switches, or globals, beyond your virt mem
constraints.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@177225 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-18 22:43:14 +00:00
| statements statement { $$ = linku1($1, $2); }
2007-08-24 13:20:18 +00:00
| error statements {$$=$2;}
2006-04-24 17:41:27 +00:00
;
2006-05-02 18:23:41 +00:00
/* hh:mm-hh:mm, due to the way the parser works we do not
* detect the '-' but only the ':' as separator
*/
timerange: word3_list COLON word3_list COLON word3_list {
2008-11-01 18:22:39 +00:00
if (asprintf(&$$, "%s:%s:%s", $1, $3, $5) < 0) {
ast_log(LOG_WARNING, "asprintf() failed\n");
$$ = NULL;
} else {
free($1);
free($3);
free($5);
}
}
2006-05-02 18:23:41 +00:00
| word { $$ = $1; }
;
2006-05-02 18:33:15 +00:00
/* full time specification range|dow|*|* */
timespec : timerange BAR word3_list BAR word3_list BAR word3_list {
$$ = nword($1, &@1);
2006-05-02 20:44:56 +00:00
$$->next = nword($3, &@3);
$$->next->next = nword($5, &@5);
$$->next->next->next = nword($7, &@7); }
2006-05-02 18:33:15 +00:00
;
2006-05-02 19:17:49 +00:00
/* expression used in if, random, while, switch */
2006-05-03 17:07:56 +00:00
test_expr : LP { reset_parencount(parseio->scanner); } word_list RP { $$ = $3; }
2006-05-02 19:17:49 +00:00
;
2006-05-02 18:08:27 +00:00
/* 'if' like statements: if, iftime, random */
2006-05-02 19:17:49 +00:00
if_like_head : KW_IF test_expr {
$$= npval2(PV_IF, &@1, &@2);
$$->u1.str = $2; }
| KW_RANDOM test_expr {
$$ = npval2(PV_RANDOM, &@1, &@2);
$$->u1.str=$2;}
2006-05-02 18:33:15 +00:00
| KW_IFTIME LP timespec RP {
$$ = npval2(PV_IFTIME, &@1, &@4);
$$->u1.list = $3;
prev_word = 0; }
2006-04-24 17:41:27 +00:00
;
/* word_list is a hack to fix a problem with context switching between bison and flex;
2006-04-26 18:43:29 +00:00
by the time you register a new context with flex, you've already got a look-ahead token
2006-04-24 17:41:27 +00:00
from the old context, with no way to put it back and start afresh. So, we kludge this
and merge the words back together. */
2006-04-26 18:43:29 +00:00
word_list : word { $$ = $1;}
2006-04-27 08:24:00 +00:00
| word word {
2008-11-01 18:22:39 +00:00
if (asprintf(&($$), "%s%s", $1, $2) < 0) {
ast_log(LOG_WARNING, "asprintf() failed\n");
$$ = NULL;
} else {
free($1);
free($2);
prev_word = $$;
}
}
2006-04-24 17:41:27 +00:00
;
2006-04-27 18:26:37 +00:00
2006-08-12 19:28:33 +00:00
hint_word : word { $$ = $1; }
| hint_word word {
2008-11-01 18:22:39 +00:00
if (asprintf(&($$), "%s %s", $1, $2) < 0) {
ast_log(LOG_WARNING, "asprintf() failed\n");
$$ = NULL;
} else {
free($1);
free($2);
}
}
2007-10-24 04:14:28 +00:00
| hint_word COLON word {
2008-11-01 18:22:39 +00:00
if (asprintf(&($$), "%s:%s", $1, $3) < 0) {
ast_log(LOG_WARNING, "asprintf() failed\n");
$$ = NULL;
} else {
free($1);
free($3);
}
}
2006-08-12 19:28:33 +00:00
| hint_word AMPER word { /* there are often '&' in hints */
2008-11-01 18:22:39 +00:00
if (asprintf(&($$), "%s&%s", $1, $3) < 0) {
ast_log(LOG_WARNING, "asprintf() failed\n");
$$ = NULL;
} else {
free($1);
free($3);
}
}
;
2006-08-12 19:28:33 +00:00
2006-04-26 18:43:29 +00:00
word3_list : word { $$ = $1;}
2006-04-27 08:24:00 +00:00
| word word {
2008-11-01 18:22:39 +00:00
if (asprintf(&($$), "%s%s", $1, $2) < 0) {
ast_log(LOG_WARNING, "asprintf() failed\n");
$$ = NULL;
} else {
free($1);
free($2);
prev_word = $$;
}
}
2006-04-27 08:24:00 +00:00
| word word word {
2008-11-01 18:22:39 +00:00
if (asprintf(&($$), "%s%s%s", $1, $2, $3) < 0) {
ast_log(LOG_WARNING, "asprintf() failed\n");
$$ = NULL;
} else {
free($1);
free($2);
free($3);
prev_word=$$;
}
}
2006-04-24 17:41:27 +00:00
;
goto_word : word { $$ = $1;}
2006-04-27 08:24:00 +00:00
| word word {
2008-11-01 18:22:39 +00:00
if (asprintf(&($$), "%s%s", $1, $2) < 0) {
ast_log(LOG_WARNING, "asprintf() failed\n");
$$ = NULL;
} else {
free($1);
free($2);
}
}
2006-07-19 02:55:24 +00:00
| goto_word COLON word {
2008-11-01 18:22:39 +00:00
if (asprintf(&($$), "%s:%s", $1, $3) < 0) {
ast_log(LOG_WARNING, "asprintf() failed\n");
$$ = NULL;
} else {
free($1);
free($3);
}
}
2006-04-24 17:41:27 +00:00
;
2006-05-03 16:08:35 +00:00
switch_statement : KW_SWITCH test_expr LC case_statements RC {
$$ = npval2(PV_SWITCH, &@1, &@5);
$$->u1.str = $2;
2006-08-07 12:59:47 +00:00
$$->u2.statements = $4; set_dads($$,$4);}
2006-04-24 17:41:27 +00:00
;
2006-04-27 18:09:20 +00:00
/*
* Definition of a statememt in our language
*/
2006-04-27 16:40:25 +00:00
statement : LC statements RC {
2006-04-27 18:09:20 +00:00
$$ = npval2(PV_STATEMENTBLOCK, &@1, &@3);
2006-08-07 12:59:47 +00:00
$$->u1.list = $2; set_dads($$,$2);}
2006-05-02 20:13:58 +00:00
| assignment { $$ = $1; }
2006-04-27 16:40:25 +00:00
| KW_GOTO target SEMI {
2006-04-27 19:14:07 +00:00
$$ = npval2(PV_GOTO, &@1, &@3);
2006-04-27 16:40:25 +00:00
$$->u1.list = $2;}
| KW_JUMP jumptarget SEMI {
2006-04-28 06:26:27 +00:00
$$ = npval2(PV_GOTO, &@1, &@3);
2006-04-27 16:40:25 +00:00
$$->u1.list = $2;}
| word COLON {
2006-04-28 06:26:27 +00:00
$$ = npval2(PV_LABEL, &@1, &@2);
2006-04-27 16:40:25 +00:00
$$->u1.str = $1; }
2006-04-24 17:41:27 +00:00
| KW_FOR LP {reset_semicount(parseio->scanner);} word SEMI
{reset_semicount(parseio->scanner);} word SEMI
2006-05-02 19:17:49 +00:00
{reset_parencount(parseio->scanner);} word RP statement { /* XXX word_list maybe ? */
2006-04-28 06:26:27 +00:00
$$ = npval2(PV_FOR, &@1, &@12);
2006-04-27 16:40:25 +00:00
$$->u1.for_init = $4;
$$->u2.for_test=$7;
$$->u3.for_inc = $10;
2006-08-07 12:59:47 +00:00
$$->u4.for_statements = $12; set_dads($$,$12);}
2006-05-02 19:17:49 +00:00
| KW_WHILE test_expr statement {
$$ = npval2(PV_WHILE, &@1, &@3);
$$->u1.str = $2;
2006-08-07 12:59:47 +00:00
$$->u2.statements = $3; set_dads($$,$3);}
2006-05-03 16:08:35 +00:00
| switch_statement { $$ = $1; }
2006-05-03 17:07:56 +00:00
| AMPER macro_call SEMI { $$ = update_last($2, &@2); }
| application_call SEMI { $$ = update_last($1, &@2); }
2006-04-27 08:37:40 +00:00
| word SEMI {
2006-04-28 11:20:21 +00:00
$$= npval2(PV_APPLICATION_CALL, &@1, &@2);
2006-04-27 08:37:40 +00:00
$$->u1.str = $1;}
2006-04-24 17:41:27 +00:00
| application_call EQ {reset_semicount(parseio->scanner);} word SEMI {
2006-04-27 08:37:40 +00:00
char *bufx;
int tot=0;
pval *pptr;
2006-04-28 11:20:21 +00:00
$$ = npval2(PV_VARDEC, &@1, &@5);
2006-04-27 08:37:40 +00:00
$$->u2.val=$4;
/* rebuild the original string-- this is not an app call, it's an unwrapped vardec, with a func call on the LHS */
/* string to big to fit in the buffer? */
tot+=strlen($1->u1.str);
for(pptr=$1->u2.arglist;pptr;pptr=pptr->next) {
tot+=strlen(pptr->u1.str);
tot++; /* for a sep like a comma */
}
tot+=4; /* for safety */
2006-05-02 03:03:27 +00:00
bufx = calloc(1, tot);
2006-04-27 08:37:40 +00:00
strcpy(bufx,$1->u1.str);
strcat(bufx,"(");
/* XXX need to advance the pointer or the loop is very inefficient */
for (pptr=$1->u2.arglist;pptr;pptr=pptr->next) {
if ( pptr != $1->u2.arglist )
strcat(bufx,",");
strcat(bufx,pptr->u1.str);
}
strcat(bufx,")");
2006-04-24 17:41:27 +00:00
#ifdef AAL_ARGCHECK
2006-04-27 08:37:40 +00:00
if ( !ael_is_funcname($1->u1.str) )
ast_log(LOG_WARNING, "==== File: %s, Line %d, Cols: %d-%d: Function call? The name %s is not in my internal list of function names\n",
my_file, @1.first_line, @1.first_column, @1.last_column, $1->u1.str);
2006-04-24 17:41:27 +00:00
#endif
2006-04-27 08:37:40 +00:00
$$->u1.str = bufx;
destroy_pval($1); /* the app call it is not, get rid of that chain */
prev_word = 0;
}
2006-04-28 11:20:21 +00:00
| KW_BREAK SEMI { $$ = npval2(PV_BREAK, &@1, &@2); }
| KW_RETURN SEMI { $$ = npval2(PV_RETURN, &@1, &@2); }
| KW_CONTINUE SEMI { $$ = npval2(PV_CONTINUE, &@1, &@2); }
2006-05-02 18:08:27 +00:00
| if_like_head statement opt_else {
$$ = update_last($1, &@2);
2006-08-07 12:59:47 +00:00
$$->u2.statements = $2; set_dads($$,$2);
$$->u3.else_statements = $3;set_dads($$,$3);}
2006-04-24 17:41:27 +00:00
| SEMI { $$=0; }
;
2006-04-30 08:21:46 +00:00
opt_else : KW_ELSE statement { $$ = $2; }
| { $$ = NULL ; }
2007-08-24 13:20:18 +00:00
2006-04-30 13:57:08 +00:00
target : goto_word { $$ = nword($1, &@1); }
2006-04-27 06:44:38 +00:00
| goto_word BAR goto_word {
2006-04-30 13:57:08 +00:00
$$ = nword($1, &@1);
$$->next = nword($3, &@3); }
2006-04-27 06:44:38 +00:00
| goto_word COMMA goto_word {
2006-04-30 13:57:08 +00:00
$$ = nword($1, &@1);
$$->next = nword($3, &@3); }
2006-04-27 17:59:09 +00:00
| goto_word BAR goto_word BAR goto_word {
2006-04-30 13:57:08 +00:00
$$ = nword($1, &@1);
$$->next = nword($3, &@3);
$$->next->next = nword($5, &@5); }
2006-04-27 17:59:09 +00:00
| goto_word COMMA goto_word COMMA goto_word {
2006-04-30 13:57:08 +00:00
$$ = nword($1, &@1);
$$->next = nword($3, &@3);
$$->next->next = nword($5, &@5); }
2006-04-27 17:59:09 +00:00
| KW_DEFAULT BAR goto_word BAR goto_word {
2006-04-30 13:57:08 +00:00
$$ = nword(strdup("default"), &@1);
$$->next = nword($3, &@3);
$$->next->next = nword($5, &@5); }
2006-04-27 17:59:09 +00:00
| KW_DEFAULT COMMA goto_word COMMA goto_word {
2006-04-30 13:57:08 +00:00
$$ = nword(strdup("default"), &@1);
$$->next = nword($3, &@3);
$$->next->next = nword($5, &@5); }
2006-04-24 17:41:27 +00:00
;
2006-05-03 17:07:56 +00:00
opt_pri : /* empty */ { $$ = strdup("1"); }
| COMMA word { $$ = $2; }
;
2006-04-30 14:06:04 +00:00
/* XXX please document the form of jumptarget */
2006-05-03 17:07:56 +00:00
jumptarget : goto_word opt_pri { /* ext[, pri] default 1 */
2006-04-30 13:57:08 +00:00
$$ = nword($1, &@1);
2006-05-03 17:07:56 +00:00
$$->next = nword($2, &@2); } /* jump extension[,priority][@context] */
| goto_word opt_pri AT context_name { /* context, ext, pri */
$$ = nword($4, &@4);
2006-05-02 14:25:01 +00:00
$$->next = nword($1, &@1);
2006-05-03 17:07:56 +00:00
$$->next->next = nword($2, &@2); }
2006-04-27 06:44:38 +00:00
;
2006-04-24 17:41:27 +00:00
2006-04-27 17:59:09 +00:00
macro_call : word LP {reset_argcount(parseio->scanner);} eval_arglist RP {
2006-04-27 18:18:12 +00:00
/* XXX original code had @2 but i think we need @5 */
$$ = npval2(PV_MACRO_CALL, &@1, &@5);
2006-04-27 17:59:09 +00:00
$$->u1.str = $1;
$$->u2.arglist = $4;}
| word LP RP {
2006-04-27 18:18:12 +00:00
$$= npval2(PV_MACRO_CALL, &@1, &@3);
2006-04-27 17:59:09 +00:00
$$->u1.str = $1; }
2006-04-24 17:41:27 +00:00
;
2006-04-30 23:53:22 +00:00
/* XXX application_call_head must be revised. Having 'word LP { ...'
* just as above should work fine, however it gives a different result.
*/
application_call_head: word LP {reset_argcount(parseio->scanner);} {
2006-04-27 08:37:40 +00:00
if (strcasecmp($1,"goto") == 0) {
2006-05-01 00:02:12 +00:00
$$ = npval2(PV_GOTO, &@1, &@2);
2006-04-27 06:44:38 +00:00
free($1); /* won't be using this */
ast_log(LOG_WARNING, "==== File: %s, Line %d, Cols: %d-%d: Suggestion: Use the goto statement instead of the Goto() application call in AEL.\n", my_file, @1.first_line, @1.first_column, @1.last_column );
2006-05-01 00:02:12 +00:00
} else {
$$= npval2(PV_APPLICATION_CALL, &@1, &@2);
$$->u1.str = $1;
} }
2006-04-24 17:41:27 +00:00
;
2006-04-30 12:12:39 +00:00
application_call : application_call_head eval_arglist RP {
$$ = update_last($1, &@3);
2006-04-24 17:41:27 +00:00
if( $$->type == PV_GOTO )
$$->u1.list = $2;
else
$$->u2.arglist = $2;
2006-04-30 12:12:39 +00:00
}
| application_call_head RP { $$ = update_last($1, &@2); }
2006-04-24 17:41:27 +00:00
;
2006-04-30 08:21:46 +00:00
opt_word : word { $$ = $1 }
| { $$ = strdup(""); }
;
2006-04-30 14:06:04 +00:00
eval_arglist : word_list { $$ = nword($1, &@1); }
2006-04-27 17:59:09 +00:00
| /*nothing! */ {
$$= npval(PV_WORD,0/*@1.first_line*/,0/*@1.last_line*/,0/* @1.first_column*/, 0/*@1.last_column*/);
$$->u1.str = strdup(""); }
2006-05-02 14:27:19 +00:00
| eval_arglist COMMA opt_word { $$ = linku1($1, nword($3, &@3)); }
2006-04-24 17:41:27 +00:00
;
2006-05-02 20:18:02 +00:00
case_statements: /* empty */ { $$ = NULL; }
This patch fixes a regression of sorts that was introduced in
rev 24425.
It basically fixes AST-190/ABE-1782.
What was wrong: the user has 6000 extensions in one context; and
then 6000 contexts, one per extension. The parser could only handle
about 4893 of the 6000 extens in the single context.
This was due to the regression I mentioned. To get rid of
shift/reduce conflicts, Luigi set up right-recursive lists
for globals, context elements, switch lists, and statements.
Right recursive lists got rid of the warnings, but instead, they
use up a tremendous amount of stack space when the lists are long.
I saw this a few years back, and resolved not to fix it until
someone complained. That day has arrived!
After the changes were made, I ran the regression test suite,
and there were no problems.
I took the test case the user provided, and added 100,000
extensions to the single context, that already had 6,000 extens
in it. (I'll see your 6, and raise you 100!) It takes a few minutes
to read it all in, check it and generate code for it, but no
problems.
So, I think I can say that fundamentally, there are no longer
any limits on the number of items you can place in contexts,
statement blocks, switches, or globals, beyond your virt mem
constraints.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@177225 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-18 22:43:14 +00:00
| case_statements case_statement { $$ = linku1($1, $2); }
2006-04-24 17:41:27 +00:00
;
2006-05-03 16:33:00 +00:00
case_statement: KW_CASE word COLON statements {
2006-04-27 19:14:07 +00:00
$$ = npval2(PV_CASE, &@1, &@3); /* XXX 3 or 4 ? */
$$->u1.str = $2;
2006-08-07 12:59:47 +00:00
$$->u2.statements = $4; set_dads($$,$4);}
2006-05-03 16:33:00 +00:00
| KW_DEFAULT COLON statements {
2006-04-27 19:14:07 +00:00
$$ = npval2(PV_DEFAULT, &@1, &@3);
$$->u1.str = NULL;
2006-08-07 12:59:47 +00:00
$$->u2.statements = $3;set_dads($$,$3);}
2006-05-03 16:33:00 +00:00
| KW_PATTERN word COLON statements {
2006-04-27 19:14:07 +00:00
$$ = npval2(PV_PATTERN, &@1, &@4); /* XXX@3 or @4 ? */
$$->u1.str = $2;
2006-08-07 12:59:47 +00:00
$$->u2.statements = $4;set_dads($$,$4);}
2006-04-24 17:41:27 +00:00
;
2006-05-02 18:51:33 +00:00
macro_statements: /* empty */ { $$ = NULL; }
This patch fixes a regression of sorts that was introduced in
rev 24425.
It basically fixes AST-190/ABE-1782.
What was wrong: the user has 6000 extensions in one context; and
then 6000 contexts, one per extension. The parser could only handle
about 4893 of the 6000 extens in the single context.
This was due to the regression I mentioned. To get rid of
shift/reduce conflicts, Luigi set up right-recursive lists
for globals, context elements, switch lists, and statements.
Right recursive lists got rid of the warnings, but instead, they
use up a tremendous amount of stack space when the lists are long.
I saw this a few years back, and resolved not to fix it until
someone complained. That day has arrived!
After the changes were made, I ran the regression test suite,
and there were no problems.
I took the test case the user provided, and added 100,000
extensions to the single context, that already had 6,000 extens
in it. (I'll see your 6, and raise you 100!) It takes a few minutes
to read it all in, check it and generate code for it, but no
problems.
So, I think I can say that fundamentally, there are no longer
any limits on the number of items you can place in contexts,
statement blocks, switches, or globals, beyond your virt mem
constraints.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@177225 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-18 22:43:14 +00:00
| macro_statements macro_statement { $$ = linku1($1, $2); }
2006-04-24 17:41:27 +00:00
;
macro_statement : statement {$$=$1;}
2007-06-05 21:30:18 +00:00
| includes { $$=$1;}
2006-04-28 06:26:27 +00:00
| KW_CATCH word LC statements RC {
$$ = npval2(PV_CATCH, &@1, &@5);
$$->u1.str = $2;
2006-08-07 12:59:47 +00:00
$$->u2.statements = $4; set_dads($$,$4);}
2006-04-24 17:41:27 +00:00
;
2006-05-03 16:38:50 +00:00
switches : KW_SWITCHES LC switchlist RC {
2006-04-30 12:46:15 +00:00
$$ = npval2(PV_SWITCHES, &@1, &@2);
2006-08-07 12:59:47 +00:00
$$->u1.list = $3; set_dads($$,$3);}
2006-04-24 17:41:27 +00:00
;
2006-05-03 16:38:50 +00:00
eswitches : KW_ESWITCHES LC switchlist RC {
2006-04-30 12:44:54 +00:00
$$ = npval2(PV_ESWITCHES, &@1, &@2);
2006-08-07 12:59:47 +00:00
$$->u1.list = $3; set_dads($$,$3);}
2006-04-24 17:41:27 +00:00
;
2006-05-03 16:37:14 +00:00
switchlist : /* empty */ { $$ = NULL; }
This patch fixes a regression of sorts that was introduced in
rev 24425.
It basically fixes AST-190/ABE-1782.
What was wrong: the user has 6000 extensions in one context; and
then 6000 contexts, one per extension. The parser could only handle
about 4893 of the 6000 extens in the single context.
This was due to the regression I mentioned. To get rid of
shift/reduce conflicts, Luigi set up right-recursive lists
for globals, context elements, switch lists, and statements.
Right recursive lists got rid of the warnings, but instead, they
use up a tremendous amount of stack space when the lists are long.
I saw this a few years back, and resolved not to fix it until
someone complained. That day has arrived!
After the changes were made, I ran the regression test suite,
and there were no problems.
I took the test case the user provided, and added 100,000
extensions to the single context, that already had 6,000 extens
in it. (I'll see your 6, and raise you 100!) It takes a few minutes
to read it all in, check it and generate code for it, but no
problems.
So, I think I can say that fundamentally, there are no longer
any limits on the number of items you can place in contexts,
statement blocks, switches, or globals, beyond your virt mem
constraints.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@177225 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-18 22:43:14 +00:00
| switchlist word SEMI { $$ = linku1($1,nword($2, &@2)); }
| switchlist word AT word SEMI {
2008-11-01 18:22:39 +00:00
char *x;
This patch fixes a regression of sorts that was introduced in
rev 24425.
It basically fixes AST-190/ABE-1782.
What was wrong: the user has 6000 extensions in one context; and
then 6000 contexts, one per extension. The parser could only handle
about 4893 of the 6000 extens in the single context.
This was due to the regression I mentioned. To get rid of
shift/reduce conflicts, Luigi set up right-recursive lists
for globals, context elements, switch lists, and statements.
Right recursive lists got rid of the warnings, but instead, they
use up a tremendous amount of stack space when the lists are long.
I saw this a few years back, and resolved not to fix it until
someone complained. That day has arrived!
After the changes were made, I ran the regression test suite,
and there were no problems.
I took the test case the user provided, and added 100,000
extensions to the single context, that already had 6,000 extens
in it. (I'll see your 6, and raise you 100!) It takes a few minutes
to read it all in, check it and generate code for it, but no
problems.
So, I think I can say that fundamentally, there are no longer
any limits on the number of items you can place in contexts,
statement blocks, switches, or globals, beyond your virt mem
constraints.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@177225 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-18 22:43:14 +00:00
if (asprintf(&x,"%s@%s", $2, $4) < 0) {
2008-11-01 18:22:39 +00:00
ast_log(LOG_WARNING, "asprintf() failed\n");
$$ = NULL;
} else {
This patch fixes a regression of sorts that was introduced in
rev 24425.
It basically fixes AST-190/ABE-1782.
What was wrong: the user has 6000 extensions in one context; and
then 6000 contexts, one per extension. The parser could only handle
about 4893 of the 6000 extens in the single context.
This was due to the regression I mentioned. To get rid of
shift/reduce conflicts, Luigi set up right-recursive lists
for globals, context elements, switch lists, and statements.
Right recursive lists got rid of the warnings, but instead, they
use up a tremendous amount of stack space when the lists are long.
I saw this a few years back, and resolved not to fix it until
someone complained. That day has arrived!
After the changes were made, I ran the regression test suite,
and there were no problems.
I took the test case the user provided, and added 100,000
extensions to the single context, that already had 6,000 extens
in it. (I'll see your 6, and raise you 100!) It takes a few minutes
to read it all in, check it and generate code for it, but no
problems.
So, I think I can say that fundamentally, there are no longer
any limits on the number of items you can place in contexts,
statement blocks, switches, or globals, beyond your virt mem
constraints.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@177225 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-18 22:43:14 +00:00
free($2);
free($4);
$$ = linku1($1,nword(x, &@2));
2008-11-01 18:22:39 +00:00
}
}
2007-08-24 13:20:18 +00:00
| error switchlist {$$=$2;}
2006-04-24 17:41:27 +00:00
;
2006-05-03 16:28:48 +00:00
included_entry : context_name { $$ = nword($1, &@1); }
| context_name BAR timespec {
2006-05-02 14:25:01 +00:00
$$ = nword($1, &@1);
2006-05-02 18:33:15 +00:00
$$->u2.arglist = $3;
2006-05-02 18:41:57 +00:00
prev_word=0; /* XXX sure ? */ }
;
/* list of ';' separated context names followed by optional timespec */
2006-05-03 16:28:48 +00:00
includeslist : included_entry SEMI { $$ = $1; }
| includeslist included_entry SEMI { $$ = linku1($1, $2); }
2006-04-24 17:41:27 +00:00
| includeslist error {$$=$1;}
;
2006-04-27 06:44:38 +00:00
includes : KW_INCLUDES LC includeslist RC {
2006-04-27 18:18:12 +00:00
$$ = npval2(PV_INCLUDES, &@1, &@4);
2006-08-07 12:59:47 +00:00
$$->u1.list = $3;set_dads($$,$3);}
2006-04-27 06:44:38 +00:00
| KW_INCLUDES LC RC {
2006-04-27 18:18:12 +00:00
$$ = npval2(PV_INCLUDES, &@1, &@3);}
2006-04-24 17:41:27 +00:00
;
%%
2006-04-26 18:43:29 +00:00
static char *token_equivs1[] =
2006-04-24 17:41:27 +00:00
{
"AMPER",
"AT",
"BAR",
"COLON",
"COMMA",
"EQ",
"EXTENMARK",
2006-04-26 18:43:29 +00:00
"KW_BREAK",
"KW_CASE",
"KW_CATCH",
2006-04-24 17:41:27 +00:00
"KW_CONTEXT",
2006-04-26 18:43:29 +00:00
"KW_CONTINUE",
"KW_DEFAULT",
2006-04-24 17:41:27 +00:00
"KW_ELSE",
"KW_ESWITCHES",
2006-04-26 18:43:29 +00:00
"KW_FOR",
2006-04-24 17:41:27 +00:00
"KW_GLOBALS",
"KW_GOTO",
"KW_HINT",
"KW_IFTIME",
"KW_IF",
"KW_IGNOREPAT",
"KW_INCLUDES"
"KW_JUMP",
"KW_MACRO",
2006-04-26 18:43:29 +00:00
"KW_PATTERN",
"KW_REGEXTEN",
"KW_RETURN",
"KW_SWITCHES",
2006-04-24 17:41:27 +00:00
"KW_SWITCH",
2006-04-26 18:43:29 +00:00
"KW_WHILE",
2006-04-24 17:41:27 +00:00
"LC",
"LP",
"RC",
"RP",
"SEMI",
};
2006-04-26 18:43:29 +00:00
static char *token_equivs2[] =
2006-04-24 17:41:27 +00:00
{
"&",
"@",
"|",
":",
",",
"=",
"=>",
2006-04-26 18:43:29 +00:00
"break",
"case",
"catch",
2006-04-24 17:41:27 +00:00
"context",
2006-04-26 18:43:29 +00:00
"continue",
"default",
2006-04-24 17:41:27 +00:00
"else",
"eswitches",
2006-04-26 18:43:29 +00:00
"for",
2006-04-24 17:41:27 +00:00
"globals",
"goto",
"hint",
"ifTime",
"if",
"ignorepat",
"includes"
"jump",
"macro",
2006-04-26 18:43:29 +00:00
"pattern",
"regexten",
"return",
"switches",
2006-04-24 17:41:27 +00:00
"switch",
2006-04-26 18:43:29 +00:00
"while",
2006-04-24 17:41:27 +00:00
"{",
"(",
"}",
")",
";",
};
2007-09-21 14:37:20 +00:00
static char *ael_token_subst(const char *mess)
2006-04-24 17:41:27 +00:00
{
/* calc a length, malloc, fill, and return; yyerror had better free it! */
int len=0,i;
2007-09-21 14:37:20 +00:00
const char *p;
2006-04-24 17:41:27 +00:00
char *res, *s,*t;
int token_equivs_entries = sizeof(token_equivs1)/sizeof(char*);
for (p=mess; *p; p++) {
for (i=0; i<token_equivs_entries; i++) {
if ( strncmp(p,token_equivs1[i],strlen(token_equivs1[i])) == 0 )
{
len+=strlen(token_equivs2[i])+2;
p += strlen(token_equivs1[i])-1;
break;
}
}
len++;
}
2006-05-02 03:03:27 +00:00
res = calloc(1, len+1);
2006-04-24 17:41:27 +00:00
res[0] = 0;
s = res;
for (p=mess; *p;) {
int found = 0;
for (i=0; i<token_equivs_entries; i++) {
if ( strncmp(p,token_equivs1[i],strlen(token_equivs1[i])) == 0 ) {
*s++ = '\'';
for (t=token_equivs2[i]; *t;) {
*s++ = *t++;
}
*s++ = '\'';
p += strlen(token_equivs1[i]);
found = 1;
break;
}
}
if( !found )
*s++ = *p++;
}
*s++ = 0;
return res;
}
void yyerror(YYLTYPE *locp, struct parse_io *parseio, char const *s)
{
2007-09-21 14:37:20 +00:00
char *s2 = ael_token_subst(s);
2006-04-24 17:41:27 +00:00
if (locp->first_line == locp->last_line) {
ast_log(LOG_ERROR, "==== File: %s, Line %d, Cols: %d-%d: Error: %s\n", my_file, locp->first_line, locp->first_column, locp->last_column, s2);
} else {
ast_log(LOG_ERROR, "==== File: %s, Line %d Col %d to Line %d Col %d: Error: %s\n", my_file, locp->first_line, locp->first_column, locp->last_line, locp->last_column, s2);
}
free(s2);
parseio->syntax_error_count++;
}
2006-04-27 17:39:55 +00:00
static struct pval *npval(pvaltype type, int first_line, int last_line,
int first_column, int last_column)
2006-04-24 17:41:27 +00:00
{
2006-05-02 03:03:27 +00:00
pval *z = calloc(1, sizeof(struct pval));
2006-04-24 17:41:27 +00:00
z->type = type;
z->startline = first_line;
z->endline = last_line;
z->startcol = first_column;
z->endcol = last_column;
z->filename = strdup(my_file);
return z;
}
2006-04-27 18:09:20 +00:00
static struct pval *npval2(pvaltype type, YYLTYPE *first, YYLTYPE *last)
{
return npval(type, first->first_line, last->last_line,
first->first_column, last->last_column);
}
2006-04-30 12:12:39 +00:00
static struct pval *update_last(pval *obj, YYLTYPE *last)
{
obj->endline = last->last_line;
obj->endcol = last->last_column;
return obj;
}
2006-04-30 13:57:08 +00:00
/* frontend for npval to create a PV_WORD string from the given token */
static pval *nword(char *string, YYLTYPE *pos)
{
pval *p = npval2(PV_WORD, pos, pos);
if (p)
p->u1.str = string;
return p;
}
2006-04-26 22:41:16 +00:00
/* append second element to the list in the first one */
2006-04-28 14:17:03 +00:00
static pval * linku1(pval *head, pval *tail)
2006-04-24 17:41:27 +00:00
{
2006-04-28 14:17:03 +00:00
if (!head)
return tail;
2006-05-02 14:08:18 +00:00
if (tail) {
if (!head->next) {
head->next = tail;
} else {
head->u1_last->next = tail;
}
head->u1_last = tail;
2006-08-07 12:59:47 +00:00
tail->prev = head; /* the dad link only points to containers */
2006-04-24 17:41:27 +00:00
}
2006-04-28 14:17:03 +00:00
return head;
2006-04-24 17:41:27 +00:00
}
2006-08-07 12:59:47 +00:00
/* this routine adds a dad ptr to each element in the list */
static void set_dads(struct pval *dad, struct pval *child_list)
{
struct pval *t;
for(t=child_list;t;t=t->next) /* simple stuff */
t->dad = dad;
}