Browse Source

Fixes issue #117 - long empty comments not lexed correctly.

Xanathar 10 years ago
parent
commit
c193d3dc4c

+ 8 - 0
src/MoonSharp.Interpreter.Tests/EndToEnd/SimpleTests.cs

@@ -10,6 +10,14 @@ namespace MoonSharp.Interpreter.Tests
 	[TestFixture]
 	[TestFixture]
 	public class SimpleTests
 	public class SimpleTests
 	{
 	{
+		[Test]
+		public void EmptyLongComment()
+		{
+			Script S = new Script(CoreModules.None);
+			DynValue res = S.DoString("--[[]]");
+		}
+
+
 		[Test]
 		[Test]
 		public void EmptyChunk()
 		public void EmptyChunk()
 		{
 		{

+ 1 - 1
src/MoonSharp.Interpreter/Tree/Lexer/Lexer.cs

@@ -436,7 +436,7 @@ namespace MoonSharp.Interpreter.Tree
 				if (c == '[' && !extraneousFound && text.Length > 0)
 				if (c == '[' && !extraneousFound && text.Length > 0)
 				{
 				{
 					text.Append('[');
 					text.Append('[');
-					CursorCharNext();
+					//CursorCharNext();
 					string comment = ReadLongString(fromLine, fromCol, text.ToString(), "comment");
 					string comment = ReadLongString(fromLine, fromCol, text.ToString(), "comment");
 					return CreateToken(TokenType.Comment, fromLine, fromCol, comment);
 					return CreateToken(TokenType.Comment, fromLine, fromCol, comment);
 				}
 				}