diff options
Diffstat (limited to '')
3 files changed, 33 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs index ec34a7b..f7aee66 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 | |||
43 | /// <param name="script">String containing LSL source.</param> | 43 | /// <param name="script">String containing LSL source.</param> |
44 | public CSCodeGenerator(string script) | 44 | public CSCodeGenerator(string script) |
45 | { | 45 | { |
46 | Parser p = new LSLSyntax(); | 46 | Parser p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true)); |
47 | // Obviously this needs to be in a try/except block. | 47 | // Obviously this needs to be in a try/except block. |
48 | LSL2CSCodeTransformer codeTransformer = new LSL2CSCodeTransformer(p.Parse(script)); | 48 | LSL2CSCodeTransformer codeTransformer = new LSL2CSCodeTransformer(p.Parse(script)); |
49 | m_astRoot = codeTransformer.Transform(); | 49 | m_astRoot = codeTransformer.Transform(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index 78c636e..82c7eda 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 | |||
43 | /// <param name="script">String containing LSL source.</param> | 43 | /// <param name="script">String containing LSL source.</param> |
44 | public CSCodeGenerator(string script) | 44 | public CSCodeGenerator(string script) |
45 | { | 45 | { |
46 | Parser p = new LSLSyntax(); | 46 | Parser p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true)); |
47 | // Obviously this needs to be in a try/except block. | 47 | // Obviously this needs to be in a try/except block. |
48 | LSL2CSCodeTransformer codeTransformer = new LSL2CSCodeTransformer(p.Parse(script)); | 48 | LSL2CSCodeTransformer codeTransformer = new LSL2CSCodeTransformer(p.Parse(script)); |
49 | m_astRoot = codeTransformer.Transform(); | 49 | 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 6e42c16..56a5b4c 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 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Text.RegularExpressions; | ||
29 | using NUnit.Framework; | 30 | using NUnit.Framework; |
30 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; | 31 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; |
31 | 32 | ||
@@ -1299,5 +1300,35 @@ default | |||
1299 | string output = cg.Generate(); | 1300 | string output = cg.Generate(); |
1300 | Assert.AreEqual(expected, output); | 1301 | Assert.AreEqual(expected, output); |
1301 | } | 1302 | } |
1303 | |||
1304 | [Test] | ||
1305 | [ExpectedException("Tools.CSToolsException")] | ||
1306 | public void TestSyntaxError() | ||
1307 | { | ||
1308 | string input = @"default | ||
1309 | { | ||
1310 | state_entry() | ||
1311 | { | ||
1312 | integer y | ||
1313 | } | ||
1314 | } | ||
1315 | "; | ||
1316 | try | ||
1317 | { | ||
1318 | CSCodeGenerator cg = new CSCodeGenerator(input); | ||
1319 | string output = cg.Generate(); | ||
1320 | } | ||
1321 | catch (Tools.CSToolsException e) | ||
1322 | { | ||
1323 | // The syntax error is on line 6, char 5 (expected ';', found | ||
1324 | // '}'). | ||
1325 | Regex r = new Regex("Line ([0-9]+), char ([0-9]+)"); | ||
1326 | Match m = r.Match(e.Message); | ||
1327 | Assert.AreEqual("6", m.Groups[1].Value); | ||
1328 | Assert.AreEqual("5", m.Groups[2].Value); | ||
1329 | |||
1330 | throw; | ||
1331 | } | ||
1332 | } | ||
1302 | } | 1333 | } |
1303 | } | 1334 | } |