mirror of
https://github.com/opensim/opensim.git
synced 2026-08-02 23:18:34 +08:00
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:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user