when target_in_foo is fulfilled, the transformer call doesn't seek the method target_in_foo(). Instead, it seeks foo__target_in_foo(). This means that transformer alias methods need to carry the module name of the matched target.
For refactoring of grammar files ie moving targets between files, this adds the burden of also renaming the transformer target methods.
Describe alternatives you've considered
In my transformer class, I have patched around this by adding a __getattr__() shim, which detects the modulename__ prefixes and strips them, returning references for target alias methods that are named without the prefixes.
Suggestion Requesting a constructor option to disable the "double underscore" prefixing of targets based on grammar module names.
Consider grammar file
main.lark
:and grammar file
foo.lark
when
target_in_foo
is fulfilled, the transformer call doesn't seek the methodtarget_in_foo()
. Instead, it seeksfoo__target_in_foo()
. This means that transformer alias methods need to carry the module name of the matched target.For refactoring of grammar files ie moving targets between files, this adds the burden of also renaming the transformer target methods.
Describe alternatives you've considered In my transformer class, I have patched around this by adding a
__getattr__()
shim, which detects themodulename__
prefixes and strips them, returning references for target alias methods that are named without the prefixes.