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

Class OrRule

Rule --+
       |
      OrRule


A set of alternative rules. This object matches one of the alternative subrules contained in it. The rules are matched in left-to-right order. Matching stops after a rule matches.

This class is not intended for direct use. It is created by the |-operator of the Rule class.
Method Summary
  __init__(self, left_rule, right_rule)
Initialize this rule with two subrules.
  __or__(self, right_rule)
Reimplementation of the |-operator to concat subsequent rules into one object.
  __str__(self)
Return a human readable representation of that rule.
  match(self, input_reader)
Match the subrules of this rule against the input.
    Inherited from Rule
  __add__(self, second_rule)
Define an operator to concat two rules.
  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, left_rule, right_rule)
(Constructor)

Initialize this rule with two subrules.
Parameters:
left_rule - The left operand of the creating |-operator.
           (type=Rule)
right_rule - The right operand of the creating |-operator
           (type=Rule)

__or__(self, right_rule)
(Or operator)

Reimplementation of the |-operator to concat subsequent rules into one object. This serves the purpose of simplifying the structure of the resulting parser.
Parameters:
right_rule - The right operand of the |-operator.
           (type=Rule)
Returns:
self
Overrides:
yeanpypa.Rule.__or__

__str__(self)
(Informal representation operator)

Return a human readable representation of that rule.
Returns:
The string representation of that rule.

match(self, input_reader)

Match the subrules of this rule against the input. The matching is done in left-to-right order and stops after the first match.
Parameters:
input_reader - The input reader to read characters from.
           (type=InputReader)
Returns:
A list of token matched by the first matching subrule.
Overrides:
yeanpypa.Rule.match

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