-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtranslator.h
More file actions
34 lines (30 loc) · 962 Bytes
/
translator.h
File metadata and controls
34 lines (30 loc) · 962 Bytes
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
#pragma once
#include<vector>
#include<string>
#include"lexicalAnalysis.h"
#include"syntaxAnalysis.h"
#define TEMPORARY "通用寄存器"
#define DECLARE_TYPE "声明类型"
#define DECLARE_NUMBER "声明数量"
#define END_OF_PROGRAM "程序结束"
#define CONDITIONAL "条件转移"
#define UNCONDITIONAL "无条件转移"
#define RESULT "结果寄存器"
#define IS_TRUE "结果寄存器为真则转移至"
#define IS_FALSE "结果寄存器为假则转移至"
#define OUTPUT "输出"
#define JUMP_TO "跳转至地址"
class translator
{
public:
translator();
~translator();
//get expression instruction vector
std::vector<std::vector<std::pair<size_t, std::string>>> getExpTuple(generalTreeNode* root);
//get statement instruction vector
std::vector<std::vector<std::pair<size_t, std::string>>> getTuple(generalTreeNode* root);
//get the number of a block of instruction
size_t count_instruction(generalTreeNode* root);
private:
std::pair<size_t, std::string > result;
};