Patch from Mike: errors from the LSL/C# compilers are now reported to the user in-world
parent
38da8960e9
commit
d41c1f40a8
|
@ -43,7 +43,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
|||
/// <param name="script">String containing LSL source.</param>
|
||||
public CSCodeGenerator(string script)
|
||||
{
|
||||
Parser p = new LSLSyntax();
|
||||
Parser p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true));
|
||||
// Obviously this needs to be in a try/except block.
|
||||
LSL2CSCodeTransformer codeTransformer = new LSL2CSCodeTransformer(p.Parse(script));
|
||||
m_astRoot = codeTransformer.Transform();
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
/// <param name="script">String containing LSL source.</param>
|
||||
public CSCodeGenerator(string script)
|
||||
{
|
||||
Parser p = new LSLSyntax();
|
||||
Parser p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true));
|
||||
// Obviously this needs to be in a try/except block.
|
||||
LSL2CSCodeTransformer codeTransformer = new LSL2CSCodeTransformer(p.Parse(script));
|
||||
m_astRoot = codeTransformer.Transform();
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using NUnit.Framework;
|
||||
using OpenSim.Region.ScriptEngine.Shared.CodeTools;
|
||||
|
||||
|
@ -1299,5 +1300,35 @@ default
|
|||
string output = cg.Generate();
|
||||
Assert.AreEqual(expected, output);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException("Tools.CSToolsException")]
|
||||
public void TestSyntaxError()
|
||||
{
|
||||
string input = @"default
|
||||
{
|
||||
state_entry()
|
||||
{
|
||||
integer y
|
||||
}
|
||||
}
|
||||
";
|
||||
try
|
||||
{
|
||||
CSCodeGenerator cg = new CSCodeGenerator(input);
|
||||
string output = cg.Generate();
|
||||
}
|
||||
catch (Tools.CSToolsException e)
|
||||
{
|
||||
// The syntax error is on line 6, char 5 (expected ';', found
|
||||
// '}').
|
||||
Regex r = new Regex("Line ([0-9]+), char ([0-9]+)");
|
||||
Match m = r.Match(e.Message);
|
||||
Assert.AreEqual("6", m.Groups[1].Value);
|
||||
Assert.AreEqual("5", m.Groups[2].Value);
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue