Allow empty assignment in for-loop

For loops with no assignment are no longer syntax errors. For example,
this is now valid:

    for ( ; i < 10; i++) { ... }

Corresponding changes to lsl.{lexer,parser} in r99 in opensim-libs.

Fixes Mantis #2501. Fixes Mantis #2884.
This commit is contained in:
Mike Mazur
2009-06-07 10:22:41 +00:00
parent a3c91de17d
commit 48bc2f3a42
5 changed files with 7976 additions and 7756 deletions

View File

@@ -1515,6 +1515,31 @@ default
Assert.AreEqual(expected, output);
}
[Test]
public void TestForLoopWithNoAssignment()
{
string input = @"default
{
state_entry()
{
integer x = 4;
for (; 1<0; x += 2);
}
}";
string expected =
"\n public void default_event_state_entry()" +
"\n {" +
"\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(4);" +
"\n for (; new LSL_Types.LSLInteger(1) < new LSL_Types.LSLInteger(0); x += new LSL_Types.LSLInteger(2))" +
"\n ;" +
"\n }\n";
CSCodeGenerator cg = new CSCodeGenerator();
string output = cg.Convert(input);
Assert.AreEqual(expected, output);
}
[Test]
public void TestAssignmentInIfWhileDoWhile()
{