Browse Source

Fix: fail to parse empty elseif/else blocks

AnnulusGames 11 months ago
parent
commit
4a103a90e5
1 changed files with 6 additions and 8 deletions
  1. 6 8
      src/Lua/CodeAnalysis/Syntax/Parser.cs

+ 6 - 8
src/Lua/CodeAnalysis/Syntax/Parser.cs

@@ -309,22 +309,20 @@ public ref struct Parser
                     MoveNextWithValidation(ref enumerator);
                     enumerator.SkipEoL();
 
-                    // skip 'then' keyword
-                    CheckCurrentAndSkip(ref enumerator, SyntaxTokenType.Then, out _);
-                    enumerator.SkipEoL();
+                    // check 'then' keyword
+                    CheckCurrent(ref enumerator, SyntaxTokenType.Then);
 
                     // set elseif state
                     state = 1;
+
+                    continue;
                 }
                 else if (tokenType is SyntaxTokenType.Else)
                 {
-                    // skip 'else' keywords
-                    MoveNextWithValidation(ref enumerator);
-
-                    enumerator.SkipEoL();
-
                     // set else state
                     state = 2;
+
+                    continue;
                 }
                 else if (tokenType is SyntaxTokenType.End)
                 {