Skip to content

Commit 81fbfe4

Browse files
committed
fix bugs
1 parent a56d144 commit 81fbfe4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lark/lark.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class Lark(Serialize):
278278
def __init__(self, grammar: 'Union[Grammar, str, IO[str]]', **options) -> None:
279279
self.options = LarkOptions(options)
280280
if self.options.cache_grammar:
281-
self.__serialize_fields__ += 'grammar'
281+
self.__serialize_fields__.append('grammar')
282282
re_module: types.ModuleType
283283

284284
# Set regex or re module
@@ -341,7 +341,7 @@ def __init__(self, grammar: 'Union[Grammar, str, IO[str]]', **options) -> None:
341341
username = "unknown"
342342

343343

344-
cache_fn = tempfile.gettempdir() + "/.lark_%s_%s_%s_%s_%s_%s.tmp" % (
344+
cache_fn = tempfile.gettempdir() + "/.lark_%s_%s_%s_%s_%s.tmp" % (
345345
"cache_grammar" if self.options.cache_grammar else "cache", username, cache_sha256, *sys.version_info[:2])
346346

347347
old_options = self.options

lark/reconstruct.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ class Reconstructor(TreeMatcher):
7979
write_tokens: WriteTokensTransformer
8080

8181
def __init__(self, parser: Lark, term_subs: Optional[Dict[str, Callable[[Symbol], str]]]=None) -> None:
82-
TreeMatcher.__init__(self, parser)
83-
8482
if not hasattr(parser, 'grammar') and parser.options.cache:
8583
raise ConfigurationError('Unanalyzed grammar not available from cached parser, use cache_grammar=True')
8684

85+
TreeMatcher.__init__(self, parser)
86+
8787
self.write_tokens = WriteTokensTransformer({t.name:t for t in self.tokens}, term_subs or {})
8888

8989
def _reconstruct(self, tree):

0 commit comments

Comments
 (0)