mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
- untabified sre_constants.py
This commit is contained in:
parent
a4657f736c
commit
43b3b49b5a
6 changed files with 146 additions and 90 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue