Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lark/grammar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Tuple, ClassVar, Sequence
from typing import Any, Dict, Optional, Tuple, ClassVar, Sequence

from .utils import Serialize

Expand Down Expand Up @@ -57,6 +57,11 @@ class NonTerminal(Symbol):

is_term: ClassVar[bool] = False

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


class RuleOptions(Serialize):
__serialize_fields__ = 'keep_all_tokens', 'expand1', 'priority', 'template_source', 'empty_indices'
Expand Down
Loading