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

@@ -92,10 +92,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
for (int i = 0; i < s.kids.Count; i++)
{
if (!(s is Assignment || s is ArgumentDeclarationList) && s.kids[i] is Declaration)
AddImplicitInitialization(s, i);
// It's possible that a child is null, for instance when the
// assignment part in a for-loop is left out, ie:
//
// for ( ; i < 10; i++)
// {
// ...
// }
//
// We need to check for that here.
if (null != s.kids[i])
{
if (!(s is Assignment || s is ArgumentDeclarationList) && s.kids[i] is Declaration)
AddImplicitInitialization(s, i);
TransformNode((SYMBOL) s.kids[i]);
TransformNode((SYMBOL) s.kids[i]);
}
}
}