
    ,              	           S r SSKrSSKrSSKrSSKJrJr  SSKJrJ	r	   " S S5      r
 " S S5      r " S	 S
5      rS rS\	4S\R                  S\\   S\S\4S jjrg)zU
Module of utilities for transforming a lark.Tree into a custom Abstract Syntax Tree
    N)OptionalCallable)Transformerv_argsc                       \ rS rSrSrSrg)Ast   zGAbstract class

Subclasses will be collected by `create_transformer()`
 N__name__
__module____qualname____firstlineno____doc____static_attributes__r
       !lib/third_party/lark/ast_utils.pyr   r           	r   r   c                       \ rS rSrSrSrg)AsList   zrAbstract class

Subclasses will be instantiated with the parse results as a single list, instead of as arguments.
r
   Nr   r
   r   r   r   r      s    r   r   c                       \ rS rSrSrSrg)WithMeta   zuAbstract class

Subclasses will be instantiated with the Meta instance of the tree. (see ``v_args`` for more detail)
r
   Nr   r
   r   r   r   r      r   r   r   c                 N    [         R                  " SSU 5      R                  5       $ )Nz(?<!^)(?=[A-Z])_)resublower)names    r   camel_to_snaker!      s    66$c406688r   
ast_moduletransformerdecorator_factoryreturnc                    U=(       d
    [        5       n[        R                  " U 5       H  u  pEUR                  S5      (       a  M  [        R                  " U5      (       d  M:  [        U[        5      (       d  MQ  U" [        U[        5      (       + [        U[        5      S9nU" U5      R                  U5      n[        U[        U5      U5        M     U$ )a  Collects `Ast` subclasses from the given module, and creates a Lark transformer that builds the AST.

For each class, we create a corresponding rule in the transformer, with a matching name.
CamelCase names will be converted into snake_case. Example: "CodeBlock" -> "code_block".

Classes starting with an underscore (`_`) will be skipped.

Parameters:
    ast_module: A Python module containing all the subclasses of ``ast_utils.Ast``
    transformer (Optional[Transformer]): An initial transformer. Its attributes may be overwritten.
    decorator_factory (Callable): An optional callable accepting two booleans, inline, and meta,
        and returning a decorator for the methods of ``transformer``. (default: ``v_args``).
r   )inlinemeta)r   inspect
getmembers
startswithisclass
issubclassr   r   r   __get__setattrr!   )r"   r#   r$   tr    objwrappers          r   create_transformerr3   "   s      	${}A''
3	s##(<(<#s##+z#v7N3NU_`cemUnocl**1->$/5 4 Hr   )r   r)   r   typestypingr   r   larkr   r   r   r   r   r!   
ModuleTyper3   r
   r   r   <module>r8      sr      % $	 	 	 	9 ;?395#3#3 $,[$9*2>Ir   