summaryrefslogtreecommitdiff
path: root/Lib/sre_constants.py
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2000-06-30 10:41:31 +0000
committerFredrik Lundh <fredrik@pythonware.com>2000-06-30 10:41:31 +0000
commitd3ec25727faca271df0071538026adb104bec619 (patch)
treebfa276ed69782723981b4f25660eed0ad72db58d /Lib/sre_constants.py
parent355f850398acf06c0fb27b5b514c77ccb4ba86ce (diff)
downloadcpython-d3ec25727faca271df0071538026adb104bec619.tar.gz
- fixed lookahead assertions (#10, #11, #12)
- untabified sre_constants.py
Diffstat (limited to 'Lib/sre_constants.py')
-rw-r--r--Lib/sre_constants.py32
1 files changed, 24 insertions, 8 deletions
diff --git a/Lib/sre_constants.py b/Lib/sre_constants.py
index f5e7894e3b..45f4f482d2 100644
--- a/Lib/sre_constants.py
+++ b/Lib/sre_constants.py
@@ -23,6 +23,7 @@ SUCCESS = "success"
ANY = "any"
ASSERT = "assert"
+ASSERT_NOT = "assert_not"
AT = "at"
BRANCH = "branch"
CALL = "call"
@@ -81,7 +82,7 @@ OPCODES = [
FAILURE, SUCCESS,
ANY,
- ASSERT,
+ ASSERT, ASSERT_NOT,
AT,
BRANCH,
CALL,
@@ -121,8 +122,8 @@ def makedict(list):
d = {}
i = 0
for item in list:
- d[item] = i
- i = i + 1
+ d[item] = i
+ i = i + 1
return d
OPCODES = makedict(OPCODES)
@@ -176,12 +177,27 @@ SRE_FLAG_VERBOSE = 64
if __name__ == "__main__":
import string
def dump(f, d, prefix):
- items = d.items()
- items.sort(lambda a, b: cmp(a[1], b[1]))
- for k, v in items:
- f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v))
+ items = d.items()
+ items.sort(lambda a, b: cmp(a[1], b[1]))
+ for k, v in items:
+ f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v))
f = open("sre_constants.h", "w")
- f.write("/* generated from sre_constants.py */\n")
+ f.write("""\
+/*
+ * Secret Labs' Regular Expression Engine
+ *
+ * regular expression matching engine
+ *
+ * NOTE: This file is generated by sre_constants.py. If you need
+ * to change anything in here, edit sre_constants.py and run it.
+ *
+ * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved.
+ *
+ * See the _sre.c file for information on usage and redistribution.
+ */
+
+""")
+
dump(f, OPCODES, "SRE_OP")
dump(f, ATCODES, "SRE")
dump(f, CHCODES, "SRE")