Skip to content
Snippets Groups Projects
Commit 1d76a236 authored by Henning Glawe's avatar Henning Glawe
Browse files

remove unnecessary 'try' block.

either exception is treated within mainFunction/stream, or it will kill the
parser, as it should
parent 77d950c0
No related branches found
No related tags found
No related merge requests found
from __future__ import division from __future__ import division
from future import standard_library from future import standard_library
from future.utils import raise_from
standard_library.install_aliases() standard_library.install_aliases()
from builtins import str from builtins import str
from builtins import range from builtins import range
...@@ -1061,37 +1060,33 @@ class SimpleParser(object): ...@@ -1061,37 +1060,33 @@ class SimpleParser(object):
def parseStep(self): def parseStep(self):
if not self.context: if not self.context:
return False return False
try: currentContext = self.context[len(self.context) - 1]
currentContext = self.context[len(self.context) - 1] if logger.isEnabledFor(logging.DEBUG):
if logger.isEnabledFor(logging.DEBUG): logger.debug("lineNr: %d context: %s", self.fIn.lineNr,self.contextDesc())
logger.debug("lineNr: %d context: %s", self.fIn.lineNr,self.contextDesc()) if currentContext.startEnd == ParsingContext.Start:
if currentContext.startEnd == ParsingContext.Start: nextI = currentContext.compiledMatcher.findNextMatch(self)
nextI = currentContext.compiledMatcher.findNextMatch(self) else:
else: nextI = currentContext.compiledMatcher.findNextMatchEnd(self)
nextI = currentContext.compiledMatcher.findNextMatchEnd(self) logger.debug("lineNr: %d nextI: %d", self.fIn.lineNr, nextI)
logger.debug("lineNr: %d nextI: %d", self.fIn.lineNr, nextI)
if nextI < 0:
if nextI < 0: cNames = self.contextDesc()
cNames = self.contextDesc() while self.context:
while self.context: self.contextPop()
self.contextPop() if nextI != -1 and nextI != -3:
if nextI != -1 and nextI != -3: raise Exception("finished with error with parsing context %s" % (cNames))
raise Exception("finished with error with parsing context %s" % (cNames)) else:
index = nextI // 2
startEnd = nextI % 2
matcherNew = self.parserBuilder.flatIndex[index]
self.goToMatcher(matcherNew, startEnd)
logger.debug("new context: %s\n", self.contextDesc())
currentCtx = self.context[len(self.context) - 1]
if startEnd == ParsingContext.End:
self.lastMatch = currentCtx.compiledMatcher.handleEndMatch(self)
self.contextClose(currentCtx)
else: else:
index = nextI // 2 self.lastMatch = currentCtx.compiledMatcher.handleStartMatch(self)
startEnd = nextI % 2
matcherNew = self.parserBuilder.flatIndex[index]
self.goToMatcher(matcherNew, startEnd)
logger.debug("new context: %s\n", self.contextDesc())
currentCtx = self.context[len(self.context) - 1]
if startEnd == ParsingContext.End:
self.lastMatch = currentCtx.compiledMatcher.handleEndMatch(self)
self.contextClose(currentCtx)
else:
self.lastMatch = currentCtx.compiledMatcher.handleStartMatch(self)
except Exception as e:
origin = traceback.format_exc()
raise_from(Exception("Failure, context %s, line %d coming from %s"%(self.contextDesc(), self.fIn.lineNr, origin)), e)
return len(self.context) > 0 return len(self.context) > 0
def parse(self): def parse(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment