vbscript: Added parser support for numeric literals.
[wine] / dlls / vbscript / parse.h
1 /*
2  * Copyright 2011 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 typedef enum {
20     EXPR_BOOL,
21     EXPR_DOUBLE,
22     EXPR_EMPTY,
23     EXPR_EQUAL,
24     EXPR_MEMBER,
25     EXPR_NOT,
26     EXPR_NULL,
27     EXPR_STRING,
28     EXPR_ULONG,
29     EXPR_USHORT
30 } expression_type_t;
31
32 typedef struct _expression_t {
33     expression_type_t type;
34     struct _expression_t *next;
35 } expression_t;
36
37 typedef struct {
38     expression_t expr;
39     VARIANT_BOOL value;
40 } bool_expression_t;
41
42 typedef struct {
43     expression_t expr;
44     LONG value;
45 } int_expression_t;
46
47 typedef struct {
48     expression_t expr;
49     double value;
50 } double_expression_t;
51
52 typedef struct {
53     expression_t expr;
54     const WCHAR *value;
55 } string_expression_t;
56
57 typedef struct {
58     expression_t expr;
59     expression_t *subexpr;
60 } unary_expression_t;
61
62 typedef struct {
63     expression_t expr;
64     expression_t *left;
65     expression_t *right;
66 } binary_expression_t;
67
68 typedef struct {
69     expression_t expr;
70     expression_t *obj_expr;
71     const WCHAR *identifier;
72     expression_t *args;
73 } member_expression_t;
74
75 typedef enum {
76     STAT_CALL
77 } statement_type_t;
78
79 typedef struct _statement_t {
80     statement_type_t type;
81     struct _statement_t *next;
82 } statement_t;
83
84 typedef struct {
85     statement_t stat;
86     member_expression_t *expr;
87 } call_statement_t;
88
89 typedef struct {
90     const WCHAR *code;
91     const WCHAR *ptr;
92     const WCHAR *end;
93
94     BOOL option_explicit;
95     BOOL parse_complete;
96     HRESULT hres;
97
98     int last_token;
99     unsigned last_nl;
100
101     statement_t *stats;
102     statement_t *stats_tail;
103
104     vbsheap_t heap;
105 } parser_ctx_t;
106
107 HRESULT parse_script(parser_ctx_t*,const WCHAR*) DECLSPEC_HIDDEN;
108 void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
109 int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
110 void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;