From 99c036bb56a7e6f2f7bfec69ecffd6f8086ac889 Mon Sep 17 00:00:00 2001 From: "bruno cuconato (@odanoburu)" Date: Tue, 12 Nov 2024 19:56:47 -0300 Subject: [PATCH 1/2] Mention internal/external transformers in the documentation Helps users not fall into a problem similar to #408. --- lark/parse_tree_builder.py | 2 +- lark/visitors.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lark/parse_tree_builder.py b/lark/parse_tree_builder.py index e3a4171..1acad4d 100644 --- a/lark/parse_tree_builder.py +++ b/lark/parse_tree_builder.py @@ -320,7 +320,7 @@ def inplace_transformer(func): def apply_visit_wrapper(func, name, wrapper): if wrapper is _vargs_meta or wrapper is _vargs_meta_inline: - raise NotImplementedError("Meta args not supported for internal transformer") + raise NotImplementedError("Meta args not supported for internal transformer; use YourTransformer().transform(parser.parse()) instead") @wraps(func) def f(children): diff --git a/lark/visitors.py b/lark/visitors.py index 0e051ed..ae79a14 100644 --- a/lark/visitors.py +++ b/lark/visitors.py @@ -523,7 +523,7 @@ def v_args(inline: bool = False, meta: bool = False, tree: bool = False, wrapper Parameters: inline (bool, optional): Children are provided as ``*args`` instead of a list argument (not recommended for very long lists). - meta (bool, optional): Provides two arguments: ``meta`` and ``children`` (instead of just the latter) + meta (bool, optional): Provides two arguments: ``meta`` and ``children`` (instead of just the latter); ``meta`` is only available for external transformers (i.e., those not supplied as ``Lark``'s ``transformer`` parameter). tree (bool, optional): Provides the entire tree as the argument, instead of the children. wrapper (function, optional): Provide a function to decorate all methods. From aeeef0a3da348462adf5c4ba4ede19e850c28e70 Mon Sep 17 00:00:00 2001 From: "bruno cuconato (@odanoburu)" Date: Wed, 13 Nov 2024 10:39:06 -0300 Subject: [PATCH 2/2] improve doc writing --- lark/visitors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lark/visitors.py b/lark/visitors.py index ae79a14..b6db3ea 100644 --- a/lark/visitors.py +++ b/lark/visitors.py @@ -523,7 +523,7 @@ def v_args(inline: bool = False, meta: bool = False, tree: bool = False, wrapper Parameters: inline (bool, optional): Children are provided as ``*args`` instead of a list argument (not recommended for very long lists). - meta (bool, optional): Provides two arguments: ``meta`` and ``children`` (instead of just the latter); ``meta`` is only available for external transformers (i.e., those not supplied as ``Lark``'s ``transformer`` parameter). + meta (bool, optional): Provides two arguments: ``meta`` and ``children`` (instead of just the latter); ``meta`` isn't available for transformers supplied to Lark using the ``transformer`` parameter (aka internal transformers). tree (bool, optional): Provides the entire tree as the argument, instead of the children. wrapper (function, optional): Provide a function to decorate all methods.