You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The __default__ method on Transformers is never called when using "Tree-less LALR" mode.
To Reproduce
Here's an example based on "ab.lark" from the unit tests. __default__() should be called for every rule here, but when using tree-less LALR mode (change BUILD_TREE to False), it's not called at all.
fromlarkimportLark, TransformerBUILD_TREE=True# Change to False to try tree-less LALR modegrammar=r""" start: expr expr: A B | A expr B A: "a" B: "b" %import common.WS %ignore WS"""classAbTransformer(Transformer):
def__default__(self, data, children, meta):
print(f'__default__({data!r}, {children!r}, {meta!r})')
returndatadefparse(x):
ifBUILD_TREE:
parser=Lark(grammar, parser='lalr')
returnAbTransformer().transform(parser.parse(x))
else:
parser=Lark(grammar, parser='lalr', transformer=AbTransformer())
returnparser.parse(x)
print(parse('a a a b b b')) # should print "start"
The text was updated successfully, but these errors were encountered:
Describe the bug
The
__default__
method onTransformer
s is never called when using "Tree-less LALR" mode.To Reproduce
Here's an example based on "ab.lark" from the unit tests.
__default__()
should be called for every rule here, but when using tree-less LALR mode (changeBUILD_TREE
to False), it's not called at all.The text was updated successfully, but these errors were encountered: