Commit 3f701132 authored by Igor Dejanovic's avatar Igor Dejanovic

Fix in exception handling for in-comment NoMatches.

parent 60abc657
......@@ -1220,15 +1220,23 @@ class Parser(object):
# Do not report NoMatch for comments matching.
# Use last exception instead.
if not self._in_parse_comment or self.nm is None:
# Non-comment nm will override comment nm
if self.nm is not None:
override = self.nm._in_comment and not self._in_parse_comment
else:
override = True
if len(args) == 1 and isinstance(args[0], NoMatch):
# Do not report soft failures
if not args[0].soft:
if self.nm is None or args[0].position > self.nm.position:
if override or args[0].position > self.nm.position:
self.nm = args[0]
self.nm._in_comment = self._in_parse_comment
else:
rule, position, parser = args
if self.nm is None or position > self.nm.position:
if override or position > self.nm.position:
self.nm = NoMatch(rule, position, parser)
self.nm._in_comment = self._in_parse_comment
raise self.nm
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment