2011-09-06 13:18:40 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-07 12:08:21 +00:00
|
|
|
typedef enum {
|
2011-09-12 10:31:58 +00:00
|
|
|
EXPR_ADD,
|
2011-09-14 10:59:02 +00:00
|
|
|
EXPR_AND,
|
2011-09-08 12:56:36 +00:00
|
|
|
EXPR_BOOL,
|
2011-09-12 10:30:47 +00:00
|
|
|
EXPR_CONCAT,
|
2011-09-13 09:40:39 +00:00
|
|
|
EXPR_DIV,
|
2011-09-12 10:29:59 +00:00
|
|
|
EXPR_DOUBLE,
|
2011-09-09 12:49:26 +00:00
|
|
|
EXPR_EMPTY,
|
2011-09-09 12:48:13 +00:00
|
|
|
EXPR_EQUAL,
|
2011-09-14 10:59:49 +00:00
|
|
|
EXPR_EQV,
|
2011-09-13 09:41:15 +00:00
|
|
|
EXPR_EXP,
|
2011-09-13 09:40:14 +00:00
|
|
|
EXPR_IDIV,
|
2011-09-14 10:59:49 +00:00
|
|
|
EXPR_IMP,
|
2011-09-08 12:56:58 +00:00
|
|
|
EXPR_MEMBER,
|
2011-09-13 09:39:53 +00:00
|
|
|
EXPR_MOD,
|
2011-09-13 09:40:39 +00:00
|
|
|
EXPR_MUL,
|
2011-09-12 10:31:37 +00:00
|
|
|
EXPR_NEG,
|
2011-09-12 10:32:27 +00:00
|
|
|
EXPR_NEQUAL,
|
2011-09-15 12:18:12 +00:00
|
|
|
EXPR_NEW,
|
2011-09-09 12:47:32 +00:00
|
|
|
EXPR_NOT,
|
2011-09-15 12:18:56 +00:00
|
|
|
EXPR_NOTHING,
|
2011-09-09 12:49:36 +00:00
|
|
|
EXPR_NULL,
|
2011-09-14 10:59:26 +00:00
|
|
|
EXPR_OR,
|
2011-09-12 10:29:59 +00:00
|
|
|
EXPR_STRING,
|
2011-09-12 10:31:58 +00:00
|
|
|
EXPR_SUB,
|
2011-09-12 10:29:59 +00:00
|
|
|
EXPR_ULONG,
|
2011-09-14 10:59:49 +00:00
|
|
|
EXPR_USHORT,
|
|
|
|
EXPR_XOR
|
2011-09-07 12:08:21 +00:00
|
|
|
} expression_type_t;
|
|
|
|
|
|
|
|
typedef struct _expression_t {
|
|
|
|
expression_type_t type;
|
|
|
|
struct _expression_t *next;
|
|
|
|
} expression_t;
|
|
|
|
|
2011-09-08 12:56:36 +00:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
VARIANT_BOOL value;
|
|
|
|
} bool_expression_t;
|
|
|
|
|
2011-09-12 10:29:59 +00:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
LONG value;
|
|
|
|
} int_expression_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
double value;
|
|
|
|
} double_expression_t;
|
|
|
|
|
2011-09-08 12:56:58 +00:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
const WCHAR *value;
|
|
|
|
} string_expression_t;
|
|
|
|
|
2011-09-09 12:47:32 +00:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
expression_t *subexpr;
|
|
|
|
} unary_expression_t;
|
|
|
|
|
2011-09-09 12:48:13 +00:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
expression_t *left;
|
|
|
|
expression_t *right;
|
|
|
|
} binary_expression_t;
|
|
|
|
|
2011-09-07 12:08:21 +00:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
expression_t *obj_expr;
|
|
|
|
const WCHAR *identifier;
|
|
|
|
expression_t *args;
|
|
|
|
} member_expression_t;
|
|
|
|
|
|
|
|
typedef enum {
|
2011-09-12 10:32:38 +00:00
|
|
|
STAT_ASSIGN,
|
2011-09-13 09:36:26 +00:00
|
|
|
STAT_CALL,
|
2011-09-14 10:54:50 +00:00
|
|
|
STAT_DIM,
|
2011-09-14 10:58:10 +00:00
|
|
|
STAT_EXITFUNC,
|
2011-09-14 10:57:27 +00:00
|
|
|
STAT_EXITSUB,
|
2011-09-14 10:54:50 +00:00
|
|
|
STAT_FUNC,
|
2011-09-15 12:17:38 +00:00
|
|
|
STAT_IF,
|
|
|
|
STAT_SET
|
2011-09-07 12:08:21 +00:00
|
|
|
} statement_type_t;
|
|
|
|
|
|
|
|
typedef struct _statement_t {
|
|
|
|
statement_type_t type;
|
|
|
|
struct _statement_t *next;
|
|
|
|
} statement_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
member_expression_t *expr;
|
|
|
|
} call_statement_t;
|
|
|
|
|
2011-09-12 10:32:38 +00:00
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
member_expression_t *member_expr;
|
|
|
|
expression_t *value_expr;
|
|
|
|
} assign_statement_t;
|
|
|
|
|
2011-09-13 09:36:26 +00:00
|
|
|
typedef struct _dim_decl_t {
|
|
|
|
const WCHAR *name;
|
|
|
|
struct _dim_decl_t *next;
|
|
|
|
} dim_decl_t;
|
|
|
|
|
|
|
|
typedef struct _dim_statement_t {
|
|
|
|
statement_t stat;
|
|
|
|
dim_decl_t *dim_decls;
|
|
|
|
} dim_statement_t;
|
|
|
|
|
2011-09-14 10:54:50 +00:00
|
|
|
typedef struct _arg_decl_t {
|
|
|
|
const WCHAR *name;
|
|
|
|
BOOL by_ref;
|
|
|
|
struct _arg_decl_t *next;
|
|
|
|
} arg_decl_t;
|
|
|
|
|
|
|
|
typedef struct _function_decl_t {
|
|
|
|
const WCHAR *name;
|
|
|
|
function_type_t type;
|
|
|
|
arg_decl_t *args;
|
|
|
|
statement_t *body;
|
|
|
|
struct _function_decl_t *next;
|
|
|
|
} function_decl_t;
|
|
|
|
|
|
|
|
typedef struct _function_statement_t {
|
|
|
|
statement_t stat;
|
|
|
|
function_decl_t *func_decl;
|
|
|
|
} function_statement_t;
|
|
|
|
|
2011-09-15 12:16:47 +00:00
|
|
|
typedef struct _class_decl_t {
|
|
|
|
const WCHAR *name;
|
|
|
|
struct _class_decl_t *next;
|
|
|
|
} class_decl_t;
|
|
|
|
|
2011-09-13 09:38:04 +00:00
|
|
|
typedef struct _elseif_decl_t {
|
|
|
|
expression_t *expr;
|
|
|
|
statement_t *stat;
|
|
|
|
struct _elseif_decl_t *next;
|
|
|
|
} elseif_decl_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
expression_t *expr;
|
|
|
|
statement_t *if_stat;
|
|
|
|
elseif_decl_t *elseifs;
|
|
|
|
statement_t *else_stat;
|
|
|
|
} if_statement_t;
|
|
|
|
|
2011-09-06 13:18:40 +00:00
|
|
|
typedef struct {
|
|
|
|
const WCHAR *code;
|
|
|
|
const WCHAR *ptr;
|
|
|
|
const WCHAR *end;
|
|
|
|
|
2011-09-09 12:47:00 +00:00
|
|
|
BOOL option_explicit;
|
2011-09-06 13:18:40 +00:00
|
|
|
BOOL parse_complete;
|
|
|
|
HRESULT hres;
|
2011-09-06 13:18:55 +00:00
|
|
|
|
|
|
|
int last_token;
|
|
|
|
unsigned last_nl;
|
2011-09-07 12:08:21 +00:00
|
|
|
|
|
|
|
statement_t *stats;
|
|
|
|
statement_t *stats_tail;
|
2011-09-15 12:16:47 +00:00
|
|
|
class_decl_t *class_decls;
|
2011-09-12 10:29:31 +00:00
|
|
|
|
|
|
|
vbsheap_t heap;
|
2011-09-06 13:18:40 +00:00
|
|
|
} parser_ctx_t;
|
|
|
|
|
2011-09-06 13:18:55 +00:00
|
|
|
HRESULT parse_script(parser_ctx_t*,const WCHAR*) DECLSPEC_HIDDEN;
|
2011-09-12 10:29:31 +00:00
|
|
|
void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
|
2011-09-06 13:18:55 +00:00
|
|
|
int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
|
2011-09-07 12:08:07 +00:00
|
|
|
void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;
|