//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+ Student: Junshan Li + //+ Proj. Assignemnt: Three + //+ Due Date: Febuary 19, 2001 + //+ Course Name: MSCS 518 - Compiler Design + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // TokFiler.h #ifndef TOKFILERH #define TOKFILERH // This is a header file for TokFiler class. It provides function prototypes // of TokFiler class. This class deals with text file handling. #include #include #include "Token.h" #include "pmglobs.h" //enum bool {false, true}; #define STRSIZE 80 // holds the file name #define MAXLINES 5000 // the maximum number of lines of a program source file class TokFiler { public: bool ENDOFPROGRAM; // TRUE if en-of-file (program) is true; TokFiler(); // class constructor, init ENDOFPROGRAM to false void closeTokenFile(); // closes the file that was openned; void createTokenFile(); // creates a new token file void emitToken(Token tok); // place a token in the file; Token getNextToken(); // reads and returns next character in file void initLineNumber(); // initialize lineNumber to zero. void removeTokenFile(); // closes the file that was openned; void retrieveTokenFile(); // opens named file if it exists else writes an // error message and terminate execution void storeFileName(char* aFileName); // saves file name in fileName[]; void seeTokenFile(); // displays entire file on output device (include // line number for each program line private: fstream finOut; // a fstream object, cout be both input or output 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. Token tok; // a Token class instance variable. }; // end of class declaration. #endif