
    \h
                     d    S r SSKJr  SSKJr  SSKJrJrJrJ	r	J
r
JrJrJr   " S S\5      rS rg)	a  
This module implements the functionality to take any Python expression as a
string and fix all numbers and other things before evaluating it,
thus

1/2

returns

Integer(1)/Integer(2)

We use the ast module for this. It is well documented at docs.python.org.

Some tips to understand how this works: use dump() to get a nice
representation of any node. Then write a string of what you want to get,
e.g. "Integer(1)", parse it, dump it and you'll see that you need to do
"Call(Name('Integer', Load()), [node], [], None, None)". You do not need
to bother with lineno and col_offset, just call fix_missing_locations()
before returning the node.
    )Basic)SympifyError)parseNodeTransformerCallNameLoadfix_missing_locationsConstantTuplec                   ,    \ rS rSrS rS rS rS rSrg)	Transform   c                 H    [         R                  " U 5        Xl        X l        g )N)r   __init__
local_dictglobal_dict)selfr   r   s      P/var/www/auris/envauris/lib/python3.13/site-packages/sympy/parsing/ast_parser.pyr   Transform.__init__   s      &$&    c           	         [        UR                  [        5      (       a'  [        [	        [        S[        5       5      U// S95      $ [        UR                  [        5      (       a'  [        [	        [        S[        5       5      U// S95      $ U$ )NIntegerfuncargskeywordsFloat)
isinstancevalueintr
   r   r   r	   float)r   nodes     r   visit_ConstantTransform.visit_Constant#   su    djj#&&(4	463J"*. / /

E**(43H"*. / /r   c           	         UR                   U R                  ;   a  U$ UR                   U R                  ;   aG  U R                  UR                      n[        U[        [
        45      (       d  [        U5      (       a  U$ OUR                   S;   a  U$ [        [        [        S[        5       5      [        UR                   5      // S95      $ )N)TrueFalseSymbolr   )idr   r   r   r   typecallabler
   r   r   r	   r   )r   r#   name_objs      r   
visit_NameTransform.visit_Name,   s    77doo%KWW(((''0H(UDM22hx6H6H 7IWW))K$TtHdf/Etww'(2&7 8 	8r   c                 "   UR                   R                    Vs/ s H  o R                  U5      PM     nnU R                  UR                  5      n[        [	        S[        5       5      [        U[        5       5      U// S9n[        U5      $ s  snf )NLambdar   )r   visitbodyr   r   r	   r   r
   )r   r#   argr   r3   ns         r   visit_LambdaTransform.visit_Lambda9   sn    +/99>>:>C

3>:zz$))$d8TV,df%t,r;$Q''	 ;s   B)r   r   N)	__name__
__module____qualname____firstlineno__r   r$   r.   r6   __static_attributes__ r   r   r   r      s    '
8(r   r   c                     0 n[        SU5         [        U R                  5       SS9n[        X5      R                  U5      n[        USS5      n[        XBU5      $ ! [         a    [	        S[        U 5      -  5      ef = f)z
Converts the string "s" to a SymPy expression, in local_dict.

It converts all numbers to Integers before feeding it to Python and
automatically creates Symbols.
zfrom sympy import *eval)modezCannot parse %s.z<string>)
execr   stripSyntaxErrorr   reprr   r2   compiler?   )sr   r   aes        r   
parse_exprrI   @   s     K	,9!'')&) 	**003A:v&A
++	  9-Q7889s   A "A=N)__doc__sympy.core.basicr   sympy.core.sympifyr   astr   r   r   r   r	   r
   r   r   r   rI   r=   r   r   <module>rN      s3   * # ++ + +"( "(H,r   