summaryrefslogtreecommitdiffstats
path: root/Lib/sre_constants.py
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2000-06-30 10:41:31 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2000-06-30 10:41:31 (GMT)
commit43b3b49b5ab486295baef3a35cd8e836f735c065 (patch)
tree3ca960c788dafde87799443f2087dc661dc52d48 /Lib/sre_constants.py
parenta4657f736c34e4bb1802b40246028c5bec545fe6 (diff)
downloadcpython-43b3b49b5ab486295baef3a35cd8e836f735c065.zip
cpython-43b3b49b5ab486295baef3a35cd8e836f735c065.tar.gz
cpython-43b3b49b5ab486295baef3a35cd8e836f735c065.tar.bz2
- 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 f5e7894..45f4f48 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")