def __init__(self, patterns, ignore, input):
        """Initialize the scanner.

        @param patterns: [(terminal, uncompiled regex), ...] or C{None}
        @param ignore: [terminal,...]
        @param input: string

        If patterns is C{None}, we assume that the subclass has defined
        C{self.patterns} : [(terminal, compiled regex), ...]. Note that the
        patterns parameter expects uncompiled regexes, whereas the
        C{self.patterns} field expects compiled regexes.
        """
        self.tokens = [] # [(begin char pos, end char pos, token name, matched text), ...]
        self.restrictions = []
        self.input = input
        self.pos = 0
        self.ignore = ignore
        self.first_line_number = 1

        if patterns is not None:
            # Compile the regex strings into regex objects
            self.patterns = []
            for terminal, regex in patterns:
                self.patterns.append( (terminal, re.compile(regex)) )
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/words/xish/xpathparser.py/Scanner.__init__/original