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

Class Optional

Rule --+
       |
      Optional


This rule matches its subrule optionally once. If the subrule does not match, the Optional() rule matches anyway.
Method Summary
  __init__(self, rule)
Initialize the rule with a subrule.
  __str__(self)
Return a string representation of this 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, rule)
(Constructor)

Initialize the rule with a subrule.
Parameters:
rule - The rule to match optionally
           (type=Rule)

__str__(self)
(Informal representation operator)

Return a string representation of this rule.
Returns:
a human readable representation of this rule.

match(self, input_reader)

Match this rule against the input.
Parameters:
input_reader - The input reader to read from.
           (type=InputReader @return A list of token matched by the subrule (or None, if none))
Overrides:
yeanpypa.Rule.match

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