Skip to content

Commit 21c37ce

Browse files
committed
Correctly use instance methods in the transformer
1 parent df801ee commit 21c37ce

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -352,19 +352,19 @@ def replace_fn(match):
352352
rule_names = filter(
353353
lambda s: not s.startswith("_"), set(r.origin.name for r in temp.rules)
354354
)
355-
null_function = lambda *args: None
355+
null_function = lambda self, *args: None
356356
# Create dictionary of methods for type() creation
357357
methods = {r: null_function for r in rule_names}
358358

359359
# Even in this case we do want to report duplicate identifiers
360360
# so these need to be captured
361-
methods["id"] = lambda *args: args
362-
methods["simple_entity_instance"] = lambda tree: instance_identifiers.append(
361+
methods["id"] = lambda self, *args: args
362+
methods["simple_entity_instance"] = lambda self, tree: instance_identifiers.append(
363363
(int(tree[0][0][0][1:]), int(tree[0][0][0].line))
364364
)
365365

366366
NT = type("NullTransformer", (Transformer,), methods)
367-
transformer = {"transformer": NT}
367+
transformer = {"transformer": NT()}
368368

369369
parser = Lark(grammar, parser="lalr", start="file", **transformer)
370370

0 commit comments

Comments
 (0)