typped.text_stream

The TextStream class. Not currently used, may become an abstraction layer for the stream of text to be parsed.

class typped.text_stream.TextStream[source]

Bases: object

This is just a unified wrapper for a stream of text characters which may come from various sources.

clear()[source]

Clear and reset the text stream.

set_string_in(str_val)[source]

Set a string to be the text source.

set_file_in(f_name)[source]

Set a file to be the text source.

set_raw_in()[source]

Read input interactively for text source.

next()[source]

Get the next character in the text stream. Can be used as:

while not ts.end_of_text_stream():
   char = ts.next()
   ...

or else as:

for char in ts:
   ...
refill_char_buffer_if_empty()[source]

Read a line to refill the char buffer. Return False if end of stream is encountered, True otherwise.

peek()[source]

Peeks one character ahead in the text stream. Returns empty string if peek is attempted after end_of_text_stream() is True.

get_pos_of_last_next()[source]

Return a tuple containing the line number of the last character returned, numbered from 1, followed by the position of the character on that line, also numbered from 1. Useful for error messages.

end_of_text_stream()[source]

True if the last character in the text stream has been returned.

beginning_of_text_stream()[source]