From cda6b2466868cc74367da1b17d676f7168b84f6d Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Sun, 7 Jun 2009 10:22:55 +0000 Subject: Skip lone ident statments or for-loop assignments SL's LSL supports lone idents: integer x; x; as well as lone idents in for-loop assignments: for (x; x < 10; x++) { ... } while those are errors in C# (MONO at least). This patch skips lone idents in such places. Fixes Mantis #3042. --- .../ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index ab9968f..91747af 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs @@ -90,7 +90,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools m_warnings.Clear(); ResetCounters(); Parser p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true)); - // Obviously this needs to be in a try/except block. + LSL2CSCodeTransformer codeTransformer; try { @@ -446,8 +446,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools // Jump label prints its own colon, we don't need a semicolon. printSemicolon = !(s.kids.Top is JumpLabel); - foreach (SYMBOL kid in s.kids) - retstr += GenerateNode(kid); + // If we encounter a lone Ident, we skip it, since that's a C# + // (MONO) error. + if (!(s.kids.Top is IdentExpression && 1 == s.kids.Count)) + foreach (SYMBOL kid in s.kids) + retstr += GenerateNode(kid); } if (printSemicolon) @@ -711,6 +714,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools int comma = fls.kids.Count - 1; // tells us whether to print a comma + // It's possible that all we have is an empty Ident, for example: + // + // for (x; x < 10; x++) { ... } + // + // Which is illegal in C# (MONO). We'll skip it. + if (fls.kids.Top is IdentExpression && 1 == fls.kids.Count) + return retstr; + foreach (SYMBOL s in fls.kids) { retstr += GenerateNode(s); -- cgit v1.1