Skip to content

Commit 38a7f29

Browse files
committed
Fix: GetLookAHead
1 parent 0360832 commit 38a7f29

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

NeoLua/LuaLexer.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -681,14 +681,15 @@ public bool IsLookAHead(string value, int offset = 0)
681681
} // func LookAHead
682682

683683
/// <summary>Get look a head.</summary>
684-
/// <param name="offset"></param>
684+
/// <param name="idx"></param>
685685
/// <returns></returns>
686-
public char GetLookAHead(int offset = 0)
686+
public char GetLookAHead(int idx = 0)
687687
{
688-
if (offset > lookAheadBuffer.Length)
689-
throw new ArgumentOutOfRangeException(nameof(offset), lookAheadBuffer.Length, "Look a head buffer is to small.");
688+
if (idx > lookAheadBuffer.Length)
689+
throw new ArgumentOutOfRangeException(nameof(idx), lookAheadBuffer.Length, "Look a head buffer is to small.");
690690

691-
return lookAheadBuffer[offset];
691+
var i = (lookAheadOffset + idx) % lookAheadBuffer.Length;
692+
return lookAheadBuffer[i];
692693
}// func GetLookAHead
693694

694695
/// <summary></summary>

0 commit comments

Comments
 (0)