ReactOS 0.4.16-dev-297-gc569aee
parser.h
Go to the documentation of this file.
1/*
2 * Copyright 2014 Jacek Caban for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#pragma once
20
24
25typedef struct {
27 union {
29 double n;
30 } u;
31} ccval_t;
32
33typedef struct _parser_ctx_t {
34 const WCHAR *begin;
35 const WCHAR *end;
36 const WCHAR *ptr;
37
46
48 unsigned cc_if_depth;
49
52
55
57
58static inline void *parser_alloc(parser_ctx_t *ctx, DWORD size)
59{
60 return heap_pool_alloc(&ctx->heap, size);
61}
62
64{
65 return heap_pool_alloc(&ctx->script->tmp_heap, size);
66}
67
70HRESULT parse_decimal(const WCHAR**,const WCHAR*,double*) DECLSPEC_HIDDEN;
71
72typedef enum {
79
80typedef struct {
82 union {
83 double dval;
86 struct {
87 jsstr_t *str;
89 } regexp;
90 } u;
91} literal_t;
92
95
99
101 struct _variable_declaration_t *global_next; /* for compiler */
103
104typedef enum {
122
126};
127
128typedef struct {
132
133typedef struct {
137
138typedef struct {
142
143typedef struct {
149
150typedef struct {
156
157typedef struct {
165
166typedef struct {
173
174typedef struct {
178
179typedef struct {
184
185typedef struct {
190
191typedef struct _case_clausule_t {
194
197
198typedef struct {
203
204typedef struct {
208
209typedef struct {
215
216typedef enum {
276
279};
280
281typedef struct _parameter_t {
285
289};
290
299 unsigned func_id;
300
301 struct _function_expression_t *next; /* for compiler */
303
304typedef struct {
309
310typedef struct {
314
315typedef struct {
321
322typedef struct {
327
328typedef struct _argument_t {
330
333
334typedef struct {
339
340typedef struct {
344
345typedef struct {
349
350typedef struct _array_element_t {
353
356
357typedef struct {
362
364 unsigned type;
367
370
371typedef struct {
375
378
379static inline ccval_t ccval_num(double n)
380{
381 ccval_t r;
382 r.is_num = TRUE;
383 r.u.n = n;
384 return r;
385}
386
387static inline ccval_t ccval_bool(BOOL b)
388{
389 ccval_t r;
390 r.is_num = FALSE;
391 r.u.b = b;
392 return r;
393}
394
395static inline BOOL get_ccbool(ccval_t v)
396{
397 return v.is_num ? v.u.n != 0 : v.u.b;
398}
399
400static inline double get_ccnum(ccval_t v)
401{
402 return v.is_num ? v.u.n : v.u.b;
403}
404
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
BOOL is_identifier_char(WCHAR) DECLSPEC_HIDDEN
Definition: lex.c:81
void parser_release(parser_ctx_t *) DECLSPEC_HIDDEN
HRESULT script_parse(script_ctx_t *, struct _compiler_ctx_t *, const WCHAR *, const WCHAR *, BOOL, parser_ctx_t **) DECLSPEC_HIDDEN
static void * parser_alloc(parser_ctx_t *ctx, DWORD size)
Definition: parser.h:58
expression_type_t
Definition: parser.h:216
@ EXPR_MEMBER
Definition: parser.h:266
@ EXPR_PREDEC
Definition: parser.h:238
@ EXPR_RSHIFT
Definition: parser.h:250
@ EXPR_LESS
Definition: parser.h:243
@ EXPR_ASSIGNADD
Definition: parser.h:256
@ EXPR_GREATER
Definition: parser.h:245
@ EXPR_THIS
Definition: parser.h:269
@ EXPR_BOR
Definition: parser.h:220
@ EXPR_LITERAL
Definition: parser.h:274
@ EXPR_EQEQ
Definition: parser.h:240
@ EXPR_ASSIGNRRSHIFT
Definition: parser.h:255
@ EXPR_ASSIGNDIV
Definition: parser.h:259
@ EXPR_ARRAY
Definition: parser.h:265
@ EXPR_ASSIGNMUL
Definition: parser.h:258
@ EXPR_BXOR
Definition: parser.h:221
@ EXPR_ASSIGNMOD
Definition: parser.h:260
@ EXPR_MOD
Definition: parser.h:229
@ EXPR_FUNC
Definition: parser.h:270
@ EXPR_BAND
Definition: parser.h:222
@ EXPR_VOID
Definition: parser.h:231
@ EXPR_NEW
Definition: parser.h:267
@ EXPR_POSTDEC
Definition: parser.h:236
@ EXPR_ASSIGNOR
Definition: parser.h:262
@ EXPR_GREATEREQ
Definition: parser.h:246
@ EXPR_ASSIGNLSHIFT
Definition: parser.h:253
@ EXPR_CALL
Definition: parser.h:268
@ EXPR_LSHIFT
Definition: parser.h:249
@ EXPR_LOGNEG
Definition: parser.h:248
@ EXPR_PROPVAL
Definition: parser.h:273
@ EXPR_DELETE
Definition: parser.h:230
@ EXPR_ARRAYLIT
Definition: parser.h:272
@ EXPR_DIV
Definition: parser.h:228
@ EXPR_ADD
Definition: parser.h:225
@ EXPR_ASSIGN
Definition: parser.h:252
@ EXPR_TYPEOF
Definition: parser.h:232
@ EXPR_IDENT
Definition: parser.h:271
@ EXPR_IN
Definition: parser.h:224
@ EXPR_INSTANCEOF
Definition: parser.h:223
@ EXPR_PLUS
Definition: parser.h:234
@ EXPR_MUL
Definition: parser.h:227
@ EXPR_BITNEG
Definition: parser.h:247
@ EXPR_COND
Definition: parser.h:264
@ EXPR_PREINC
Definition: parser.h:237
@ EXPR_OR
Definition: parser.h:218
@ EXPR_NOTEQ
Definition: parser.h:241
@ EXPR_NOTEQEQ
Definition: parser.h:242
@ EXPR_POSTINC
Definition: parser.h:235
@ EXPR_ASSIGNAND
Definition: parser.h:261
@ EXPR_RRSHIFT
Definition: parser.h:251
@ EXPR_ASSIGNSUB
Definition: parser.h:257
@ EXPR_SUB
Definition: parser.h:226
@ EXPR_EQ
Definition: parser.h:239
@ EXPR_ASSIGNRSHIFT
Definition: parser.h:254
@ EXPR_LESSEQ
Definition: parser.h:244
@ EXPR_MINUS
Definition: parser.h:233
@ EXPR_COMMA
Definition: parser.h:217
@ EXPR_ASSIGNXOR
Definition: parser.h:263
@ EXPR_AND
Definition: parser.h:219
static ccval_t ccval_bool(BOOL b)
Definition: parser.h:387
static double get_ccnum(ccval_t v)
Definition: parser.h:400
literal_type_t
Definition: parser.h:72
@ LT_BOOL
Definition: parser.h:75
@ LT_STRING
Definition: parser.h:74
@ LT_NULL
Definition: parser.h:76
@ LT_REGEXP
Definition: parser.h:77
@ LT_DOUBLE
Definition: parser.h:73
struct _parameter_t parameter_t
BOOL parse_cc_expr(parser_ctx_t *) DECLSPEC_HIDDEN
struct _parser_ctx_t parser_ctx_t
HRESULT parse_decimal(const WCHAR **, const WCHAR *, double *) DECLSPEC_HIDDEN
Definition: lex.c:397
struct _function_expression_t function_expression_t
BOOL try_parse_ccval(parser_ctx_t *, ccval_t *) DECLSPEC_HIDDEN
Definition: lex.c:907
statement_type_t
Definition: parser.h:104
@ STAT_CONTINUE
Definition: parser.h:107
@ STAT_FOR
Definition: parser.h:110
@ STAT_EMPTY
Definition: parser.h:108
@ STAT_THROW
Definition: parser.h:116
@ STAT_SWITCH
Definition: parser.h:115
@ STAT_VAR
Definition: parser.h:118
@ STAT_EXPR
Definition: parser.h:109
@ STAT_TRY
Definition: parser.h:117
@ STAT_RETURN
Definition: parser.h:114
@ STAT_BLOCK
Definition: parser.h:105
@ STAT_WITH
Definition: parser.h:120
@ STAT_IF
Definition: parser.h:112
@ STAT_FORIN
Definition: parser.h:111
@ STAT_BREAK
Definition: parser.h:106
@ STAT_LABEL
Definition: parser.h:113
@ STAT_WHILE
Definition: parser.h:119
static ccval_t ccval_num(double n)
Definition: parser.h:379
struct _array_element_t array_element_t
static void * parser_alloc_tmp(parser_ctx_t *ctx, DWORD size)
Definition: parser.h:63
BOOL unescape(WCHAR *, size_t *) DECLSPEC_HIDDEN
Definition: lex.c:227
struct _variable_declaration_t variable_declaration_t
struct _property_definition_t property_definition_t
struct _case_clausule_t case_clausule_t
struct _argument_t argument_t
literal_t * new_boolean_literal(parser_ctx_t *, BOOL) DECLSPEC_HIDDEN
Definition: lex.c:387
jsstr_t * compiler_alloc_string_len(struct _compiler_ctx_t *, const WCHAR *, unsigned) DECLSPEC_HIDDEN
Definition: compile.c:133
literal_t * parse_regexp(parser_ctx_t *) DECLSPEC_HIDDEN
Definition: lex.c:1115
static BOOL get_ccbool(ccval_t v)
Definition: parser.h:395
expression_type_t
Definition: parse.h:21
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
const GLdouble * v
Definition: gl.h:2040
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizeiptr size
Definition: glext.h:5919
GLdouble n
Definition: glext.h:7729
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
void * heap_pool_alloc(heap_pool_t *, DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN
Definition: jsutils.c:77
#define b
Definition: ke_i.h:79
const WCHAR * str
int parser_lex(void)
expression_t * expr
Definition: parser.h:329
struct _argument_t * next
Definition: parser.h:331
expression_t * expr
Definition: parser.h:352
struct _array_element_t * next
Definition: parser.h:354
struct _case_clausule_t * next
Definition: parser.h:195
statement_t * stat
Definition: parser.h:193
expression_t * expr
Definition: parser.h:192
expression_type_t type
Definition: parser.h:278
const WCHAR * event_target
Definition: parser.h:294
parameter_t * parameter_list
Definition: parser.h:295
expression_t expr
Definition: parser.h:292
const WCHAR * src_str
Definition: parser.h:297
struct _function_expression_t * next
Definition: parser.h:301
source_elements_t * source_elements
Definition: parser.h:296
const WCHAR * identifier
Definition: parser.h:293
Definition: jsstr.h:39
struct _parameter_t * next
Definition: parser.h:283
const WCHAR * identifier
Definition: parser.h:282
heap_pool_t heap
Definition: parser.h:50
ccval_t ccval
Definition: parser.h:47
source_elements_t * source
Definition: parser.h:40
script_ctx_t * script
Definition: parser.h:38
const WCHAR * ptr
Definition: parser.h:36
BOOL is_html
Definition: parser.h:43
BOOL nl
Definition: parser.h:41
BOOL implicit_nl_semicolon
Definition: parser.h:42
unsigned cc_if_depth
Definition: parser.h:48
HRESULT hres
Definition: parser.h:45
struct _compiler_ctx_t * compiler
Definition: parser.h:39
BOOL lexer_error
Definition: parser.h:44
const WCHAR * begin
Definition: parser.h:34
const WCHAR * end
Definition: parser.h:35
struct _property_definition_t * next
Definition: parser.h:368
literal_t * name
Definition: parser.h:365
expression_t * value
Definition: parser.h:366
statement_t * statement
Definition: parser.h:287
statement_t * statement_tail
Definition: parser.h:288
statement_type_t type
Definition: parser.h:124
statement_t * next
Definition: parser.h:125
union _statement_t::@5031 u
const WCHAR * identifier
Definition: parser.h:97
struct _variable_declaration_t * global_next
Definition: parser.h:101
expression_t * expr
Definition: parser.h:98
struct _variable_declaration_t * next
Definition: parser.h:100
array_element_t * element_list
Definition: parser.h:359
expression_t expr
Definition: parser.h:305
expression_t * expression1
Definition: parser.h:306
expression_t * expression2
Definition: parser.h:307
statement_t stat
Definition: parser.h:129
statement_t * stat_list
Definition: parser.h:130
statement_t stat
Definition: parser.h:175
const WCHAR * identifier
Definition: parser.h:176
expression_t * expression
Definition: parser.h:336
expression_t expr
Definition: parser.h:335
argument_t * argument_list
Definition: parser.h:337
statement_t * statement
Definition: parser.h:206
const WCHAR * identifier
Definition: parser.h:205
Definition: parser.h:25
double n
Definition: parser.h:29
BOOL b
Definition: parser.h:28
BOOL is_num
Definition: parser.h:26
expression_t * true_expression
Definition: parser.h:318
expression_t * expression
Definition: parser.h:317
expression_t expr
Definition: parser.h:316
expression_t * false_expression
Definition: parser.h:319
expression_t * expr
Definition: parser.h:140
statement_t stat
Definition: parser.h:139
statement_t stat
Definition: parser.h:158
expression_t * expr
Definition: parser.h:161
statement_t * statement
Definition: parser.h:163
expression_t * end_expr
Definition: parser.h:162
expression_t * begin_expr
Definition: parser.h:160
variable_declaration_t * variable_list
Definition: parser.h:159
variable_declaration_t * variable
Definition: parser.h:168
statement_t stat
Definition: parser.h:167
statement_t * statement
Definition: parser.h:171
expression_t * in_expr
Definition: parser.h:170
expression_t * expr
Definition: parser.h:169
expression_t expr
Definition: parser.h:341
const WCHAR * identifier
Definition: parser.h:342
statement_t stat
Definition: parser.h:144
statement_t * if_stat
Definition: parser.h:146
expression_t * expr
Definition: parser.h:145
statement_t * else_stat
Definition: parser.h:147
const WCHAR * identifier
Definition: parser.h:187
statement_t * statement
Definition: parser.h:188
statement_t stat
Definition: parser.h:186
literal_t * literal
Definition: parser.h:347
expression_t expr
Definition: parser.h:346
DWORD flags
Definition: parser.h:88
BOOL bval
Definition: parser.h:85
double dval
Definition: parser.h:83
literal_type_t type
Definition: parser.h:81
jsstr_t * str
Definition: parser.h:84
const WCHAR * identifier
Definition: parser.h:325
expression_t expr
Definition: parser.h:323
expression_t * expression
Definition: parser.h:324
property_definition_t * property_list
Definition: parser.h:373
expression_t * expr
Definition: parser.h:200
case_clausule_t * case_list
Definition: parser.h:201
statement_t stat
Definition: parser.h:199
statement_t stat
Definition: parser.h:210
catch_block_t * catch_block
Definition: parser.h:212
statement_t * try_statement
Definition: parser.h:211
statement_t * finally_statement
Definition: parser.h:213
expression_t * expression
Definition: parser.h:312
expression_t expr
Definition: parser.h:311
variable_declaration_t * variable_list
Definition: parser.h:135
statement_t stat
Definition: parser.h:134
expression_t * expr
Definition: parser.h:153
statement_t stat
Definition: parser.h:151
statement_t * statement
Definition: parser.h:154
expression_t * expr
Definition: parser.h:181
statement_t stat
Definition: parser.h:180
statement_t * statement
Definition: parser.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180