annotate Lib/regex_syntax.py @ 4566:6403c94de50d legacy-trunk

Added safeguard against failure in __del__.
author Guido van Rossum <guido@python.org>
date Wed, 27 Nov 1996 19:39:58 +0000
parents 48eaf4fc53cb
children fdb77636c074
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
540
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # These bits are passed to regex.set_syntax() to choose among
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 # alternative regexp syntaxes.
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 # 1 means plain parentheses serve as grouping, and backslash
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 # parentheses are needed for literal searching.
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 # 0 means backslash-parentheses are grouping, and plain parentheses
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 # are for literal searching.
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 RE_NO_BK_PARENS = 1
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 # 1 means plain | serves as the "or"-operator, and \| is a literal.
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 # 0 means \| serves as the "or"-operator, and | is a literal.
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 RE_NO_BK_VBAR = 2
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 # 0 means plain + or ? serves as an operator, and \+, \? are literals.
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 # 1 means \+, \? are operators and plain +, ? are literals.
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 RE_BK_PLUS_QM = 4
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 # 1 means | binds tighter than ^ or $.
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 # 0 means the contrary.
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 RE_TIGHT_VBAR = 8
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 # 1 means treat \n as an _OR operator
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 # 0 means treat it as a normal character
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 RE_NEWLINE_OR = 16
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
25
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 # 0 means that a special characters (such as *, ^, and $) always have
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 # their special meaning regardless of the surrounding context.
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 # 1 means that special characters may act as normal characters in some
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 # contexts. Specifically, this applies to:
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 # ^ - only special at the beginning, or after ( or |
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 # $ - only special at the end, or before ) or |
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 # *, +, ? - only special when not after the beginning, (, or |
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 RE_CONTEXT_INDEP_OPS = 32
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
34
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 # Now define combinations of bits for the standard possibilities.
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 RE_SYNTAX_AWK = (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS)
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 RE_SYNTAX_EGREP = (RE_SYNTAX_AWK | RE_NEWLINE_OR)
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 RE_SYNTAX_GREP = (RE_BK_PLUS_QM | RE_NEWLINE_OR)
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 RE_SYNTAX_EMACS = 0
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
40
48eaf4fc53cb Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 # (Python's obsolete "regexp" module used a syntax similar to awk.)