-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.h
More file actions
41 lines (41 loc) · 1.08 KB
/
parse.h
File metadata and controls
41 lines (41 loc) · 1.08 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
#ifndef PARSE_H
#define PARSE_H
#include "lexer.h"
typedef double(*FuncPtr)(double);
using namespace std;
struct ExprNode
{
Token_Type OpCode; // 记号种类
union
{
struct {
ExprNode *Left, *Right;
} CaseOperator; // 二元运算
struct {
ExprNode * Child;
FuncPtr MathFuncPtr;
} CaseFunc; // 函数调用
double CaseConst; // 常数,绑定右值
double * CaseParmPtr; // 参数T,绑定左值
} Content;
};
void analyse_tree();
void SyntanError(int i);
void match(Token_Type a);
static struct ExprNode* Make_tree_FUN(Token_Type root, FuncPtr fun, ExprNode * child);
static struct ExprNode* Make_tree_T(Token_Type root);
static struct ExprNode* Make_tree_CONST_ID(Token_Type root, double value);
static struct ExprNode * Make_tree(Token_Type opcode, ExprNode *left, ExprNode *right);
struct ExprNode * Expression();
struct ExprNode * Term();
struct ExprNode * Factor();
struct ExprNode * Component();
struct ExprNode * Atom();
void ForStatment();
void RotStatment();
void ScaleStatment();
void OriginStatment();
void Statement();
void Program();
void print_tree(ExprNode* root, int indent);
#endif