-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompiler.hpp
More file actions
47 lines (40 loc) · 1.29 KB
/
Compiler.hpp
File metadata and controls
47 lines (40 loc) · 1.29 KB
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
#pragma once
#include <bits/stdc++.h>
#include "Symbol.h"
// 前向声明
class Scanner;
class Parser;
class Interpreter;
class Table;
#define norw 10 // number of reserved words
#define txmax_val 100 // maxmium size of symbol table
#define smax_val 100 // maxmium length of a string
#define nmax 14 // maxmium number of digits of a number
#define max_length 10 // maxmium length of an identifier
#define maxerr 30 // maxmium number of errors
#define amax 2048 // upper bound of address
#define levmax 3 // maxmium number of nested declaration levels
#define cxmax 300 // maxmium number of VMcode's rows
#define symnum 33 // number of symbols
using namespace std;
// 全局变量声明
extern bool listswitch; // 是否列出代码
extern bool tableswitch; // 是否列出符号表
extern ofstream fas; // 一般输出文件流
extern ofstream fcode; // 指令代码输出文件流
extern ofstream ftable; // 符号表输出文件流
extern ofstream fresult; // 程序执行结果输出文件流
class Compiler
{
private:
/* data */
public:
Table *table;
Parser *parser;
Interpreter *interp;
Scanner *lex; // 词法分析器
bool compile();
bool execute(); // 执行生成的指令
Compiler(ifstream &fin);
~Compiler();
};