/*------------------------------------------------------------------------*/ /* capaLexerDef.flex created by Isaac Tsai Jul 15 1996 */ /* added /END(variable) */ /* added /HIN .... /DIS(variable) ... */ /* Jan 15 1998 /{KeyWord}{KeyWord}{KeyWord} */ /* replaced by /DIS */ /* catch "No /END() statement found" */ /* catch "/DIS(")" and "/DIS(""")" errors " */ /* catch "/LET var = " */ /* add a new token EoL to indicate '\n' '\r''\n' and '\r' */ /* This file is based on flex 2.5.3, flex 2.3 apparantly cannot take it :-( */ /* DONE /RMAP() function July 14, 1998 */ /* DONE /AND /OR answer formats July 20, 1998 */ /* DONE /IF () /ENDIF July 26, 1998 */ /* DONE /WHILE () /ENDWHILE August 10 1998 */ /* DONE /VERB /ENDVERB Feb 20 1998 */ /*------------------------------------------------------------------------*/ /**************************************************************************/ %{ #include #include /* strtod(), strtol() */ #include #ifdef NeXT #include #else #include /* access() */ #endif #include "capaCommon.h" /* capa_access() */ #include "capaParser.h" /* _symbol structure def */ #include "lex_debug.h" /* defined RETURN(xxx) macro */ #ifdef YYSTYPE #undef YYSTYPE #endif #define YYSTYPE Symbol_p #include "capaToken.h" /* from YACC -d capaGrammarDef.y */ /* ============================================== begin of code */ #define LEX_BUFLEN (8*1024) /* lexical buffer size (for each opened file) */ #ifdef YYLMAX #undef YYLMAX #define YYLMAX 8192 #endif void yyfatalerror(char*msg); #define YY_FATAL_ERROR yyfatalerror #ifdef LEX_DBUG #define LLDBUG_PRL1(xx) { printf("Line %d ",Current_line[Input_idx]); printf(xx); fflush(stdout); } #define LLDBUG_PRL2(xx,yy) { printf("Line %d ",Current_line[Input_idx]); printf(xx,yy); fflush(stdout); } #define LLDBUG_PR1(xx) { printf(xx); fflush(stdout); } #define LLDBUG_PR2(xx,yy) { printf(xx,yy); fflush(stdout); } #define LLDBUG_PR3(xx,yy,zz) { printf(xx,yy,zz); fflush(stdout); } #else #define LLDBUG_PRL1(xx) { } #define LLDBUG_PRL2(xx,yy) { } #define LLDBUG_PR1(xx) { } #define LLDBUG_PR2(xx,yy) { } #define LLDBUG_PR3(xx,yy,zz) { } #endif #ifdef LEX_INPUT_DBUG #define LIDBUG_PR1(xx) { printf(xx); fflush(stdout); } #define LIDBUG_PR2(xx,yy) { printf(xx,yy); fflush(stdout); } #define LIDBUG_PR3(xx,yy,zz) { printf(xx,yy,zz); fflush(stdout); } #else #define LIDBUG_PR1(xx) { } #define LIDBUG_PR2(xx,yy) { } #define LIDBUG_PR3(xx,yy,zz) { } #endif #ifdef USE_DYNAMIC_SYMBOLS #define USE_DYNAMIC_LEXBUFS #endif Symbol *yylval; /* global pointer to symbol */ FILE *(Input_stream[MAX_OPENED_FILE]); /* <-- perhaps we can use linked list */ char Opened_filename[MAX_OPENED_FILE][QUARTER_K]; /* <-- perhaps we can use linked list */ int Input_idx; int Lexi_pos[MAX_OPENED_FILE]; /* Current position in the line */ #ifdef USE_DYNAMIC_LEXBUFS char *(Lexi_buf[MAX_OPENED_FILE]); /* Line Buffer for current file */ #else char Lexi_buf[MAX_OPENED_FILE][LEX_BUFLEN+4]; /* Line Buffer for current file */ #endif /* USE_DYNAMIC_LEXBUFS */ char String_buf[LEX_BUFLEN]; /* Constant String buffer <-- perhaps we can use char pointer */ char *Dynamic_buf; int Dynamic_buf_max; int Dynamic_buf_cur; static int End_of_input; static int Pcount, Bcount; /* static means only available in this file */ /* --------------------------------------------------------------------------- */ /* GLOBAL VARIABLES */ /* --------------------------------------------------------------------------- */ int Lexi_line; /* Current source file line number, counting from beginning */ extern int Current_line[MAX_OPENED_FILE]; int Func_idx; Symbol FuncStack[MAX_FUNC_NEST]; /* <-- perhaps we can use linked list */ int Array_idx; Symbol *ArraySymbList_p; Symbol *ArraySymbLast_p; Symbol *FmlSymbList_p; Symbol *FmlSymbLast_p; int FmlSymb_cnt; int Symb_count; int IFstatus[MAX_FUNC_NEST]; /* <-- perhaps we can use linked list */ int IFcurrent[MAX_FUNC_NEST]; /* <-- perhaps we can use linked list */ int IFcount; WhileLoop_t WhileStack[MAX_FUNC_NEST]; /* <-- perhaps we can use linked list */ int While_idx, Wcount; #ifdef USE_DYNAMIC_SYMBOLS Symbol *SymbList_p; Symbol *SymbLast_p; #else Symbol SymbArray[MAX_SYMB_COUNT]; #endif /* USE_DYNAMIC_SYMBOLS */ char *Current_char_p; /* Collect string constant */ extern char *EndText_p; extern char *StartText_p; extern Problem_t *LexiProblem_p; extern Problem_t *LastProblem_p; int first_run=1; int Stop_Parser; int scriptopen=0; #define FLEX #define YY_STACK_USED 1 /* for yy_push_state(), yy_pop_state() */ #ifdef FLEX int capaL_unput(); int capaL_input(); /* YY_INPUT() Controls scanner input. By default, YY_INPUT reads from the file-pointer yyin. Its action is to place up to max_size characters in the character array buf and return in the integer variable result either the number of characters read or the constant YY_NULL to indicate EOF. max_size is defined to be num_to_read = 8192 in liby Following is a sample redefinition of YY_INPUT, in the definitions section of the input file: %{ #undef YY_INPUT #define YY_INPUT(buf,result,max_size)\ {\ int c = getchar();\ result = (c == EOF) ? YY_NULL : (buf[0] = c, 1);\ } %} */ /* fgets() reads the input stream until n-1 bytes have been read OR a newline character is read and transferred to string OR an EOF (End-of-File) condition is encountered The string is then terminated with a NULL character. ii = fseek(FILE *stream,0L,SEEK_END) ; if(ii!=0) { error } leng = ftell(FILE *stream) + 1 ; fseek(FILE *stream,0L,SEEK_SET) ; Lexi_buf[Input_idx] = (char *)capa_malloc(sizeof(char)*leng,1); */ #ifdef AVOIDYYINPUT #define MAX_INCLUDE_DEPTH 10 YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; int include_stack_ptr = 0; #else #ifdef USE_DYNAMIC_LEXBUFS #define NEWYYINPUT #endif #ifdef NEWYYINPUT void newyy_input (char *buf,int *result,int max_size); #define YY_INPUT(buf,result,max_size) newyy_input(buf,&result,max_size) #else #ifdef USE_DYNAMIC_LEXBUFS #define YY_INPUT(buf,result,max_size) \ { int ii, leng, out_of_char; \ if (!Lexi_line) { /* was startup */ \ for(ii=0;ii < MAX_OPENED_FILE;ii++) { \ Lexi_buf[ii] = NULL; \ Lexi_pos[ii] = 0; \ Current_line[ii] = 0; \ } \ Input_idx = 0; \ first_run=0; \ yyin = Input_stream[Input_idx]; LIDBUG_PR1("<>\n"); \ } \ out_of_char = 0; \ if ( Lexi_buf[Input_idx] == NULL ) { \ Lexi_buf[Input_idx] = (char *)capa_malloc(sizeof(char)*LEX_BUFLEN+1,1); out_of_char=1; \ } else { \ if (!Lexi_buf[Input_idx][Lexi_pos[Input_idx]]) { /* test if the line buffer is empty or at the end */ \ out_of_char=1; \ } \ } \ if( out_of_char ) { \ if (fgets(Lexi_buf[Input_idx],LEX_BUFLEN-1,Input_stream[Input_idx])==NULL) { /* read in one line */ \ LIDBUG_PR2("<>\n",Input_idx); \ if( (Input_idx > 0) && ( Lexi_buf[Input_idx][Lexi_pos[Input_idx]] == '\0') ) { \ LIDBUG_PR2("<>\n",Input_idx); \ fclose(Input_stream[Input_idx]); \ capa_mfree((char *)Lexi_buf[Input_idx]); \ Lexi_buf[Input_idx] = NULL; \ Input_idx--; \ yyin = Input_stream[Input_idx]; \ /* (Lexi_pos[Input_idx])++; */ \ buf[0] = Lexi_buf[Input_idx][Lexi_pos[Input_idx]-1]; \ result = 1; \ } else { \ result = YY_NULL; /* End of File */ \ } \ } else { /* successfully read in one line */ \ if (Lexi_buf[Input_idx]==NULL) puts("Whatup?");\ leng = strlen(Lexi_buf[Input_idx]); \ LIDBUG_PR3("<>\n",leng,Input_idx); \ Lexi_pos[Input_idx] = 0; \ Lexi_line++; \ Current_line[Input_idx]++; \ (Lexi_pos[Input_idx])++; \ buf[0] = Lexi_buf[Input_idx][Lexi_pos[Input_idx]-1]; \ /* need to take care of return continuation conditions */ \ /* so, we return to one-char-at-a-time approach */ \ /* for(ii=0;ii>\n",Input_idx); */ \ (Lexi_pos[Input_idx])++; \ buf[0] = Lexi_buf[Input_idx][Lexi_pos[Input_idx]-1]; \ result = 1; \ } \ if (Stop_Parser==1) { \ result = YY_NULL; \ } \ } #else #define YY_INPUT(buf,result,max_size) \ { int ii, leng; \ if (!Lexi_line) { /* was startup */ \ for(ii=0;ii < MAX_OPENED_FILE;ii++) { \ Lexi_buf[ii][0]=0; \ Lexi_pos[ii] = 0; \ Current_line[ii] = 0; \ } \ Input_idx = 0; \ first_run=0; \ yyin = Input_stream[Input_idx]; LIDBUG_PR1("<>\n"); \ } \ if (!Lexi_buf[Input_idx][Lexi_pos[Input_idx]]) { /* test if the line buffer is empty or at the end */ \ if (fgets(Lexi_buf[Input_idx],LEX_BUFLEN-1,Input_stream[Input_idx])==NULL) { /* read in one line */ \ LIDBUG_PR2("<>\n",Input_idx); \ if( (Input_idx > 0) && ( Lexi_buf[Input_idx][Lexi_pos[Input_idx]] == '\0') ) { \ LIDBUG_PR2("<>\n",Input_idx); \ fclose(Input_stream[Input_idx]); \ Input_idx--; \ yyin = Input_stream[Input_idx]; \ /* (Lexi_pos[Input_idx])++; */ \ buf[0] = Lexi_buf[Input_idx][Lexi_pos[Input_idx]-1]; \ result = 1; \ } else { \ result = YY_NULL; /* End of File */ \ } \ } else { /* successfully read in one line */ \ leng = strlen(Lexi_buf[Input_idx]); \ LIDBUG_PR3("<>\n",leng,Input_idx); \ Lexi_pos[Input_idx] = 0; \ Lexi_line++; \ Current_line[Input_idx]++; \ (Lexi_pos[Input_idx])++; \ buf[0] = Lexi_buf[Input_idx][Lexi_pos[Input_idx]-1]; \ /* need to take care of return continuation conditions */ \ /* so, we return to one-char-at-a-time approach */ \ /* for(ii=0;ii>\n",Input_idx); */ \ (Lexi_pos[Input_idx])++; \ buf[0] = Lexi_buf[Input_idx][Lexi_pos[Input_idx]-1]; \ result = 1; \ } \ if (Stop_Parser==1) { \ result = YY_NULL; \ } \ } #endif /* USE_DYNAMIC_LEXBUFS */ #endif /*NEWYYINPUT*/ #endif /*AVOIDYYINPUT*/ #else #undef input #undef unput #endif int capa_eof(); %} Alpha [a-zA-Z_] KeyChar [A-Z] AlphaNum [a-zA-Z_0-9] Number [0-9] HexNumber [0-9a-fA-F] Space [ \t] Spaces ({Space}*) FileName (\"[^"\n]*\") Qchar ([0-9a-zA-Z \t!?\._,:;'"`~@#$%\^&\+\-\*=|\[\]{}()]) Operator ([=\+\-\*/%<>!&|,]) Identifier ([a-zA-Z_][a-zA-Z_0-9]*) EndLine ([\r][\n]|[\n]) %a 10500 %o 15000 %k 10000 %p 10000 %n 1000 %x S_COMMENT S_HINT S_HINTEXLAINX S_IMPORT S_EXPLAIN S_ENDX S_UNIT S_IGNORE %x S_SKIP S_VARIABLE S_LET S_DEFINE S_TEXT S_MAP S_FIGURE S_ANSWER %x S_STRING S_ANSCONTINUE S_TRUE_FALSE_STMT S_IF_SKIP S_WHILE_SKIP %x S_NEXT_LINE S_VERB %array %% { {EndLine} BEGIN S_IGNORE; [^\n]*$ BEGIN S_IGNORE; <> { capa_eof(); #ifndef AVOIDYYINPUT yyterminate(); #endif } } { {EndLine}{Spaces}"//"[^\n]*$ {LLDBUG_PRL2("[COMMENT<%s>]\n",yytext); remove_delayed(); send("%s",yytext); send_delayed("\n\n"); } [^\n]*{EndLine} BEGIN S_TEXT; } { ^{Spaces}"/LET" | ^{Spaces}"/BEG" { LLDBUG_PRL1("[LET]"); Pcount = 0; BEGIN S_LET; if (!scriptopen){send(""); } } { [;,] { LLDBUG_PR2("[%c]",yytext[0]); return(yytext[0]); } [\)] { LLDBUG_PR1("[) in MAP]"); Pcount--; if(Pcount==0) { BEGIN S_SKIP; } return(yytext[0]); } } { {Space}+ { /* ignore white spaces */ } [\\]{Space}*{EndLine} { /* continuation */ } {EndLine} { /* end of answer and/or other answers */ LLDBUG_PR1("[complete an answer]"); BEGIN S_TEXT; } "/AND" { LLDBUG_PR1("[AND]"); RETURN(ANS_AND); } "/OR" { LLDBUG_PR1("[OR]"); RETURN(ANS_OR); } } { ^{Spaces}"/IF"[^\n]*{EndLine} { IFcount++; LLDBUG_PRL2("[Skip IF ]\n",IFcount); IFstatus[IFcount] = IF_DONT_CARE; } ^{Spaces}"/ELSE"[^\n]*{EndLine} { LLDBUG_PRL2("[Skip ELSE ]",IFcount); IFcurrent[IFcount]=RUN_ELSE_PORTION; if( IFstatus[IFcount] == IF_FALSE ) { LLDBUG_PRL1("[ELSE begin TEXT CR]\n"); BEGIN S_TEXT; } if( IFstatus[IFcount] == IF_TRUE ) { LLDBUG_PRL1("[ELSE THIS SHOULD NEVER HAPPEN.]\n"); } } ^{Spaces}"/ENDIF"[^\n]*{EndLine} { IFcount--; LLDBUG_PRL2("[Skip ENDIF ]\n",IFcount); if( IFcount == 0 ) { LLDBUG_PRL1("[ENDIF begin TEXT CR]\n"); BEGIN S_TEXT; } if( (IFcurrent[IFcount] == RUN_IF_PORTION )&&(IFstatus[IFcount] == IF_TRUE)) { LLDBUG_PRL1("[ENDIF begin TEXT CR]\n"); BEGIN S_TEXT; } if( (IFcurrent[IFcount] == RUN_ELSE_PORTION )&&(IFstatus[IFcount] == IF_FALSE)) { LLDBUG_PRL1("[ENDIF begin TEXT CR]\n"); BEGIN S_TEXT; } } {EndLine} { LLDBUG_PRL1("[SkipIF a CR]\n"); } [^\n]*$ { LLDBUG_PRL2("[SkipIF anything ]",IFcount); } } { ([.]*){EndLine} { /* this ignores everything until it hits an EoL */ LLDBUG_PRL2("[ skip \'%s\' until EoL]\n",yytext); BEGIN S_TEXT; } } { ^{Spaces}"/WHILE"[^\n]*{EndLine} { Wcount++; LLDBUG_PRL2("[SkipWHILE /WHILE ]\n",Wcount); } ^{Spaces}"/ENDWHILE"[^\n]*{EndLine} { if(Wcount==0) { LLDBUG_PRL2("[SkipWHILE->/ENDWHILE ]\n",Wcount); BEGIN S_TEXT; } else { Wcount--; LLDBUG_PRL2("[SkipWHILE /ENDWHILE ]\n",Wcount); } } {EndLine} { LLDBUG_PRL1("[SkipWHILE a CR]\n"); } [^\n]*$ { LLDBUG_PRL2("[SkipWHILE anything ]",Wcount); } } { ^{Spaces}"/ENDVERB" { LLDBUG_PRL1("[END VERB]\n"); yylval = (Symbol *) capa_malloc(1, sizeof(Symbol)); yylval->s_str = strsave(Dynamic_buf); /* **** */ yylval->s_type = S_CONSTANT; capa_mfree(Dynamic_buf); Dynamic_buf_cur=-1; Dynamic_buf_max=0; BEGIN S_TEXT; RETURN(VERBATIM); } .*|{EndLine} { append_dynamic_buf(yytext); } } %% /* ========================================================================================== */ extern void begin_if_skip() { BEGIN S_IF_SKIP; } extern void begin_while_skip() { Wcount=0; While_idx--; /* while is FALSE, pop it out from stack */ BEGIN S_WHILE_SKIP; } extern void begin_next_line() { BEGIN S_NEXT_LINE; } extern void begin_var() { BEGIN S_VARIABLE; } extern void begin_let() { BEGIN S_LET; } extern void begin_def() { BEGIN S_DEFINE; } extern void begin_ans() { BEGIN S_ANSWER; } extern void begin_map() { BEGIN S_MAP; } extern void begin_ignore() { BEGIN S_IGNORE; } extern void begin_text() { BEGIN S_TEXT; } extern void begin_question() { LLDBUG_PR1("[]"); IFcount = 0; While_idx=0; /* initialize some stacks */ End_of_input = 0; YY_FLUSH_BUFFER; BEGIN S_TEXT; } extern void end_problemset() { End_of_input = 0; YY_FLUSH_BUFFER; BEGIN S_TEXT; } /* ========================================================================================== */ #define NUM_KEY 2 int match_keyword(key) char *key; { char *keyword[NUM_KEY] = {"/DIS", "/DIR" }; int i; for(i=0;i < NUM_KEY; i++) { if( !strncmp(keyword[i], key, 4) ) { return (1); } } return (0); } int match_functionid(key) char *key; { char *keyword[NUM_KEY] = {"/DIS", "/DIR" }; int i; for(i=0;i < NUM_KEY; i++) { if( !strncmp(keyword[i], key, 4) ) { return (1); } } return (0); } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void init_funcstack() { int ii; for(ii=0;ii>\n"); if (!Lexi_line) { /* was startup */ for(Input_idx=0;Input_idx < MAX_OPENED_FILE;Input_idx++) { /* for(ii=0;ii= MAX_INCLUDE_DEPTH ) { sprintf(warn_msg,"Includes nested too deeply" ); capa_msg(MESSAGE_ERROR,warn_msg); return; } include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; yyin = fopen( fname, "r" ); yy_switch_to_buffer( yy_create_buffer( yyin, YY_BUF_SIZE ) ); } void parse_filename(char *line) { char *start, fname[MAX_BUFFER_SIZE], warn_msg[WARN_MSG_LENGTH]; int ii,len; start = index(line, '\"'); /*** hpux complained */ if( start == NULL ) { sprintf(warn_msg,"/IMP was not given a filename.\n"); capa_msg(MESSAGE_ERROR,warn_msg); return; } start++; len = strlen(start) - 1; ii = 0; while( start[ii] != '\"' ) fname[ii++] = start[ii]; fname[ii] = 0; LLDBUG_PR2("[parse_filename<%s>]\n",fname); change_file(fname); } void parse_import_id(char *line) { char fname[QUARTER_K], warn_msg[WARN_MSG_LENGTH]; int ii, dup_open; Symbol *symb_p; int no_error = 0; ii = 0; while( line[ii] != '\0' && line[ii] != ' ' && line[ii] != '\n' && line[ii] != '\t' ) fname[ii++] = line[ii]; fname[ii] = 0; LLDBUG_PR2("[parse_import_id<%s>]\n",fname); /*symb_p = find_identifier(fname);*/ switch (symb_p->s_type) { case IDENTIFIER: sprintf(warn_msg,"/IMP %s, var is not defined.\n", fname); capa_msg(MESSAGE_ERROR,warn_msg); break; case I_VAR: case I_CONSTANT: case R_VAR: case R_CONSTANT: sprintf(warn_msg,"var cannot be a number.\n"); capa_msg(MESSAGE_ERROR,warn_msg); break; case S_VAR: case S_CONSTANT: sprintf(fname,"%s",symb_p->s_str); no_error = 1; break; } if( no_error ) change_file(fname); } #else void parse_filename(char *line) { char *start, fname[QUARTER_K], warn_msg[WARN_MSG_LENGTH]; int ii, len, dup_open; /* printf("IMPORT %s\n", line); */ start = index(line, '\"'); /*** hpux complained */ if( start != NULL ) { start++; len = strlen(start) - 1; ii = 0; while( start[ii] != '\"' ) { fname[ii] = start[ii]; ii++; } fname[ii] = 0; LLDBUG_PR2("[parse_filename<%s>]\n",fname); if(Input_idx < (MAX_OPENED_FILE -1)) { dup_open = 0; /* -- no need to check duplicated opening a file for(ii=0;ii]\n",fname); /*symb_p = find_identifier(fname);*/ switch (symb_p->s_type) { case IDENTIFIER: sprintf(warn_msg,"/IMP %s, var is not defined.\n", fname); capa_msg(MESSAGE_ERROR,warn_msg); break; case I_VAR: case I_CONSTANT: case R_VAR: case R_CONSTANT: sprintf(warn_msg,"var cannot be a number.\n"); capa_msg(MESSAGE_ERROR,warn_msg); break; case S_VAR: case S_CONSTANT: sprintf(fname,"%s",symb_p->s_str); no_error = 1; break; } if( no_error ) { if(Input_idx < (MAX_OPENED_FILE -1) ) { dup_open = 0; /* no need to check duplicated opening a file for(ii=0;iiDynamic_buf_max) { char *temp_text; Dynamic_buf_max=(Dynamic_buf_cur+len)*2; temp_text=(char*)capa_malloc(sizeof(char),Dynamic_buf_max); strncpy(temp_text,Dynamic_buf,Dynamic_buf_max); free(Dynamic_buf); Dynamic_buf=temp_text; } for(ii=0;ii>\n"); } out_of_char = 0; if ( Lexi_buf[Input_idx] == NULL ) { Lexi_buf[Input_idx] = (char *)capa_malloc(sizeof(char)*LEX_BUFLEN+1,1); out_of_char=1; } else { if (!Lexi_buf[Input_idx][Lexi_pos[Input_idx]]) { /* test if the line buffer is empty or at the end */ out_of_char=1; } } if( out_of_char ) { if (fgets(Lexi_buf[Input_idx],LEX_BUFLEN-1,Input_stream[Input_idx])==NULL) { /* read in one line */ LIDBUG_PR2("<>\n",Input_idx); if( (Input_idx > 0) && ( Lexi_buf[Input_idx][Lexi_pos[Input_idx]] == '\0') ) { LIDBUG_PR2("<>\n",Input_idx); fclose(Input_stream[Input_idx]); capa_mfree((char *)Lexi_buf[Input_idx]); Lexi_buf[Input_idx] = NULL; Input_idx--; yyin = Input_stream[Input_idx]; /* (Lexi_pos[Input_idx])++; */ buf[0] = Lexi_buf[Input_idx][Lexi_pos[Input_idx]-1]; *result = 1; } else { *result = YY_NULL; /* End of File */ } } else { /* successfully read in one line */ leng = strlen(Lexi_buf[Input_idx]); LIDBUG_PR3("<>\n", leng,Input_idx); Lexi_pos[Input_idx] = 0; Lexi_line++; Current_line[Input_idx]++; (Lexi_pos[Input_idx])++; buf[0] = Lexi_buf[Input_idx][Lexi_pos[Input_idx]-1]; /* need to take care of return continuation conditions */ /* so, we return to one-char-at-a-time approach */ /* for(ii=0;ii>\n",Input_idx); */ (Lexi_pos[Input_idx])++; buf[0] = Lexi_buf[Input_idx][Lexi_pos[Input_idx]-1]; *result = 1; } if (Stop_Parser==1) *result = YY_NULL; } int capa_eof() { #ifdef AVOIDYYINPUT if ( --include_stack_ptr < 0 ) yyterminate(); else { yy_delete_buffer( YY_CURRENT_BUFFER ); yy_switch_to_buffer(include_stack[include_stack_ptr]); } #else if(Input_idx == 0) { fclose(Input_stream[Input_idx]); capa_mfree((char *)Lexi_buf[Input_idx]); /*free_problems(LexiProblem_p);*/ LexiProblem_p=NULL; /* printf("\nCAPA EOF\n"); fflush(stdout); */ } return (0); #endif /*AVOIDYYINPUT*/ } /* ------------ */ /* =========================================================== */