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

@@ -671,9 +671,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
retstr += GenerateIndented("for (", fl);
// It's possible that we don't have an assignment, in which case
// the child will be null and we only print the semicolon.
// for ( x = 0 ; x < 10 ; x++ )
// ^^^^^^^
retstr += GenerateForLoopStatement((ForLoopStatement) fl.kids.Pop());
ForLoopStatement s = (ForLoopStatement) fl.kids.Pop();
if (null != s)
{
retstr += GenerateForLoopStatement(s);
}
retstr += Generate("; ");
// for ( x = 0 ; x < 10 ; x++ )
// ^^^^^^^^