Skip to content
Snippets Groups Projects
Commit 69b373c6 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Fixed a couple of typos.

parent 20b9b778
No related branches found
No related tags found
No related merge requests found
......@@ -74,10 +74,9 @@ class SimpleMatcher(object):
defLine=0,
defFile='',
coverageIgnore=False, # mark line as ignored in coverage analysis
endAction = None, # A function that is called when this SimpleMatcher finishes
onClose = None, # A dictionary of onClose callbacks that are specific to this SimpleMatcher
onOpen = None, # A dictionary of onOpen callbacks that are specific to this SimpleMatcher
startReTransform = None, # A callback function that is called with the groups that were matched from the startReStr.
startReAction = None, # A callback function that is called when the starting regex is matcher. If the regex has any capturing groups, they will be provided as well to this function as parameter called "groups".
):
self.index = -1
self.startReStr = startReStr
......@@ -99,10 +98,9 @@ class SimpleMatcher(object):
self.name = name
self.fixedStartValues = fixedStartValues
self.fixedEndValues = fixedEndValues
self.endAction = endAction
self.onClose = onClose
self.onOpen = onOpen
self.startReTransform = startReTransform
self.startReAction = startReAction
self.keep = False # Boolean flag used by the ParserOptimizer to determine which SimpleMatchers to keep
# boolean flag to signal that this SimpleMatcher does not have any
# effect (besides progressing input file):
......@@ -110,14 +108,13 @@ class SimpleMatcher(object):
# - no submatchers
# - no adHoc
# - no sections
# - no endActions
# - no startReActions
self.does_nothing = (len(subMatchers) == 0 and
len(sections) == 0 and
fixedStartValues is None and
fixedEndValues is None and
adHoc is None and
endAction is None and
startReTransform is None)
startReAction is None)
if self.does_nothing:
if startReStr is not None and len(extractGroupNames(startReStr))>0:
self.does_nothing = False
......@@ -171,10 +168,9 @@ class SimpleMatcher(object):
dependencies = self.dependencies,
defLine = self.defLine,
defFile = self.defFile,
endAction = self.endAction,
onClose = self.onClose,
onOpen = self.onOpen,
startReTransform = self.startReTransform,
startReAction = self.startReAction,
)
simpleMatcher.keep = self.keep
return simpleMatcher
......@@ -349,9 +345,9 @@ def disableGroups(regex):
else:
raise Exception('unexpected character sequence "(P%s"' % c)
elif c in 'im':
if c == 'i':
if c == 'i':
flags += 'i'
res += regexp[i : j - 3]
res += regex[i : j - 3]
while j < l:
c = regex[j]
j += 1
......@@ -365,14 +361,14 @@ def disableGroups(regex):
elif c in 'Lsux':
raise Exception('Regexp flag %s is not supported by disableGroups' % c)
elif c == '#':
res += regexp[i]
j = closingParen(regexp, j, 1)
res += regex[i]
j = closingParen(regex, j, 1)
i = j
elif c in '=!':
pass
elif c == '<':
if j < l:
c = regexp[j]
c = regex[j]
j += 1
if c in '=!':
raise Exception("Regexp sequence (?<%s...) unknwon" % c)
......@@ -634,8 +630,8 @@ class CompiledMatcher(object):
result_dict = {}
# If a separate transform function was defined in the matcher, call it
if self.matcher.startReTransform is not None:
self.matcher.startReTransform(parser.backend, m.groups())
if self.matcher.startReAction is not None:
self.matcher.startReAction(parser.backend, m.groups())
for k, v in sorted(m.groupdict().items()):
if v is None:
......@@ -1154,12 +1150,6 @@ class SimpleParser(object):
def contextPop(self):
cNow = self.context.pop()
# Handle end action before closing sections
# Call the end action
if cNow.compiledMatcher.matcher.endAction:
cNow.compiledMatcher.matcher.endAction()
self.contextClose(cNow)
def contextDesc(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment