[PATCH v2] vbscript: Improve parsing of separators in loops and switches.
Dmitry Kislyuk
dimaki at rocketmail.com
Fri Oct 6 16:27:44 CDT 2017
v2. Per Jacek's suggestion, changed stSep itself to accept multiple separators
and added more tests instead of changing some existing ones.
Signed-off-by: Dmitry Kislyuk <dimaki at rocketmail.com>
---
dlls/vbscript/parser.y | 6 ++++--
dlls/vbscript/tests/lang.vbs | 50 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y
index 6b303eea35..beb4e4c7d0 100644
--- a/dlls/vbscript/parser.y
+++ b/dlls/vbscript/parser.y
@@ -164,7 +164,7 @@ StatementsNl
| StatementNl StatementsNl { $$ = link_statements($1, $2); }
StatementNl
- : Statement tNL { $$ = $1; }
+ : Statement tNL { $$ = $1; }
Statement
: ':' { $$ = NULL; }
@@ -448,10 +448,12 @@ Identifier
: tIdentifier { $$ = $1; }
| tPROPERTY { $$ = propertyW; }
-/* Some statements accept both new line and ':' as a separator */
+/* Most statements accept both new line and ':' as separators */
StSep
: tNL
| ':'
+ | tNL StSep
+ | ':' StSep
%%
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index 23402cd893..7f7c835631 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -330,6 +330,13 @@ WHILE x < 3 : x = x + 1
Wend
Call ok(x = 3, "x not equal to 3")
+z = 2
+while z > -4 :
+
+
+z = z -2
+wend
+
x = false
y = false
do while not (x and y)
@@ -353,6 +360,12 @@ Do While x < 2 : x = x + 1
Loop
Call ok(x = 2, "x not equal to 2")
+x = 0
+Do While x >= -2 :
+x = x - 1
+Loop
+Call ok(x = -3, "x not equal to -3")
+
x = false
y = false
do until x and y
@@ -376,6 +389,14 @@ Do: :: x = x + 2
Loop Until x = 4
Call ok(x = 4, "x not equal to 4")
+x = 5
+Do: :
+
+: x = x * 2
+Loop Until x = 40
+Call ok(x = 40, "x not equal to 40")
+
+
x = false
do
if x then exit do
@@ -495,6 +516,12 @@ for x = 1 to 100
Call ok(false, "exit for not escaped the loop?")
next
+for x = 1 to 5 :
+:
+: :exit for
+ Call ok(false, "exit for not escaped the loop?")
+next
+
do while true
for x = 1 to 100
exit do
@@ -507,6 +534,14 @@ while null
call ok(false, "while null evaluated")
wend
+Call collectionObj.reset()
+y = 0
+for each x in collectionObj :
+
+ :y = y + 3
+next
+Call ok(y = 9, "y = " & y)
+
Call collectionObj.reset()
y = 0
x = 10
@@ -611,6 +646,21 @@ select case 2: case 5,6,7: Call ok(false, "unexpected case")
end select
Call ok(x, "wrong case")
+x = False
+select case 1 :
+
+ :case 3, 4 :
+
+
+ case 5
+:
+ Call ok(false, "unexpected case") :
+ Case Else:
+
+ x = True
+end select
+Call ok(x, "wrong case")
+
if false then
Sub testsub
x = true
--
2.14.1
More information about the wine-patches
mailing list