[svn-commits] murf: branch murf/AEL2-1.2 r39566 - in /team/murf/AEL2-1.2: doc/ include/aste...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sat Aug 12 11:21:31 MST 2006


Author: murf
Date: Sat Aug 12 13:21:31 2006
New Revision: 39566

URL: http://svn.digium.com/view/asterisk?rev=39566&view=rev
Log:
update everything to match the developments on the trunk version, up to and not include bug_7721


Modified:
    team/murf/AEL2-1.2/doc/ael2.txt
    team/murf/AEL2-1.2/include/asterisk/ael_structs.h
    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/pbx/pbx_ael2.c
    team/murf/AEL2-1.2/utils/ael_main.c

Modified: team/murf/AEL2-1.2/doc/ael2.txt
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2-1.2/doc/ael2.txt?rev=39566&r1=39565&r2=39566&view=diff
==============================================================================
--- team/murf/AEL2-1.2/doc/ael2.txt (original)
+++ team/murf/AEL2-1.2/doc/ael2.txt Sat Aug 12 13:21:31 2006
@@ -607,6 +607,16 @@
 context zoombo 
 {
 	819/7079953345 => { NoOp(hello, 3345); }
+}
+
+In the above,  the 819/7079953345 extension will only be matched if the
+CallerID is 7079953345, and the dialed number is 819. Hopefully you have
+another 819 extension defined for all those who wish 819, that are not so lucky
+as to have 7079953345 as their CallerID!
+
+context zoombo
+{
+        819/7079953345 => { NoOp(hello, 3345); }
 }
 
 In the above,  the 819/7079953345 extension will only be matched if the

Modified: team/murf/AEL2-1.2/include/asterisk/ael_structs.h
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2-1.2/include/asterisk/ael_structs.h?rev=39566&r1=39565&r2=39566&view=diff
==============================================================================
--- team/murf/AEL2-1.2/include/asterisk/ael_structs.h (original)
+++ team/murf/AEL2-1.2/include/asterisk/ael_structs.h Sat Aug 12 13:21:31 2006
@@ -1,13 +1,16 @@
+#ifndef _ASTERISK_AEL_STRUCTS_H
+#define _ASTERISK_AEL_STRUCTS_H
+
 #if !defined(SOLARIS) && !defined(__CYGWIN__)
 #include <err.h>
 #else
 #define quad_t int64_t
 #endif
 
-#ifdef LONG_LONG_MIN
+#if defined(LONG_LONG_MIN) && !defined(QUAD_MIN)
 #define QUAD_MIN LONG_LONG_MIN
 #endif
-#ifdef LONG_LONG_MAX
+#if defined(LONG_LONG_MAX) && !defined(QUAD_MAX)
 #define QUAD_MAX LONG_LONG_MAX
 #endif
 
@@ -18,38 +21,37 @@
 #   define QUAD_MAX     (0x7fffffffffffffffLL)
 #  endif
 
-#include "asterisk/argdesc.h"
 
 typedef enum 
 {
-	PV_WORD, /* an ident, string, name, label, etc. A user-supplied string. */
-	PV_MACRO,
-	PV_CONTEXT,
-	PV_MACRO_CALL,
-	PV_APPLICATION_CALL,
-	PV_CASE,
-	PV_PATTERN,
-	PV_DEFAULT,
-	PV_CATCH,
-	PV_SWITCHES,
-	PV_ESWITCHES,
-	PV_INCLUDES,
-	PV_STATEMENTBLOCK,
-	PV_VARDEC, /* you know, var=val; */
-	PV_GOTO,
-	PV_LABEL,
-	PV_FOR,
-	PV_WHILE,
-	PV_BREAK,
-	PV_RETURN,
-	PV_CONTINUE,
-	PV_IF,
-	PV_IFTIME,
-	PV_RANDOM,
-	PV_SWITCH,
-	PV_EXTENSION,
-	PV_IGNOREPAT,
-	PV_GLOBALS,
+	PV_WORD, /* an ident, string, name, label, etc. A user-supplied string. */ /* 0 */
+	PV_MACRO,             /* 1 */
+	PV_CONTEXT,           /* 2 */
+	PV_MACRO_CALL,        /* 3 */
+	PV_APPLICATION_CALL,  /* 4 */
+	PV_CASE,              /* 5 */
+	PV_PATTERN,           /* 6 */
+	PV_DEFAULT,           /* 7 */
+	PV_CATCH,             /* 8 */
+	PV_SWITCHES,          /* 9 */
+	PV_ESWITCHES,         /* 10 */
+	PV_INCLUDES,          /* 11 */
+	PV_STATEMENTBLOCK,    /* 12 */
+	PV_VARDEC, /* you know, var=val; */  /* 13 */
+	PV_GOTO,              /* 14 */
+	PV_LABEL,             /* 15 */
+	PV_FOR,               /* 16 */
+	PV_WHILE,             /* 17 */
+	PV_BREAK,             /* 18 */
+	PV_RETURN,            /* 19 */
+	PV_CONTINUE,          /* 20 */
+	PV_IF,                /* 21 */
+	PV_IFTIME,            /* 22 */
+	PV_RANDOM,            /* 23 */
+	PV_SWITCH,            /* 24 */
+	PV_EXTENSION,         /* 25 */
+	PV_IGNOREPAT,         /* 26 */
+	PV_GLOBALS,           /* 27 */
 
 } pvaltype;
 
@@ -86,7 +88,8 @@
 		struct pval *statements; /* used in case, default, catch, while's statement, CONTEXT elements, GLOBALS */
 		char *val;  /* used in VARDEC */
 		char *for_test; /* used in FOR */
-		
+		int label_in_case; /* a boolean for LABELs */
+		struct pval *goto_target;  /* used in GOTO */
 	} u2;
 	
 	union
@@ -96,6 +99,8 @@
 		struct pval *macro_statements; /* used in MACRO */
 		int abstract;  /* used for context */
 		char *hints; /* used in EXTENSION */
+		int goto_target_in_case; /* used in GOTO */
+		struct ael_extension *compiled_label;
 	} u3;
 	
 	union
@@ -104,29 +109,33 @@
 		int regexten;                /* used in EXTENSION */
 	} u4;
 	
-	
 	struct pval *next; /* the pval at the end of this ptr will ALWAYS be of the same type as this one! 
 						  EXCEPT for objects of the different types, that are in the same list, like contexts & macros, etc */
 	
-	
+	struct pval *dad; /* the 'container' of this struct instance */
+	struct pval *prev; /* the opposite of the 'next' pointer */
 } ;
 
 
 typedef struct pval pval;
 
+#if 0
 pval *npval(pvaltype type, int first_line, int last_line, int first_column, int last_column);
 void linku1(pval *head, pval *tail);
 void print_pval_list(FILE *f, pval *item, int depth);
 void print_pval(FILE *f, pval *item, int depth);
-void check_pval(pval *item, struct argapp *apps);
 void ael2_semantic_check(pval *item, int *errs, int *warns, int *notes);
 struct pval *find_label_in_current_context(char *exten, char *label);
 struct pval *find_label_in_current_extension(char *label);
 int count_labels_in_current_context(char *label);
 struct pval *find_label_in_current_db(char *context, char *exten, char *label);
-struct pval *ael2_parse(char *fname, int *errs);
+void ael2_print(char *fname, pval *tree);
+#endif
+struct pval *ael2_parse(char *fname, int *errs);	/* in ael.flex */
 void destroy_pval(pval *item);
-void ael2_print(char *fname, pval *tree);
+
+extern char *prev_word;	/* in ael.flex */
+
 #ifndef YY_TYPEDEF_YY_SCANNER_T
 #define YY_TYPEDEF_YY_SCANNER_T
 typedef void* yyscan_t;
@@ -168,6 +177,8 @@
 	char *hints;
 	int regexten;
 	
+	struct ast_context *context;
+	
 	struct ael_priority *plist;
 	struct ael_priority *plist_last;
 	struct ael_extension *next_exten;
@@ -178,4 +189,4 @@
 	int return_needed;
 };
 
-
+#endif /* _ASTERISK_AEL_STRUCTS_H */

Modified: team/murf/AEL2-1.2/pbx/ael.flex
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2-1.2/pbx/ael.flex?rev=39566&r1=39565&r2=39566&view=diff
==============================================================================
--- team/murf/AEL2-1.2/pbx/ael.flex (original)
+++ team/murf/AEL2-1.2/pbx/ael.flex Sat Aug 12 13:21:31 2006
@@ -1,4 +1,3 @@
-%{
 /*
  * Asterisk -- An open source telephony toolkit.
  *
@@ -19,482 +18,437 @@
 /*! \file
  *
  * \brief Flex scanner description of tokens used in AEL2 .
- * 
- */#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "asterisk.h"
-#include "asterisk/logger.h"
-#include "ael.tab.h"
-#include "asterisk/ael_structs.h"
-
-static char pbcstack[400];
-static int pbcpos = 0;
-
-static int parencount = 0;
-static int commaout = 0;
-int my_lineno = 1;
-int my_col = 0;
-char *my_file = 0;
-char *prev_word;
-#define MAX_INCLUDE_DEPTH 50
-
-void reset_parencount(yyscan_t yyscanner );
-void reset_semicount(yyscan_t yyscanner );
-void reset_argcount(yyscan_t yyscanner );
-struct pval *ael2_parse(char *filename, int *errors);
-int ael_yyget_column  (yyscan_t yyscanner);
-void ael_yyset_column (int  column_no , yyscan_t yyscanner);
-int ael_yyparse (struct parse_io *);
-static void pbcpush(char x);
-static int pbcpop(char x);
-static void pbcwhere(char *text, int *line, int *col );
-static int c_prevword(void);
-
-struct stackelement
-{
-     char *fname;
-	 int lineno;
-     int colno;
-	 YY_BUFFER_STATE bufstate;
-};
-struct stackelement  include_stack[MAX_INCLUDE_DEPTH];
-int include_stack_index = 0;
-
-%}
-
+ *
+ */
+
+/*
+ * Start with flex options:
+ *
+ * %x describes the contexts we have: paren, semic and argg, plus INITIAL
+ */
 %x paren semic argg
+
+/* prefix used for various globally-visible functions and variables.
+ * This renames also yywrap, but since we do not use it, we just
+ * add option noyywrap to remove it.
+ */
 %option prefix="ael_yy"
+%option noyywrap
+
+/* batch gives a bit more performance if we are using it in
+ * a non-interactive mode. We probably don't care much.
+ */
 %option batch
+
+/* outfile is the filename to be used instead of lex.yy.c */
 %option outfile="ael_lex.c"
+
+/*
+ * These are not supported in flex 2.5.4, but we need them
+ * at the moment:
+ * reentrant produces a thread-safe parser. Not 100% sure that
+ * we require it, though.
+ * bison-bridge passes an additional yylval argument to yylex().
+ * bison-locations is probably not needed.
+ */
 %option reentrant
 %option bison-bridge
 %option bison-locations
-/* %option yylineno I've tried hard, but haven't been able to use this */
-%option noyywrap
+
+%{
+#include "asterisk.h"
+#include "asterisk/logger.h"
+#include "asterisk/utils.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "ael.tab.h"
+#include "asterisk/ael_structs.h"
+
+/*
+ * A stack to keep track of matching brackets ( [ { } ] )
+ */
+static char pbcstack[400];	/* XXX missing size checks */
+static int pbcpos = 0;
+static void pbcpush(char x);
+static int pbcpop(char x);
+
+static int parencount = 0;
+
+/*
+ * current line, column and filename, updated as we read the input.
+ */
+static int my_lineno = 1;	/* current line in the source */
+static int my_col = 1;		/* current column in the source */
+char *my_file = 0;		/* used also in the bison code */
+char *prev_word;		/* XXX document it */
+
+#define MAX_INCLUDE_DEPTH 50
+
+/*
+ * flex is not too smart, and generates global functions
+ * without prototypes so the compiler may complain.
+ * To avoid that, we declare the prototypes here,
+ * even though these functions are not used.
+ */
+int ael_yyget_column  (yyscan_t yyscanner);
+void ael_yyset_column (int  column_no , yyscan_t yyscanner);
+
+int ael_yyparse (struct parse_io *);
+
+/*
+ * A stack to process include files.
+ * As we switch into the new file we need to store the previous
+ * state to restore it later.
+ */
+struct stackelement {
+	char *fname;
+	int lineno;
+	int colno;
+	YY_BUFFER_STATE bufstate;
+};
+
+static struct stackelement  include_stack[MAX_INCLUDE_DEPTH];
+static int include_stack_index = 0;
+
+/*
+ * if we use the @n feature of bison, we must supply the start/end
+ * location of tokens in the structure pointed by yylloc.
+ * Simple tokens are just assumed to be on the same line, so
+ * the line number is constant, and the column is incremented
+ * by the length of the token.
+ */
+#ifdef FLEX_BETA	/* set for 2.5.33 */
+
+/* compute the total number of lines and columns in the text
+ * passed as argument.
+ */
+static void pbcwhere(const char *text, int *line, int *col )
+{
+	int loc_line = *line;
+	int loc_col = *col;
+	char c;
+	while ( (c = *text++) ) {
+		if ( c == '\t' ) {
+			loc_col += 8 - (loc_col % 8);
+		} else if ( c == '\n' ) {
+			loc_line++;
+			loc_col = 1;
+		} else
+			loc_col++;
+	}
+	*line = loc_line;
+	*col = loc_col;
+}
+
+#define	STORE_POS do {							\
+		yylloc->first_line = yylloc->last_line = my_lineno;	\
+		yylloc->first_column=my_col;				\
+		yylloc->last_column=my_col+yyleng-1;			\
+		my_col+=yyleng;						\
+	} while (0)
+
+#define	STORE_LOC do {					\
+		yylloc->first_line = my_lineno;		\
+		yylloc->first_column=my_col;		\
+		pbcwhere(yytext, &my_lineno, &my_col);	\
+		yylloc->last_line = my_lineno;		\
+		yylloc->last_column = my_col - 1;	\
+	} while (0)
+#else
+#define	STORE_POS
+#define	STORE_LOC
+#endif
+%}
+
+
+NOPARENS	([^()\[\]\{\}]|\\[()\[\]\{\}])*
+
+NOARGG		([^(),\{\}\[\]]|\\[,()\[\]\{\}])*
+
+NOSEMIC		([^;()\{\}\[\]]|\\[;()\[\]\{\}])*
 
 %%
-\{	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return LC;}
-\}	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return RC;}
-\(	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return LP;}
-\)	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return RP;}
-\;	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return SEMI;}
-\=	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return EQ;}
-\,	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return COMMA;}
-\:	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return COLON;}
-\&	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return AMPER;}
-\|	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return BAR;}
-\=\>	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return EXTENMARK;}
-\@	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return AT;}
-\/\/[^\n]*  {/*comment*/}
-context	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_CONTEXT;}
-abstract	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_ABSTRACT;}
-macro	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_MACRO;};
-globals	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_GLOBALS;}
-ignorepat	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_IGNOREPAT;}
-switch	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_SWITCH;}
-if	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_IF;}
-ifTime	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_IFTIME;}
-random	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_RANDOM;}
-regexten	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_REGEXTEN;}
-hint	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_HINT;}
-else	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_ELSE;}
-goto	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_GOTO;}
-jump	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_JUMP;}
-return	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_RETURN;}
-break	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_BREAK;}
-continue	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_CONTINUE;}
-for	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_FOR;}
-while	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_WHILE;}
-case	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_CASE;}
-default	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_DEFAULT;}
-pattern	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_PATTERN;}
-catch	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_CATCH;}
-switches	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_SWITCHES;}
-eswitches	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_ESWITCHES;}
-includes	{yylloc->first_line = yylloc->last_line = my_lineno; yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col;my_col+=yyleng;return KW_INCLUDES;}
-
-\n		{my_lineno++;my_col=0;}
-[ ]+	{/* nothing */ my_col+=yyleng;}
-[	]+	{/* nothing */ int wid = 8-(my_col%8); my_col+=wid;}
+
+\{		{ STORE_POS; return LC;}
+\}		{ STORE_POS; return RC;}
+\(		{ STORE_POS; return LP;}
+\)		{ STORE_POS; return RP;}
+\;		{ STORE_POS; return SEMI;}
+\=		{ STORE_POS; return EQ;}
+\,		{ STORE_POS; return COMMA;}
+\:		{ STORE_POS; return COLON;}
+\&		{ STORE_POS; return AMPER;}
+\|		{ STORE_POS; return BAR;}
+\=\>		{ STORE_POS; return EXTENMARK;}
+\@		{ STORE_POS; return AT;}
+\/\/[^\n]*	{/*comment*/}
+context		{ STORE_POS; return KW_CONTEXT;}
+abstract	{ STORE_POS; return KW_ABSTRACT;}
+macro		{ STORE_POS; return KW_MACRO;};
+globals		{ STORE_POS; return KW_GLOBALS;}
+ignorepat	{ STORE_POS; return KW_IGNOREPAT;}
+switch		{ STORE_POS; return KW_SWITCH;}
+if		{ STORE_POS; return KW_IF;}
+ifTime		{ STORE_POS; return KW_IFTIME;}
+random		{ STORE_POS; return KW_RANDOM;}
+regexten	{ STORE_POS; return KW_REGEXTEN;}
+hint		{ STORE_POS; return KW_HINT;}
+else		{ STORE_POS; return KW_ELSE;}
+goto		{ STORE_POS; return KW_GOTO;}
+jump		{ STORE_POS; return KW_JUMP;}
+return		{ STORE_POS; return KW_RETURN;}
+break		{ STORE_POS; return KW_BREAK;}
+continue	{ STORE_POS; return KW_CONTINUE;}
+for		{ STORE_POS; return KW_FOR;}
+while		{ STORE_POS; return KW_WHILE;}
+case		{ STORE_POS; return KW_CASE;}
+default		{ STORE_POS; return KW_DEFAULT;}
+pattern		{ STORE_POS; return KW_PATTERN;}
+catch		{ STORE_POS; return KW_CATCH;}
+switches	{ STORE_POS; return KW_SWITCHES;}
+eswitches	{ STORE_POS; return KW_ESWITCHES;}
+includes	{ STORE_POS; return KW_INCLUDES;}
+
+\n		{ my_lineno++; my_col = 1; }
+[ ]+		{ my_col += yyleng; }
+[\t]+		{ my_col += (yyleng*8)-(my_col%8); }
 
 [-a-zA-Z0-9'"_/.\<\>\*\+!$#\[\]][-a-zA-Z0-9'"_/.!\*\+\<\>\{\}$#\[\]]*	{
-                                               yylloc->first_line = yylloc->last_line = my_lineno;yylloc->last_column=my_col+yyleng-1; yylloc->first_column=my_col; /* set up the ptr */
-                                               yylval->str = strdup(yytext);  
-                                               /* printf("\nGot WORD %s[%d][%d:%d]\n", yylval->str, my_lineno ,yylloc->first_column,yylloc->last_column );  */
-                                               my_col+=yyleng; 
-                                               prev_word = yylval->str;
-                                               return word;
-                                        }
-
-<paren>[^()\[\]\{\}]*\)	{yylloc->first_line = my_lineno; yylloc->first_column=my_col; 
-                         if ( pbcpop(')') ) {
-                             /* error */
-                             int l4,c4;
-                             pbcwhere(yytext, &l4, &c4);
-                             ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression: %s !\n", my_file, my_lineno+l4, c4, yytext);
-                             BEGIN(0);
-                             yylloc->last_line = my_lineno+l4;
-                             yylloc->last_column=c4; 
-                             my_col=c4;
-                             my_lineno += l4;
-		                     yylval->str = strdup(yytext);
-                             prev_word = 0;
-                             return word;
-                         }
-                 parencount--;
-                 if ( parencount >= 0) {
-                   yymore();
-                 } else { 
-                   int l4,c4;
-                   pbcwhere(yytext, &l4, &c4);
-                   yylloc->last_line = my_lineno+l4;
-				   yylloc->last_column=c4; 
-                   yylval->str = strdup(yytext); 
-                   *(yylval->str+strlen(yylval->str)-1)=0;
-                   /* printf("Got paren word %s\n", yylval->str); */ 
-                   unput(')'); 
-	               my_col=c4;
-                   my_lineno += l4;
-                   BEGIN(0); 
-                   return word;
-                 } 
-                }
-
-<paren>[^()\[\]\{\}]*\(	{yylloc->first_line = my_lineno; yylloc->first_column=my_col; 
-                  parencount++; pbcpush('(');
-                  yymore();
-                 }
-<paren>[^()\[\]\{\}]*\[	{yylloc->first_line = my_lineno;yylloc->first_column=my_col; yymore(); pbcpush('['); }
-<paren>[^()\[\]\{\}]*\]	{yylloc->first_line = my_lineno;yylloc->first_column=my_col; 
-                         if ( pbcpop(']') ) {
-                             /* error */
-                             int l4,c4;
-                             pbcwhere(yytext, &l4, &c4);
-                             ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ']' in expression!\n", my_file, my_lineno+l4, c4);
-                             BEGIN(0);
-                             yylloc->last_line = my_lineno+l4;
-                             yylloc->last_column=c4; 
-                             my_col=c4;
-                             my_lineno += l4;
-		                     yylval->str = strdup(yytext);
-                             return word;
-                         }
-                         yymore();
-                        }
-<paren>[^()\[\]\{\}]*\{	{yylloc->first_line = my_lineno;yylloc->first_column=my_col;  yymore(); pbcpush('{'); }
-<paren>[^()\[\]\{\}]*\}	{yylloc->first_line = my_lineno;
-                         yylloc->first_column=my_col; 
-                         if ( pbcpop('}') ) {
-                             /* error */
-                             int l4,c4;
-                             pbcwhere(yytext, &l4, &c4);
-                             ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '}' in expression!\n", my_file, my_lineno+l4, c4);
-                             BEGIN(0);
-                             yylloc->last_line = my_lineno+l4;
-                             yylloc->last_column=c4; 
-                             my_col=c4;
-                             my_lineno += l4;
-		                     yylval->str = strdup(yytext);
-                             return word;
-                         }
-                         yymore();
-                        }
-
-
-<argg>[^(),\{\}\[\]]*\)	{/* printf("ARGG:%s\n",yytext); */
-					int linecount = 0;
-                    int colcount = my_col;
-					char *pt = yytext;
-
-					yylloc->first_line = my_lineno;
-                    yylloc->first_column=my_col; 
-                         if ( pbcpop(')') ) {
-                             /* error */
-                             int l4,c4;
-                             pbcwhere(yytext, &l4, &c4);
-                             ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression!\n", my_file, my_lineno+l4, c4);
-                             BEGIN(0);
-                             yylloc->last_line = my_lineno+l4;
-                             yylloc->last_column=c4; 
-                             my_col=c4;
-                             my_lineno += l4;
-		                     yylval->str = strdup(yytext);
-                             return word;
-                         }
-                   
-
-					while (*pt) {
-                       if (*pt == '\n') {
-                           linecount++;
-                           colcount=0;
-                       }
-                       pt++;
-                       colcount++;
-                    }
-                    yylloc->last_line = my_lineno+linecount;
-                    yylloc->last_column=colcount; 
-                    parencount--;
-                    if( parencount >= 0){ 
-                        yymore(); 
-                    } else { 
-                        yylval->str = strdup(yytext); 
-					   if(yyleng > 1 ) 
-                              *(yylval->str+yyleng-1)=0;
-                       /* printf("Got argg word '%s'\n", yylval->str);  */
-                       BEGIN(0); 
-                       if ( !strcmp(yylval->str,")") ) { 
-                             free(yylval->str); 
-                             yylval->str = 0; 
-                             my_col+=1;
-                             return RP;  
-                       } else {
-                             unput(')');
-                             my_col=colcount;
-							 my_lineno+=linecount;
-                             return word;
-                       }
-                    } 
-                }
-<argg>[^(),\{\}\[\]]*\(	  { /* printf("ARGG:%s\n",yytext); */
-                      /* printf("GOT AN LP!!!\n"); */
-                      yylloc->first_line = my_lineno;
-                      yylloc->first_column=my_col; 
-                      parencount++; 
-                      pbcpush('(');
-                      yymore();
-                  }
-
-<argg>[^(),\{\}\[\]]*\,	{  /* printf("ARGG:%s\n",yytext); */
-                  if( parencount != 0) { 
-					/* printf("Folding in a comma!\n"); */ 
-					yymore();
-				  } else  { 
-                     /* printf("got a comma!\n\n");  */
-					 int linecount = 0;
-                     int colcount = my_col;
-					 char *pt;
-
-					 pt = yytext;
-					 while (*pt) {
-                        if ( *pt == '\n' ) {
-                           linecount++;
-                           colcount=0;
-                        }
-                        pt++;
-                        colcount++;
-                     }
-                     yylloc->first_line = my_lineno; 
-                     yylloc->last_line = my_lineno+linecount; 
-                     yylloc->last_column=colcount; 
-                     yylloc->first_column=my_col;
-                     if( !commaout ) { 
-						if( !strcmp(yytext,"," ) ) 
-							{commaout = 0; my_col+=1; return COMMA;} 
-						yylval->str = strdup(yytext); /* printf("Got argg2 word %s\n", yylval->str); */ 
-						unput(','); 
-						commaout = 1; 
-						if(yyleng > 1 ) 
-							*(yylval->str+yyleng-1)=0;
-                        my_lineno+=linecount;
-						my_col=colcount;
-						return word;
-					 } else {
-                            commaout = 0;
-							my_col+=1;
-							return COMMA;
-						}
-                   }
+		STORE_POS;
+		yylval->str = strdup(yytext);
+		prev_word = yylval->str;
+		return word;
+	}
+
+
+
+	/*
+	 * context used for arguments of if_head, random_head, switch_head,
+	 * for (last statement), while (XXX why not iftime_head ?).
+	 * End with the matching parentheses.
+	 * A comma at the top level is valid here, unlike in argg where it
+	 * is an argument separator so it must be returned as a token.
+	 */
+<paren>{NOPARENS}\)	{
+		if ( pbcpop(')') ) {	/* error */
+			STORE_LOC;
+			ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression: %s !\n", my_file, my_lineno, my_col, yytext);
+			BEGIN(0);
+			yylval->str = strdup(yytext);
+			prev_word = 0;
+			return word;
+		}
+		parencount--;
+		if ( parencount >= 0) {
+			yymore();
+		} else {
+			STORE_LOC;
+			yylval->str = strdup(yytext);
+			yylval->str[yyleng-1] = '\0'; /* trim trailing ')' */
+			unput(')');
+			BEGIN(0);
+			return word;
+		}
+	}
+
+<paren>{NOPARENS}[\(\[\{]	{
+		char c = yytext[yyleng-1];
+		if (c == '(')
+			parencount++;
+		pbcpush(c);
+		yymore();
+	}
+
+<paren>{NOPARENS}[\]\}]	{
+		char c = yytext[yyleng-1];
+		if ( pbcpop(c))  { /* error */
+			STORE_LOC;
+			ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n",
+				my_file, my_lineno, my_col, c);
+			BEGIN(0);
+			yylval->str = strdup(yytext);
+			return word;
+		}
+		yymore();
+	}
+
+
+	/*
+	 * handlers for arguments to a macro or application calls.
+	 * We enter this context when we find the initial '(' and
+	 * stay here until we close all matching parentheses,
+	 * and find the comma (argument separator) or the closing ')'
+	 * of the (external) call, which happens when parencount == 0
+	 * before the decrement.
+	 */
+<argg>{NOARGG}[\(\[\{]	  {
+		char c = yytext[yyleng-1];
+		if (c == '(')
+			parencount++;
+		pbcpush(c);
+		yymore();
+	}
+
+<argg>{NOARGG}\)	{
+		if ( pbcpop(')') ) { /* error */
+			STORE_LOC;
+			ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression!\n", my_file, my_lineno, my_col);
+			BEGIN(0);
+			yylval->str = strdup(yytext);
+			return word;
+		}
+
+		parencount--;
+		if( parencount >= 0){
+			yymore();
+		} else {
+			STORE_LOC;
+			BEGIN(0);
+			if ( !strcmp(yytext, ")") )
+				return RP;
+			yylval->str = strdup(yytext);
+			yylval->str[yyleng-1] = '\0'; /* trim trailing ')' */
+			unput(')');
+			return word;
+		}
+	}
+
+<argg>{NOARGG}\,	{
+		if( parencount != 0) { /* printf("Folding in a comma!\n"); */
+			yymore();
+		} else  {
+			STORE_LOC;
+			if( !strcmp(yytext,"," ) )
+				return COMMA;
+			yylval->str = strdup(yytext);
+			yylval->str[yyleng-1] = '\0';
+			unput(',');
+			return word;
+		}
+	}
+
+<argg>{NOARGG}[\]\}]	{
+		char c = yytext[yyleng-1];
+		if ( pbcpop(c) ) { /* error */
+			STORE_LOC;
+			ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n", my_file, my_lineno, my_col, c);
+			BEGIN(0);
+			yylval->str = strdup(yytext);
+			return word;
+		}
+		yymore();
+	}
+
+	/*
+	 * context used to find tokens in the right hand side of assignments,
+	 * or in the first and second operand of a 'for'. As above, match
+	 * commas and use ';' as a separator (hence return it as a separate token).
+	 */
+<semic>{NOSEMIC}[\(\[\{]	{
+		char c = yytext[yyleng-1];
+		yymore();
+		pbcpush(c);
+	}
+
+<semic>{NOSEMIC}[\)\]\}]	{
+		char c = yytext[yyleng-1];
+		if ( pbcpop(c) ) { /* error */
+			STORE_LOC;
+			ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '%c' in expression!\n", my_file, my_lineno, my_col, c);
+			BEGIN(0);
+			yylval->str = strdup(yytext);
+			return word;
+		}
+		yymore();
+	}
+
+<semic>{NOSEMIC};	{
+		STORE_LOC;
+		yylval->str = strdup(yytext);
+		yylval->str[yyleng-1] = '\0';
+		unput(';');
+		BEGIN(0);
+		return word;
+	}
+
+\#include[ \t]+\"[^\"]+\" {
+		FILE *in1;
+		char fnamebuf[1024],*p1,*p2;
+		int error = 1;	/* don't use the file if set */
+		p1 = strchr(yytext,'"');
+		p2 = strrchr(yytext,'"');
+		if ( include_stack_index >= MAX_INCLUDE_DEPTH ) {
+			ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Includes nested too deeply! Wow!!! How did you do that?\n", my_file, my_lineno, my_col);
+		} else if ( (int)(p2-p1) > sizeof(fnamebuf) - 1 ) {
+			ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Filename is incredibly way too long (%d chars!). Inclusion ignored!\n", my_file, my_lineno, my_col, yyleng - 10);
+		} else {
+			int i;
+			strncpy(fnamebuf, p1, p2-p1);
+			fnamebuf[p2-p1] = 0;
+			for (i=0; i<include_stack_index; i++) {
+				if ( !strcmp(fnamebuf,include_stack[i].fname )) {
+					ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Nice Try!!! But %s has already been included (perhaps by another file), and would cause an infinite loop of file inclusions!!! Include directive ignored\n",
+						my_file, my_lineno, my_col, fnamebuf);
+					break;
 				}
-
-<argg>[^(),\{\}\[\]]*\{	{/*printf("ARGG:%s\n",yytext);*/yylloc->first_line = my_lineno;yylloc->first_column=my_col; pbcpush('{'); yymore();  }
-<argg>[^(),\{\}\[\]]*\}	{/*printf("ARGG:%s\n",yytext);*/yylloc->first_line = my_lineno;yylloc->first_column=my_col; 
-                         if ( pbcpop('}') ) {
-                             /* error */
-                             int l4,c4;
-                             pbcwhere(yytext, &l4, &c4);
-                             ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '}' in expression!\n", my_file, my_lineno+l4, my_col+c4);
-                             BEGIN(0);
-                             yylloc->last_line = my_lineno+l4;
-                             yylloc->last_column=my_col+c4; 
-                             my_col=c4;
-                             my_lineno += l4;
-		                     yylval->str = strdup(yytext);
-                             return word;
-                         }
-                         yymore();
-				}
-<argg>[^(),\{\}\[\]]*\[	{/*printf("ARGG:%s\n",yytext);*/yylloc->first_line = my_lineno;yylloc->first_column=my_col; yymore(); pbcpush('['); }
-<argg>[^(),\{\}\[\]]*\]	{/*printf("ARGG:%s\n",yytext);*/yylloc->first_line = my_lineno;yylloc->first_column=my_col; 
-                         if ( pbcpop(']') ) {
-                             /* error */
-                             int l4,c4;
-                             pbcwhere(yytext, &l4, &c4);
-                             ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ']' in expression!\n", my_file, my_lineno+l4, c4);
-                             BEGIN(0);
-                             yylloc->last_line = my_lineno+l4;
-                             yylloc->last_column=c4; 
-                             my_col=c4;
-                             my_lineno += l4;
-		                     yylval->str = strdup(yytext);
-                             return word;
-                         }
-                         yymore();
-				}
-
-
-<semic>[^;()\{\}\[\]]*\[	{/*printf("SEMIC:%s\n",yytext);*/yylloc->first_line = my_lineno;yylloc->first_column=my_col; yymore(); pbcpush('['); }
-<semic>[^;()\{\}\[\]]*\]	{/*printf("SEMIC:%s\n",yytext);*/yylloc->first_line = my_lineno;yylloc->first_column=my_col; 
-                         if ( pbcpop(']') ) {
-                             /* error */
-                             int l4,c4;
-                             pbcwhere(yytext, &l4, &c4);
-                             ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ']' in expression!\n", my_file, my_lineno+l4, c4);
-                             BEGIN(0);
-                             yylloc->last_line = my_lineno+l4;
-                             yylloc->last_column=c4; 
-                             my_col=c4;
-                             my_lineno += l4;
-		                     yylval->str = strdup(yytext);
-                             return word;
-                         }
-                         yymore();}
-<semic>[^;()\{\}\[\]]*\{	{/*printf("SEMIC:%s\n",yytext);*/yylloc->first_line = my_lineno;yylloc->first_column=my_col; yymore(); pbcpush('{');}
-<semic>[^;()\{\}\[\]]*\}	{/*printf("SEMIC:%s\n",yytext);*/yylloc->first_line = my_lineno;yylloc->first_column=my_col; 
-                         if ( pbcpop('}') ) {
-                             /* error */
-                             int l4,c4;
-                             pbcwhere(yytext, &l4, &c4);
-                             ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched '}' in expression!\n", my_file, my_lineno+l4, my_col+c4);
-                             BEGIN(0);
-                             yylloc->last_line = my_lineno+l4;
-                             yylloc->last_column=my_col+c4; 
-                             my_col=c4;
-                             my_lineno += l4;
-		                     yylval->str = strdup(yytext);
-                             return word;
-                         }
-                         yymore();}
-<semic>[^;()\{\}\[\]]*\(	{/*printf("SEMIC:%s\n",yytext);*/yylloc->first_line = my_lineno;yylloc->first_column=my_col; yymore(); pbcpush('(');}
-<semic>[^;()\{\}\[\]]*\)	{/*printf("SEMIC:%s\n",yytext);*/yylloc->first_line = my_lineno;yylloc->first_column=my_col; 
-                         if ( pbcpop(')') ) {
-                             /* error */
-                             int l4,c4;
-                             pbcwhere(yytext, &l4, &c4);
-                             ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Mismatched ')' in expression!\n", my_file, my_lineno+l4, my_col+c4);
-                             BEGIN(0);
-                             yylloc->last_line = my_lineno+l4;
-                             yylloc->last_column=my_col+c4; 
-                             my_col=c4;
-                             my_lineno += l4;
-		                     yylval->str = strdup(yytext);
-                             return word;
-                         }
-                         yymore();}
-<semic>[^;()\{\}\[\]]*;	{
-					int linecount = 0;
-                    int colcount = my_col;
-					char *pt = yytext;
-					while (*pt) {
-                       if ( *pt == '\n' ) {
-                           linecount++;
-                           colcount=0;
-                       }
-                       pt++;
-                       colcount++;
-                    }
-                    yylloc->first_line = my_lineno; 
-					yylloc->last_line = my_lineno+linecount; 
-					yylloc->last_column=colcount; 
-					yylloc->first_column=my_col;
-                    yylval->str = strdup(yytext);
-                    if(yyleng > 1)
-                      *(yylval->str+yyleng-1)=0;
-                    /* printf("Got semic word %s\n", yylval->str); */
-                    unput(';');
-                    BEGIN(0);
-                    my_col=colcount;
-                    my_lineno += linecount;
-                    return word;
-                }
-
-\#include[ \t]+\"[^\"]+\" {
-                     FILE *in1;
-					 char fnamebuf[1024],*p1,*p2;
-                     if ( include_stack_index >= MAX_INCLUDE_DEPTH ) {
-						ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Includes nested too deeply! Wow!!! How did you do that?\n", my_file, my_lineno, my_col);
-                     } else {
-                         p1 = strchr(yytext,'"');
-                         p2 = strrchr(yytext,'"');
-                         if ( (int)(p2-p1) > 1023 ) {
-							ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Filename is incredibly way too long (%d chars!). Inclusion ignored!\n", my_file, my_lineno, my_col, yyleng - 10);
-        	             } else {
-								int i;
-								int found = 0;
-								for (i=0; i<include_stack_index; i++) {
-									if ( !strcmp(fnamebuf,include_stack[i].fname )) {
-										ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Nice Try!!! But %s has already been included (perhaps by another file), and would cause an infinite loop of file inclusions!!! Include directive ignored\n", 
-												my_file, my_lineno, my_col, fnamebuf);
-										found=1;
-										break;
-									}
-								}
-								if( !found )
-								{

[... 9591 lines stripped ...]


More information about the svn-commits mailing list