Closed sliekens closed 9 years ago
Being able to backtrack within a text source is an important requirement for most parsing algorithms.
Backtracking is currently implemented like this:
Stream.Seek(offset, SeekOrigin.Current)
PushbackInputStream
Right now, the TextScanner class implements both behaviors using a complex soup of if..else blocks to determine which of the two strategies to use.
TextScanner
if..else
Instead, I want to split the TextScanner class into two classes, where each class implements one of the two backtracking strategies:
BufferedTextScanner
Being able to backtrack within a text source is an important requirement for most parsing algorithms.
Backtracking is currently implemented like this:
Stream.Seek(offset, SeekOrigin.Current)
for any stream that support seekingPushbackInputStream
class for streams that do not support seekingPushbackInputStream
class uses internal byte buffers to store pushed-back bytesRight now, the
TextScanner
class implements both behaviors using a complex soup ofif..else
blocks to determine which of the two strategies to use.Instead, I want to split the
TextScanner
class into two classes, where each class implements one of the two backtracking strategies:TextScanner
will implement the seeking strategyBufferedTextScanner
will implement the pushback strategy