From: Vern Paxson Date: Sun, 5 Mar 1995 16:50:49 +0000 (+0000) Subject: Added switch_streams X-Git-Tag: flex-2-5-5b~98 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3987e1c0f01f08560c23373d6a8c2e13dc85e68e;p=flex Added switch_streams --- diff --git a/FlexLexer.h b/FlexLexer.h index f430b68..8289148 100644 --- a/FlexLexer.h +++ b/FlexLexer.h @@ -66,6 +66,18 @@ public: virtual int yylex() = 0; + // Call yylex with new input/output sources. + int yylex( istream* new_in = 0, ostream* new_out = 0 ) + { + switch_streams( new_in, new_out ); + return yylex(); + } + + // Switch to new input/output streams. A nil stream pointer + // indicates "keep the current one". + virtual void switch_streams( istream* new_in = 0, + ostream* new_out = 0 ) = 0; + protected: char* yytext; int yyleng; @@ -89,6 +101,7 @@ public: void yyrestart( istream* s ); virtual int yylex(); + virtual void switch_streams( istream* new_in, ostream* new_out ); protected: virtual int LexerInput( char* buf, int max_size );