-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfb3-2.h
90 lines (70 loc) · 1.64 KB
/
fb3-2.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
struct symbol {
char *name;
double value;
struct ast *func;
struct symlist *syms;
};
#define NHASH 9997
extern struct symbol symtab[NHASH];
struct symbol *lookup(char*);
struct symlist {
struct symbol *sym;
struct symlist *next;
};
struct symlist *newsymlist(struct symbol *sym, struct symlist *next);
void symlistfree(struct symlist *sl);
enum bifs {
B_sqrt = 1,
B_exp,
B_log,
B_print
};
struct ast {
int nodetype;
struct ast *l;
struct ast *r;
};
struct fncall {
int nodetype;
struct ast *l;
enum bifs functype;
};
struct ufncall {
int nodetype;
struct ast *l;
struct symbol *s;
};
struct flow {
int nodetype;
struct ast *cond;
struct ast *tl;
struct ast *el;
};
struct numval {
int nodetype;
double number;
};
struct symref {
int nodetype;
struct symbol *s;
};
struct symasgn {
int nodetype;
struct symbol *s;
struct ast *v;
};
struct ast *newast(int nodetype, struct ast *l, struct ast *r);
struct ast *newcmp(int cmptype, struct ast *l, struct ast *r);
struct ast *newfunc(int functype, struct ast *l);
struct ast *newcall(struct symbol *s, struct ast *l);
struct ast *newref(struct symbol *s);
struct ast *newasgn(struct symbol *s, struct ast *v);
struct ast *newnum(double d);
struct ast *newflow(int nodetype, struct ast *cond, struct ast *tl, struct ast *tr);
void dodef(struct symbol *name, struct symlist *syms, struct ast *stmts);
double eval(struct ast *);
void treefree(struct ast *);
extern int yylineno;
void yyerror(char *s, ...);
extern int debug;
void dumpast(struct ast *a, int level);