Small refactoring.

This commit is contained in:
Dave Halter
2017-08-06 16:11:31 +02:00
parent 1a30afdd9e
commit 524f332e7d
2 changed files with 4 additions and 5 deletions

View File

@@ -21,7 +21,7 @@ class Grammar(object):
:param text: A BNF representation of your grammar.
"""
_error_finder_config = None
_error_normalizer_config = None
_default_normalizer_config = pep8.PEP8NormalizerConfig()
def __init__(self, text, tokenizer, parser=BaseParser, diff_parser=None):
@@ -161,7 +161,6 @@ class Grammar(object):
class PythonGrammar(Grammar):
_error_normalizer_config = ErrorFinderConfig()
_parser_cls = PythonParser
def __init__(self, version_info, bnf_text):
super(PythonGrammar, self).__init__(

View File

@@ -127,7 +127,7 @@ def _get_for_stmt_definition_exprs(for_stmt):
return list(_iter_definition_exprs_from_lists(exprlist))
class Context(object):
class _Context(object):
def __init__(self, node, add_syntax_error, parent_context=None):
self.node = node
self.blocks = []
@@ -245,7 +245,7 @@ class Context(object):
self.blocks.pop()
def add_context(self, node):
return Context(node, self._add_syntax_error, parent_context=self)
return _Context(node, self._add_syntax_error, parent_context=self)
def close_child_context(self, child_context):
self._nonlocal_names_in_subscopes += child_context.finalize()
@@ -266,7 +266,7 @@ class ErrorFinder(Normalizer):
parent_scope = node
else:
parent_scope = search_ancestor(node, allowed)
self._context = Context(parent_scope, self._add_syntax_error)
self._context = _Context(parent_scope, self._add_syntax_error)
self._indentation_count = 0
def visit(self, node):