From 48bc2f3a4299390538efeb1c0bd97424cfa1ea28 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Sun, 7 Jun 2009 10:22:41 +0000 Subject: 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. --- .../Shared/CodeTools/LSL2CSCodeTransformer.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs index 0dddede..cacb8be 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs @@ -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]); + } } } -- cgit v1.1