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.
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.
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.
20 # 0 means plain + or ? serves as an operator, and \+, \? are literals.
21 # 1 means \+, \? are operators and plain +, ? are literals.
24 # 1 means | binds tighter than ^ or $.
25 # 0 means the contrary.
28 # 1 means treat \n as an _OR operator
29 # 0 means treat it as a normal character
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
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
)
53 # (Python's obsolete "regexp" module used a syntax similar to awk.)