2011-09-06 15:18:40 +02: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 14:08:21 +02:00
|
|
|
typedef enum {
|
2011-09-12 12:31:58 +02:00
|
|
|
EXPR_ADD,
|
2011-09-14 12:59:02 +02:00
|
|
|
EXPR_AND,
|
2011-09-08 14:56:36 +02:00
|
|
|
EXPR_BOOL,
|
2012-07-03 17:04:51 +02:00
|
|
|
EXPR_BRACKETS,
|
2019-10-28 18:39:49 +01:00
|
|
|
EXPR_CALL,
|
2011-09-12 12:30:47 +02:00
|
|
|
EXPR_CONCAT,
|
2011-09-13 11:40:39 +02:00
|
|
|
EXPR_DIV,
|
2019-10-29 19:01:14 +01:00
|
|
|
EXPR_DOT,
|
2011-09-12 12:29:59 +02:00
|
|
|
EXPR_DOUBLE,
|
2011-09-09 14:49:26 +02:00
|
|
|
EXPR_EMPTY,
|
2011-09-09 14:48:13 +02:00
|
|
|
EXPR_EQUAL,
|
2011-09-14 12:59:49 +02:00
|
|
|
EXPR_EQV,
|
2011-09-13 11:41:15 +02:00
|
|
|
EXPR_EXP,
|
2011-09-19 14:07:12 +02:00
|
|
|
EXPR_GT,
|
|
|
|
EXPR_GTEQ,
|
2011-09-13 11:40:14 +02:00
|
|
|
EXPR_IDIV,
|
2011-09-14 12:59:49 +02:00
|
|
|
EXPR_IMP,
|
2019-08-22 19:31:49 +02:00
|
|
|
EXPR_INT,
|
2011-09-19 14:08:02 +02:00
|
|
|
EXPR_IS,
|
2011-09-19 14:07:12 +02:00
|
|
|
EXPR_LT,
|
|
|
|
EXPR_LTEQ,
|
2011-09-19 14:09:57 +02:00
|
|
|
EXPR_ME,
|
2011-09-08 14:56:58 +02:00
|
|
|
EXPR_MEMBER,
|
2011-09-13 11:39:53 +02:00
|
|
|
EXPR_MOD,
|
2011-09-13 11:40:39 +02:00
|
|
|
EXPR_MUL,
|
2011-09-12 12:31:37 +02:00
|
|
|
EXPR_NEG,
|
2011-09-12 12:32:27 +02:00
|
|
|
EXPR_NEQUAL,
|
2011-09-15 14:18:12 +02:00
|
|
|
EXPR_NEW,
|
2015-01-28 19:28:17 +01:00
|
|
|
EXPR_NOARG, /* not a real expression */
|
2011-09-09 14:47:32 +02:00
|
|
|
EXPR_NOT,
|
2011-09-15 14:18:56 +02:00
|
|
|
EXPR_NOTHING,
|
2011-09-09 14:49:36 +02:00
|
|
|
EXPR_NULL,
|
2011-09-14 12:59:26 +02:00
|
|
|
EXPR_OR,
|
2011-09-12 12:29:59 +02:00
|
|
|
EXPR_STRING,
|
2011-09-12 12:31:58 +02:00
|
|
|
EXPR_SUB,
|
2011-09-14 12:59:49 +02:00
|
|
|
EXPR_XOR
|
2011-09-07 14:08:21 +02:00
|
|
|
} expression_type_t;
|
|
|
|
|
|
|
|
typedef struct _expression_t {
|
|
|
|
expression_type_t type;
|
|
|
|
struct _expression_t *next;
|
|
|
|
} expression_t;
|
|
|
|
|
2011-09-08 14:56:36 +02:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
VARIANT_BOOL value;
|
|
|
|
} bool_expression_t;
|
|
|
|
|
2011-09-12 12:29:59 +02:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
LONG value;
|
|
|
|
} int_expression_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
double value;
|
|
|
|
} double_expression_t;
|
|
|
|
|
2011-09-08 14:56:58 +02:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
const WCHAR *value;
|
|
|
|
} string_expression_t;
|
|
|
|
|
2011-09-09 14:47:32 +02:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
expression_t *subexpr;
|
|
|
|
} unary_expression_t;
|
|
|
|
|
2011-09-09 14:48:13 +02:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
expression_t *left;
|
|
|
|
expression_t *right;
|
|
|
|
} binary_expression_t;
|
|
|
|
|
2011-09-07 14:08:21 +02:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
expression_t *obj_expr;
|
|
|
|
const WCHAR *identifier;
|
|
|
|
} member_expression_t;
|
|
|
|
|
2019-10-28 18:39:49 +01:00
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
expression_t *call_expr;
|
|
|
|
expression_t *args;
|
|
|
|
} call_expression_t;
|
|
|
|
|
2011-09-07 14:08:21 +02:00
|
|
|
typedef enum {
|
2011-09-12 12:32:38 +02:00
|
|
|
STAT_ASSIGN,
|
2011-09-13 11:36:26 +02:00
|
|
|
STAT_CALL,
|
2011-09-21 14:03:18 +02:00
|
|
|
STAT_CONST,
|
2011-09-14 12:54:50 +02:00
|
|
|
STAT_DIM,
|
2011-09-16 13:30:39 +02:00
|
|
|
STAT_DOUNTIL,
|
|
|
|
STAT_DOWHILE,
|
2011-09-16 13:30:20 +02:00
|
|
|
STAT_EXITDO,
|
2011-09-22 14:24:44 +02:00
|
|
|
STAT_EXITFOR,
|
2011-09-14 12:58:10 +02:00
|
|
|
STAT_EXITFUNC,
|
2011-09-16 13:28:29 +02:00
|
|
|
STAT_EXITPROP,
|
2011-09-14 12:57:27 +02:00
|
|
|
STAT_EXITSUB,
|
2012-01-04 11:50:29 +01:00
|
|
|
STAT_FOREACH,
|
2011-09-22 14:22:40 +02:00
|
|
|
STAT_FORTO,
|
2011-09-14 12:54:50 +02:00
|
|
|
STAT_FUNC,
|
2011-09-15 14:17:38 +02:00
|
|
|
STAT_IF,
|
2011-09-19 14:10:19 +02:00
|
|
|
STAT_ONERROR,
|
2019-11-01 17:50:57 +01:00
|
|
|
STAT_REDIM,
|
2012-07-20 16:28:32 +02:00
|
|
|
STAT_SELECT,
|
2011-09-15 14:22:27 +02:00
|
|
|
STAT_SET,
|
2011-09-16 13:29:59 +02:00
|
|
|
STAT_STOP,
|
2011-09-16 13:30:31 +02:00
|
|
|
STAT_UNTIL,
|
2011-09-16 13:30:09 +02:00
|
|
|
STAT_WHILE,
|
2019-09-17 14:54:31 +02:00
|
|
|
STAT_WHILELOOP,
|
2019-10-29 19:01:14 +01:00
|
|
|
STAT_WITH,
|
2019-09-17 14:54:31 +02:00
|
|
|
STAT_RETVAL
|
2011-09-07 14:08:21 +02:00
|
|
|
} statement_type_t;
|
|
|
|
|
|
|
|
typedef struct _statement_t {
|
|
|
|
statement_type_t type;
|
2020-01-22 23:27:14 +01:00
|
|
|
unsigned loc;
|
2011-09-07 14:08:21 +02:00
|
|
|
struct _statement_t *next;
|
|
|
|
} statement_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
2019-10-28 18:39:49 +01:00
|
|
|
call_expression_t *expr;
|
2011-09-07 14:08:21 +02:00
|
|
|
} call_statement_t;
|
|
|
|
|
2011-09-12 12:32:38 +02:00
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
2020-01-30 17:25:59 +01:00
|
|
|
expression_t *left_expr;
|
2011-09-12 12:32:38 +02:00
|
|
|
expression_t *value_expr;
|
|
|
|
} assign_statement_t;
|
|
|
|
|
2013-11-13 16:28:55 +01:00
|
|
|
typedef struct _dim_list_t {
|
|
|
|
unsigned val;
|
|
|
|
struct _dim_list_t *next;
|
|
|
|
} dim_list_t;
|
|
|
|
|
2011-09-13 11:36:26 +02:00
|
|
|
typedef struct _dim_decl_t {
|
|
|
|
const WCHAR *name;
|
2013-11-13 16:28:55 +01:00
|
|
|
BOOL is_array;
|
2014-03-07 14:27:12 +01:00
|
|
|
BOOL is_public; /* Used only for class members. */
|
2013-11-13 16:28:55 +01:00
|
|
|
dim_list_t *dims;
|
2011-09-13 11:36:26 +02:00
|
|
|
struct _dim_decl_t *next;
|
|
|
|
} dim_decl_t;
|
|
|
|
|
|
|
|
typedef struct _dim_statement_t {
|
|
|
|
statement_t stat;
|
|
|
|
dim_decl_t *dim_decls;
|
|
|
|
} dim_statement_t;
|
|
|
|
|
2019-11-01 17:50:57 +01:00
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
const WCHAR *identifier;
|
|
|
|
BOOL preserve;
|
|
|
|
expression_t *dims;
|
|
|
|
} redim_statement_t;
|
|
|
|
|
2011-09-14 12:54:50 +02: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;
|
2011-09-15 14:20:05 +02:00
|
|
|
BOOL is_public;
|
2020-10-13 18:58:06 +02:00
|
|
|
BOOL is_default;
|
2011-09-14 12:54:50 +02:00
|
|
|
arg_decl_t *args;
|
|
|
|
statement_t *body;
|
|
|
|
struct _function_decl_t *next;
|
2011-09-16 13:28:00 +02:00
|
|
|
struct _function_decl_t *next_prop_func;
|
2011-09-14 12:54:50 +02:00
|
|
|
} function_decl_t;
|
|
|
|
|
2011-09-16 13:27:11 +02:00
|
|
|
typedef struct {
|
2011-09-14 12:54:50 +02:00
|
|
|
statement_t stat;
|
|
|
|
function_decl_t *func_decl;
|
|
|
|
} function_statement_t;
|
|
|
|
|
2011-09-15 14:16:47 +02:00
|
|
|
typedef struct _class_decl_t {
|
|
|
|
const WCHAR *name;
|
2011-09-15 19:04:43 +02:00
|
|
|
function_decl_t *funcs;
|
2014-03-07 14:27:12 +01:00
|
|
|
dim_decl_t *props;
|
2011-09-15 14:16:47 +02:00
|
|
|
struct _class_decl_t *next;
|
|
|
|
} class_decl_t;
|
|
|
|
|
2011-09-13 11:38:04 +02:00
|
|
|
typedef struct _elseif_decl_t {
|
|
|
|
expression_t *expr;
|
|
|
|
statement_t *stat;
|
2020-01-22 23:27:14 +01:00
|
|
|
unsigned loc;
|
2011-09-13 11:38:04 +02:00
|
|
|
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-16 13:29:59 +02:00
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
expression_t *expr;
|
|
|
|
statement_t *body;
|
|
|
|
} while_statement_t;
|
|
|
|
|
2011-09-22 14:22:40 +02:00
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
const WCHAR *identifier;
|
|
|
|
expression_t *from_expr;
|
|
|
|
expression_t *to_expr;
|
|
|
|
expression_t *step_expr;
|
|
|
|
statement_t *body;
|
|
|
|
} forto_statement_t;
|
|
|
|
|
2012-01-04 11:50:29 +01:00
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
const WCHAR *identifier;
|
|
|
|
expression_t *group_expr;
|
|
|
|
statement_t *body;
|
|
|
|
} foreach_statement_t;
|
|
|
|
|
2011-09-19 14:10:19 +02:00
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
BOOL resume_next;
|
|
|
|
} onerror_statement_t;
|
|
|
|
|
2011-09-21 14:03:18 +02:00
|
|
|
typedef struct _const_decl_t {
|
|
|
|
const WCHAR *name;
|
|
|
|
expression_t *value_expr;
|
|
|
|
struct _const_decl_t *next;
|
|
|
|
} const_decl_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
const_decl_t *decls;
|
|
|
|
} const_statement_t;
|
|
|
|
|
2012-07-20 16:28:32 +02:00
|
|
|
typedef struct _case_clausule_t {
|
|
|
|
expression_t *expr;
|
|
|
|
statement_t *stat;
|
|
|
|
struct _case_clausule_t *next;
|
|
|
|
} case_clausule_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
expression_t *expr;
|
|
|
|
case_clausule_t *case_clausules;
|
|
|
|
} select_statement_t;
|
|
|
|
|
2019-10-29 19:01:14 +01:00
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
expression_t *expr;
|
|
|
|
statement_t *body;
|
|
|
|
} with_statement_t;
|
|
|
|
|
2019-09-17 14:54:31 +02:00
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
expression_t *expr;
|
|
|
|
} retval_statement_t;
|
|
|
|
|
2011-09-06 15:18:40 +02:00
|
|
|
typedef struct {
|
|
|
|
const WCHAR *code;
|
|
|
|
const WCHAR *ptr;
|
|
|
|
const WCHAR *end;
|
|
|
|
|
2011-09-09 14:47:00 +02:00
|
|
|
BOOL option_explicit;
|
2012-10-18 11:49:17 +02:00
|
|
|
BOOL is_html;
|
2011-09-06 15:18:40 +02:00
|
|
|
HRESULT hres;
|
2020-01-22 23:27:54 +01:00
|
|
|
int error_loc;
|
2011-09-06 15:18:55 +02:00
|
|
|
|
|
|
|
int last_token;
|
|
|
|
unsigned last_nl;
|
2011-09-07 14:08:21 +02:00
|
|
|
|
|
|
|
statement_t *stats;
|
|
|
|
statement_t *stats_tail;
|
2011-09-15 14:16:47 +02:00
|
|
|
class_decl_t *class_decls;
|
2011-09-12 12:29:31 +02:00
|
|
|
|
2013-02-15 15:11:13 +01:00
|
|
|
heap_pool_t heap;
|
2011-09-06 15:18:40 +02:00
|
|
|
} parser_ctx_t;
|
|
|
|
|
2019-09-17 14:54:31 +02:00
|
|
|
HRESULT parse_script(parser_ctx_t*,const WCHAR*,const WCHAR*,DWORD) DECLSPEC_HIDDEN;
|
2011-09-12 12:29:31 +02:00
|
|
|
void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
|
2020-01-22 23:27:14 +01:00
|
|
|
int parser_lex(void*,unsigned*,parser_ctx_t*) DECLSPEC_HIDDEN;
|
2011-09-07 14:08:07 +02:00
|
|
|
void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;
|