
    XhE              	           d Z ddlZddlZddlZddlmZmZ ddlmZm	Z	  G d d      Z
 G d d      Z G d	 d
      Zd Zde	fdej                  dee   dedefdZy)zr
    Module of utilities for transforming a lark.Tree into a custom Abstract Syntax Tree (AST defined in classes)
    N)OptionalCallable)Transformerv_argsc                       e Zd ZdZy)AstzOAbstract class

    Subclasses will be collected by `create_transformer()`
    N__name__
__module____qualname____doc__     B/var/www/html/myenv/lib/python3.12/site-packages/lark/ast_utils.pyr   r           	r   r   c                       e Zd ZdZy)AsListzzAbstract class

    Subclasses will be instantiated with the parse results as a single list, instead of as arguments.
    Nr	   r   r   r   r   r      s    r   r   c                       e Zd ZdZy)WithMetaz}Abstract class

    Subclasses will be instantiated with the Meta instance of the tree. (see ``v_args`` for more detail)
    Nr	   r   r   r   r   r      r   r   r   c                 L    t        j                  dd|       j                         S )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                 v   |xs
 t               }t        j                  |       D ]  \  }}|j                  d      rt        j                  |      s.t        |t              s? |t        |t               t        |t                    } ||      j                  |      }t        |t        |      |        |S )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_transformerr.   "   s      	${}A''
3 6	cs#(<#s#+z#v7N3NU_`cemUnocl**1->$/56 Hr   )r   r$   r   typestypingr   r   larkr   r   r   r   r   r   
ModuleTyper.   r   r   r   <module>r3      sr      % $	 	 	 	9 ;?395#3#3 $,[$9*2>Ir   