vbscript: Added compiler/parser support for call expressions.
[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_EQUAL,
22     EXPR_MEMBER,
23     EXPR_NOT,
24     EXPR_STRING
25 } expression_type_t;
26
27 typedef struct _expression_t {
28     expression_type_t type;
29     struct _expression_t *next;
30 } expression_t;
31
32 typedef struct {
33     expression_t expr;
34     VARIANT_BOOL value;
35 } bool_expression_t;
36
37 typedef struct {
38     expression_t expr;
39     const WCHAR *value;
40 } string_expression_t;
41
42 typedef struct {
43     expression_t expr;
44     expression_t *subexpr;
45 } unary_expression_t;
46
47 typedef struct {
48     expression_t expr;
49     expression_t *left;
50     expression_t *right;
51 } binary_expression_t;
52
53 typedef struct {
54     expression_t expr;
55     expression_t *obj_expr;
56     const WCHAR *identifier;
57     expression_t *args;
58 } member_expression_t;
59
60 typedef enum {
61     STAT_CALL
62 } statement_type_t;
63
64 typedef struct _statement_t {
65     statement_type_t type;
66     struct _statement_t *next;
67 } statement_t;
68
69 typedef struct {
70     statement_t stat;
71     member_expression_t *expr;
72 } call_statement_t;
73
74 typedef struct {
75     const WCHAR *code;
76     const WCHAR *ptr;
77     const WCHAR *end;
78
79     BOOL option_explicit;
80     BOOL parse_complete;
81     HRESULT hres;
82
83     int last_token;
84     unsigned last_nl;
85
86     statement_t *stats;
87     statement_t *stats_tail;
88 } parser_ctx_t;
89
90 HRESULT parse_script(parser_ctx_t*,const WCHAR*) DECLSPEC_HIDDEN;
91 int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
92 void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;