MC: Save one indentation level
This commit is contained in:
parent
06a7d301e2
commit
017783a77e
|
@ -373,56 +373,56 @@ class MatchCompiler:
|
||||||
res = self.parseMatch(line, pos1)
|
res = self.parseMatch(line, pos1)
|
||||||
if res == None:
|
if res == None:
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
assert(len(res)>=3 or len(res) < 6) # assert that Token::find(simple)match has either 2, 3 or four arguments
|
|
||||||
|
|
||||||
g0 = res[0]
|
assert(len(res)>=3 or len(res) < 6) # assert that Token::find(simple)match has either 2, 3 or four arguments
|
||||||
arg1 = res[1]
|
|
||||||
pattern = res[2]
|
|
||||||
|
|
||||||
# Check for varId
|
g0 = res[0]
|
||||||
varId = None
|
arg1 = res[1]
|
||||||
if is_findmatch and g0.find("%varid%") != -1:
|
pattern = res[2]
|
||||||
if len(res) == 5:
|
|
||||||
varId = res[4]
|
|
||||||
else:
|
|
||||||
varId = res[3]
|
|
||||||
|
|
||||||
# endToken support. We resolve the overloaded type by checking if varId is used or not.
|
# Check for varId
|
||||||
# Function protoypes:
|
varId = None
|
||||||
# Token *findsimplematch(const Token *tok, const char pattern[]);
|
if is_findmatch and g0.find("%varid%") != -1:
|
||||||
# Token *findsimplematch(const Token *tok, const char pattern[], const Token *end);
|
if len(res) == 5:
|
||||||
# Token *findmatch(const Token *tok, const char pattern[], unsigned int varId = 0);
|
varId = res[4]
|
||||||
# Token *findmatch(const Token *tok, const char pattern[], const Token *end, unsigned int varId = 0);
|
|
||||||
endToken = None
|
|
||||||
if is_findmatch == False and len(res) == 4:
|
|
||||||
endToken = res[3]
|
|
||||||
elif is_findmatch == True:
|
|
||||||
if varId and len(res) == 5:
|
|
||||||
endToken = res[3]
|
|
||||||
elif varId == None and len(res) == 4:
|
|
||||||
endToken = res[3]
|
|
||||||
|
|
||||||
res = re.match(r'\s*"([^"]*)"\s*$', pattern)
|
|
||||||
if res == None:
|
|
||||||
break # Non-const pattern - bailout
|
|
||||||
else:
|
else:
|
||||||
pattern = res.group(1)
|
varId = res[3]
|
||||||
a3 = ''
|
|
||||||
if endToken:
|
|
||||||
a3 += ',' + endToken
|
|
||||||
if varId:
|
|
||||||
a3 += ',' + varId
|
|
||||||
|
|
||||||
# Compile function or use previously compiled one
|
# endToken support. We resolve the overloaded type by checking if varId is used or not.
|
||||||
findMatchNumber = self._lookupMatchFunctionId(pattern, endToken, varId, True)
|
# Function protoypes:
|
||||||
|
# Token *findsimplematch(const Token *tok, const char pattern[]);
|
||||||
|
# Token *findsimplematch(const Token *tok, const char pattern[], const Token *end);
|
||||||
|
# Token *findmatch(const Token *tok, const char pattern[], unsigned int varId = 0);
|
||||||
|
# Token *findmatch(const Token *tok, const char pattern[], const Token *end, unsigned int varId = 0);
|
||||||
|
endToken = None
|
||||||
|
if is_findmatch == False and len(res) == 4:
|
||||||
|
endToken = res[3]
|
||||||
|
elif is_findmatch == True:
|
||||||
|
if varId and len(res) == 5:
|
||||||
|
endToken = res[3]
|
||||||
|
elif varId == None and len(res) == 4:
|
||||||
|
endToken = res[3]
|
||||||
|
|
||||||
if findMatchNumber == None:
|
res = re.match(r'\s*"([^"]*)"\s*$', pattern)
|
||||||
findMatchNumber = len(self._rawMatchFunctions) + 1
|
if res == None:
|
||||||
self._insertMatchFunctionId(findMatchNumber, pattern, endToken, varId, True)
|
break # Non-const pattern - bailout
|
||||||
self._rawMatchFunctions.append(self._compileFindPattern(pattern, findMatchNumber, endToken, varId))
|
|
||||||
|
|
||||||
line = line[:pos1]+'findmatch'+str(findMatchNumber)+'('+arg1+a3+')'+line[pos1+len(g0):]
|
pattern = res.group(1)
|
||||||
|
a3 = ''
|
||||||
|
if endToken:
|
||||||
|
a3 += ',' + endToken
|
||||||
|
if varId:
|
||||||
|
a3 += ',' + varId
|
||||||
|
|
||||||
|
# Compile function or use previously compiled one
|
||||||
|
findMatchNumber = self._lookupMatchFunctionId(pattern, endToken, varId, True)
|
||||||
|
|
||||||
|
if findMatchNumber == None:
|
||||||
|
findMatchNumber = len(self._rawMatchFunctions) + 1
|
||||||
|
self._insertMatchFunctionId(findMatchNumber, pattern, endToken, varId, True)
|
||||||
|
self._rawMatchFunctions.append(self._compileFindPattern(pattern, findMatchNumber, endToken, varId))
|
||||||
|
|
||||||
|
line = line[:pos1]+'findmatch'+str(findMatchNumber)+'('+arg1+a3+')'+line[pos1+len(g0):]
|
||||||
|
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue