diff --git a/lark/reconstruct.py b/lark/reconstruct.py index 46dc6c5..2e51e93 100644 --- a/lark/reconstruct.py +++ b/lark/reconstruct.py @@ -34,7 +34,8 @@ class WriteTokensTransformer(Transformer_InPlace): for sym in meta.orig_expansion: if is_discarded_terminal(sym): t = self.tokens[sym.name] - assert isinstance(t.pattern, PatternStr) + if not isinstance(t.pattern, PatternStr): + raise NotImplementedError("Reconstructing regexps not supported yet: %s" % t) to_write.append(t.pattern.value) else: x = next(iter_args) diff --git a/tests/test_reconstructor.py b/tests/test_reconstructor.py index ec264a0..5111d2b 100644 --- a/tests/test_reconstructor.py +++ b/tests/test_reconstructor.py @@ -40,9 +40,9 @@ class TestReconstructor(TestCase): def test_starred_group(self): g = """ - start: (rule | _NL)* + start: (rule | NL)* rule: WORD ":" NUMBER - _NL: /(\\r?\\n)+\s*/ + NL: /(\\r?\\n)+\s*/ """ + common code = """