-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast.h
42 lines (38 loc) · 1.23 KB
/
ast.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
#pragma once
#include<stack>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include "nodetype.h"
#include "scope.h"
#include "matrix.hpp"
using namespace std;
class record
{
public:
static Scope globalScope;
};
namespace ast
{
static const char cLowestPriority = ';';
static const string sLowestPriority = ";";//字符串结尾
static const char cReturnFlag = '$';//返回值标记
static const char cDenineFunFlag = '#';//函数定义
const char cType_ParSpacer = ':';//函数的形参中,参数和参数名分隔符,非引用
const char cType_ParSpacerQuote = '!';//函数的形参中,参数和参数名分隔符,引用
extern bool isInit;
extern map<string,int> BinOpPriority;
extern map<int, bool> BinOpCombination;
void Init();
bool canpush(stack<string> &, const string &);
bool isNum(const char &);
bool isBinOp(const char &);
bool isBinOp(const string &);
bool isLetter(const char &);
int StringToType(const string&);
BasicNode* __toAST(string &, Scope*);
void __output(BasicNode*, ostream &, const string& = sLowestPriority);
void output(BasicNode*, ostream & = cout);
BasicNode* toAST(string, Scope* = &record::globalScope);
}