diff --git a/src/GDShrapt.Reader.Tests/InvalidTokenTests.cs b/src/GDShrapt.Reader.Tests/InvalidTokenTests.cs
index 56c6c0b..0ac3b94 100644
--- a/src/GDShrapt.Reader.Tests/InvalidTokenTests.cs
+++ b/src/GDShrapt.Reader.Tests/InvalidTokenTests.cs
@@ -1,4 +1,5 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using FluentAssertions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
namespace GDShrapt.Reader.Tests
@@ -35,5 +36,25 @@ public void DoubleStaticTest()
Assert.AreEqual("static", declaration.AllInvalidTokens.First().Sequence);
AssertHelper.CompareCodeStrings(code, declaration.ToString());
}
+
+ [TestMethod]
+ public void InvalidClassNameTest()
+ {
+ var reader = new GDScriptReader();
+
+ var code = @"tool
+class_name 123H+=Ter^5r3_-ain-DataSaver
+extends ResourceFormatSaver
+";
+
+ var @class = reader.ParseFileContent(code);
+ Assert.IsNotNull(@class);
+
+ @class.AllInvalidTokens.Select(x => x.ToString()).Should().BeEquivalentTo(new string[]
+ {
+ "123",
+ "H+=Ter^5r3_-ain-DataSaver"
+ });
+ }
}
}
diff --git a/src/GDShrapt.Reader/GDReadingState.cs b/src/GDShrapt.Reader/GDReadingState.cs
index a96fd8e..ec47e34 100644
--- a/src/GDShrapt.Reader/GDReadingState.cs
+++ b/src/GDShrapt.Reader/GDReadingState.cs
@@ -12,8 +12,6 @@ internal class GDReadingState
{
public GDReadSettings Settings { get; }
- private readonly StackTrace _stackTrace;
-
///
/// Main reading stack
///
@@ -23,7 +21,6 @@ internal class GDReadingState
public GDReadingState(GDReadSettings settings)
{
Settings = settings;
- _stackTrace = new StackTrace(false);
}
///
@@ -121,7 +118,7 @@ public T Push(T reader)
if (Settings.MaxReadingStack.HasValue && _readersStack.Count == Settings.MaxReadingStack.Value)
throw new StackOverflowException("Maximum reading reading stack is reached.");
- if (Settings.MaxStacktraceFramesCount.HasValue && _stackTrace.FrameCount >= Settings.MaxStacktraceFramesCount.Value)
+ if (Settings.MaxStacktraceFramesCount.HasValue && new StackTrace(false).FrameCount >= Settings.MaxStacktraceFramesCount.Value)
throw new StackOverflowException("Maximum stackTrace frames count is reached.");
_readersStack.Push(reader);
diff --git a/src/GDShrapt.Reader/GDShrapt.Reader.csproj b/src/GDShrapt.Reader/GDShrapt.Reader.csproj
index 0aa7aae..5e8eac5 100644
--- a/src/GDShrapt.Reader/GDShrapt.Reader.csproj
+++ b/src/GDShrapt.Reader/GDShrapt.Reader.csproj
@@ -16,8 +16,8 @@ Usage: Just create a GDScriptReader instance and call methods from it.https://github.com/elamaunt/GDShrapt
git
GDShrapt GDScript reader parser codegeneration Godot lexical analyzer
- 4.0.0
- 4.0.0
+ 4.0.1
+ 4.0.1
true
diff --git a/src/GDShrapt.Reader/Resolvers/GDClassMembersResolver.cs b/src/GDShrapt.Reader/Resolvers/GDClassMembersResolver.cs
index 51ef36c..3d5eaf0 100644
--- a/src/GDShrapt.Reader/Resolvers/GDClassMembersResolver.cs
+++ b/src/GDShrapt.Reader/Resolvers/GDClassMembersResolver.cs
@@ -64,7 +64,7 @@ internal override void HandleCharAfterIntendation(char c, GDReadingState state)
else
{
SendIntendationTokensToOwner();
- Owner.HandleReceivedToken(state.Push(new GDInvalidToken(x => x != '@' || char.IsLetter(x) || x.IsSpace() || x.IsNewLine())));
+ Owner.HandleReceivedToken(state.Push(new GDInvalidToken(x => x == '@' || char.IsLetter(x) || x.IsSpace() || x.IsNewLine())));
}
state.PassChar(c);