diff options
author | Fredrik Lundh <fredrik@pythonware.com> | 2000-06-30 22:37:31 (GMT) |
---|---|---|
committer | Fredrik Lundh <fredrik@pythonware.com> | 2000-06-30 22:37:31 (GMT) |
commit | 55a4f4a528b6eade932b01d7a0bee0a34fae1f6a (patch) | |
tree | ca3b29a5036c251fca80910640da0449a5dddfbc /Lib | |
parent | 361b583e88a260553418aaf5f5b00f31cc5ce5fb (diff) | |
download | cpython-55a4f4a528b6eade932b01d7a0bee0a34fae1f6a.zip cpython-55a4f4a528b6eade932b01d7a0bee0a34fae1f6a.tar.gz cpython-55a4f4a528b6eade932b01d7a0bee0a34fae1f6a.tar.bz2 |
- fixed code generation error in multiline mode
- fixed parser flag propagation (of all stupid bugs...)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/sre_compile.py | 4 | ||||
-rw-r--r-- | Lib/sre_parse.py | 11 |
2 files changed, 8 insertions, 7 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index 6c7e588..590e45f 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -118,7 +118,7 @@ def _compile(code, pattern, flags): elif op is AT: emit(OPCODES[op]) if flags & SRE_FLAG_MULTILINE: - emit(ATCODES[AT_MULTILINE[av]]) + emit(ATCODES[AT_MULTILINE.get(av, av)]) else: emit(ATCODES[av]) elif op is BRANCH: @@ -203,7 +203,7 @@ def compile(p, flags=0): if type(p) in (type(""), type(u"")): import sre_parse pattern = p - p = sre_parse.parse(p) + p = sre_parse.parse(p, flags) else: pattern = None diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 660bae6..53616f6 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -31,7 +31,7 @@ DIGITS = tuple(string.digits) OCTDIGITS = tuple("01234567") HEXDIGITS = tuple("0123456789abcdefABCDEF") -WHITESPACE = string.whitespace +WHITESPACE = tuple(string.whitespace) ESCAPES = { r"\a": (LITERAL, 7), @@ -296,7 +296,7 @@ def _branch(pattern, items): subpattern.append((BRANCH, (None, items))) return subpattern -def _parse(source, state, flags=0): +def _parse(source, state): # parse regular expression pattern into an operator list. @@ -468,7 +468,7 @@ def _parse(source, state, flags=0): char = source.get() b = [] while 1: - p = _parse(source, state, flags) + p = _parse(source, state) if source.next == ")": if b: b.append(p) @@ -495,7 +495,7 @@ def _parse(source, state, flags=0): else: group = state.getgroup(name) while 1: - p = _parse(source, state, flags) + p = _parse(source, state) if source.match(")"): if b: b.append(p) @@ -532,9 +532,10 @@ def parse(pattern, flags=0): # parse 're' pattern into list of (opcode, argument) tuples source = Tokenizer(pattern) state = State() + state.flags = flags b = [] while 1: - p = _parse(source, state, flags) + p = _parse(source, state) tail = source.get() if tail == "|": b.append(p) |