📄 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 + -