@@ -40,8 +40,8 @@ public class LuaTableTextReader : IDisposable
4040 private readonly List < LuaContainerContext > contextStack ;
4141 private LuaContainerContext currentContext ;
4242 private readonly char [ ] buffer ;
43- private int bufferLength ;
44- private int bufferPos ;
43+ private int bufferLength ; // Loaded buffer end position
44+ private int bufferPos ; // Start of next buffer character
4545 private bool readerEof ;
4646
4747 private static readonly object boxedTrue = true ;
@@ -98,6 +98,7 @@ private enum Token
9898 private void GotoNextState ( Token token )
9999 {
100100 var next = NextStateTable [ ( int ) currentState ] [ ( int ) token ] ;
101+ Debug . WriteLine ( "GotoNextState: {0}[{1}] -> {2}" , currentState , token , next ) ;
101102 if ( next == State . Error )
102103 {
103104 if ( currentState == State . End )
@@ -230,6 +231,7 @@ private bool EnsureBuffer(int length = 0)
230231 bufferLength = bufferLength - bufferPos ;
231232 bufferPos = 0 ;
232233 }
234+ // Read from where the current loaded buffer ends.
233235 var charsRead = Reader . ReadBlock ( buffer , bufferLength , charsNeeded ) ;
234236 bufferLength += charsRead ;
235237 if ( charsRead < charsNeeded )
@@ -438,6 +440,7 @@ public LuaTableReaderToken Read()
438440 if ( ( o = ReadLiteral ( ) ) != null )
439441 {
440442 GotoNextState ( Token . Literal ) ;
443+ Debug . WriteLine ( "Literal: {0}" , o ) ;
441444 if ( currentState == State . Key )
442445 {
443446 currentContext . BoxedKey = o ;
@@ -456,6 +459,7 @@ public LuaTableReaderToken Read()
456459 GotoNextState ( Token . KeyStart ) ;
457460 GotoNextState ( Token . Literal ) ;
458461 GotoNextState ( Token . KeyEnd ) ;
462+ Debug . WriteLine ( "Identifier: {0}" , o ) ;
459463 CurrentValue = o ;
460464 // We keep using BoxedKey instead of Key in Reader.
461465 currentContext . BoxedKey = ( string ) o ;
0 commit comments