Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
6c557029
Commit
6c557029
authored
Sep 07, 2011
by
Jacek Caban
Committed by
Alexandre Julliard
Sep 07, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vbscript: Added function call statement parsing beginning implementation.
parent
91cc7bd7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
4 deletions
+131
-4
compile.c
dlls/vbscript/compile.c
+7
-2
parse.h
dlls/vbscript/parse.h
+33
-0
parser.y
dlls/vbscript/parser.y
+91
-2
No files found.
dlls/vbscript/compile.c
View file @
6c557029
...
...
@@ -53,13 +53,18 @@ static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op)
return
ctx
->
instr_cnt
++
;
}
static
HRESULT
compile_func
(
compile_ctx_t
*
ctx
,
function_t
*
func
)
static
HRESULT
compile_func
(
compile_ctx_t
*
ctx
,
statement_t
*
stat
,
function_t
*
func
)
{
func
->
code_off
=
ctx
->
instr_cnt
;
if
(
push_instr
(
ctx
,
OP_ret
)
==
-
1
)
return
E_OUTOFMEMORY
;
if
(
stat
)
{
FIXME
(
"statements compilation not implemented
\n
"
);
return
E_NOTIMPL
;
}
return
S_OK
;
}
...
...
@@ -113,7 +118,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret)
if
(
!
ctx
.
code
)
return
E_OUTOFMEMORY
;
hres
=
compile_func
(
&
ctx
,
&
ctx
.
code
->
global_code
);
hres
=
compile_func
(
&
ctx
,
ctx
.
parser
.
stats
,
&
ctx
.
code
->
global_code
);
if
(
FAILED
(
hres
))
{
release_vbscode
(
ctx
.
code
);
return
hres
;
...
...
dlls/vbscript/parse.h
View file @
6c557029
...
...
@@ -16,6 +16,36 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
typedef
enum
{
EXPR_MEMBER
}
expression_type_t
;
typedef
struct
_expression_t
{
expression_type_t
type
;
struct
_expression_t
*
next
;
}
expression_t
;
typedef
struct
{
expression_t
expr
;
expression_t
*
obj_expr
;
const
WCHAR
*
identifier
;
expression_t
*
args
;
}
member_expression_t
;
typedef
enum
{
STAT_CALL
}
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
;
typedef
struct
{
const
WCHAR
*
code
;
const
WCHAR
*
ptr
;
...
...
@@ -26,6 +56,9 @@ typedef struct {
int
last_token
;
unsigned
last_nl
;
statement_t
*
stats
;
statement_t
*
stats_tail
;
}
parser_ctx_t
;
HRESULT
parse_script
(
parser_ctx_t
*
,
const
WCHAR
*
)
DECLSPEC_HIDDEN
;
...
...
dlls/vbscript/parser.y
View file @
6c557029
...
...
@@ -33,6 +33,12 @@ static int parser_error(const char*);
static void parse_complete(parser_ctx_t*);
static void source_add_statement(parser_ctx_t*,statement_t*);
static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,const WCHAR*);
static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
%}
%pure_parser
...
...
@@ -40,14 +46,34 @@ static void parse_complete(parser_ctx_t*);
%union {
const WCHAR *string;
statement_t *statement;
member_expression_t *member;
}
%token tEOF tNL
%token tEOF tNL
blah
%token <string> tIdentifier
%type <statement> Statement StatementNl
%type <member> MemberExpression
%%
Program : tEOF { parse_complete(ctx); }
Program
: SourceElements tEOF { parse_complete(ctx); }
SourceElements
: /* empty */
| SourceElements StatementNl { source_add_statement(ctx, $2); }
StatementNl
: Statement tNL { $$ = $1; }
Statement
: MemberExpression /* FIXME: Arguments_opt */ { $$ = new_call_statement(ctx, $1); }
MemberExpression
: tIdentifier { $$ = new_member_expression(ctx, NULL, $1); }
/* FIXME: MemberExpressionArgs '.' tIdentifier */
%%
...
...
@@ -56,11 +82,73 @@ static int parser_error(const char *str)
return 0;
}
static void source_add_statement(parser_ctx_t *ctx, statement_t *stat)
{
if(ctx->stats) {
ctx->stats_tail->next = stat;
ctx->stats_tail = stat;
}else {
ctx->stats = ctx->stats_tail = stat;
}
}
static void parse_complete(parser_ctx_t *ctx)
{
ctx->parse_complete = TRUE;
}
static void *new_expression(parser_ctx_t *ctx, expression_type_t type, unsigned size)
{
expression_t *expr;
expr = parser_alloc(ctx, size ? size : sizeof(*expr));
if(expr) {
expr->type = type;
expr->next = NULL;
}
return expr;
}
static member_expression_t *new_member_expression(parser_ctx_t *ctx, expression_t *obj_expr, const WCHAR *identifier)
{
member_expression_t *expr;
expr = new_expression(ctx, EXPR_MEMBER, sizeof(*expr));
if(!expr)
return NULL;
expr->obj_expr = obj_expr;
expr->identifier = identifier;
expr->args = NULL;
return expr;
}
static void *new_statement(parser_ctx_t *ctx, statement_type_t type, unsigned size)
{
statement_t *stat;
stat = parser_alloc(ctx, size);
if(stat) {
stat->type = type;
stat->next = NULL;
}
return stat;
}
static statement_t *new_call_statement(parser_ctx_t *ctx, member_expression_t *expr)
{
call_statement_t *stat;
stat = new_statement(ctx, STAT_CALL, sizeof(*stat));
if(!stat)
return NULL;
stat->expr = expr;
return &stat->stat;
}
void *parser_alloc(parser_ctx_t *ctx, size_t size)
{
void *ret;
...
...
@@ -82,6 +170,7 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code)
ctx->last_token = tNL;
ctx->last_nl = 0;
ctx->stats = ctx->stats_tail = NULL;
parser_parse(ctx);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment