Here is a part of code ( Parso ) in Python 3.6:
class BaseParser:
"""Parser engine.
A Parser instance contains state pertaining to the current token
sequence, and should not be used concurrently by different threads
to parse separate token sequences.
See python/tokenize.py for how to get input tokens by a string.
When a syntax error occurs, error_recovery() is called.
"""
node_map: Dict[str, type] = {}
default_node = tree.Node
leaf_map: Dict[str, type] = {}
default_leaf = tree.Leaf
def __init__(self, pgen_grammar, start_nonterminal='file_input', error_recovery=False):
self._pgen_grammar = pgen_grammar
self._start_nonterminal = start_nonterminal
self._error_recovery = error_recovery
How can I make it compatible with Python 3.3? What is the usage of leaf_map: Dict[str, type] = {}
? Can I remove it?
Dict[str, type]
is python type annotations. It has no impact in runtime and can be removed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.