Module yeanpypa :: Class CallbackParser
[show private | hide private]
[frames | no frames]

Class CallbackParser

Rule --+
       |
      CallbackParser


A class calling a function for the next input character to determine a match. This class calls a user-supplied function for the next input character in order to determine whether the character should match or not.
Method Summary
  __init__(self, callback)
Initialize the object with a callback.
  __str__(self)
Return a human-readable description of the rule.
  match(self, input_reader)
Match this rule against the input.
    Inherited from Rule
  __add__(self, second_rule)
Define an operator to concat two rules.
  __or__(self, second_rule)
Define an operator to concat two rules via OR.
  callAction(self, param)
Call the action attached to this rule.
  hide(self)
Tell this rule to not produce any token output.
  returnToken(self, token)
Helper function encapsulating the hide()-functionality.
  setAction(self, action)
Set the action to execute on a rule match.

Class Variable Summary
    Inherited from Rule
NoneType action = None                                                                  
bool hide_token = False

Method Details

__init__(self, callback)
(Constructor)

Initialize the object with a callback. The callback takes a single character as parameter and returns True if it should match and False otherwise:
Parameters:
callback - The callback function determining the match.
           (type=Callable)

__str__(self)
(Informal representation operator)

Return a human-readable description of the rule.
Returns:
A human-readable description of this rule.

match(self, input_reader)

Match this rule against the input. The rule calls the callback to determine whether the next character should match or not and returns the character if so.
Parameters:
input_reader - The input reader to read input from.
           (type=InputReader)
Returns:
The matched character, if any.
Overrides:
yeanpypa.Rule.match

Generated by Epydoc 2.1 on Sat Feb 10 16:11:43 2007 http://epydoc.sf.net