Package ZestyParser :: Module Parser :: Class ZestyParser
[show private | hide private]
[frames | no frames]

Class ZestyParser

Known Subclasses:
DebuggingParser

Parses one stream of data, by means of tokens.
Method Summary
  __init__(self, data)
Initializes the parser, optionally calling useData
tuple coord(self, loc)
Returns row/column coordinates for a given point in the input stream, or cursor by default.
iterator iter(self, token, skip, until)
Returns a generator iterator which scans for token every time it is invoked.
object scan(self, token)
Scan for one token.
bool skip(self, token)
A convenience method that skips one token and returns whether it matched.
  useData(self, data)
Begin parsing a stream of data

Instance Variable Summary
dict context: A dictionary which can be used for storing any necessary state information.
int cursor: The current position of the parser in data.
sequence data: The sequence being parsed (probably a string).
token last: The last matched token.

Class Variable Summary
int len = 0                                                                     

Method Details

__init__(self, data=None)
(Constructor)

Initializes the parser, optionally calling useData

coord(self, loc=None)

Returns row/column coordinates for a given point in the input stream, or cursor by default. Counting starts at (1, 1).
Parameters:
loc - An index of data.
           (type=int)
Returns:
A 2-tuple representing (row, column).
           (type=tuple)

iter(self, token, skip=None, until=None)

Returns a generator iterator which scans for token every time it is invoked.
Parameters:
token - The token to scan for.
skip - An optional token to skip before each scan for token.
           (type=token)
until - An optional 2-tuple. If defined, the iterator will scan for token until it reaches the token until[0]; if scan returns None before the iterator encounters this token, it raises a ParseError with the message given in until[1].
           (type=tuple)
Returns:
iterator

scan(self, token)

Scan for one token.
Parameters:
token - The token to scan for.
Returns:
The return value of the matching token, or None if the token raised NotMatched.
           (type=object)
Raises:
ParseError - If a token fails to match and it has a failMessage parameter.

skip(self, token)

A convenience method that skips one token and returns whether it matched.
Parameters:
token - The token to scan for.
           (type=token)
Returns:
Whether or not the token matched.
           (type=bool)

useData(self, data)

Begin parsing a stream of data
Parameters:
data - The data to parse.
           (type=sequence)

Instance Variable Details

context

A dictionary which can be used for storing any necessary state information.
Type:
dict
Value:
{}                                                                     

cursor

The current position of the parser in data.
Type:
int
Value:
0                                                                     

data

The sequence being parsed (probably a string).
Type:
sequence
Value:
None                                                                  

last

The last matched token.
Type:
token
Value:
None                                                                  

Class Variable Details

len

Type:
int
Value:
0                                                                     

Generated by Epydoc 2.1 on Thu Mar 22 02:13:39 2007 http://epydoc.sf.net