blob: b0a0dbf20c45f0dc2f8014d97430ebb4c9756471 [file] [log] [blame]
Guido van Rossume7b146f2000-02-04 15:28:42 +00001"""Constants for selecting regexp syntaxes for the obsolete regex module.
2
3This module is only for backward compatibility. "regex" has now
4been replaced by the new regular expression module, "re".
5
6These bits are passed to regex.set_syntax() to choose among
7alternative regexp syntaxes.
8"""
Guido van Rossum6c6b78d1991-12-30 16:03:05 +00009
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.
14RE_NO_BK_PARENS = 1
15
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.
18RE_NO_BK_VBAR = 2
19
20# 0 means plain + or ? serves as an operator, and \+, \? are literals.
21# 1 means \+, \? are operators and plain +, ? are literals.
22RE_BK_PLUS_QM = 4
23
24# 1 means | binds tighter than ^ or $.
25# 0 means the contrary.
26RE_TIGHT_VBAR = 8
27
28# 1 means treat \n as an _OR operator
29# 0 means treat it as a normal character
30RE_NEWLINE_OR = 16
31
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:
Tim Peters0c9886d2001-01-15 01:18:21 +000036# ^ - 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 |
Guido van Rossum6c6b78d1991-12-30 16:03:05 +000039RE_CONTEXT_INDEP_OPS = 32
40
Guido van Rossum24986201997-10-22 16:28:53 +000041# ANSI sequences (\n etc) and \xhh
42RE_ANSI_HEX = 64
43
44# No GNU extensions
45RE_NO_GNU_EXTENSIONS = 128
46
Guido van Rossum6c6b78d1991-12-30 16:03:05 +000047# Now define combinations of bits for the standard possibilities.
48RE_SYNTAX_AWK = (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS)
49RE_SYNTAX_EGREP = (RE_SYNTAX_AWK | RE_NEWLINE_OR)
50RE_SYNTAX_GREP = (RE_BK_PLUS_QM | RE_NEWLINE_OR)
51RE_SYNTAX_EMACS = 0
52
53# (Python's obsolete "regexp" module used a syntax similar to awk.)