ReactOS  0.4.13-dev-242-g611e6d7
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 
22 typedef struct _expression_t expression_t;
23 typedef struct _statement_t statement_t;
24 
25 typedef struct {
27  union {
29  double n;
30  } u;
31 } ccval_t;
32 
33 typedef struct _parser_ctx_t {
34  const WCHAR *begin;
35  const WCHAR *end;
36  const WCHAR *ptr;
37 
45 
47  unsigned cc_if_depth;
48 
50 } parser_ctx_t;
51 
54 
56 
57 static inline void *parser_alloc(parser_ctx_t *ctx, DWORD size)
58 {
59  return heap_pool_alloc(&ctx->heap, size);
60 }
61 
62 static inline void *parser_alloc_tmp(parser_ctx_t *ctx, DWORD size)
63 {
64  return heap_pool_alloc(&ctx->script->tmp_heap, size);
65 }
66 
69 HRESULT parse_decimal(const WCHAR**,const WCHAR*,double*) DECLSPEC_HIDDEN;
70 
71 typedef enum {
78 
79 typedef struct {
81  union {
82  double dval;
83  const WCHAR *wstr;
85  struct {
86  const WCHAR *str;
89  } regexp;
90  } u;
91 } literal_t;
92 
95 
96 typedef struct _variable_declaration_t {
97  const WCHAR *identifier;
99 
101  struct _variable_declaration_t *global_next; /* for compiler */
103 
104 typedef enum {
122 
123 struct _statement_t {
126 };
127 
128 typedef struct {
132 
133 typedef struct {
137 
138 typedef struct {
142 
143 typedef struct {
149 
150 typedef struct {
156 
157 typedef struct {
165 
166 typedef struct {
173 
174 typedef struct {
178 
179 typedef struct {
184 
185 typedef struct {
190 
191 typedef struct _case_clausule_t {
194 
197 
198 typedef struct {
203 
204 typedef struct {
207 } catch_block_t;
208 
209 typedef struct {
215 
216 typedef enum {
276 
279 };
280 
281 typedef struct _parameter_t {
284 } parameter_t;
285 
289 };
290 
291 typedef struct _function_expression_t {
297  const WCHAR *src_str;
299  unsigned func_id;
300 
301  struct _function_expression_t *next; /* for compiler */
303 
304 typedef struct {
309 
310 typedef struct {
314 
315 typedef struct {
321 
322 typedef struct {
327 
328 typedef struct _argument_t {
330 
331  struct _argument_t *next;
332 } argument_t;
333 
334 typedef struct {
339 
340 typedef struct {
344 
345 typedef struct {
349 
350 typedef struct _array_element_t {
351  int elision;
353 
356 
357 typedef struct {
360  int length;
362 
363 typedef struct _property_definition_t {
364  unsigned type;
367 
370 
371 typedef struct {
375 
378 
379 static 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 
387 static 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 
395 static inline BOOL get_ccbool(ccval_t v)
396 {
397  return v.is_num ? v.u.n != 0 : v.u.b;
398 }
399 
400 static inline double get_ccnum(ccval_t v)
401 {
402  return v.is_num ? v.u.n : v.u.b;
403 }
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
statement_t stat
Definition: parser.h:175
expression_t expr
Definition: parser.h:305
expression_type_t
Definition: parser.h:216
const WCHAR * identifier
Definition: parser.h:97
struct _function_expression_t * next
Definition: parser.h:301
BOOL lexer_error
Definition: parser.h:43
#define TRUE
Definition: types.h:120
BOOL try_parse_ccval(parser_ctx_t *, ccval_t *) DECLSPEC_HIDDEN
Definition: lex.c:944
expression_t * expression
Definition: parser.h:324
int parser_lex(void *, parser_ctx_t *) DECLSPEC_HIDDEN
Definition: lex.c:1142
expression_t * expression2
Definition: parser.h:307
BOOL is_identifier_char(WCHAR) DECLSPEC_HIDDEN
Definition: lex.c:123
struct _case_clausule_t case_clausule_t
variable_declaration_t * variable
Definition: parser.h:168
struct _argument_t * next
Definition: parser.h:331
expression_t * expr
Definition: parser.h:200
case_clausule_t * case_list
Definition: parser.h:201
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
void * heap_pool_alloc(heap_pool_t *, DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN
Definition: jsutils.c:75
struct _variable_declaration_t * next
Definition: parser.h:100
expression_t * expr
Definition: parser.h:153
struct _property_definition_t * next
Definition: parser.h:368
statement_t stat
Definition: parser.h:199
literal_t * parse_regexp(parser_ctx_t *) DECLSPEC_HIDDEN
Definition: lex.c:1155
DWORD flags
Definition: parser.h:88
statement_t * if_stat
Definition: parser.h:146
const WCHAR * str
Definition: parser.h:86
statement_t * statement
Definition: parser.h:287
GLdouble n
Definition: glext.h:7729
static double get_ccnum(ccval_t v)
Definition: parser.h:400
statement_t * statement_tail
Definition: parser.h:288
BOOL is_num
Definition: parser.h:26
statement_t * stat_list
Definition: parser.h:130
variable_declaration_t * variable_list
Definition: parser.h:135
double dval
Definition: parser.h:82
struct _parameter_t parameter_t
source_elements_t * source
Definition: parser.h:39
expression_t expr
Definition: parser.h:323
Definition: parser.h:74
const WCHAR * identifier
Definition: parser.h:176
static ccval_t ccval_bool(BOOL b)
Definition: parser.h:387
const WCHAR * identifier
Definition: parser.h:293
const WCHAR * identifier
Definition: parser.h:205
array_element_t * element_list
Definition: parser.h:359
statement_t stat
Definition: parser.h:158
expression_type_t type
Definition: parser.h:278
struct _function_expression_t function_expression_t
DWORD str_len
Definition: parser.h:87
expression_t * true_expression
Definition: parser.h:318
const WCHAR * identifier
Definition: parser.h:282
statement_t * next
Definition: parser.h:125
expression_t expr
Definition: parser.h:292
expression_t * expr
Definition: parser.h:329
Definition: parser.h:75
const WCHAR * event_target
Definition: parser.h:294
expression_t expr
Definition: parser.h:311
expression_t * expression1
Definition: parser.h:306
BOOL implicit_nl_semicolon
Definition: parser.h:41
unsigned int BOOL
Definition: ntddk_ex.h:94
expression_t * expr
Definition: parser.h:140
statement_t * stat
Definition: parser.h:193
statement_t * statement
Definition: parser.h:163
source_elements_t * source_elements
Definition: parser.h:296
expression_t * expr
Definition: parser.h:192
const WCHAR * identifier
Definition: parser.h:325
static ccval_t ccval_num(double n)
Definition: parser.h:379
ccval_t ccval
Definition: parser.h:46
const WCHAR * wstr
Definition: parser.h:83
struct _case_clausule_t * next
Definition: parser.h:195
struct _parser_ctx_t parser_ctx_t
expression_t * expr
Definition: parser.h:352
statement_type_t type
Definition: parser.h:124
literal_t * name
Definition: parser.h:365
expression_t * expr
Definition: parser.h:98
#define b
Definition: ke_i.h:79
struct _property_definition_t property_definition_t
statement_t * statement
Definition: parser.h:171
const WCHAR * end
Definition: parser.h:35
struct _argument_t argument_t
statement_t * statement
Definition: parser.h:188
void parser_release(parser_ctx_t *) DECLSPEC_HIDDEN
Definition: parser.tab.c:4330
heap_pool_t heap
Definition: parse.h:271
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
BOOL b
Definition: parser.h:28
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
BOOL bval
Definition: parser.h:84
HRESULT parse_decimal(const WCHAR **, const WCHAR *, double *) DECLSPEC_HIDDEN
Definition: lex.c:426
argument_t * argument_list
Definition: parser.h:337
expression_t expr
Definition: parser.h:316
unsigned long DWORD
Definition: ntddk_ex.h:95
const WCHAR * begin
Definition: parser.h:34
expression_t * in_expr
Definition: parser.h:170
statement_t stat
Definition: parser.h:167
statement_type_t
Definition: parser.h:104
struct _variable_declaration_t * global_next
Definition: parser.h:101
statement_t stat
Definition: parser.h:134
literal_type_t
Definition: parser.h:71
expression_t * expression
Definition: parser.h:312
BOOL unescape(WCHAR *) DECLSPEC_HIDDEN
Definition: lex.c:269
statement_t stat
Definition: parser.h:186
heap_pool_t heap
Definition: parser.h:49
expression_t * expr
Definition: parser.h:161
struct _array_element_t * next
Definition: parser.h:354
static void * parser_alloc_tmp(parser_ctx_t *ctx, DWORD size)
Definition: parser.h:62
statement_t stat
Definition: parser.h:129
statement_t * try_statement
Definition: parser.h:211
HRESULT hres
Definition: parser.h:44
const WCHAR * identifier
Definition: parser.h:187
const WCHAR * identifier
Definition: parser.h:342
struct _parameter_t * next
Definition: parser.h:283
literal_t * new_boolean_literal(parser_ctx_t *, BOOL) DECLSPEC_HIDDEN
Definition: lex.c:416
statement_t * else_stat
Definition: parser.h:147
literal_type_t type
Definition: parser.h:80
property_definition_t * property_list
Definition: parser.h:373
static void * parser_alloc(parser_ctx_t *ctx, DWORD size)
Definition: parser.h:57
double n
Definition: parser.h:29
parameter_t * parameter_list
Definition: parser.h:295
statement_t stat
Definition: parser.h:210
expression_t * expression
Definition: parser.h:336
statement_t * statement
Definition: parser.h:182
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
literal_t * literal
Definition: parser.h:347
const GLdouble * v
Definition: gl.h:2040
BOOL is_html
Definition: parser.h:42
expression_t * expr
Definition: parser.h:169
expression_t expr
Definition: parser.h:335
static BOOL get_ccbool(ccval_t v)
Definition: parser.h:395
variable_declaration_t * variable_list
Definition: parser.h:159
expression_t * end_expr
Definition: parser.h:162
catch_block_t * catch_block
Definition: parser.h:212
expression_t expr
Definition: parser.h:346
Definition: parser.h:25
const WCHAR * src_str
Definition: parser.h:297
statement_t stat
Definition: parser.h:180
struct _variable_declaration_t variable_declaration_t
expression_t * expr
Definition: parser.h:181
expression_t expr
Definition: parser.h:341
struct _array_element_t array_element_t
BOOL parse_cc_expr(parser_ctx_t *) DECLSPEC_HIDDEN
expression_t * begin_expr
Definition: parser.h:160
statement_t * finally_statement
Definition: parser.h:213
statement_t * statement
Definition: parser.h:206
statement_t stat
Definition: parser.h:151
union _statement_t::@4022 u
BOOL nl
Definition: parser.h:40
statement_t stat
Definition: parser.h:139
HRESULT script_parse(script_ctx_t *, const WCHAR *, const WCHAR *, BOOL, parser_ctx_t **) DECLSPEC_HIDDEN
Definition: parser.tab.c:4337
unsigned cc_if_depth
Definition: parser.h:47
expression_t * false_expression
Definition: parser.h:319
const WCHAR * ptr
Definition: parser.h:36
expression_t * expression
Definition: parser.h:317
expression_t * value
Definition: parser.h:366
script_ctx_t * script
Definition: parser.h:38
statement_t stat
Definition: parser.h:144
expression_t * expr
Definition: parser.h:145
statement_t * statement
Definition: parser.h:154