11 #include "bindparser.h"
14 #define MAX_INCLUDE_DEPTH 10
15 YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
16 int include_stack_ln[MAX_INCLUDE_DEPTH];
17 char *include_stack_name[MAX_INCLUDE_DEPTH];
18 char *current_filename;
19 char *original_filename;
20 int include_stack_ptr = 0;
21 extern const char *bind_directory;
30 %option noyy_top_state
37 <comment>[^*\n]* /* eat anything that's not a '*' */
38 <comment>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
39 <comment>\n ++linenumber;
40 <comment>"*"+"/" BEGIN(INITIAL);
43 <incl>[ \t;]* /* eat the whitespace */
44 <incl>\"[^ \t\n";]+\"; { /* got the include file name */
46 if ( include_stack_ptr >= MAX_INCLUDE_DEPTH )
48 fprintf( stderr, "Includes nested too deeply" );
52 yytext[strlen(yytext)-2]=0;
54 include_stack[include_stack_ptr]=YY_CURRENT_BUFFER;
55 include_stack_name[include_stack_ptr]=current_filename=strdup(yytext+1);
56 include_stack_ln[include_stack_ptr++]=linenumber;
59 strcpy(filename,yytext+1);
61 strcpy(filename,bind_directory);
63 strcat(filename,yytext+1);
66 if (*yytext &&!(yyin=fopen(filename,"r"))) {
67 fprintf( stderr, "Unable to open '%s': %s\n",filename,strerror(errno));
72 yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
78 if ( --include_stack_ptr < 0 )
86 yy_delete_buffer(YY_CURRENT_BUFFER);
87 yy_switch_to_buffer(include_stack[include_stack_ptr]);
88 linenumber=include_stack_ln[include_stack_ptr];
89 free(include_stack_name[include_stack_ptr]);
91 current_filename=include_stack_name[include_stack_ptr-1];
93 current_filename=original_filename;
103 options return OPTIONSTOK;
104 also-notify return ALSONOTIFYTOK;
106 logging return LOGGINGTOK;
107 directory return DIRECTORYTOK;
108 masters return MASTERTOK;
110 \" yy_push_state(quoted);
111 <quoted>[^\"]* yylval=strdup(yytext); return QUOTEDWORD;
112 <quoted>\" yy_pop_state();
113 [^\" \t\n{};]* yylval=strdup(yytext);return AWORD;
122 fprintf(stderr,"Parsing '%s': unable to parse line %d at character '%s'\n",current_filename, linenumber, yytext);