class documentation

`StateMachine` subclass specialized for whitespace recognition. There are three methods provided for extracting indented text blocks: - `get_indented()`: use when the indent is unknown. - `get_known_indented()`: use when the indent is known for all lines. - `get_first_known_indented()`: use when only the first line's indent is known.

Method get_first_known_indented Return an indented block and info.
Method get_indented Return a block of indented lines of text, and info.
Method get_known_indented Return an indented block and info.

Inherited from StateMachine:

Method __init__ Initialize a `StateMachine` object; add state objects.
Method abs_line_number Return line number of current line (counting from 1).
Method abs_line_offset Return line offset of current line, from beginning of file.
Method add_state Initialize & add a `state_class` (`State` subclass) object.
Method add_states Add `state_classes` (a list of `State` subclasses).
Method at_bof Return 1 if the input is at or before beginning-of-file.
Method at_eof Return 1 if the input is at or past end-of-file.
Method attach_observer The `observer` parameter is a function or bound method which takes two arguments, the source and offset of the current line.
Method check_line Examine one line of input for a transition match & execute its method.
Method detach_observer Undocumented
Method error Report error details.
Method get_source Return source of line at absolute line offset `line_offset`.
Method get_source_and_line Return (source, line) tuple for current or given line number.
Method get_state Return current state object; set it first if `next_state` given.
Method get_text_block Return a contiguous block of text.
Method goto_line Jump to absolute line offset `line_offset`, load and return it.
Method insert_input Undocumented
Method is_next_line_blank Return True if the next line is blank or non-existent.
Method next_line Load `self.line` with the `n`'th next line and return it.
Method notify_observers Undocumented
Method previous_line Load `self.line` with the `n`'th previous line and return it.
Method run Run the state machine on `input_lines`. Return results (a list).
Method runtime_init Initialize `self.states`.
Method unlink Remove circular references to objects no longer required.
Instance Variable current_state The name of the current state (key to `self.states`).
Instance Variable debug Debugging mode on/off.
Instance Variable initial_state The name of the initial state (key to `self.states`).
Instance Variable input_lines `StringList` of input lines (without newlines). Filled by `self.run()`.
Instance Variable input_offset Offset of `self.input_lines` from the beginning of the file.
Instance Variable line Current input line.
Instance Variable line_offset Current input line offset from beginning of `self.input_lines`.
Instance Variable observers List of bound methods or functions to call whenever the current line changes. Observers are called with one argument, ``self``. Cleared at the end of `run()`.
Instance Variable states Mapping of {state_name: State_object}.
def get_first_known_indented(self, indent, until_blank=False, strip_indent=True, strip_top=True): (source)

Return an indented block and info. Extract an indented block where the indent is known for the first line and unknown for all other lines. :Parameters: - `indent`: The first line's indent (# of columns/characters). - `until_blank`: Stop collecting at the first blank line if true (1). - `strip_indent`: Strip `indent` characters of indentation if true (1, default). - `strip_top`: Strip blank lines from the beginning of the block. :Return: - the indented block, - its indent, - its first line offset from BOF, and - whether or not it finished with a blank line.

def get_indented(self, until_blank=False, strip_indent=True): (source)

Return a block of indented lines of text, and info. Extract an indented block where the indent is unknown for all lines. :Parameters: - `until_blank`: Stop collecting at the first blank line if true. - `strip_indent`: Strip common leading indent if true (default). :Return: - the indented block (a list of lines of text), - its indent, - its first line offset from BOF, and - whether or not it finished with a blank line.

def get_known_indented(self, indent, until_blank=False, strip_indent=True): (source)

Return an indented block and info. Extract an indented block where the indent is known for all lines. Starting with the current line, extract the entire text block with at least `indent` indentation (which must be whitespace, except for the first line). :Parameters: - `indent`: The number of indent columns/characters. - `until_blank`: Stop collecting at the first blank line if true. - `strip_indent`: Strip `indent` characters of indentation if true (default). :Return: - the indented block, - its first line offset from BOF, and - whether or not it finished with a blank line.