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