mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-25 17:58:35 +08:00
Rename ast_mapping to node_map.
This commit is contained in:
@@ -31,7 +31,7 @@ class ParserSyntaxError(Exception):
|
|||||||
|
|
||||||
|
|
||||||
class BaseParser(object):
|
class BaseParser(object):
|
||||||
ast_mapping = {}
|
node_map = {}
|
||||||
default_node = tree.Node
|
default_node = tree.Node
|
||||||
|
|
||||||
def __init__(self, grammar, start_symbol='file_input', error_recovery=False):
|
def __init__(self, grammar, start_symbol='file_input', error_recovery=False):
|
||||||
@@ -66,7 +66,7 @@ class BaseParser(object):
|
|||||||
# TODO REMOVE symbol, we don't want type here.
|
# TODO REMOVE symbol, we don't want type here.
|
||||||
symbol = grammar.number2symbol[type]
|
symbol = grammar.number2symbol[type]
|
||||||
try:
|
try:
|
||||||
return self.ast_mapping[symbol](children)
|
return self.node_map[symbol](children)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return self.default_node(symbol, children)
|
return self.default_node(symbol, children)
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from jedi.parser.parser import BaseParser
|
|||||||
|
|
||||||
|
|
||||||
class Parser(BaseParser):
|
class Parser(BaseParser):
|
||||||
ast_mapping = {
|
node_map = {
|
||||||
'expr_stmt': tree.ExprStmt,
|
'expr_stmt': tree.ExprStmt,
|
||||||
'classdef': tree.Class,
|
'classdef': tree.Class,
|
||||||
'funcdef': tree.Function,
|
'funcdef': tree.Function,
|
||||||
@@ -86,7 +86,7 @@ class Parser(BaseParser):
|
|||||||
# TODO REMOVE symbol, we don't want type here.
|
# TODO REMOVE symbol, we don't want type here.
|
||||||
symbol = grammar.number2symbol[type]
|
symbol = grammar.number2symbol[type]
|
||||||
try:
|
try:
|
||||||
return self.ast_mapping[symbol](children)
|
return self.node_map[symbol](children)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if symbol == 'suite':
|
if symbol == 'suite':
|
||||||
# We don't want the INDENT/DEDENT in our parser tree. Those
|
# We don't want the INDENT/DEDENT in our parser tree. Those
|
||||||
|
|||||||
Reference in New Issue
Block a user