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:
Dave Halter
2017-05-21 17:02:15 -04:00
parent 973f7c5f61
commit 23d1470618
8 changed files with 81 additions and 57 deletions

View File

@@ -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'])