Start parsing the pattern.
325914
def root(self, pattern, current):
        """"""

        self.set_after_start()
        i = util.StringIter(pattern)
        iter(i)
        root_specified = False
        if self.win_drive_detect:
            m = RE_WIN_PATH.match(pattern)
            if m:
                drive = m.group(0).replace('\\\\', '\\')
                if drive.endswith('\\'):
                    slash = True
                drive = drive[:-1]
                current.append(re.escape(drive))
                if slash:
                    current.append(self.get_path_sep() + _ONE_OR_MORE)
                i.advance(m.end(0))
                self.consume_path_sep(i)
                root_specified = True
            elif pattern.startswith('\\\\'):
                root_specified = True
        elif not self.win_drive_detect and self.pathname and pattern.startswith('/'):
            root_specified = True

        if not root_specified and self.realpath:
            current.append(_NO_WIN_ROOT if self.win_drive_detect else _NO_ROOT)
            current.append('')

        for c in i:

            index = i.index
            if self.extend and c in EXT_TYPES and self.parse_extend(c, i, current, True):
                # Nothing to do
                pass
            elif c == '*':
                self._handle_star(i, current)
            elif c == '?':
                current.append(self._restrict_sequence() + _QMARK)
            elif c == '/':
                if self.pathname:
                    self.set_start_dir()
                    self.clean_up_inverse(current)
                    current.append(self.get_path_sep() + _ONE_OR_MORE)
                    self.consume_path_sep(i)
                else:
                    current.append(re.escape(c))
            elif c == '\\':
                index = i.index
                try:
                    value = self._references(i)
                    if self.dir_start:
                        self.clean_up_inverse(current)
                        self.consume_path_sep(i)
                    current.append(value)
                except StopIteration:
                    i.rewind(i.index - index)
                    current.append(re.escape(c))
            elif c == '[':
                index = i.index
                try:
                    current.append(self._sequence(i))
                except StopIteration:
                    i.rewind(i.index - index)
                    current.append(re.escape(c))
            else:
                current.append(re.escape(c))

            self.update_dir_state()

        self.clean_up_inverse(current)
        if self.pathname:
            current.append(_PATH_TRAIL % self.get_path_sep())
1232693
private void parsePattern(String pattern){

		int currentIndex = 0;
		int patternLength = pattern.length();
		Vector<FormatCommandInterface> converterVector = new Vector<FormatCommandInterface>(20);

		while (currentIndex < patternLength) {
			char currentChar = pattern.charAt(currentIndex);

			if (currentChar == '%') {

				currentIndex++;
				currentChar = pattern.charAt(currentIndex);

				switch (currentChar) {
					case CLIENT_ID_CONVERSION_CHAR:
						converterVector.addElement(new ClientIdFormatCommand());
						break;
					case CATEGORY_CONVERSION_CHAR:
						CategoryFormatCommand categoryFormatCommand = new CategoryFormatCommand();
						String specifier = extraxtSpecifier(pattern, currentIndex);
						int specifierLength = specifier.length();
						if (specifierLength > 0) {
							categoryFormatCommand.init(specifier);
							currentIndex = currentIndex + specifierLength + 2;
						}
						converterVector.addElement(categoryFormatCommand);
						break;
					case DATE_CONVERSION_CHAR:
						DateFormatCommand formatCommand = new DateFormatCommand();
						specifier = extraxtSpecifier(pattern, currentIndex);
						specifierLength = specifier.length();
						if (specifierLength > 0) {
							formatCommand.init(specifier);
							currentIndex = currentIndex + specifierLength + 2;
						}
						converterVector.addElement(formatCommand);
						break;
					case MESSAGE_CONVERSION_CHAR:
						converterVector.addElement(new MessageFormatCommand());
						break;

					case PRIORITY_CONVERSION_CHAR:
						converterVector.addElement(new PriorityFormatCommand());
						break;

					case RELATIVE_TIME_CONVERSION_CHAR:
						converterVector.addElement(new TimeFormatCommand());
						break;

					case THREAD_CONVERSION_CHAR:
						converterVector.addElement(new ThreadFormatCommand());
						break;

					case THROWABLE_CONVERSION_CHAR:
						converterVector.addElement(new ThrowableFormatCommand());
						break;

					case PERCENT_CONVERSION_CHAR:
						NoFormatCommand noFormatCommand = new NoFormatCommand();
						noFormatCommand.init("%");
						converterVector.addElement(noFormatCommand);
						break;

					default:
						Log.e(TAG, "Unrecognized conversion character " + currentChar);
						break;
				}

				currentIndex++;

			} else {

				int percentIndex = pattern.indexOf("%", currentIndex);
				String noFormatString = "";
				if (percentIndex != -1) {
					noFormatString = pattern.substring(currentIndex, percentIndex);
				} else {
					noFormatString = pattern.substring(currentIndex, patternLength);
				}

				NoFormatCommand noFormatCommand = new NoFormatCommand();
				noFormatCommand.init(noFormatString);
				converterVector.addElement(noFormatCommand);

				currentIndex = currentIndex + noFormatString.length();
			}

		}

		commandArray = new FormatCommandInterface[converterVector.size()];
		converterVector.copyInto(commandArray);

		patternParsed = true;
	}
819808
protected void parseBegin() {
        BeginNode beginNode = new BeginNode();
        peek().addChild(beginNode);
        push(beginNode);
        parseEnd();
    }
687546
def prep_regex(patterns):
    """"""

    flags = 0 if Config.options.case_sensitive else re.I

    return [re.compile(pattern, flags) for pattern in patterns]
1330538
def _preprocess(argument, casesensitive):
        """"""
        pattern_set = PatternSet()
        if argument is not None:
            if isinstance(argument, STRING_TYPES):
                argument = [argument, ]

            for glob in argument:
                if isinstance(glob, str):
                    patterns = Pattern.create(glob, casesensitive)
                    pattern_set.extend(patterns)

                elif isinstance(glob, Pattern):
                    pattern_set.append(glob)

        return pattern_set
635040
async def _process_lines(self, pattern: Optional[str] = None) -> None:
        """"""
        if pattern is not None:
            cmp = re.compile(pattern)

        _LOGGER.debug("Start working with pattern '%s'.", pattern)

        # read lines
        while self.is_running:
            try:
                line = await self._input.readline()
                if not line:
                    break
                line = line.decode()
            except Exception:  # pylint: disable=broad-except
                break

            match = True if pattern is None else cmp.search(line)
            if match:
                _LOGGER.debug("Process: %s", line)
                await self._que.put(line)

        try:
            await self._loop.run_in_executor(None, self._proc.wait)
        finally:
            await self._que.put(None)
            _LOGGER.debug("Close read ffmpeg output.")
379187
private void parseGroupPattern(String groupPattern) {
		List<String> patternList = StrUtil.split(groupPattern, '|');
		for (String pattern : patternList) {
			parseSinglePattern(pattern);
		}
	}
839336
def parse(self, generator):
        """"""
        gen = iter(generator)
        for line in gen:
            block = {}
            for rule in self.rules:
                if rule[0](line):
                    block = rule[1](line, gen)
                    break
            yield block
582106
private static void patternCompile() {
		try {
			ptnNumber = Pattern.compile(strNumberPattern);
			ptnShortDate = Pattern.compile(strShortDatePattern);
			ptnLongDate = Pattern.compile(strLongDatePattern);
			ptnPercentage = Pattern.compile(strPercentagePattern);
			ptnCurrency = Pattern.compile(strCurrencyPattern);
			ptnViCurrency = Pattern.compile(strViCurrencyPattern);
		} catch (PatternSyntaxException ex) {
			System.err.println(ex.getMessage());
			System.exit(1);
		}

	}
76353
def parse(s):
    """"""
    stopwatch = StopWatch()
    for line in s.splitlines():
      if line.strip():
        parts = line.split(None)
        name = parts[0]
        if name != "%":  # ie not the header line
          rest = (float(v) for v in parts[2:])
          stopwatch.times[parts[0]].merge(Stat.build(*rest))
    return stopwatch
228794
def run(self):
        """"""
        self.signal_init()
        self.listen_init()
        self.logger.info('starting')
        self.loop.start()
1361337
private static void parsePatternTo(DateTimeFormatterBuilder builder, String pattern) {
        int length = pattern.length();
        int[] indexRef = new int[1];

        for (int i=0; i<length; i++) {
            indexRef[0] = i;
            String token = parseToken(pattern, indexRef);
            i = indexRef[0];

            int tokenLen = token.length();
            if (tokenLen == 0) {
                break;
            }
            char c = token.charAt(0);

            switch (c) {
            case 'G': // era designator (text)
                builder.appendEraText();
                break;
            case 'C': // century of era (number)
                builder.appendCenturyOfEra(tokenLen, tokenLen);
                break;
            case 'x': // weekyear (number)
            case 'y': // year (number)
            case 'Y': // year of era (number)
                if (tokenLen == 2) {
                    boolean lenientParse = true;

                    // Peek ahead to next token.
                    if (i + 1 < length) {
                        indexRef[0]++;
                        if (isNumericToken(parseToken(pattern, indexRef))) {
                            // If next token is a number, cannot support
                            // lenient parse, because it will consume digits
                            // that it should not.
                            lenientParse = false;
                        }
                        indexRef[0]--;
                    }

                    // Use pivots which are compatible with SimpleDateFormat.
                    switch (c) {
                    case 'x':
                        builder.appendTwoDigitWeekyear
                            (new DateTime().getWeekyear() - 30, lenientParse);
                        break;
                    case 'y':
                    case 'Y':
                    default:
                        builder.appendTwoDigitYear(new DateTime().getYear() - 30, lenientParse);
                        break;
                    }
                } else {
                    // Try to support long year values.
                    int maxDigits = 9;

                    // Peek ahead to next token.
                    if (i + 1 < length) {
                        indexRef[0]++;
                        if (isNumericToken(parseToken(pattern, indexRef))) {
                            // If next token is a number, cannot support long years.
                            maxDigits = tokenLen;
                        }
                        indexRef[0]--;
                    }

                    switch (c) {
                    case 'x':
                        builder.appendWeekyear(tokenLen, maxDigits);
                        break;
                    case 'y':
                        builder.appendYear(tokenLen, maxDigits);
                        break;
                    case 'Y':
                        builder.appendYearOfEra(tokenLen, maxDigits);
                        break;
                    }
                }
                break;
            case 'M': // month of year (text and number)
                if (tokenLen >= 3) {
                    if (tokenLen >= 4) {
                        builder.appendMonthOfYearText();
                    } else {
                        builder.appendMonthOfYearShortText();
                    }
                } else {
                    builder.appendMonthOfYear(tokenLen);
                }
                break;
            case 'd': // day of month (number)
                builder.appendDayOfMonth(tokenLen);
                break;
            case 'a': // am/pm marker (text)
                builder.appendHalfdayOfDayText();
                break;
            case 'h': // clockhour of halfday (number, 1..12)
                builder.appendClockhourOfHalfday(tokenLen);
                break;
            case 'H': // hour of day (number, 0..23)
                builder.appendHourOfDay(tokenLen);
                break;
            case 'k': // clockhour of day (1..24)
                builder.appendClockhourOfDay(tokenLen);
                break;
            case 'K': // hour of halfday (0..11)
                builder.appendHourOfHalfday(tokenLen);
                break;
            case 'm': // minute of hour (number)
                builder.appendMinuteOfHour(tokenLen);
                break;
            case 's': // second of minute (number)
                builder.appendSecondOfMinute(tokenLen);
                break;
            case 'S': // fraction of second (number)
                builder.appendFractionOfSecond(tokenLen, tokenLen);
                break;
            case 'e': // day of week (number)
                builder.appendDayOfWeek(tokenLen);
                break;
            case 'E': // dayOfWeek (text)
                if (tokenLen >= 4) {
                    builder.appendDayOfWeekText();
                } else {
                    builder.appendDayOfWeekShortText();
                }
                break;
            case 'D': // day of year (number)
                builder.appendDayOfYear(tokenLen);
                break;
            case 'w': // week of weekyear (number)
                builder.appendWeekOfWeekyear(tokenLen);
                break;
            case 'z': // time zone (text)
                if (tokenLen >= 4) {
                    builder.appendTimeZoneName();
                } else {
                    builder.appendTimeZoneShortName(null);
                }
                break;
            case 'Z': // time zone offset
                if (tokenLen == 1) {
                    builder.appendTimeZoneOffset(null, "Z", false, 2, 2);
                } else if (tokenLen == 2) {
                    builder.appendTimeZoneOffset(null, "Z", true, 2, 2);
                } else {
                    builder.appendTimeZoneId();
                }
                break;
            case '\'': // literal text
                String sub = token.substring(1);
                if (sub.length() == 1) {
                    builder.appendLiteral(sub.charAt(0));
                } else {
                    // Create copy of sub since otherwise the temporary quoted
                    // string would still be referenced internally.
                    builder.appendLiteral(new String(sub));
                }
                break;
            default:
                throw new IllegalArgumentException
                    ("Illegal pattern component: " + token);
            }
        }
    }
608783
def get_pattern_context(pattern, index):
    """"""

    last = 0
    current_line = 1
    col = 1
    text = []
    line = 1

    # Split pattern by newline and handle the text before the newline
    for m in RE_PATTERN_LINE_SPLIT.finditer(pattern):
        linetext = pattern[last:m.start(0)]
        if not len(m.group(0)) and not len(text):
            indent = ''
            offset = -1
            col = index - last + 1
        elif last <= index < m.end(0):
            indent = '--> '
            offset = (-1 if index > m.start(0) else 0) + 3
            col = index - last + 1
        else:
            indent = '    '
            offset = None
        if len(text):
            # Regardless of whether we are presented with `\r\n`, `\r`, or `\n`,
            # we will render the output with just `\n`. We will still log the column
            # correctly though.
            text.append('\n')
        text.append('{}{}'.format(indent, linetext))
        if offset is not None:
            text.append('\n')
            text.append(' ' * (col + offset) + '^')
            line = current_line

        current_line += 1
        last = m.end(0)

    return ''.join(text), line, col
1301678
def _parse(self):
        """"""
        if not self.pattern:
            raise TiffSequence.ParseError('invalid pattern')
        pattern = re.compile(self.pattern, re.IGNORECASE | re.VERBOSE)
        matches = pattern.findall(os.path.split(self.files[0])[-1])
        if not matches:
            raise TiffSequence.ParseError('pattern does not match file names')
        matches = matches[-1]
        if len(matches) % 2:
            raise TiffSequence.ParseError(
                'pattern does not match axis name and index')
        axes = ''.join(m for m in matches[::2] if m)
        if not axes:
            raise TiffSequence.ParseError('pattern does not match file names')

        indices = []
        for fname in self.files:
            fname = os.path.split(fname)[-1]
            matches = pattern.findall(fname)[-1]
            if axes != ''.join(m for m in matches[::2] if m):
                raise ValueError('axes do not match within image sequence')
            indices.append([int(m) for m in matches[1::2] if m])
        shape = tuple(numpy.max(indices, axis=0))
        startindex = tuple(numpy.min(indices, axis=0))
        shape = tuple(i-j+1 for i, j in zip(shape, startindex))
        if product(shape) != len(self.files):
            log.warning(
                'TiffSequence: files are missing. Missing data are zeroed')

        self.axes = axes.upper()
        self.shape = shape
        self._indices = indices
        self._startindex = startindex
1339473
def ImportPatterns(self, s):
    ""
    for line, strli, direction, seq, station_id in  \
    ReadCSV(s, ['LI_NR', 'STR_LI_VAR', 'LI_RI_NR', 'LI_LFD_NR', 'ORT_NR']):
      pattern_id = u'Pat.%s.%s.%s' % (line, strli, direction)
      pattern = self.patterns.get(pattern_id, None)
      if not pattern:
        pattern = Pattern()
        pattern.id = pattern_id
        pattern.stops = []
        pattern.stoptimes = {}
        self.patterns[pattern_id] = pattern
      seq = int(seq) - 1
      if len(pattern.stops) <= seq:
        pattern.stops.extend([None] * (seq - len(pattern.stops)  + 1))
      pattern.stops[seq] = station_id
126509
function start (inp) {
    var res = parseArgumentList(inp.skipWs());
  
    // If there is any leftover, we have input that did not match our grammar,
    // so throw a generic syntax error.
    if (inp.skipWs().buffer) syntaxError(inp);
    return res;
  }
872017
def match(self, pattern):
        """"""

        m = pattern.match(self._string, self._index)
        if m:
            self._index = m.end()
        return m