File: parse.h

package info (click to toggle)
wine 1.8.7-2~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 179,896 kB
  • sloc: ansic: 2,517,827; perl: 18,150; yacc: 15,402; makefile: 7,623; objc: 5,762; lex: 4,207; sh: 893; cpp: 816; xml: 78; awk: 69
file content (275 lines) | stat: -rw-r--r-- 5,808 bytes parent folder | download | duplicates (6)
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/*
 * Copyright 2011 Jacek Caban for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

typedef enum {
    EXPR_ADD,
    EXPR_AND,
    EXPR_BOOL,
    EXPR_BRACKETS,
    EXPR_CONCAT,
    EXPR_DIV,
    EXPR_DOUBLE,
    EXPR_EMPTY,
    EXPR_EQUAL,
    EXPR_EQV,
    EXPR_EXP,
    EXPR_GT,
    EXPR_GTEQ,
    EXPR_IDIV,
    EXPR_IMP,
    EXPR_IS,
    EXPR_LT,
    EXPR_LTEQ,
    EXPR_ME,
    EXPR_MEMBER,
    EXPR_MOD,
    EXPR_MUL,
    EXPR_NEG,
    EXPR_NEQUAL,
    EXPR_NEW,
    EXPR_NOARG, /* not a real expression */
    EXPR_NOT,
    EXPR_NOTHING,
    EXPR_NULL,
    EXPR_OR,
    EXPR_STRING,
    EXPR_SUB,
    EXPR_ULONG,
    EXPR_USHORT,
    EXPR_XOR
} expression_type_t;

typedef struct _expression_t {
    expression_type_t type;
    struct _expression_t *next;
} expression_t;

typedef struct {
    expression_t expr;
    VARIANT_BOOL value;
} bool_expression_t;

typedef struct {
    expression_t expr;
    LONG value;
} int_expression_t;

typedef struct {
    expression_t expr;
    double value;
} double_expression_t;

typedef struct {
    expression_t expr;
    const WCHAR *value;
} string_expression_t;

typedef struct {
    expression_t expr;
    expression_t *subexpr;
} unary_expression_t;

typedef struct {
    expression_t expr;
    expression_t *left;
    expression_t *right;
} binary_expression_t;

typedef struct {
    expression_t expr;
    expression_t *obj_expr;
    const WCHAR *identifier;
    expression_t *args;
} member_expression_t;

typedef enum {
    STAT_ASSIGN,
    STAT_CALL,
    STAT_CONST,
    STAT_DIM,
    STAT_DOUNTIL,
    STAT_DOWHILE,
    STAT_EXITDO,
    STAT_EXITFOR,
    STAT_EXITFUNC,
    STAT_EXITPROP,
    STAT_EXITSUB,
    STAT_FOREACH,
    STAT_FORTO,
    STAT_FUNC,
    STAT_IF,
    STAT_ONERROR,
    STAT_SELECT,
    STAT_SET,
    STAT_STOP,
    STAT_UNTIL,
    STAT_WHILE,
    STAT_WHILELOOP
} statement_type_t;

typedef struct _statement_t {
    statement_type_t type;
    struct _statement_t *next;
} statement_t;

typedef struct {
    statement_t stat;
    member_expression_t *expr;
    BOOL is_strict;
} call_statement_t;

typedef struct {
    statement_t stat;
    member_expression_t *member_expr;
    expression_t *value_expr;
} assign_statement_t;

typedef struct _dim_list_t {
    unsigned val;
    struct _dim_list_t *next;
} dim_list_t;

typedef struct _dim_decl_t {
    const WCHAR *name;
    BOOL is_array;
    BOOL is_public; /* Used only for class members. */
    dim_list_t *dims;
    struct _dim_decl_t *next;
} dim_decl_t;

typedef struct _dim_statement_t {
    statement_t stat;
    dim_decl_t *dim_decls;
} dim_statement_t;

typedef struct _arg_decl_t {
    const WCHAR *name;
    BOOL by_ref;
    struct _arg_decl_t *next;
} arg_decl_t;

typedef struct _function_decl_t {
    const WCHAR *name;
    function_type_t type;
    BOOL is_public;
    arg_decl_t *args;
    statement_t *body;
    struct _function_decl_t *next;
    struct _function_decl_t *next_prop_func;
} function_decl_t;

typedef struct {
    statement_t stat;
    function_decl_t *func_decl;
} function_statement_t;

typedef struct _class_decl_t {
    const WCHAR *name;
    function_decl_t *funcs;
    dim_decl_t *props;
    struct _class_decl_t *next;
} class_decl_t;

typedef struct _elseif_decl_t {
    expression_t *expr;
    statement_t *stat;
    struct _elseif_decl_t *next;
} elseif_decl_t;

typedef struct {
    statement_t stat;
    expression_t *expr;
    statement_t *if_stat;
    elseif_decl_t *elseifs;
    statement_t *else_stat;
} if_statement_t;

typedef struct {
    statement_t stat;
    expression_t *expr;
    statement_t *body;
} while_statement_t;

typedef struct {
    statement_t stat;
    const WCHAR *identifier;
    expression_t *from_expr;
    expression_t *to_expr;
    expression_t *step_expr;
    statement_t *body;
} forto_statement_t;

typedef struct {
    statement_t stat;
    const WCHAR *identifier;
    expression_t *group_expr;
    statement_t *body;
} foreach_statement_t;

typedef struct {
    statement_t stat;
    BOOL resume_next;
} onerror_statement_t;

typedef struct _const_decl_t {
    const WCHAR *name;
    expression_t *value_expr;
    struct _const_decl_t *next;
} const_decl_t;

typedef struct {
    statement_t stat;
    const_decl_t *decls;
} const_statement_t;

typedef struct _case_clausule_t {
    expression_t *expr;
    statement_t *stat;
    struct _case_clausule_t *next;
} case_clausule_t;

typedef struct {
    statement_t stat;
    expression_t *expr;
    case_clausule_t *case_clausules;
} select_statement_t;

typedef struct {
    const WCHAR *code;
    const WCHAR *ptr;
    const WCHAR *end;

    BOOL option_explicit;
    BOOL parse_complete;
    BOOL is_html;
    HRESULT hres;

    int last_token;
    unsigned last_nl;

    statement_t *stats;
    statement_t *stats_tail;
    class_decl_t *class_decls;

    heap_pool_t heap;
} parser_ctx_t;

HRESULT parse_script(parser_ctx_t*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;