1
0
forked from VimPlug/jedi

Add the grammar as an argument to saving the parser.

This makes collisions of different grammars when loading from the cache impossible.
This commit is contained in:
Dave Halter
2017-03-22 18:32:49 +01:00
parent c41bee4253
commit 26cce4d078
10 changed files with 41 additions and 34 deletions
+4 -2
View File
@@ -16,8 +16,9 @@ fallback token code OP, but the parser needs the actual token code.
"""
# Python imports
import pickle
import hashlib
class Grammar(object):
@@ -74,7 +75,7 @@ class Grammar(object):
"""
def __init__(self):
def __init__(self, bnf_text):
self.symbol2number = {}
self.number2symbol = {}
self.states = []
@@ -84,6 +85,7 @@ class Grammar(object):
self.tokens = {}
self.symbol2label = {}
self.start = 256
self.sha256 = hashlib.sha256(bnf_text.encode("utf-8")).hexdigest()
def dump(self, filename):
"""Dump the grammar tables to a pickle file."""