Parser: Allow more complex expressions as for loop variables.
Also, use LValue in ForStatement.
--
MOS_MIGRATED_REVID=89122760
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java b/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
index 9698474..07501da 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
@@ -844,50 +844,28 @@
}
@Test
- public void testForLoopMultipleVariablesFail() throws Exception {
- // For loops with multiple variables are not allowed, when parsePython is not set
- syntaxEvents.setFailFast(false);
- List<Statement> stmts = parseFile(
- "[ i for i, j, k in [(1, 2, 3)] ]\n",
- false /* no parsePython */);
- assertThat(stmts).hasSize(1);
- syntaxEvents.assertContainsEvent("For loops with multiple variables are not yet supported");
- }
-
- @Test
public void testForLoopMultipleVariables() throws Exception {
- // For loops with multiple variables is ok, when parsePython is set
- List<Statement> stmts1 = parseFile(
- "[ i for i, j, k in [(1, 2, 3)] ]\n",
- true /* parsePython */);
+ List<Statement> stmts1 = parseFile("[ i for i, j, k in [(1, 2, 3)] ]\n");
assertThat(stmts1).hasSize(1);
- List<Statement> stmts2 = parseFile(
- "[ i for i, j in [(1, 2, 3)] ]\n",
- true /* parsePython */);
+ List<Statement> stmts2 = parseFile("[ i for i, j in [(1, 2, 3)] ]\n");
assertThat(stmts2).hasSize(1);
- List<Statement> stmts3 = parseFile(
- "[ i for (i, j, k) in [(1, 2, 3)] ]\n",
- true /* parsePython */);
+ List<Statement> stmts3 = parseFile("[ i for (i, j, k) in [(1, 2, 3)] ]\n");
assertThat(stmts3).hasSize(1);
}
@Test
public void testForLoopBadSyntax() throws Exception {
syntaxEvents.setFailFast(false);
- parseFile(
- "[1 for (a, b, c in var]\n",
- false /* no parsePython */);
+ parseFile("[1 for (a, b, c in var]\n");
syntaxEvents.assertContainsEvent("syntax error");
}
@Test
public void testForLoopBadSyntax2() throws Exception {
syntaxEvents.setFailFast(false);
- parseFile(
- "[1 for () in var]\n",
- false /* no parsePython */);
+ parseFile("[1 for in var]\n");
syntaxEvents.assertContainsEvent("syntax error");
}