?? tokenizer.h
字號:
#ifndef MY_TOKENIZER_H_
#define MY_TOKENIZER_H_
/**: Tokenizer.h header file
&
* return char from source file;
* author: lonelyforest;
* data: 2006.03.16
*/
#include "minic.h"
/**: class Tokenizer
* 將源文件直接讀入到std::vector<stirng> lines_of_source
* 中,來增加操作上的時間效率,代價是空間!
* 重要接口 char getNextChar() & void unGetNextChar()
* 分別從源文件中提取 return lines_of_source[lineno_-1][linepos++];
* 出一個字符 & 退回一個字符。
*
* author: lonelyforest;
* data: 2006.03.16
*/
class Tokenizer {
public:
Tokenizer(const std::string& filename); // use filename.c_str()
virtual ~Tokenizer();
//-------------------------------------------------------------------------
char getNextChar(); // ...primary interface to scanner...
void unGetNextChar();
//-------------------------------------------------------------------------
bool is_good() const { return is_good_ ; } // very importent
std::vector<std::string>::size_type lineno() const // line start with 1
{ return lineno_; }
//-------------------------------------------------------------------------
protected:
// interface of insert the trace source messages;
void insert_list(const std::string& msg);
void insert_list(const char* msg);
//-------------------------------------------------------------------------
// read and store file to vector<string>,
void read_file(const char* filename);
void store_file(ifstream& is);
//-------------------------------------------------------------------------
string source_name; // record the source file name;
std::vector<std::string> list_msg_; // trace source
//-------------------------------------------------------------------------
bool is_good_; // 幫助測試是否能夠正常工作!
bool TraceSource;// create list file;
//-------------------------------------------------------------------------
int warn_count; // count warning
int err_count; // count the error;
private:
//-------------------------------------------------------------------------
// source file
std::vector<std::string> lines_of_source;
std::vector<std::string>::size_type lineno_; // record source file line no
//-------------------------------------------------------------------------
int bufsize; // record a line size
int linepos; // current line position
};
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -