//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+ Student: Junshan Li + //+ Proj. Assignemnt: Two + //+ Due Date: Febuary 12, 2001 + //+ Course Name: MSCS 518 - Compiler Design + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // FileManager.h #ifndef FILEMANAGERH #define FILEMANAGERH #include #include #include "pmglobs.h" //enum bool {false, true}; // This is a header file for FileManager class. It provides function prototypes // of FileManager class. This class deals with text file handling. #define STRSIZE 80 // holds the file name #define MAXLINES 5000 // the maximum number of lines of a program source file class FileManager { public: bool ENDOFPROGRAM; // TRUE if en-of-file (program) is TRUE; FileManager(); // class constructor, init ENDOFPROGRAM to FALSE void initLineNumber(); // initialize lineNumber to zero. void retrieveProgram(char * aFileName); // opens named file if it exists else writes an // error message and terminate execution void storeFileName(char* aFileName); // saves file name in fileName[]; char* getProgramName(); // retrieves stored file name from fileName[]; void closeProgram(); // closes the file that was openned; char getNextChar(); // reads and returns next character in file char peekNextChar(); // returns the next char without extraction. // istream's member function peek does the job. void seeProgramFile(); // displays entire file on output device (include // line number for each program line void seeErrorLines(int lineNum); // displays 2 contiguous lines of file starting // with line=lineNum if lineNum > 1 else displays // only file line. private: ifstream fin; // an input text file object char fileName[STRSIZE]; // holds the file name char buffer[STRSIZE]; // holds the file name char ch; int lineNumber; // provide the total line number of the input prog. int countLines(); // count the lines of the program. }; // end of class declaration. #endif