forked from VimPlug/jedi
Switch grammars depending on Python version.
This commit is contained in:
@@ -104,7 +104,7 @@ class Script(object):
|
|||||||
|
|
||||||
cache.clear_time_caches()
|
cache.clear_time_caches()
|
||||||
debug.reset_time()
|
debug.reset_time()
|
||||||
self._grammar = load_grammar('grammar3.4')
|
self._grammar = load_grammar('grammar%s.%s' % sys.version_info[:2])
|
||||||
self._user_context = UserContext(self.source, self._pos)
|
self._user_context = UserContext(self.source, self._pos)
|
||||||
self._parser = UserContextParser(self._grammar, self.source, path,
|
self._parser = UserContextParser(self._grammar, self.source, path,
|
||||||
self._pos, self._user_context)
|
self._pos, self._user_context)
|
||||||
|
|||||||
@@ -33,6 +33,13 @@ _loaded_grammars = {}
|
|||||||
|
|
||||||
|
|
||||||
def load_grammar(file='grammar3.4'):
|
def load_grammar(file='grammar3.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'
|
||||||
|
|
||||||
global _loaded_grammars
|
global _loaded_grammars
|
||||||
path = os.path.join(os.path.dirname(__file__), file) + '.txt'
|
path = os.path.join(os.path.dirname(__file__), file) + '.txt'
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user