summaryrefslogtreecommitdiff
path: root/Lib/sre_constants.py
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2000-06-29 08:58:44 +0000
committerFredrik Lundh <fredrik@pythonware.com>2000-06-29 08:58:44 +0000
commitbe6d4f6acc485bd6e15179e6db34080690630824 (patch)
tree8c7754d43b098cb9d03a045b3620083f6bd03ddf /Lib/sre_constants.py
parent85ac5e9afd1d82a33417516d9f1ce4c9f394ca65 (diff)
downloadcpython-be6d4f6acc485bd6e15179e6db34080690630824.tar.gz
towards 1.6b1
Diffstat (limited to 'Lib/sre_constants.py')
-rw-r--r--Lib/sre_constants.py72
1 files changed, 50 insertions, 22 deletions
diff --git a/Lib/sre_constants.py b/Lib/sre_constants.py
index 531dc319cb..c9969609f2 100644
--- a/Lib/sre_constants.py
+++ b/Lib/sre_constants.py
@@ -15,6 +15,11 @@
# other compatibility work.
#
+# should this really be here?
+
+class error(Exception):
+ pass
+
# operators
FAILURE = "failure"
@@ -30,20 +35,20 @@ GROUP = "group"
GROUP_IGNORE = "group_ignore"
IN = "in"
IN_IGNORE = "in_ignore"
+INFO = "info"
JUMP = "jump"
LITERAL = "literal"
LITERAL_IGNORE = "literal_ignore"
MARK = "mark"
MAX_REPEAT = "max_repeat"
MAX_REPEAT_ONE = "max_repeat_one"
-MAX_UNTIL = "max_until"
MIN_REPEAT = "min_repeat"
-MIN_UNTIL = "min_until"
NEGATE = "negate"
NOT_LITERAL = "not_literal"
NOT_LITERAL_IGNORE = "not_literal_ignore"
RANGE = "range"
REPEAT = "repeat"
+REPEAT_ONE = "repeat_one"
SUBPATTERN = "subpattern"
# positions
@@ -63,14 +68,16 @@ CATEGORY_WORD = "category_word"
CATEGORY_NOT_WORD = "category_not_word"
CATEGORY_LINEBREAK = "category_linebreak"
CATEGORY_NOT_LINEBREAK = "category_not_linebreak"
-CATEGORY_LOC_DIGIT = "category_loc_digit"
-CATEGORY_LOC_NOT_DIGIT = "category_loc_not_digit"
-CATEGORY_LOC_SPACE = "category_loc_space"
-CATEGORY_LOC_NOT_SPACE = "category_loc_not_space"
CATEGORY_LOC_WORD = "category_loc_word"
CATEGORY_LOC_NOT_WORD = "category_loc_not_word"
-CATEGORY_LOC_LINEBREAK = "category_loc_linebreak"
-CATEGORY_LOC_NOT_LINEBREAK = "category_loc_not_linebreak"
+CATEGORY_UNI_DIGIT = "category_uni_digit"
+CATEGORY_UNI_NOT_DIGIT = "category_uni_not_digit"
+CATEGORY_UNI_SPACE = "category_uni_space"
+CATEGORY_UNI_NOT_SPACE = "category_uni_not_space"
+CATEGORY_UNI_WORD = "category_uni_word"
+CATEGORY_UNI_NOT_WORD = "category_uni_not_word"
+CATEGORY_UNI_LINEBREAK = "category_uni_linebreak"
+CATEGORY_UNI_NOT_LINEBREAK = "category_uni_not_linebreak"
OPCODES = [
@@ -85,12 +92,13 @@ OPCODES = [
CATEGORY,
GROUP, GROUP_IGNORE,
IN, IN_IGNORE,
+ INFO,
JUMP,
LITERAL, LITERAL_IGNORE,
MARK,
- MAX_REPEAT, MAX_UNTIL,
+ MAX_REPEAT,
MAX_REPEAT_ONE,
- MIN_REPEAT, MIN_UNTIL,
+ MIN_REPEAT,
NOT_LITERAL, NOT_LITERAL_IGNORE,
NEGATE,
RANGE,
@@ -106,10 +114,11 @@ ATCODES = [
CHCODES = [
CATEGORY_DIGIT, CATEGORY_NOT_DIGIT, CATEGORY_SPACE,
CATEGORY_NOT_SPACE, CATEGORY_WORD, CATEGORY_NOT_WORD,
- CATEGORY_LINEBREAK, CATEGORY_NOT_LINEBREAK, CATEGORY_LOC_DIGIT,
- CATEGORY_LOC_NOT_DIGIT, CATEGORY_LOC_SPACE,
- CATEGORY_LOC_NOT_SPACE, CATEGORY_LOC_WORD, CATEGORY_LOC_NOT_WORD,
- CATEGORY_LOC_LINEBREAK, CATEGORY_LOC_NOT_LINEBREAK
+ CATEGORY_LINEBREAK, CATEGORY_NOT_LINEBREAK, CATEGORY_LOC_WORD,
+ CATEGORY_LOC_NOT_WORD, CATEGORY_UNI_DIGIT, CATEGORY_UNI_NOT_DIGIT,
+ CATEGORY_UNI_SPACE, CATEGORY_UNI_NOT_SPACE, CATEGORY_UNI_WORD,
+ CATEGORY_UNI_NOT_WORD, CATEGORY_UNI_LINEBREAK,
+ CATEGORY_UNI_NOT_LINEBREAK
]
def makedict(list):
@@ -138,23 +147,35 @@ AT_MULTILINE = {
}
CH_LOCALE = {
- CATEGORY_DIGIT: CATEGORY_LOC_DIGIT,
- CATEGORY_NOT_DIGIT: CATEGORY_LOC_NOT_DIGIT,
- CATEGORY_SPACE: CATEGORY_LOC_SPACE,
- CATEGORY_NOT_SPACE: CATEGORY_LOC_NOT_SPACE,
+ CATEGORY_DIGIT: CATEGORY_DIGIT,
+ CATEGORY_NOT_DIGIT: CATEGORY_NOT_DIGIT,
+ CATEGORY_SPACE: CATEGORY_SPACE,
+ CATEGORY_NOT_SPACE: CATEGORY_NOT_SPACE,
CATEGORY_WORD: CATEGORY_LOC_WORD,
CATEGORY_NOT_WORD: CATEGORY_LOC_NOT_WORD,
- CATEGORY_LINEBREAK: CATEGORY_LOC_LINEBREAK,
- CATEGORY_NOT_LINEBREAK: CATEGORY_LOC_NOT_LINEBREAK
+ CATEGORY_LINEBREAK: CATEGORY_LINEBREAK,
+ CATEGORY_NOT_LINEBREAK: CATEGORY_NOT_LINEBREAK
+}
+
+CH_UNICODE = {
+ CATEGORY_DIGIT: CATEGORY_UNI_DIGIT,
+ CATEGORY_NOT_DIGIT: CATEGORY_UNI_NOT_DIGIT,
+ CATEGORY_SPACE: CATEGORY_UNI_SPACE,
+ CATEGORY_NOT_SPACE: CATEGORY_UNI_NOT_SPACE,
+ CATEGORY_WORD: CATEGORY_UNI_WORD,
+ CATEGORY_NOT_WORD: CATEGORY_UNI_NOT_WORD,
+ CATEGORY_LINEBREAK: CATEGORY_UNI_LINEBREAK,
+ CATEGORY_NOT_LINEBREAK: CATEGORY_UNI_NOT_LINEBREAK
}
# flags
-SRE_FLAG_TEMPLATE = 1 # NYI
+SRE_FLAG_TEMPLATE = 1
SRE_FLAG_IGNORECASE = 2
SRE_FLAG_LOCALE = 4
SRE_FLAG_MULTILINE = 8
SRE_FLAG_DOTALL = 16
-SRE_FLAG_VERBOSE = 32
+SRE_FLAG_UNICODE = 32
+SRE_FLAG_VERBOSE = 64
if __name__ == "__main__":
import string
@@ -168,5 +189,12 @@ if __name__ == "__main__":
dump(f, OPCODES, "SRE_OP")
dump(f, ATCODES, "SRE")
dump(f, CHCODES, "SRE")
+ f.write("#define SRE_FLAG_TEMPLATE %d\n" % SRE_FLAG_TEMPLATE)
+ f.write("#define SRE_FLAG_IGNORECASE %d\n" % SRE_FLAG_IGNORECASE)
+ f.write("#define SRE_FLAG_LOCALE %d\n" % SRE_FLAG_LOCALE)
+ f.write("#define SRE_FLAG_MULTILINE %d\n" % SRE_FLAG_MULTILINE)
+ f.write("#define SRE_FLAG_DOTALL %d\n" % SRE_FLAG_DOTALL)
+ f.write("#define SRE_FLAG_UNICODE %d\n" % SRE_FLAG_UNICODE)
+ f.write("#define SRE_FLAG_VERBOSE %d\n" % SRE_FLAG_VERBOSE)
f.close()
print "done"