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.
This commit is contained in:
Mike Mazur
2009-06-07 10:22:55 +00:00
parent 48bc2f3a42
commit cda6b24668
2 changed files with 65 additions and 3 deletions

View File

@@ -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);