MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _parse

Function _parse

tools/python-3.11.9-amd64/Lib/re/_parser.py:516–901  ·  view source on GitHub ↗
(source, state, verbose, nested, first=False)

Source from the content-addressed store, hash-verified

514 return subpattern
515
516def _parse(source, state, verbose, nested, first=False):
517 # parse a simple pattern
518 subpattern = SubPattern(state)
519
520 # precompute constants into local variables
521 subpatternappend = subpattern.append
522 sourceget = source.get
523 sourcematch = source.match
524 _len = len
525 _ord = ord
526
527 while True:
528
529 this = source.next
530 if this is None:
531 break # end of pattern
532 if this in "|)":
533 break # end of subpattern
534 sourceget()
535
536 if verbose:
537 # skip whitespace and comments
538 if this in WHITESPACE:
539 continue
540 if this == "#":
541 while True:
542 this = sourceget()
543 if this is None or this == "\n":
544 break
545 continue
546
547 if this[0] == "\\":
548 code = _escape(source, this, state)
549 subpatternappend(code)
550
551 elif this not in SPECIAL_CHARS:
552 subpatternappend((LITERAL, _ord(this)))
553
554 elif this == "[":
555 here = source.tell() - 1
556 # character set
557 set = []
558 setappend = set.append
559## if sourcematch(":"):
560## pass # handle character classes
561 if source.next == '[':
562 import warnings
563 warnings.warn(
564 'Possible nested set at position %d' % source.tell(),
565 FutureWarning, stacklevel=nested + 6
566 )
567 negate = sourcematch("^")
568 # check remaining characters
569 while True:
570 this = sourceget()
571 if this is None:
572 raise source.error("unterminated character set",
573 source.tell() - here)

Callers 1

_parse_subFunction · 0.70

Calls 15

SubPatternClass · 0.85
_class_escapeFunction · 0.85
_uniqFunction · 0.85
_parse_subFunction · 0.85
asciiFunction · 0.85
_parse_flagsFunction · 0.85
getuntilMethod · 0.80
checkgroupnameMethod · 0.80
checkgroupMethod · 0.80
checklookbehindgroupMethod · 0.80
isidentifierMethod · 0.80
isdecimalMethod · 0.80

Tested by

no test coverage detected