Commit a921bd2e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added support for |f a, b, c| call statement.

parent 908834fe
......@@ -240,12 +240,17 @@ static int parse_string_literal(parser_ctx_t *ctx, const WCHAR **ret)
return tString;
}
static void skip_spaces(parser_ctx_t *ctx)
{
while(*ctx->ptr == ' ' || *ctx->ptr == '\t' || *ctx->ptr == '\r')
ctx->ptr++;
}
static int parse_next_token(void *lval, parser_ctx_t *ctx)
{
WCHAR c;
while(*ctx->ptr == ' ' || *ctx->ptr == '\t' || *ctx->ptr == '\r')
ctx->ptr++;
skip_spaces(ctx);
if(ctx->ptr == ctx->end)
return ctx->last_token == tNL ? tEOF : tNL;
......@@ -269,7 +274,6 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx)
else
ctx->ptr = ctx->end;
return tNL;
case '(':
case ')':
case ',':
case '=':
......@@ -281,6 +285,18 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx)
case '\\':
case '.':
return *ctx->ptr++;
case '(':
/* NOTE:
* We resolve empty brackets in lexer instead of parser to avoid complex conflicts
* in call statement special case |f()| without 'call' keyword
*/
ctx->ptr++;
skip_spaces(ctx);
if(*ctx->ptr == ')') {
ctx->ptr++;
return tEMPTYBRACKETS;
}
return '(';
case '"':
return parse_string_literal(ctx, lval);
default:
......
......@@ -56,7 +56,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
member_expression_t *member;
}
%token tEOF tNL tREM
%token tEOF tNL tREM tEMPTYBRACKETS
%token tTRUE tFALSE
%token tNOT tAND tOR tXOR tEQV tIMP tNEQ
%token tIS tLTEQ tGTEQ tMOD
......@@ -89,7 +89,7 @@ StatementNl
: Statement tNL { $$ = $1; }
Statement
: MemberExpression Arguments_opt { $1->args = $2; $$ = new_call_statement(ctx, $1); CHECK_ERROR; }
: MemberExpression ArgumentList_opt { $1->args = $2; $$ = new_call_statement(ctx, $1); CHECK_ERROR; }
| tCALL MemberExpression Arguments_opt { $2->args = $3; $$ = new_call_statement(ctx, $2); CHECK_ERROR; }
MemberExpression
......@@ -97,17 +97,21 @@ MemberExpression
/* FIXME: MemberExpressionArgs '.' tIdentifier */
Arguments_opt
: /* empty */ { $$ = NULL; }
| '(' ArgumentList_opt ')' { $$ = $2; }
: EmptyBrackets_opt { $$ = NULL; }
| '(' ArgumentList ')' { $$ = $2; }
ArgumentList_opt
: /* empty */ { $$ = NULL; }
: EmptyBrackets_opt { $$ = NULL; }
| ArgumentList { $$ = $1; }
ArgumentList
: Expression { $$ = $1; }
| Expression ',' ArgumentList { $1->next = $3; $$ = $1; }
EmptyBrackets_opt
: /* empty */
| tEMPTYBRACKETS
Expression
: LiteralExpression /* FIXME */ { $$ = $1; }
......
......@@ -17,5 +17,6 @@
'
call ok(true, "true is not true?")
ok true, "true is not true?"
reportSuccess()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment