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 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}