Skip to content

Commit 23c95ea

Browse files
committed
Bugfix: issue when unpickling in the standalone parser, due to lingering
Lark instances
1 parent d1a456d commit 23c95ea

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lark/grammar.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Tuple, ClassVar, Sequence
1+
from typing import Any, Dict, Optional, Tuple, ClassVar, Sequence
22

33
from .utils import Serialize
44

@@ -57,6 +57,11 @@ class NonTerminal(Symbol):
5757

5858
is_term: ClassVar[bool] = False
5959

60+
def serialize(self, memo=None) -> Dict[str, Any]:
61+
# TODO this is here because self.name can be a Token instance.
62+
# remove this function when the issue is fixed. (backwards-incompatible)
63+
return {'name': str(self.name), '__type__': 'NonTerminal'}
64+
6065

6166
class RuleOptions(Serialize):
6267
__serialize_fields__ = 'keep_all_tokens', 'expand1', 'priority', 'template_source', 'empty_indices'

0 commit comments

Comments
 (0)