-
Notifications
You must be signed in to change notification settings - Fork 0
/
mini.h
68 lines (62 loc) · 1.78 KB
/
mini.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once
#include "Lib.h"
#include <vector>
#include <list>
#include <utility>
typedef pair<String,String> variable;
typedef pair<String,bool>SI; //包含是否跳过信息的栈元素类型
class Tree
{
private:
Tree* father;
public:
//基本操作
void addField(variable var);
void deleteField(String var);
void addPar(variable var);
void deletePar(String var);
void addChildNode(Tree *tree);
void deleteTree(Tree *tree);
Tree* getFather();
static Tree* searchSubTree(Tree *nowTree, vector<String> &layer);
//实际操作
String readVar(String var);
String readPar(String var);
//特殊操作
String getCode(String tab=NULL_String);
//子树和成员
vector<Tree*>subtree;
vector<variable>field;
vector<variable>par;
String name;
Tree(String name,Tree* father=nullptr):father(father),name(name){}
~Tree();
};
enum MINIsta{CODE,TREE,ALL};
class MINI
{
public:
MINI(String content,bool ispath=true);
MINI(Tree *tree);
~MINI();
void setCode(String code);
Tree* toTree(); //把代码翻译成树
Tree* getTree();
String toCode(String path=NULL_String);
String getCode(String path=NULL_String);
MINIsta getState();
void format();
//读
String readVar(vector<String>layer,String var);
String getBlockCode(vector<String>layer);
String readPar(vector<String>layer,String par);
String readVarInTree(vector<String>layer,String var);
String readParInTree(vector<String>layer,String par);
//写
String writeVar(vector<String>layer, String var, String val, String path=NULL_String);
String writePar(vector<String>layer, String var, String val, String path=NULL_String);
private:
void initParsetree();
list<String>codelist;
Tree *parsetree=nullptr;
};