def __mul__(self,other):
if isinstance(other,int):<EOL><INDENT>minElements, optElements = other,<NUM_LIT:0><EOL><DEDENT>elif isinstance(other,tuple):<EOL><INDENT>other = (other + (None, None))[:<NUM_LIT:2>]<EOL>if other[<NUM_LIT:0>] is None:<EOL><INDENT>other = (<NUM_LIT:0>, other[<NUM_LIT:1>])<EOL><DEDENT>if isinstance(other[<NUM_LIT:0>],int) and other[<NUM_LIT:1>] is None:<EOL><INDENT>if other[<NUM_LIT:0>] == <NUM_LIT:0>:<EOL><INDENT>return ZeroOrMore(self)<EOL><DEDENT>if other[<NUM_LIT:0>] == <NUM_LIT:1>:<EOL><INDENT>return OneOrMore(self)<EOL><DEDENT>else:<EOL><INDENT>return self*other[<NUM_LIT:0>] + ZeroOrMore(self)<EOL><DEDENT><DEDENT>elif isinstance(other[<NUM_LIT:0>],int) and isinstance(other[<NUM_LIT:1>],int):<EOL><INDENT>minElements, optElements = other<EOL>optElements -= minElements<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>", type(other[<NUM_LIT:0>]),type(other[<NUM_LIT:1>]))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>", type(other))<EOL><DEDENT>if minElements < <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if optElements < <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if minElements == optElements == <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if (optElements):<EOL><INDENT>def makeOptionalList(n):<EOL><INDENT>if n><NUM_LIT:1>:<EOL><INDENT>return Optional(self + makeOptionalList(n-<NUM_LIT:1>))<EOL><DEDENT>else:<EOL><INDENT>return Optional(self)<EOL><DEDENT><DEDENT>if minElements:<EOL><INDENT>if minElements == <NUM_LIT:1>:<EOL><INDENT>ret = self + makeOptionalList(optElements)<EOL><DEDENT>else:<EOL><INDENT>ret = And([self]*minElements) + makeOptionalList(optElements)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>ret = makeOptionalList(optElements)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if minElements == <NUM_LIT:1>:<EOL><INDENT>ret = self<EOL><DEDENT>else:<EOL><INDENT>ret = And([self]*minElements)<EOL><DEDENT><DEDENT>return ret<EOL>
Implementation of * operator, allows use of ``expr * 3`` in place of
``expr + expr + expr``.  Expressions may also me multiplied by a 2-integer
tuple, similar to ``{min,max}`` multipliers in regular expressions.  Tuples
may also include ``None`` as in:
 - ``expr*(n,None)`` or ``expr*(n,)`` is equivalent
      to ``expr*n + ZeroOrMore(expr)``
      (read as "at least n instances of ``expr``")
 - ``expr*(None,n)`` is equivalent to ``expr*(0,n)``
      (read as "0 to n instances of ``expr``")
 - ``expr*(None,None)`` is equivalent to ``ZeroOrMore(expr)``
 - ``expr*(1,None)`` is equivalent to ``OneOrMore(expr)``

Note that ``expr*(None,n)`` does not raise an exception if
more than n exprs exist in the input stream; that is,
``expr*(None,n)`` does not enforce a maximum number of expr
occurrences.  If this behavior is desired, then write
``expr*(None,n) + ~expr``