Grammar versioning has now a smoother interface.
This commit is contained in:
1 parent
a373e34229
commit
eb2e41f771
4 files changed
+11
-9
No files matched your search
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user