-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstdafx.h
93 lines (78 loc) · 2.18 KB
/
stdafx.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef STDAFX_H_INCLUDED
#define STDAFX_H_INCLUDED
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <exception>
#include <cstdlib>
#include <cassert>
#include <climits>
using namespace std;
typedef unsigned int uint;
//token type constant definition
enum token_t {
chrlit_tk, strlit_tk, intlit_tk, id_tk, //complicate types
const_tk, int_tk, char_tk, void_tk, if_tk, while_tk, switch_tk, case_tk, default_tk, return_tk, //keywords
semicln_tk, comma_tk, assign_tk, lbrkt_tk, rbrkt_tk, lprt_tk, rprt_tk, lbrc_tk, rbrc_tk, cln_tk, //single signs
addsub_tk, multdiv_tk, rltop_tk, //operators
eof_tk //control token
};
enum addsub_tk_v { addop, subop }; // + -
enum multdiv_tk_v { multop, divop }; // * /
enum rltop_tk_v { ltop, leop, gtop, geop, neqlop, eqlop }; // < <= > >= != ==
enum type_t { void_t, int_t, char_t, string_t };
extern int size_of[];
//program level global declaration
extern int errcnt;
extern bool flg_lexonly;
extern bool flg_syxonly;
extern bool flg_tbl;
extern bool flg_opt;
extern bool flg_no_dag;
extern bool flg_no_reduce;
extern bool flg_debug;
extern bool flg_glbreg;
extern istream *src_input;
extern ostream *lex_output;
extern ostream *syx_output;
extern ostream *tbl_output;
extern ostream *asm_output;
//lex level global declaration
extern signed char ch; //last character
extern int cc; //character counter
extern int lc; //line counter
extern int tkntyp; //token type
extern int tknval; //number value, operator subtype
extern char tknchar; //char literal
extern string tknstr; //string literal, identifier name
//semantics level declaration
#include "semantics.h"
//optimization level declaration
#include "actvar.h"
void lex_init();
void gettoken();
void lex_dump();
void syx_init();
void program();
void optimize();
void opt_DAG();
void genasm();
void WARNING(string msg);
void ERROR(string msg);
void FATAL_ERROR(string msg);
void handler();
template <typename T>
string tostr(const T &x)
{
ostringstream o;
if(o << x)
return o.str();
ERROR("error in to_string");
return "(error)";
}
#endif // STDAFX_H_INCLUDED