parameters: (self,other)
return_statement: return ret
docstring: Implementation of * operator, allows use of C{expr * 3} in place of
          C{expr + expr + expr}.  Expressions may also me multiplied by a 2-integer
          tuple, similar to C{{min,max}} multipliers in regular expressions.  Tuples
          may also include C{None} as in:
           - C{expr*(n,None)} or C{expr*(n,)} is equivalent
                to C{expr*n + L{ZeroOrMore}(expr)}
                (read as "at least n instances of C{expr}")
           - C{expr*(None,n)} is equivalent to C{expr*(0,n)}
                (read as "0 to n instances of C{expr}")
           - C{expr*(None,None)} is equivalent to C{L{ZeroOrMore}(expr)}
           - C{expr*(1,None)} is equivalent to C{L{OneOrMore}(expr)}
  
          Note that C{expr*(None,n)} does not raise an exception if
          more than n exprs exist in the input stream; that is,
          C{expr*(None,n)} does not enforce a maximum number of expr
          occurrences.  If this behavior is desired, then write
          C{expr*(None,n) + ~expr}
docstring_summary: Implementation of * operator, allows use of C{expr * 3} in place of
          C{expr + expr + expr}.  Expressions may also me multiplied by a 2-integer
          tuple, similar to C{{min,max}} multipliers in regular expressions.  Tuples
          may also include C{None} as in:
           - C{expr*(n,None)} or C{expr*(n,)} is equivalent
                to C{expr*n + L{ZeroOrMore}(expr)}
                (read as "at least n instances of C{expr}")
           - C{expr*(None,n)} is equivalent to C{expr*(0,n)}
                (read as "0 to n instances of C{expr}")
           - C{expr*(None,None)} is equivalent to C{L{ZeroOrMore}(expr)}
           - C{expr*(1,None)} is equivalent to C{L{OneOrMore}(expr)}
docstring_tokens: Implementation of * operator allows use of C { expr * 3 } in place of C { expr + expr + expr } . Expressions may also me multiplied by a 2 - integer tuple similar to C {{ min max }} multipliers in regular expressions . Tuples may also include C { None } as in : - C { expr * ( n None ) } or C { expr * ( n ) } is equivalent to C { expr * n + L { ZeroOrMore } ( expr ) } ( read as at least n instances of C { expr } ) - C { expr * ( None n ) } is equivalent to C { expr * ( 0 n ) } ( read as 0 to n instances of C { expr } ) - C { expr * ( None None ) } is equivalent to C { L { ZeroOrMore } ( expr ) } - C { expr * ( 1 None ) } is equivalent to C { L { OneOrMore } ( expr ) }
function: def __mul__(self,other):
          """
          Implementation of * operator, allows use of C{expr * 3} in place of
          C{expr + expr + expr}.  Expressions may also me multiplied by a 2-integer
          tuple, similar to C{{min,max}} multipliers in regular expressions.  Tuples
          may also include C{None} as in:
           - C{expr*(n,None)} or C{expr*(n,)} is equivalent
                to C{expr*n + L{ZeroOrMore}(expr)}
                (read as "at least n instances of C{expr}")
           - C{expr*(None,n)} is equivalent to C{expr*(0,n)}
                (read as "0 to n instances of C{expr}")
           - C{expr*(None,None)} is equivalent to C{L{ZeroOrMore}(expr)}
           - C{expr*(1,None)} is equivalent to C{L{OneOrMore}(expr)}
  
          Note that C{expr*(None,n)} does not raise an exception if
          more than n exprs exist in the input stream; that is,
          C{expr*(None,n)} does not enforce a maximum number of expr
          occurrences.  If this behavior is desired, then write
          C{expr*(None,n) + ~expr}
          """
          if isinstance(other,int):
              minElements, optElements = other,0
          elif isinstance(other,tuple):
              other = (other + (None, None))[:2]
              if other[0] is None:
                  other = (0, other[1])
              if isinstance(other[0],int) and other[1] is None:
                  if other[0] == 0:
                      return ZeroOrMore(self)
                  if other[0] == 1:
                      return OneOrMore(self)
                  else:
                      return self*other[0] + ZeroOrMore(self)
              elif isinstance(other[0],int) and isinstance(other[1],int):
                  minElements, optElements = other
                  optElements -= minElements
              else:
                  raise TypeError("cannot multiply 'ParserElement' and ('%s','%s') objects", type(other[0]),type(other[1]))
          else:
              raise TypeError("cannot multiply 'ParserElement' and '%s' objects", type(other))
  
          if minElements < 0:
              raise ValueError("cannot multiply ParserElement by negative value")
          if optElements < 0:
              raise ValueError("second tuple value must be greater or equal to first tuple value")
          if minElements == optElements == 0:
              raise ValueError("cannot multiply ParserElement by 0 or (0,0)")
  
          if (optElements):
              def makeOptionalList(n):
                  if n>1:
                      return Optional(self + makeOptionalList(n-1))
                  else:
                      return Optional(self)
              if minElements:
                  if minElements == 1:
                      ret = self + makeOptionalList(optElements)
                  else:
                      ret = And([self]*minElements) + makeOptionalList(optElements)
              else:
                  ret = makeOptionalList(optElements)
          else:
              if minElements == 1:
                  ret = self
              else:
                  ret = And([self]*minElements)
          return ret
function_tokens: def __mul__ ( self , other ) : if isinstance ( other , int ) : minElements , optElements = other , 0 elif isinstance ( other , tuple ) : other = ( other + ( None , None ) ) [ : 2 ] if other [ 0 ] is None : other = ( 0 , other [ 1 ] ) if isinstance ( other [ 0 ] , int ) and other [ 1 ] is None : if other [ 0 ] == 0 : return ZeroOrMore ( self ) if other [ 0 ] == 1 : return OneOrMore ( self ) else : return self * other [ 0 ] + ZeroOrMore ( self ) elif isinstance ( other [ 0 ] , int ) and isinstance ( other [ 1 ] , int ) : minElements , optElements = other optElements -= minElements else : raise TypeError ( "cannot multiply 'ParserElement' and ('%s','%s') objects" , type ( other [ 0 ] ) , type ( other [ 1 ] ) ) else : raise TypeError ( "cannot multiply 'ParserElement' and '%s' objects" , type ( other ) ) if minElements < 0 : raise ValueError ( "cannot multiply ParserElement by negative value" ) if optElements < 0 : raise ValueError ( "second tuple value must be greater or equal to first tuple value" ) if minElements == optElements == 0 : raise ValueError ( "cannot multiply ParserElement by 0 or (0,0)" ) if ( optElements ) : def makeOptionalList ( n ) : if n > 1 : return Optional ( self + makeOptionalList ( n - 1 ) ) else : return Optional ( self ) if minElements : if minElements == 1 : ret = self + makeOptionalList ( optElements ) else : ret = And ( [ self ] * minElements ) + makeOptionalList ( optElements ) else : ret = makeOptionalList ( optElements ) else : if minElements == 1 : ret = self else : ret = And ( [ self ] * minElements ) return ret