parser.h (660f7b90) parser.h (3e2d6582)
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 *

--- 22 unchanged lines hidden (view full) ---

31} ccval_t;
32
33typedef struct _parser_ctx_t {
34 const WCHAR *begin;
35 const WCHAR *end;
36 const WCHAR *ptr;
37
38 script_ctx_t *script;
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 *

--- 22 unchanged lines hidden (view full) ---

31} ccval_t;
32
33typedef struct _parser_ctx_t {
34 const WCHAR *begin;
35 const WCHAR *end;
36 const WCHAR *ptr;
37
38 script_ctx_t *script;
39 struct _compiler_ctx_t *compiler;
39 source_elements_t *source;
40 BOOL nl;
41 BOOL implicit_nl_semicolon;
42 BOOL is_html;
43 BOOL lexer_error;
44 HRESULT hres;
45
46 ccval_t ccval;
47 unsigned cc_if_depth;
48
49 heap_pool_t heap;
50} parser_ctx_t;
51
40 source_elements_t *source;
41 BOOL nl;
42 BOOL implicit_nl_semicolon;
43 BOOL is_html;
44 BOOL lexer_error;
45 HRESULT hres;
46
47 ccval_t ccval;
48 unsigned cc_if_depth;
49
50 heap_pool_t heap;
51} parser_ctx_t;
52
52HRESULT script_parse(script_ctx_t*,const WCHAR*,const WCHAR*,BOOL,parser_ctx_t**) DECLSPEC_HIDDEN;
53HRESULT script_parse(script_ctx_t*,struct _compiler_ctx_t*,const WCHAR*,const WCHAR*,BOOL,parser_ctx_t**) DECLSPEC_HIDDEN;
53void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
54
55int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
56
57static inline void *parser_alloc(parser_ctx_t *ctx, DWORD size)
58{
59 return heap_pool_alloc(&ctx->heap, size);
60}
61
62static inline void *parser_alloc_tmp(parser_ctx_t *ctx, DWORD size)
63{
64 return heap_pool_alloc(&ctx->script->tmp_heap, size);
65}
66
67BOOL is_identifier_char(WCHAR) DECLSPEC_HIDDEN;
54void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
55
56int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
57
58static inline void *parser_alloc(parser_ctx_t *ctx, DWORD size)
59{
60 return heap_pool_alloc(&ctx->heap, size);
61}
62
63static inline void *parser_alloc_tmp(parser_ctx_t *ctx, DWORD size)
64{
65 return heap_pool_alloc(&ctx->script->tmp_heap, size);
66}
67
68BOOL is_identifier_char(WCHAR) DECLSPEC_HIDDEN;
68BOOL unescape(WCHAR*) DECLSPEC_HIDDEN;
69BOOL unescape(WCHAR*,size_t*) DECLSPEC_HIDDEN;
69HRESULT parse_decimal(const WCHAR**,const WCHAR*,double*) DECLSPEC_HIDDEN;
70
71typedef enum {
72 LT_DOUBLE,
73 LT_STRING,
74 LT_BOOL,
75 LT_NULL,
76 LT_REGEXP
77}literal_type_t;
78
79typedef struct {
80 literal_type_t type;
81 union {
82 double dval;
70HRESULT parse_decimal(const WCHAR**,const WCHAR*,double*) DECLSPEC_HIDDEN;
71
72typedef enum {
73 LT_DOUBLE,
74 LT_STRING,
75 LT_BOOL,
76 LT_NULL,
77 LT_REGEXP
78}literal_type_t;
79
80typedef struct {
81 literal_type_t type;
82 union {
83 double dval;
83 const WCHAR *wstr;
84 jsstr_t *str;
84 BOOL bval;
85 struct {
85 BOOL bval;
86 struct {
86 const WCHAR *str;
87 DWORD str_len;
87 jsstr_t *str;
88 DWORD flags;
89 } regexp;
90 } u;
91} literal_t;
92
93literal_t *parse_regexp(parser_ctx_t*) DECLSPEC_HIDDEN;
94literal_t *new_boolean_literal(parser_ctx_t*,BOOL) DECLSPEC_HIDDEN;
95

--- 300 unchanged lines hidden (view full) ---

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}
88 DWORD flags;
89 } regexp;
90 } u;
91} literal_t;
92
93literal_t *parse_regexp(parser_ctx_t*) DECLSPEC_HIDDEN;
94literal_t *new_boolean_literal(parser_ctx_t*,BOOL) DECLSPEC_HIDDEN;
95

--- 300 unchanged lines hidden (view full) ---

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
405jsstr_t *compiler_alloc_string_len(struct _compiler_ctx_t*,const WCHAR *,unsigned) DECLSPEC_HIDDEN;