-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.h
87 lines (63 loc) · 1.4 KB
/
globals.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
#ifndef GLOBALS_H
#define GLOBALS_H
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef NULL
#define NULL 0
#endif
typedef int Bool;
/******************************/
// declaration in symtab.h
struct SymtabDec;
typedef struct SymtabDec * Symtab;
/******************************/
typedef enum {
Decl_Var, Decl_Fun, Decl_Param,
Stat_Compound, Stat_Select, Stat_Iterate, Stat_Return, Stat_Empty, Stat_Expression,
Expr_Assign, Expr_Binary, Expr_Fun, Expr_Var, Expr_Const
} Kind;
typedef enum { IntT, IntArrayT, VoidT, BoolT } Type;
#define MAX_CHILDREN 3
struct AstNode;
typedef struct AstNode * Ast;
struct AstNode {
Ast sibling;
Ast children[MAX_CHILDREN];
int number;
char* name;
int operator; // not char
Kind kind;
Type type;
int has_else;
int lineno;
Symtab symtab; // for semantic
};
/******************************/
#ifndef YYPARSER
#include "parse.tab.h"
#endif /* YYPARSER */
extern int yylineno;
int yylex(void);
Ast parse(void);
/******************************/
#include "scan.aux.h"
#include "parse.aux.h"
#include "semantic.aux.h"
#include "semantic.h"
#include "code.aux.h"
#include "code.h"
#include "util.h"
#define TRACE_SCAN FALSE
#define YYDEBUG FALSE
#define TRACE_PARSE FALSE
#define TRACE_SEMANTIC FALSE
#endif /* GLOBALS_H */