Home | Trees | Index | Help |
|
---|
Package docutils :: Module statemachine :: Class StateMachine |
|
SearchStateMachine
,
StateMachineWS
A finite state machine for text filters using regular expressions.
The input is provided in the form of a list of one-line strings (no
newlines). States are subclasses of the State
class. Transitions consist
of regular expression patterns and transition methods, and are defined in
each state.
The state machine is started with the run()
method, which returns the
results of processing in a list.
Method Summary | |
---|---|
Initialize a StateMachine object; add state objects. | |
Return line number of current line (counting from 1). | |
Return line offset of current line, from beginning of file. | |
Initialize & add a state_class (State subclass) object. | |
Add state_classes (a list of State subclasses). | |
Return 1 if the input is at or before beginning-of-file. | |
Return 1 if the input is at or past end-of-file. | |
The observer parameter is a function or bound method which takes two
arguments, the source and offset of the current line. | |
Examine one line of input for a transition match & execute its method. | |
detach_observer(self,
observer)
| |
Report error details. | |
Return current state object; set it first if next_state given. | |
Return a contiguous block of text. | |
Jump to absolute line offset line_offset , load and return it. | |
insert_input(self,
input_lines,
source)
| |
Return 1 if the next line is blank or non-existant. | |
Return the result of a regular expression match. | |
Load self.line with the n 'th next line and return it. | |
notify_observers(self)
| |
Load self.line with the n 'th previous line and return it. | |
Run the state machine on input_lines . | |
Initialize self.states . | |
Remove circular references to objects no longer required. |
Method Details |
---|
__init__(self,
state_classes,
initial_state,
debug=0)
|
abs_line_number(self)Return line number of current line (counting from 1). |
abs_line_offset(self)Return line offset of current line, from beginning of file. |
add_state(self, state_class)Initialize & add a Exception: |
add_states(self, state_classes)Addstate_classes (a list of State subclasses). |
at_bof(self)Return 1 if the input is at or before beginning-of-file. |
at_eof(self)Return 1 if the input is at or past end-of-file. |
attach_observer(self, observer)Theobserver parameter is a function or bound method which takes two
arguments, the source and offset of the current line. |
check_line(self, context, state, transitions=None)Examine one line of input for a transition match & execute its method. Parameters:
Return the values returned by the transition method:
When there is no match, state.no_match() is called and its return value is returned. |
error(self)Report error details. |
get_state(self, next_state=None)Return current state object; set it first if Parameter Exception: |
get_text_block(self, flush_left=0)Return a contiguous block of text. If |
goto_line(self, line_offset)Jump to absolute line offsetline_offset , load and return it. |
is_next_line_blank(self)Return 1 if the next line is blank or non-existant. |
match(self, pattern)Return the result of a regular expression match. Parameter |
next_line(self, n=1)Loadself.line with the n 'th next line and return it. |
previous_line(self, n=1)Loadself.line with the n 'th previous line and return it. |
run(self, input_lines, input_offset=0, context=None, input_source=None)Run the state machine on Reset Parameters:
|
runtime_init(self)Initializeself.states . |
unlink(self)Remove circular references to objects no longer required. |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.0 on Tue Jul 22 05:31:46 2003 | http://epydoc.sf.net |