forked from VimPlug/jedi
Remove start_parsing completely from the Parsers.
This commit is contained in:
@@ -116,7 +116,7 @@ def parse(code=None, path=None, grammar=None, error_recovery=True,
|
||||
p.source = code[:-1]
|
||||
_remove_last_newline(new_node)
|
||||
return new_node
|
||||
p = parser(grammar, code, start_parsing=False, **kwargs)
|
||||
p = parser(grammar, code, **kwargs)
|
||||
new_node = p.parse(tokens=tokens)
|
||||
if added_newline:
|
||||
_remove_last_newline(new_node)
|
||||
|
||||
@@ -377,7 +377,6 @@ class DiffParser(object):
|
||||
self._active_parser = ParserWithRecovery(
|
||||
self._grammar,
|
||||
source='\n',
|
||||
start_parsing=False
|
||||
)
|
||||
return self._active_parser.parse(tokens=tokens)
|
||||
|
||||
|
||||
@@ -39,10 +39,8 @@ class Parser(BaseParser):
|
||||
}
|
||||
default_node = tree.PythonNode
|
||||
|
||||
def __init__(self, grammar, source, start_symbol='file_input',
|
||||
tokens=None, start_parsing=True):
|
||||
def __init__(self, grammar, source, start_symbol='file_input'):
|
||||
super(Parser, self).__init__(grammar, start_symbol)
|
||||
# Todo Remove start_parsing (with False)
|
||||
|
||||
self.source = source
|
||||
self._added_newline = False
|
||||
@@ -52,10 +50,6 @@ class Parser(BaseParser):
|
||||
self._added_newline = True
|
||||
|
||||
self.new_code = source
|
||||
if start_parsing:
|
||||
if tokens is None:
|
||||
tokens = tokenize.source_tokens(source, use_exact_op_types=True)
|
||||
self.parse(tokens)
|
||||
|
||||
def parse(self, tokens):
|
||||
node = super(Parser, self).parse(tokens)
|
||||
@@ -153,10 +147,12 @@ class ParserWithRecovery(Parser):
|
||||
:param module_path: The path of the module in the file system, may be None.
|
||||
:type module_path: str
|
||||
"""
|
||||
def __init__(self, grammar, source, module_path=None, tokens=None,
|
||||
start_parsing=True):
|
||||
self.syntax_errors = []
|
||||
def __init__(self, grammar, source, module_path=None):
|
||||
super(ParserWithRecovery, self).__init__(
|
||||
grammar, source,
|
||||
)
|
||||
|
||||
self.syntax_errors = []
|
||||
self._omit_dedent_list = []
|
||||
self._indent_counter = 0
|
||||
self._module_path = module_path
|
||||
@@ -170,10 +166,6 @@ class ParserWithRecovery(Parser):
|
||||
# if self.options["print_function"]:
|
||||
# python_grammar = pygram.python_grammar_no_print_statement
|
||||
# else:
|
||||
super(ParserWithRecovery, self).__init__(
|
||||
grammar, source,
|
||||
start_parsing=start_parsing
|
||||
)
|
||||
|
||||
def parse(self, tokens):
|
||||
root_node = super(ParserWithRecovery, self).parse(self._tokenize(tokens))
|
||||
|
||||
Reference in New Issue
Block a user