vbscript: Added interp_lt implementation.
[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_ADD,
21     EXPR_AND,
22     EXPR_BOOL,
23     EXPR_CONCAT,
24     EXPR_DIV,
25     EXPR_DOUBLE,
26     EXPR_EMPTY,
27     EXPR_EQUAL,
28     EXPR_EQV,
29     EXPR_EXP,
30     EXPR_GT,
31     EXPR_GTEQ,
32     EXPR_IDIV,
33     EXPR_IMP,
34     EXPR_LT,
35     EXPR_LTEQ,
36     EXPR_MEMBER,
37     EXPR_MOD,
38     EXPR_MUL,
39     EXPR_NEG,
40     EXPR_NEQUAL,
41     EXPR_NEW,
42     EXPR_NOT,
43     EXPR_NOTHING,
44     EXPR_NULL,
45     EXPR_OR,
46     EXPR_STRING,
47     EXPR_SUB,
48     EXPR_ULONG,
49     EXPR_USHORT,
50     EXPR_XOR
51 } expression_type_t;
52
53 typedef struct _expression_t {
54     expression_type_t type;
55     struct _expression_t *next;
56 } expression_t;
57
58 typedef struct {
59     expression_t expr;
60     VARIANT_BOOL value;
61 } bool_expression_t;
62
63 typedef struct {
64     expression_t expr;
65     LONG value;
66 } int_expression_t;
67
68 typedef struct {
69     expression_t expr;
70     double value;
71 } double_expression_t;
72
73 typedef struct {
74     expression_t expr;
75     const WCHAR *value;
76 } string_expression_t;
77
78 typedef struct {
79     expression_t expr;
80     expression_t *subexpr;
81 } unary_expression_t;
82
83 typedef struct {
84     expression_t expr;
85     expression_t *left;
86     expression_t *right;
87 } binary_expression_t;
88
89 typedef struct {
90     expression_t expr;
91     expression_t *obj_expr;
92     const WCHAR *identifier;
93     expression_t *args;
94 } member_expression_t;
95
96 typedef enum {
97     STAT_ASSIGN,
98     STAT_CALL,
99     STAT_DIM,
100     STAT_DOUNTIL,
101     STAT_DOWHILE,
102     STAT_EXITDO,
103     STAT_EXITFUNC,
104     STAT_EXITPROP,
105     STAT_EXITSUB,
106     STAT_FUNC,
107     STAT_IF,
108     STAT_SET,
109     STAT_STOP,
110     STAT_UNTIL,
111     STAT_WHILE,
112     STAT_WHILELOOP
113 } statement_type_t;
114
115 typedef struct _statement_t {
116     statement_type_t type;
117     struct _statement_t *next;
118 } statement_t;
119
120 typedef struct {
121     statement_t stat;
122     member_expression_t *expr;
123 } call_statement_t;
124
125 typedef struct {
126     statement_t stat;
127     member_expression_t *member_expr;
128     expression_t *value_expr;
129 } assign_statement_t;
130
131 typedef struct _dim_decl_t {
132     const WCHAR *name;
133     struct _dim_decl_t *next;
134 } dim_decl_t;
135
136 typedef struct _dim_statement_t {
137     statement_t stat;
138     dim_decl_t *dim_decls;
139 } dim_statement_t;
140
141 typedef struct _arg_decl_t {
142     const WCHAR *name;
143     BOOL by_ref;
144     struct _arg_decl_t *next;
145 } arg_decl_t;
146
147 typedef struct _function_decl_t {
148     const WCHAR *name;
149     function_type_t type;
150     BOOL is_public;
151     arg_decl_t *args;
152     statement_t *body;
153     struct _function_decl_t *next;
154     struct _function_decl_t *next_prop_func;
155 } function_decl_t;
156
157 typedef struct {
158     statement_t stat;
159     function_decl_t *func_decl;
160 } function_statement_t;
161
162 typedef struct _class_prop_decl_t {
163     BOOL is_public;
164     const WCHAR *name;
165     struct _class_prop_decl_t *next;
166 } class_prop_decl_t;
167
168 typedef struct _class_decl_t {
169     const WCHAR *name;
170     function_decl_t *funcs;
171     class_prop_decl_t *props;
172     struct _class_decl_t *next;
173 } class_decl_t;
174
175 typedef struct _elseif_decl_t {
176     expression_t *expr;
177     statement_t *stat;
178     struct _elseif_decl_t *next;
179 } elseif_decl_t;
180
181 typedef struct {
182     statement_t stat;
183     expression_t *expr;
184     statement_t *if_stat;
185     elseif_decl_t *elseifs;
186     statement_t *else_stat;
187 } if_statement_t;
188
189 typedef struct {
190     statement_t stat;
191     expression_t *expr;
192     statement_t *body;
193 } while_statement_t;
194
195 typedef struct {
196     const WCHAR *code;
197     const WCHAR *ptr;
198     const WCHAR *end;
199
200     BOOL option_explicit;
201     BOOL parse_complete;
202     HRESULT hres;
203
204     int last_token;
205     unsigned last_nl;
206
207     statement_t *stats;
208     statement_t *stats_tail;
209     class_decl_t *class_decls;
210
211     vbsheap_t heap;
212 } parser_ctx_t;
213
214 HRESULT parse_script(parser_ctx_t*,const WCHAR*) DECLSPEC_HIDDEN;
215 void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
216 int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
217 void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;