1
0
forked from VimPlug/jedi

Grammar versioning has now a smoother interface.

This commit is contained in:
Dave Halter
2015-12-25 19:30:25 +01:00
parent a373e34229
commit eb2e41f771
4 changed files with 11 additions and 9 deletions

View File

@@ -41,16 +41,18 @@ class ParseError(Exception):
"""
def load_grammar(file='grammar3.4'):
def load_grammar(version='3.4'):
# For now we only support two different Python syntax versions: The latest
# Python 3 and Python 2. This may change.
if file.startswith('grammar3'):
file = 'grammar3.4'
else:
file = 'grammar2.7'
if version in ('3.2', '3.3'):
version = '3.4'
elif version == '2.6':
version == '2.7'
file = 'grammar' + version + '.txt'
global _loaded_grammars
path = os.path.join(os.path.dirname(__file__), file) + '.txt'
path = os.path.join(os.path.dirname(__file__), file)
try:
return _loaded_grammars[path]
except KeyError: