-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser_state.h
More file actions
38 lines (32 loc) · 933 Bytes
/
parser_state.h
File metadata and controls
38 lines (32 loc) · 933 Bytes
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
#ifndef _PARSER_STATE_H_
#define _PARSER_STATE_H_
#include "cst.h"
#include "strtbl.h"
#include "symtbl.h"
#include "typetbl.h"
typedef struct tagParserState {//编译器的全局状态
StrTbl* strtbl;
SymTbl* symtbl;
Cst* allcsts; /*节点间链接的指针*/
Cst* program; /* 语法树根节点 */
unsigned nerror;
StringId dummyname; //结构体定义的时候未给出名用dummyname表示/
TypeTbl typetbl;
struct {
Cst* error;
} noattrtokennode;
struct {
BaseTypeId inttype;
BaseTypeId floattype;
BaseTypeId errortype;
} commontype;
} ParserState;
#define pstate_appendcst(pstate, cst) pstate_appendcst_raw((pstate), (Cst*)(cst))
static inline Cst* pstate_appendcst_raw(ParserState* pstate, Cst* cst) {
cst->next = pstate->allcsts;
pstate->allcsts = cst;
return cst;
}
void pstate_init(ParserState* pstate);
void pstate_destroy(ParserState* pstate);
#endif