Saved and restored logging._handlerList at the same time as saving/restoring logging...
[python.git] / Lib / regex_syntax.py
blobb0a0dbf20c45f0dc2f8014d97430ebb4c9756471
1 """Constants for selecting regexp syntaxes for the obsolete regex module.
3 This module is only for backward compatibility. "regex" has now
4 been replaced by the new regular expression module, "re".
6 These bits are passed to regex.set_syntax() to choose among
7 alternative regexp syntaxes.
8 """
10 # 1 means plain parentheses serve as grouping, and backslash
11 # parentheses are needed for literal searching.
12 # 0 means backslash-parentheses are grouping, and plain parentheses
13 # are for literal searching.
14 RE_NO_BK_PARENS = 1
16 # 1 means plain | serves as the "or"-operator, and \| is a literal.
17 # 0 means \| serves as the "or"-operator, and | is a literal.
18 RE_NO_BK_VBAR = 2
20 # 0 means plain + or ? serves as an operator, and \+, \? are literals.
21 # 1 means \+, \? are operators and plain +, ? are literals.
22 RE_BK_PLUS_QM = 4
24 # 1 means | binds tighter than ^ or $.
25 # 0 means the contrary.
26 RE_TIGHT_VBAR = 8
28 # 1 means treat \n as an _OR operator
29 # 0 means treat it as a normal character
30 RE_NEWLINE_OR = 16
32 # 0 means that a special characters (such as *, ^, and $) always have
33 # their special meaning regardless of the surrounding context.
34 # 1 means that special characters may act as normal characters in some
35 # contexts. Specifically, this applies to:
36 # ^ - only special at the beginning, or after ( or |
37 # $ - only special at the end, or before ) or |
38 # *, +, ? - only special when not after the beginning, (, or |
39 RE_CONTEXT_INDEP_OPS = 32
41 # ANSI sequences (\n etc) and \xhh
42 RE_ANSI_HEX = 64
44 # No GNU extensions
45 RE_NO_GNU_EXTENSIONS = 128
47 # Now define combinations of bits for the standard possibilities.
48 RE_SYNTAX_AWK = (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS)
49 RE_SYNTAX_EGREP = (RE_SYNTAX_AWK | RE_NEWLINE_OR)
50 RE_SYNTAX_GREP = (RE_BK_PLUS_QM | RE_NEWLINE_OR)
51 RE_SYNTAX_EMACS = 0
53 # (Python's obsolete "regexp" module used a syntax similar to awk.)