mirror of
https://github.com/davidhalter/parso.git
synced 2026-01-21 02:22:23 +08:00
Move the utility function parse to the __init__ script.
This commit is contained in:
@@ -20,4 +20,14 @@ PythonNode(simple_stmt, [PythonNode(arith_expr, [...]), <Newline: ''>])
|
||||
from parso.parser import ParserSyntaxError
|
||||
from parso.grammar import create_grammar, load_python_grammar
|
||||
|
||||
|
||||
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()
|
||||
return grammar.parse(code, **kwargs)
|
||||
|
||||
|
||||
__version__ = '0.0.2'
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
"""
|
||||
Parsers for Python
|
||||
"""
|
||||
|
||||
def parse(code, **kwargs):
|
||||
from parso import load_python_grammar
|
||||
grammar = load_python_grammar()
|
||||
return grammar.parse(code, **kwargs)
|
||||
|
||||
@@ -12,7 +12,7 @@ the input given to the parser. This is important if you are using refactoring.
|
||||
The easiest way to play with this module is to use :class:`parsing.Parser`.
|
||||
:attr:`parsing.Parser.module` holds an instance of :class:`Module`:
|
||||
|
||||
>>> from parso.python import parse
|
||||
>>> from parso import parse
|
||||
>>> parser = parse('import os')
|
||||
>>> module = parser.get_root_node()
|
||||
>>> module
|
||||
|
||||
Reference in New Issue
Block a user