forked from ccxvii/mujs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jsparse.h
146 lines (125 loc) · 2.03 KB
/
jsparse.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#ifndef js_parse_h
#define js_parse_h
enum js_AstType
{
AST_LIST,
AST_FUNDEC,
AST_IDENTIFIER,
EXP_IDENTIFIER,
EXP_NUMBER,
EXP_STRING,
EXP_REGEXP,
/* literals */
EXP_UNDEF, /* for array elisions */
EXP_NULL,
EXP_TRUE,
EXP_FALSE,
EXP_THIS,
EXP_ARRAY,
EXP_OBJECT,
EXP_PROP_VAL,
EXP_PROP_GET,
EXP_PROP_SET,
EXP_FUN,
/* expressions */
EXP_INDEX,
EXP_MEMBER,
EXP_CALL,
EXP_NEW,
EXP_POSTINC,
EXP_POSTDEC,
EXP_DELETE,
EXP_VOID,
EXP_TYPEOF,
EXP_PREINC,
EXP_PREDEC,
EXP_POS,
EXP_NEG,
EXP_BITNOT,
EXP_LOGNOT,
EXP_MOD,
EXP_DIV,
EXP_MUL,
EXP_SUB,
EXP_ADD,
EXP_USHR,
EXP_SHR,
EXP_SHL,
EXP_IN,
EXP_INSTANCEOF,
EXP_GE,
EXP_LE,
EXP_GT,
EXP_LT,
EXP_STRICTNE,
EXP_STRICTEQ,
EXP_NE,
EXP_EQ,
EXP_BITAND,
EXP_BITXOR,
EXP_BITOR,
EXP_LOGAND,
EXP_LOGOR,
EXP_COND,
EXP_ASS,
EXP_ASS_MUL,
EXP_ASS_DIV,
EXP_ASS_MOD,
EXP_ASS_ADD,
EXP_ASS_SUB,
EXP_ASS_SHL,
EXP_ASS_SHR,
EXP_ASS_USHR,
EXP_ASS_BITAND,
EXP_ASS_BITXOR,
EXP_ASS_BITOR,
EXP_COMMA,
EXP_VAR, /* var initializer */
/* statements */
STM_BLOCK,
STM_EMPTY,
STM_VAR,
STM_IF,
STM_DO,
STM_WHILE,
STM_FOR,
STM_FOR_VAR,
STM_FOR_IN,
STM_FOR_IN_VAR,
STM_CONTINUE,
STM_BREAK,
STM_RETURN,
STM_WITH,
STM_SWITCH,
STM_THROW,
STM_TRY,
STM_DEBUGGER,
STM_LABEL,
STM_CASE,
STM_DEFAULT,
};
typedef struct js_JumpList js_JumpList;
struct js_JumpList
{
enum js_AstType type;
int inst;
js_JumpList *next;
};
struct js_Ast
{
enum js_AstType type;
int line;
js_Ast *parent, *a, *b, *c, *d;
double number;
const char *string;
js_JumpList *jumps; /* list of break/continue jumps to patch */
int casejump; /* for switch case clauses */
js_Ast *gcnext; /* next in alloc list */
};
js_Ast *jsP_parsefunction(js_State *J, const char *filename, const char *params, const char *body);
js_Ast *jsP_parse(js_State *J, const char *filename, const char *source);
void jsP_freeparse(js_State *J);
const char *jsP_aststring(enum js_AstType type);
void jsP_dumpsyntax(js_State *J, js_Ast *prog, int minify);
void jsP_dumplist(js_State *J, js_Ast *prog);
#endif