mirror of
https://github.com/davidhalter/parso.git
synced 2026-01-21 02:22:23 +08:00
load_python_grammar -> load_grammar.
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
parso is a Python parser. It's really easy to use and supports multiple Python
|
||||
versions, file caching, round-trips and other stuff:
|
||||
|
||||
>>> from parso import load_python_grammar
|
||||
>>> grammar = load_python_grammar(version='2.7')
|
||||
>>> from parso import load_grammar
|
||||
>>> grammar = load_grammar(version='2.7')
|
||||
>>> module = grammar.parse('hello + 1')
|
||||
>>> stmt = module.children[0]
|
||||
>>> stmt
|
||||
@@ -18,7 +18,7 @@ PythonNode(simple_stmt, [PythonNode(arith_expr, [...]), <Newline: ''>])
|
||||
"""
|
||||
|
||||
from parso.parser import ParserSyntaxError
|
||||
from parso.grammar import create_grammar, load_python_grammar
|
||||
from parso.grammar import create_grammar, load_grammar
|
||||
|
||||
|
||||
__version__ = '0.0.3'
|
||||
@@ -29,5 +29,5 @@ def parse(code=None, **kwargs):
|
||||
A utility function to parse Python with the current Python version. Params
|
||||
are documented in ``Grammar.parse``.
|
||||
"""
|
||||
grammar = load_python_grammar()
|
||||
grammar = load_grammar()
|
||||
return grammar.parse(code, **kwargs)
|
||||
|
||||
@@ -131,7 +131,7 @@ def create_grammar(text, tokenizer=generate_tokens, parser=BaseParser):
|
||||
return Grammar(text, tokenizer=tokenizer, parser=parser)
|
||||
|
||||
|
||||
def load_python_grammar(version=None):
|
||||
def load_grammar(version=None):
|
||||
"""
|
||||
Loads a Python grammar. The default version is always the latest.
|
||||
|
||||
@@ -160,4 +160,4 @@ def load_python_grammar(version=None):
|
||||
return _loaded_grammars.setdefault(path, grammar)
|
||||
except FileNotFoundError:
|
||||
# Just load the default if the file does not exist.
|
||||
return load_python_grammar()
|
||||
return load_grammar()
|
||||
|
||||
Reference in New Issue
Block a user