Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../lib64/python2....
File: sre_parse.py
#
[0] Fix | Delete
# Secret Labs' Regular Expression Engine
[1] Fix | Delete
#
[2] Fix | Delete
# convert re-style regular expression to sre pattern
[3] Fix | Delete
#
[4] Fix | Delete
# Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved.
[5] Fix | Delete
#
[6] Fix | Delete
# See the sre.py file for information on usage and redistribution.
[7] Fix | Delete
#
[8] Fix | Delete
[9] Fix | Delete
"""Internal support module for sre"""
[10] Fix | Delete
[11] Fix | Delete
# XXX: show string offset and offending character for all errors
[12] Fix | Delete
[13] Fix | Delete
import sys
[14] Fix | Delete
[15] Fix | Delete
from sre_constants import *
[16] Fix | Delete
[17] Fix | Delete
SPECIAL_CHARS = ".\\[{()*+?^$|"
[18] Fix | Delete
REPEAT_CHARS = "*+?{"
[19] Fix | Delete
[20] Fix | Delete
DIGITS = set("0123456789")
[21] Fix | Delete
[22] Fix | Delete
OCTDIGITS = set("01234567")
[23] Fix | Delete
HEXDIGITS = set("0123456789abcdefABCDEF")
[24] Fix | Delete
ASCIILETTERS = set("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
[25] Fix | Delete
[26] Fix | Delete
WHITESPACE = set(" \t\n\r\v\f")
[27] Fix | Delete
[28] Fix | Delete
ESCAPES = {
[29] Fix | Delete
r"\a": (LITERAL, ord("\a")),
[30] Fix | Delete
r"\b": (LITERAL, ord("\b")),
[31] Fix | Delete
r"\f": (LITERAL, ord("\f")),
[32] Fix | Delete
r"\n": (LITERAL, ord("\n")),
[33] Fix | Delete
r"\r": (LITERAL, ord("\r")),
[34] Fix | Delete
r"\t": (LITERAL, ord("\t")),
[35] Fix | Delete
r"\v": (LITERAL, ord("\v")),
[36] Fix | Delete
r"\\": (LITERAL, ord("\\"))
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
CATEGORIES = {
[40] Fix | Delete
r"\A": (AT, AT_BEGINNING_STRING), # start of string
[41] Fix | Delete
r"\b": (AT, AT_BOUNDARY),
[42] Fix | Delete
r"\B": (AT, AT_NON_BOUNDARY),
[43] Fix | Delete
r"\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]),
[44] Fix | Delete
r"\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]),
[45] Fix | Delete
r"\s": (IN, [(CATEGORY, CATEGORY_SPACE)]),
[46] Fix | Delete
r"\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]),
[47] Fix | Delete
r"\w": (IN, [(CATEGORY, CATEGORY_WORD)]),
[48] Fix | Delete
r"\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]),
[49] Fix | Delete
r"\Z": (AT, AT_END_STRING), # end of string
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
FLAGS = {
[53] Fix | Delete
# standard flags
[54] Fix | Delete
"i": SRE_FLAG_IGNORECASE,
[55] Fix | Delete
"L": SRE_FLAG_LOCALE,
[56] Fix | Delete
"m": SRE_FLAG_MULTILINE,
[57] Fix | Delete
"s": SRE_FLAG_DOTALL,
[58] Fix | Delete
"x": SRE_FLAG_VERBOSE,
[59] Fix | Delete
# extensions
[60] Fix | Delete
"t": SRE_FLAG_TEMPLATE,
[61] Fix | Delete
"u": SRE_FLAG_UNICODE,
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
class Pattern:
[65] Fix | Delete
# master pattern object. keeps track of global attributes
[66] Fix | Delete
def __init__(self):
[67] Fix | Delete
self.flags = 0
[68] Fix | Delete
self.open = []
[69] Fix | Delete
self.groups = 1
[70] Fix | Delete
self.groupdict = {}
[71] Fix | Delete
self.lookbehind = 0
[72] Fix | Delete
[73] Fix | Delete
def opengroup(self, name=None):
[74] Fix | Delete
gid = self.groups
[75] Fix | Delete
self.groups = gid + 1
[76] Fix | Delete
if name is not None:
[77] Fix | Delete
ogid = self.groupdict.get(name, None)
[78] Fix | Delete
if ogid is not None:
[79] Fix | Delete
raise error, ("redefinition of group name %s as group %d; "
[80] Fix | Delete
"was group %d" % (repr(name), gid, ogid))
[81] Fix | Delete
self.groupdict[name] = gid
[82] Fix | Delete
self.open.append(gid)
[83] Fix | Delete
return gid
[84] Fix | Delete
def closegroup(self, gid):
[85] Fix | Delete
self.open.remove(gid)
[86] Fix | Delete
def checkgroup(self, gid):
[87] Fix | Delete
return gid < self.groups and gid not in self.open
[88] Fix | Delete
[89] Fix | Delete
class SubPattern:
[90] Fix | Delete
# a subpattern, in intermediate form
[91] Fix | Delete
def __init__(self, pattern, data=None):
[92] Fix | Delete
self.pattern = pattern
[93] Fix | Delete
if data is None:
[94] Fix | Delete
data = []
[95] Fix | Delete
self.data = data
[96] Fix | Delete
self.width = None
[97] Fix | Delete
def dump(self, level=0):
[98] Fix | Delete
seqtypes = (tuple, list)
[99] Fix | Delete
for op, av in self.data:
[100] Fix | Delete
print level*" " + op,
[101] Fix | Delete
if op == IN:
[102] Fix | Delete
# member sublanguage
[103] Fix | Delete
print
[104] Fix | Delete
for op, a in av:
[105] Fix | Delete
print (level+1)*" " + op, a
[106] Fix | Delete
elif op == BRANCH:
[107] Fix | Delete
print
[108] Fix | Delete
for i, a in enumerate(av[1]):
[109] Fix | Delete
if i:
[110] Fix | Delete
print level*" " + "or"
[111] Fix | Delete
a.dump(level+1)
[112] Fix | Delete
elif op == GROUPREF_EXISTS:
[113] Fix | Delete
condgroup, item_yes, item_no = av
[114] Fix | Delete
print condgroup
[115] Fix | Delete
item_yes.dump(level+1)
[116] Fix | Delete
if item_no:
[117] Fix | Delete
print level*" " + "else"
[118] Fix | Delete
item_no.dump(level+1)
[119] Fix | Delete
elif isinstance(av, seqtypes):
[120] Fix | Delete
nl = 0
[121] Fix | Delete
for a in av:
[122] Fix | Delete
if isinstance(a, SubPattern):
[123] Fix | Delete
if not nl:
[124] Fix | Delete
print
[125] Fix | Delete
a.dump(level+1)
[126] Fix | Delete
nl = 1
[127] Fix | Delete
else:
[128] Fix | Delete
print a,
[129] Fix | Delete
nl = 0
[130] Fix | Delete
if not nl:
[131] Fix | Delete
print
[132] Fix | Delete
else:
[133] Fix | Delete
print av
[134] Fix | Delete
def __repr__(self):
[135] Fix | Delete
return repr(self.data)
[136] Fix | Delete
def __len__(self):
[137] Fix | Delete
return len(self.data)
[138] Fix | Delete
def __delitem__(self, index):
[139] Fix | Delete
del self.data[index]
[140] Fix | Delete
def __getitem__(self, index):
[141] Fix | Delete
if isinstance(index, slice):
[142] Fix | Delete
return SubPattern(self.pattern, self.data[index])
[143] Fix | Delete
return self.data[index]
[144] Fix | Delete
def __setitem__(self, index, code):
[145] Fix | Delete
self.data[index] = code
[146] Fix | Delete
def insert(self, index, code):
[147] Fix | Delete
self.data.insert(index, code)
[148] Fix | Delete
def append(self, code):
[149] Fix | Delete
self.data.append(code)
[150] Fix | Delete
def getwidth(self):
[151] Fix | Delete
# determine the width (min, max) for this subpattern
[152] Fix | Delete
if self.width:
[153] Fix | Delete
return self.width
[154] Fix | Delete
lo = hi = 0
[155] Fix | Delete
UNITCODES = (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY)
[156] Fix | Delete
REPEATCODES = (MIN_REPEAT, MAX_REPEAT)
[157] Fix | Delete
for op, av in self.data:
[158] Fix | Delete
if op is BRANCH:
[159] Fix | Delete
i = MAXREPEAT - 1
[160] Fix | Delete
j = 0
[161] Fix | Delete
for av in av[1]:
[162] Fix | Delete
l, h = av.getwidth()
[163] Fix | Delete
i = min(i, l)
[164] Fix | Delete
j = max(j, h)
[165] Fix | Delete
lo = lo + i
[166] Fix | Delete
hi = hi + j
[167] Fix | Delete
elif op is CALL:
[168] Fix | Delete
i, j = av.getwidth()
[169] Fix | Delete
lo = lo + i
[170] Fix | Delete
hi = hi + j
[171] Fix | Delete
elif op is SUBPATTERN:
[172] Fix | Delete
i, j = av[1].getwidth()
[173] Fix | Delete
lo = lo + i
[174] Fix | Delete
hi = hi + j
[175] Fix | Delete
elif op in REPEATCODES:
[176] Fix | Delete
i, j = av[2].getwidth()
[177] Fix | Delete
lo = lo + i * av[0]
[178] Fix | Delete
hi = hi + j * av[1]
[179] Fix | Delete
elif op in UNITCODES:
[180] Fix | Delete
lo = lo + 1
[181] Fix | Delete
hi = hi + 1
[182] Fix | Delete
elif op == SUCCESS:
[183] Fix | Delete
break
[184] Fix | Delete
self.width = min(lo, MAXREPEAT - 1), min(hi, MAXREPEAT)
[185] Fix | Delete
return self.width
[186] Fix | Delete
[187] Fix | Delete
class Tokenizer:
[188] Fix | Delete
def __init__(self, string):
[189] Fix | Delete
self.string = string
[190] Fix | Delete
self.index = 0
[191] Fix | Delete
self.__next()
[192] Fix | Delete
def __next(self):
[193] Fix | Delete
if self.index >= len(self.string):
[194] Fix | Delete
self.next = None
[195] Fix | Delete
return
[196] Fix | Delete
char = self.string[self.index]
[197] Fix | Delete
if char[0] == "\\":
[198] Fix | Delete
try:
[199] Fix | Delete
c = self.string[self.index + 1]
[200] Fix | Delete
except IndexError:
[201] Fix | Delete
raise error, "bogus escape (end of line)"
[202] Fix | Delete
char = char + c
[203] Fix | Delete
self.index = self.index + len(char)
[204] Fix | Delete
self.next = char
[205] Fix | Delete
def match(self, char, skip=1):
[206] Fix | Delete
if char == self.next:
[207] Fix | Delete
if skip:
[208] Fix | Delete
self.__next()
[209] Fix | Delete
return 1
[210] Fix | Delete
return 0
[211] Fix | Delete
def get(self):
[212] Fix | Delete
this = self.next
[213] Fix | Delete
self.__next()
[214] Fix | Delete
return this
[215] Fix | Delete
def tell(self):
[216] Fix | Delete
return self.index, self.next
[217] Fix | Delete
def seek(self, index):
[218] Fix | Delete
self.index, self.next = index
[219] Fix | Delete
[220] Fix | Delete
def isident(char):
[221] Fix | Delete
return "a" <= char <= "z" or "A" <= char <= "Z" or char == "_"
[222] Fix | Delete
[223] Fix | Delete
def isdigit(char):
[224] Fix | Delete
return "0" <= char <= "9"
[225] Fix | Delete
[226] Fix | Delete
def isname(name):
[227] Fix | Delete
# check that group name is a valid string
[228] Fix | Delete
if not isident(name[0]):
[229] Fix | Delete
return False
[230] Fix | Delete
for char in name[1:]:
[231] Fix | Delete
if not isident(char) and not isdigit(char):
[232] Fix | Delete
return False
[233] Fix | Delete
return True
[234] Fix | Delete
[235] Fix | Delete
def _class_escape(source, escape, nested):
[236] Fix | Delete
# handle escape code inside character class
[237] Fix | Delete
code = ESCAPES.get(escape)
[238] Fix | Delete
if code:
[239] Fix | Delete
return code
[240] Fix | Delete
code = CATEGORIES.get(escape)
[241] Fix | Delete
if code and code[0] == IN:
[242] Fix | Delete
return code
[243] Fix | Delete
try:
[244] Fix | Delete
c = escape[1:2]
[245] Fix | Delete
if c == "x":
[246] Fix | Delete
# hexadecimal escape (exactly two digits)
[247] Fix | Delete
while source.next in HEXDIGITS and len(escape) < 4:
[248] Fix | Delete
escape = escape + source.get()
[249] Fix | Delete
escape = escape[2:]
[250] Fix | Delete
if len(escape) != 2:
[251] Fix | Delete
raise error, "bogus escape: %s" % repr("\\" + escape)
[252] Fix | Delete
return LITERAL, int(escape, 16) & 0xff
[253] Fix | Delete
elif c in OCTDIGITS:
[254] Fix | Delete
# octal escape (up to three digits)
[255] Fix | Delete
while source.next in OCTDIGITS and len(escape) < 4:
[256] Fix | Delete
escape = escape + source.get()
[257] Fix | Delete
escape = escape[1:]
[258] Fix | Delete
return LITERAL, int(escape, 8) & 0xff
[259] Fix | Delete
elif c in DIGITS:
[260] Fix | Delete
raise error, "bogus escape: %s" % repr(escape)
[261] Fix | Delete
if len(escape) == 2:
[262] Fix | Delete
if sys.py3kwarning and c in ASCIILETTERS:
[263] Fix | Delete
import warnings
[264] Fix | Delete
if c in 'Uu':
[265] Fix | Delete
warnings.warn('bad escape %s; Unicode escapes are '
[266] Fix | Delete
'supported only since Python 3.3' % escape,
[267] Fix | Delete
FutureWarning, stacklevel=nested + 6)
[268] Fix | Delete
else:
[269] Fix | Delete
warnings.warnpy3k('bad escape %s' % escape,
[270] Fix | Delete
DeprecationWarning, stacklevel=nested + 6)
[271] Fix | Delete
return LITERAL, ord(escape[1])
[272] Fix | Delete
except ValueError:
[273] Fix | Delete
pass
[274] Fix | Delete
raise error, "bogus escape: %s" % repr(escape)
[275] Fix | Delete
[276] Fix | Delete
def _escape(source, escape, state, nested):
[277] Fix | Delete
# handle escape code in expression
[278] Fix | Delete
code = CATEGORIES.get(escape)
[279] Fix | Delete
if code:
[280] Fix | Delete
return code
[281] Fix | Delete
code = ESCAPES.get(escape)
[282] Fix | Delete
if code:
[283] Fix | Delete
return code
[284] Fix | Delete
try:
[285] Fix | Delete
c = escape[1:2]
[286] Fix | Delete
if c == "x":
[287] Fix | Delete
# hexadecimal escape
[288] Fix | Delete
while source.next in HEXDIGITS and len(escape) < 4:
[289] Fix | Delete
escape = escape + source.get()
[290] Fix | Delete
if len(escape) != 4:
[291] Fix | Delete
raise ValueError
[292] Fix | Delete
return LITERAL, int(escape[2:], 16) & 0xff
[293] Fix | Delete
elif c == "0":
[294] Fix | Delete
# octal escape
[295] Fix | Delete
while source.next in OCTDIGITS and len(escape) < 4:
[296] Fix | Delete
escape = escape + source.get()
[297] Fix | Delete
return LITERAL, int(escape[1:], 8) & 0xff
[298] Fix | Delete
elif c in DIGITS:
[299] Fix | Delete
# octal escape *or* decimal group reference (sigh)
[300] Fix | Delete
if source.next in DIGITS:
[301] Fix | Delete
escape = escape + source.get()
[302] Fix | Delete
if (escape[1] in OCTDIGITS and escape[2] in OCTDIGITS and
[303] Fix | Delete
source.next in OCTDIGITS):
[304] Fix | Delete
# got three octal digits; this is an octal escape
[305] Fix | Delete
escape = escape + source.get()
[306] Fix | Delete
return LITERAL, int(escape[1:], 8) & 0xff
[307] Fix | Delete
# not an octal escape, so this is a group reference
[308] Fix | Delete
group = int(escape[1:])
[309] Fix | Delete
if group < state.groups:
[310] Fix | Delete
if not state.checkgroup(group):
[311] Fix | Delete
raise error, "cannot refer to open group"
[312] Fix | Delete
if state.lookbehind:
[313] Fix | Delete
import warnings
[314] Fix | Delete
warnings.warn('group references in lookbehind '
[315] Fix | Delete
'assertions are not supported',
[316] Fix | Delete
RuntimeWarning, stacklevel=nested + 6)
[317] Fix | Delete
return GROUPREF, group
[318] Fix | Delete
raise ValueError
[319] Fix | Delete
if len(escape) == 2:
[320] Fix | Delete
if sys.py3kwarning and c in ASCIILETTERS:
[321] Fix | Delete
import warnings
[322] Fix | Delete
if c in 'Uu':
[323] Fix | Delete
warnings.warn('bad escape %s; Unicode escapes are '
[324] Fix | Delete
'supported only since Python 3.3' % escape,
[325] Fix | Delete
FutureWarning, stacklevel=nested + 6)
[326] Fix | Delete
else:
[327] Fix | Delete
warnings.warnpy3k('bad escape %s' % escape,
[328] Fix | Delete
DeprecationWarning, stacklevel=nested + 6)
[329] Fix | Delete
return LITERAL, ord(escape[1])
[330] Fix | Delete
except ValueError:
[331] Fix | Delete
pass
[332] Fix | Delete
raise error, "bogus escape: %s" % repr(escape)
[333] Fix | Delete
[334] Fix | Delete
def _parse_sub(source, state, nested):
[335] Fix | Delete
# parse an alternation: a|b|c
[336] Fix | Delete
[337] Fix | Delete
items = []
[338] Fix | Delete
itemsappend = items.append
[339] Fix | Delete
sourcematch = source.match
[340] Fix | Delete
while 1:
[341] Fix | Delete
itemsappend(_parse(source, state, nested + 1))
[342] Fix | Delete
if sourcematch("|"):
[343] Fix | Delete
continue
[344] Fix | Delete
if not nested:
[345] Fix | Delete
break
[346] Fix | Delete
if not source.next or sourcematch(")", 0):
[347] Fix | Delete
break
[348] Fix | Delete
else:
[349] Fix | Delete
raise error, "pattern not properly closed"
[350] Fix | Delete
[351] Fix | Delete
if len(items) == 1:
[352] Fix | Delete
return items[0]
[353] Fix | Delete
[354] Fix | Delete
subpattern = SubPattern(state)
[355] Fix | Delete
subpatternappend = subpattern.append
[356] Fix | Delete
[357] Fix | Delete
# check if all items share a common prefix
[358] Fix | Delete
while 1:
[359] Fix | Delete
prefix = None
[360] Fix | Delete
for item in items:
[361] Fix | Delete
if not item:
[362] Fix | Delete
break
[363] Fix | Delete
if prefix is None:
[364] Fix | Delete
prefix = item[0]
[365] Fix | Delete
elif item[0] != prefix:
[366] Fix | Delete
break
[367] Fix | Delete
else:
[368] Fix | Delete
# all subitems start with a common "prefix".
[369] Fix | Delete
# move it out of the branch
[370] Fix | Delete
for item in items:
[371] Fix | Delete
del item[0]
[372] Fix | Delete
subpatternappend(prefix)
[373] Fix | Delete
continue # check next one
[374] Fix | Delete
break
[375] Fix | Delete
[376] Fix | Delete
# check if the branch can be replaced by a character set
[377] Fix | Delete
for item in items:
[378] Fix | Delete
if len(item) != 1 or item[0][0] != LITERAL:
[379] Fix | Delete
break
[380] Fix | Delete
else:
[381] Fix | Delete
# we can store this as a character set instead of a
[382] Fix | Delete
# branch (the compiler may optimize this even more)
[383] Fix | Delete
set = []
[384] Fix | Delete
setappend = set.append
[385] Fix | Delete
for item in items:
[386] Fix | Delete
setappend(item[0])
[387] Fix | Delete
subpatternappend((IN, set))
[388] Fix | Delete
return subpattern
[389] Fix | Delete
[390] Fix | Delete
subpattern.append((BRANCH, (None, items)))
[391] Fix | Delete
return subpattern
[392] Fix | Delete
[393] Fix | Delete
def _parse_sub_cond(source, state, condgroup, nested):
[394] Fix | Delete
item_yes = _parse(source, state, nested + 1)
[395] Fix | Delete
if source.match("|"):
[396] Fix | Delete
item_no = _parse(source, state, nested + 1)
[397] Fix | Delete
if source.match("|"):
[398] Fix | Delete
raise error, "conditional backref with more than two branches"
[399] Fix | Delete
else:
[400] Fix | Delete
item_no = None
[401] Fix | Delete
if source.next and not source.match(")", 0):
[402] Fix | Delete
raise error, "pattern not properly closed"
[403] Fix | Delete
subpattern = SubPattern(state)
[404] Fix | Delete
subpattern.append((GROUPREF_EXISTS, (condgroup, item_yes, item_no)))
[405] Fix | Delete
return subpattern
[406] Fix | Delete
[407] Fix | Delete
_PATTERNENDERS = set("|)")
[408] Fix | Delete
_ASSERTCHARS = set("=!<")
[409] Fix | Delete
_LOOKBEHINDASSERTCHARS = set("=!")
[410] Fix | Delete
_REPEATCODES = set([MIN_REPEAT, MAX_REPEAT])
[411] Fix | Delete
[412] Fix | Delete
def _parse(source, state, nested):
[413] Fix | Delete
# parse a simple pattern
[414] Fix | Delete
subpattern = SubPattern(state)
[415] Fix | Delete
[416] Fix | Delete
# precompute constants into local variables
[417] Fix | Delete
subpatternappend = subpattern.append
[418] Fix | Delete
sourceget = source.get
[419] Fix | Delete
sourcematch = source.match
[420] Fix | Delete
_len = len
[421] Fix | Delete
PATTERNENDERS = _PATTERNENDERS
[422] Fix | Delete
ASSERTCHARS = _ASSERTCHARS
[423] Fix | Delete
LOOKBEHINDASSERTCHARS = _LOOKBEHINDASSERTCHARS
[424] Fix | Delete
REPEATCODES = _REPEATCODES
[425] Fix | Delete
[426] Fix | Delete
while 1:
[427] Fix | Delete
[428] Fix | Delete
if source.next in PATTERNENDERS:
[429] Fix | Delete
break # end of subpattern
[430] Fix | Delete
this = sourceget()
[431] Fix | Delete
if this is None:
[432] Fix | Delete
break # end of pattern
[433] Fix | Delete
[434] Fix | Delete
if state.flags & SRE_FLAG_VERBOSE:
[435] Fix | Delete
# skip whitespace and comments
[436] Fix | Delete
if this in WHITESPACE:
[437] Fix | Delete
continue
[438] Fix | Delete
if this == "#":
[439] Fix | Delete
while 1:
[440] Fix | Delete
this = sourceget()
[441] Fix | Delete
if this in (None, "\n"):
[442] Fix | Delete
break
[443] Fix | Delete
continue
[444] Fix | Delete
[445] Fix | Delete
if this and this[0] not in SPECIAL_CHARS:
[446] Fix | Delete
subpatternappend((LITERAL, ord(this)))
[447] Fix | Delete
[448] Fix | Delete
elif this == "[":
[449] Fix | Delete
# character set
[450] Fix | Delete
set = []
[451] Fix | Delete
setappend = set.append
[452] Fix | Delete
## if sourcematch(":"):
[453] Fix | Delete
## pass # handle character classes
[454] Fix | Delete
if sourcematch("^"):
[455] Fix | Delete
setappend((NEGATE, None))
[456] Fix | Delete
# check remaining characters
[457] Fix | Delete
start = set[:]
[458] Fix | Delete
while 1:
[459] Fix | Delete
this = sourceget()
[460] Fix | Delete
if this == "]" and set != start:
[461] Fix | Delete
break
[462] Fix | Delete
elif this and this[0] == "\\":
[463] Fix | Delete
code1 = _class_escape(source, this, nested + 1)
[464] Fix | Delete
elif this:
[465] Fix | Delete
code1 = LITERAL, ord(this)
[466] Fix | Delete
else:
[467] Fix | Delete
raise error, "unexpected end of regular expression"
[468] Fix | Delete
if sourcematch("-"):
[469] Fix | Delete
# potential range
[470] Fix | Delete
this = sourceget()
[471] Fix | Delete
if this == "]":
[472] Fix | Delete
if code1[0] is IN:
[473] Fix | Delete
code1 = code1[1][0]
[474] Fix | Delete
setappend(code1)
[475] Fix | Delete
setappend((LITERAL, ord("-")))
[476] Fix | Delete
break
[477] Fix | Delete
elif this:
[478] Fix | Delete
if this[0] == "\\":
[479] Fix | Delete
code2 = _class_escape(source, this, nested + 1)
[480] Fix | Delete
else:
[481] Fix | Delete
code2 = LITERAL, ord(this)
[482] Fix | Delete
if code1[0] != LITERAL or code2[0] != LITERAL:
[483] Fix | Delete
raise error, "bad character range"
[484] Fix | Delete
lo = code1[1]
[485] Fix | Delete
hi = code2[1]
[486] Fix | Delete
if hi < lo:
[487] Fix | Delete
raise error, "bad character range"
[488] Fix | Delete
setappend((RANGE, (lo, hi)))
[489] Fix | Delete
else:
[490] Fix | Delete
raise error, "unexpected end of regular expression"
[491] Fix | Delete
else:
[492] Fix | Delete
if code1[0] is IN:
[493] Fix | Delete
code1 = code1[1][0]
[494] Fix | Delete
setappend(code1)
[495] Fix | Delete
[496] Fix | Delete
# XXX: <fl> should move set optimization to compiler!
[497] Fix | Delete
if _len(set)==1 and set[0][0] is LITERAL:
[498] Fix | Delete
subpatternappend(set[0]) # optimization
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function