mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user