summaryrefslogtreecommitdiff
path: root/FlexLexer.h
diff options
context:
space:
mode:
authorVern Paxson <vern@ee.lbl.gov>1993-10-02 15:19:20 +0000
committerVern Paxson <vern@ee.lbl.gov>1993-10-02 15:19:20 +0000
commitc5d8db8d39ab03dd579900b948b0e206bc0e5a0a (patch)
tree1c9ce7645dd15d4f09e3183a221127376aa7d905 /FlexLexer.h
parent65dee2525e3e700eeeed462ff3ea505e630be384 (diff)
Switched from FILE*'s to stream's
Diffstat (limited to 'FlexLexer.h')
-rw-r--r--FlexLexer.h39
1 files changed, 16 insertions, 23 deletions
diff --git a/FlexLexer.h b/FlexLexer.h
index f8e0d35..0e9d183 100644
--- a/FlexLexer.h
+++ b/FlexLexer.h
@@ -1,12 +1,12 @@
// $Header$
-// FlexLexer.h -- define a base class for lexical analyzers generated by flex
+// FlexLexer.h -- define classes for lexical analyzers generated by flex
// Copyright (c) 1993 The Regents of the University of California.
// All rights reserved.
//
// This code is derived from software contributed to Berkeley by
-// Kent Williams.
+// Kent Williams and Tom Epperly.
//
// Redistribution and use in source and binary forms are permitted provided
// that: (1) source distributions retain this entire copyright notice and
@@ -22,10 +22,8 @@
// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-#ifndef __FLEXCXX_H
-#define __FLEXCXX_H
-
-#include <stdio.h>
+#ifndef __FLEX_LEXER_H
+#define __FLEX_LEXER_H
// This file defines two classes. The first, FlexLexer, is an abstract
@@ -42,9 +40,9 @@ class FlexLexer {
virtual ~FlexLexer() { }
virtual void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) = 0;
- virtual YY_BUFFER_STATE yy_create_buffer( FILE* file, int size ) = 0;
+ virtual YY_BUFFER_STATE yy_create_buffer( istream* s, int size ) = 0;
virtual void yy_delete_buffer( YY_BUFFER_STATE b ) = 0;
- virtual void yyrestart( FILE *input_file ) = 0;
+ virtual void yyrestart( istream* s ) = 0;
virtual int yylex() = 0;
};
@@ -52,7 +50,9 @@ class FlexLexer {
class yyFlexLexer : public FlexLexer {
public:
- yyFlexLexer( FILE* arg_yyin = 0, FILE* arg_yyout = 0 )
+ // arg_yyin and arg_yyout default to the cin and cout, but we
+ // only make that assignment when initializing in yylex().
+ yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 )
{
yyin = arg_yyin;
yyout = arg_yyout;
@@ -81,35 +81,28 @@ class yyFlexLexer : public FlexLexer {
}
void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer );
- YY_BUFFER_STATE yy_create_buffer( FILE* file, int size );
+ YY_BUFFER_STATE yy_create_buffer( istream* s, int size );
void yy_delete_buffer( YY_BUFFER_STATE b );
- void yyrestart( FILE *input_file );
+ void yyrestart( istream* s );
virtual int yylex();
protected:
- virtual int LexerInput( char* buf, int max_size )
- {
- return read( fileno(yyin), buf, max_size );
- }
-
- virtual void LexerOutput( const char* buf, int size )
- {
- (void) fwrite( (char*) buf, size, 1, yyout );
- }
+ virtual int LexerInput( char* buf, int max_size );
+ virtual void LexerOutput( const char* buf, int size );
void yyunput( YY_CHAR c, YY_CHAR* buf_ptr );
int yyinput();
void yy_load_buffer_state();
- void yy_init_buffer( YY_BUFFER_STATE b, FILE* file );
+ void yy_init_buffer( YY_BUFFER_STATE b, istream* s );
yy_state_type yy_get_previous_state();
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
int yy_get_next_buffer();
- FILE* yyin; // input source for default LexerInput
- FILE* yyout; // output sink for default LexerOutput
+ istream* yyin; // input source for default LexerInput
+ ostream* yyout; // output sink for default LexerOutput
YY_BUFFER_STATE yy_current_buffer;