📄 parse.h
字号:
// parse.h: interface for the parse class.
//
//////////////////////////////////////////////////////////////////////
#if !defined PHASE_H
#define PHASE_H
#include <iostream>
#include <fstream>
using namespace std;
//枚举类型
enum tokentype
{
fieldnumber, string__, if_, else_, endif_, phase_change
};
enum phase
{
preamble, tmain, conclusion
};
class token
{
friend ostream& operator<<( ostream& s, token& t );
public:
token( ifstream& input );
~token();
//枚举类型变量作标记用
tokentype ttype;
//无名联合体
union
{
int fieldnum;
unsigned char* literal;
};
//把control文件的数字参数传出 eg : the x in @?x@,or @<x>
int field_number()
{
return fieldnum;
}
//把control文件的类型参数传出 eg : 是状态@m 还是状态@c
int token_type()
{
return ttype;
}
//传出 @?x@: @~ @.三者协同作用时 是那一种情况
int nesting_level()
{
return if_level;
}
private:
void error( char* msg = " ", char* msg2 = " " );
//标记@?x@: @~ @.三者协同作用的情形
int if_level;
void get_token();
//取下一个字母, 并处理换行情况
void getnext( char& c );
//从文件中获取fieldnum
unsigned char get_value( char delimiter, char* msg );
//跳过本行
void dumpline();
};
class parse_array{
public:
parse_array( ifstream& input );
~parse_array();
int size()
{
return end_;
}
token& operator[]( int index );
phase section()
{
return p_section;
}
void build_array();
private:
token** tokenarray;
ifstream* parse_stream;
int token_count;
//标记文件调用次数
int end_;
//枚举类型变量作标记用
phase p_section;
};
#endif // PHASE_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -