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

vbscript: Added support for negative constants.

parent 378e86fa
......@@ -125,6 +125,7 @@ static const WCHAR propertyW[] = {'p','r','o','p','e','r','t','y',0};
%type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression
%type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression
%type <expression> NotExpression UnaryExpression AndExpression OrExpression XorExpression EqvExpression
%type <expression> ConstExpression NumericLiteralExpression
%type <member> MemberExpression
%type <expression> Arguments_opt ArgumentList_opt Step_opt ExpressionList
%type <bool> OptionExplicit_opt DoType
......@@ -218,7 +219,11 @@ ConstDeclList
| ConstDecl ',' ConstDeclList { $1->next = $3; $$ = $1; }
ConstDecl
: Identifier '=' LiteralExpression { $$ = new_const_decl(ctx, $1, $3); CHECK_ERROR; }
: Identifier '=' ConstExpression { $$ = new_const_decl(ctx, $1, $3); CHECK_ERROR; }
ConstExpression
: LiteralExpression { $$ = $1; }
| '-' NumericLiteralExpression { $$ = new_unary_expression(ctx, EXPR_NEG, $2); CHECK_ERROR; }
DoType
: tWHILE { $$ = TRUE; }
......@@ -354,14 +359,18 @@ LiteralExpression
: tTRUE { $$ = new_bool_expression(ctx, VARIANT_TRUE); CHECK_ERROR; }
| tFALSE { $$ = new_bool_expression(ctx, VARIANT_FALSE); CHECK_ERROR; }
| tString { $$ = new_string_expression(ctx, $1); CHECK_ERROR; }
| tShort { $$ = new_long_expression(ctx, EXPR_USHORT, $1); CHECK_ERROR; }
| '0' { $$ = new_long_expression(ctx, EXPR_USHORT, 0); CHECK_ERROR; }
| tLong { $$ = new_long_expression(ctx, EXPR_ULONG, $1); CHECK_ERROR; }
| tDouble { $$ = new_double_expression(ctx, $1); CHECK_ERROR; }
| NumericLiteralExpression { $$ = $1; }
| tEMPTY { $$ = new_expression(ctx, EXPR_EMPTY, 0); CHECK_ERROR; }
| tNULL { $$ = new_expression(ctx, EXPR_NULL, 0); CHECK_ERROR; }
| tNOTHING { $$ = new_expression(ctx, EXPR_NOTHING, 0); CHECK_ERROR; }
NumericLiteralExpression
: tShort { $$ = new_long_expression(ctx, EXPR_USHORT, $1); CHECK_ERROR; }
| '0' { $$ = new_long_expression(ctx, EXPR_USHORT, 0); CHECK_ERROR; }
| tLong { $$ = new_long_expression(ctx, EXPR_ULONG, $1); CHECK_ERROR; }
| tDouble { $$ = new_double_expression(ctx, $1); CHECK_ERROR; }
PrimaryExpression
: '(' Expression ')' { $$ = new_unary_expression(ctx, EXPR_BRACKETS, $2); }
| tME { $$ = new_expression(ctx, EXPR_ME, 0); CHECK_ERROR; }
......
......@@ -912,9 +912,19 @@ Call obj.test(obj)
Call ok(getVT(test) = "VT_DISPATCH", "getVT(test) = " & getVT(test))
Call ok(Me is Test, "Me is not Test")
Const c1 = 1, c2 = 2
Const c1 = 1, c2 = 2, c3 = -3
Call ok(c1 = 1, "c1 = " & c1)
Call ok(getVT(c1) = "VT_I2", "getVT(c1) = " & getVT(c1))
Call ok(c3 = -3, "c3 = " & c3)
Call ok(getVT(c3) = "VT_I2", "getVT(c3) = " & getVT(c3))
Const cb = True, cs = "test", cnull = null
Call ok(cb, "cb = " & cb)
Call ok(getVT(cb) = "VT_BOOL", "getVT(cb) = " & getVT(cb))
Call ok(cs = "test", "cs = " & cs)
Call ok(getVT(cs) = "VT_BSTR", "getVT(cs) = " & getVT(cs))
Call ok(isNull(cnull), "cnull = " & cnull)
Call ok(getVT(cnull) = "VT_NULL", "getVT(cnull) = " & getVT(cnull))
if false then Const conststr = "str"
Call ok(conststr = "str", "conststr = " & conststr)
......
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