diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs
index ec34a7b95e..f7aee6611c 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
/// String containing LSL source.
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();
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
index 78c636e395..82c7edaaf5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
/// String containing LSL source.
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();
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSLCompilerTest.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSLCompilerTest.cs
index 6e42c16b36..56a5b4c996 100644
--- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSLCompilerTest.cs
+++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSLCompilerTest.cs
@@ -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;
+ }
+ }
}
}