vbscript: Added interp_idiv 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_IDIV,
27     EXPR_MEMBER,
28     EXPR_MOD,
29     EXPR_NEG,
30     EXPR_NEQUAL,
31     EXPR_NOT,
32     EXPR_NULL,
33     EXPR_STRING,
34     EXPR_SUB,
35     EXPR_ULONG,
36     EXPR_USHORT
37 } expression_type_t;
38
39 typedef struct _expression_t {
40     expression_type_t type;
41     struct _expression_t *next;
42 } expression_t;
43
44 typedef struct {
45     expression_t expr;
46     VARIANT_BOOL value;
47 } bool_expression_t;
48
49 typedef struct {
50     expression_t expr;
51     LONG value;
52 } int_expression_t;
53
54 typedef struct {
55     expression_t expr;
56     double value;
57 } double_expression_t;
58
59 typedef struct {
60     expression_t expr;
61     const WCHAR *value;
62 } string_expression_t;
63
64 typedef struct {
65     expression_t expr;
66     expression_t *subexpr;
67 } unary_expression_t;
68
69 typedef struct {
70     expression_t expr;
71     expression_t *left;
72     expression_t *right;
73 } binary_expression_t;
74
75 typedef struct {
76     expression_t expr;
77     expression_t *obj_expr;
78     const WCHAR *identifier;
79     expression_t *args;
80 } member_expression_t;
81
82 typedef enum {
83     STAT_ASSIGN,
84     STAT_CALL,
85     STAT_IF,
86     STAT_DIM
87 } statement_type_t;
88
89 typedef struct _statement_t {
90     statement_type_t type;
91     struct _statement_t *next;
92 } statement_t;
93
94 typedef struct {
95     statement_t stat;
96     member_expression_t *expr;
97 } call_statement_t;
98
99 typedef struct {
100     statement_t stat;
101     member_expression_t *member_expr;
102     expression_t *value_expr;
103 } assign_statement_t;
104
105 typedef struct _dim_decl_t {
106     const WCHAR *name;
107     struct _dim_decl_t *next;
108 } dim_decl_t;
109
110 typedef struct _dim_statement_t {
111     statement_t stat;
112     dim_decl_t *dim_decls;
113 } dim_statement_t;
114
115 typedef struct _elseif_decl_t {
116     expression_t *expr;
117     statement_t *stat;
118     struct _elseif_decl_t *next;
119 } elseif_decl_t;
120
121 typedef struct {
122     statement_t stat;
123     expression_t *expr;
124     statement_t *if_stat;
125     elseif_decl_t *elseifs;
126     statement_t *else_stat;
127 } if_statement_t;
128
129 typedef struct {
130     const WCHAR *code;
131     const WCHAR *ptr;
132     const WCHAR *end;
133
134     BOOL option_explicit;
135     BOOL parse_complete;
136     HRESULT hres;
137
138     int last_token;
139     unsigned last_nl;
140
141     statement_t *stats;
142     statement_t *stats_tail;
143
144     vbsheap_t heap;
145 } parser_ctx_t;
146
147 HRESULT parse_script(parser_ctx_t*,const WCHAR*) DECLSPEC_HIDDEN;
148 void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
149 int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
150 void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;