mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 21:04:29 +08:00
Add a more API focused grammar.
This makes it so we don't have to expose all the details of a pgen grammar to the user.
This commit is contained in:
@@ -5,7 +5,8 @@ from textwrap import dedent
|
||||
import pytest
|
||||
|
||||
from parso._compatibility import u, py_version
|
||||
from parso.python import parse, load_grammar
|
||||
from parso.python import parse
|
||||
from parso import load_python_grammar
|
||||
from parso.python import tree
|
||||
from parso.utils import splitlines
|
||||
|
||||
@@ -112,7 +113,7 @@ def test_param_splitting():
|
||||
"""
|
||||
def check(src, result):
|
||||
# Python 2 tuple params should be ignored for now.
|
||||
grammar = load_grammar('%s.%s' % sys.version_info[:2])
|
||||
grammar = load_python_grammar('%s.%s' % sys.version_info[:2])
|
||||
m = parse(src, grammar=grammar)
|
||||
if py_version >= 30:
|
||||
assert not list(m.iter_funcdefs())
|
||||
@@ -160,10 +161,10 @@ def test_python3_octal():
|
||||
def test_load_newer_grammar():
|
||||
# This version shouldn't be out for a while, but if we somehow get this it
|
||||
# should just take the latest Python grammar.
|
||||
load_grammar('15.8')
|
||||
load_python_grammar('15.8')
|
||||
# The same is true for very old grammars (even though this is probably not
|
||||
# going to be an issue.
|
||||
load_grammar('1.5')
|
||||
load_python_grammar('1.5')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('code', ['foo "', 'foo """\n', 'foo """\nbar'])
|
||||
|
||||
Reference in New Issue
Block a user