+
    ‹°³j¿"  ã                   óÄ   € ^ RI HtHtHt ^ RIHt ^ RIHt ]! R4      t]! RRR./R7      t	]'       d   ^ R	I
Ht ]	'       d   ^ R
IHt ]! RR.R7       ! R R4      4       tR# )é    )ÚpycodeÚccodeÚfcode)Úimport_module)Údoctest_depends_onÚlfortranzclang.cindexÚfromlistÚcindex)Úimport_kwargs)Úsrc_to_sympy)Úparse_c)Úmodulesc                   óX   a a€ ] tR t^t oRtR	V 3R lltR tR tR tR t	R t
RtVtV ;t# )
ÚSymPyExpressiona7  Class to store and handle SymPy expressions

This class will hold SymPy Expressions and handle the API for the
conversion to and from different languages.

It works with the C and the Fortran Parser to generate SymPy expressions
which are stored here and which can be converted to multiple language's
source code.

Notes
=====

The module and its API are currently under development and experimental
and can be changed during development.

The Fortran parser does not support numeric assignments, so all the
variables have been Initialized to zero.

The module also depends on external dependencies:

- LFortran which is required to use the Fortran parser
- Clang which is required for the C parser

Examples
========

Example of parsing C code:

>>> from sympy.parsing.sym_expr import SymPyExpression
>>> src = '''
... int a,b;
... float c = 2, d =4;
... '''
>>> a = SymPyExpression(src, 'c')
>>> a.return_expr()
[Declaration(Variable(a, type=intc)),
Declaration(Variable(b, type=intc)),
Declaration(Variable(c, type=float32, value=2.0)),
Declaration(Variable(d, type=float32, value=4.0))]

An example of variable definition:

>>> from sympy.parsing.sym_expr import SymPyExpression
>>> src2 = '''
... integer :: a, b, c, d
... real :: p, q, r, s
... '''
>>> p = SymPyExpression()
>>> p.convert_to_expr(src2, 'f')
>>> p.convert_to_c()
['int a = 0', 'int b = 0', 'int c = 0', 'int d = 0', 'double p = 0.0', 'double q = 0.0', 'double r = 0.0', 'double s = 0.0']

An example of Assignment:

>>> from sympy.parsing.sym_expr import SymPyExpression
>>> src3 = '''
... integer :: a, b, c, d, e
... d = a + b - c
... e = b * d + c * e / a
... '''
>>> p = SymPyExpression(src3, 'f')
>>> p.convert_to_python()
['a = 0', 'b = 0', 'c = 0', 'd = 0', 'e = 0', 'd = a + b - c', 'e = b*d + c*e/a']

An example of function definition:

>>> from sympy.parsing.sym_expr import SymPyExpression
>>> src = '''
... integer function f(a,b)
... integer, intent(in) :: a, b
... integer :: r
... end function
... '''
>>> a = SymPyExpression(src, 'f')
>>> a.convert_to_python()
['def f(a, b):\n   f = 0\n    r = 0\n    return f']

c                ó¬  <€ \         SV `  4        V'       g   V'       g
   . V n        R# V'       d›   V'       dˆ   VP                  4       R8X  d*   \        '       d   \        V4      V n        R# \        R4      hVP                  4       R8X  d*   \        '       d   \        V4      V n        R# \        R4      h\        R4      h\        R4      h\        R4      h)	z%Constructor for SymPyExpression classÚfú4LFortran is not installed, cannot parse Fortran codeÚcú+Clang is not installed, cannot parse C codez0Parser for specified language is not implementedzSource code not presentz$Please specify a mode for conversionN)ÚsuperÚ__init__Ú_exprÚlowerr   r   ÚImportErrorÚcinr   ÚNotImplementedErrorÚ
ValueError)ÚselfÚsource_codeÚmodeÚ	__class__s   &&&€ÚW/home/luca/screen-checking/.venv/lib/python3.14/site-packages/sympy/parsing/sym_expr.pyr   ÚSymPyExpression.__init__^   s    ø€ ä‰ÑÔß—{ØˆDŽJßßØ—:‘:“< 3Ô&ß“xÜ%1°+Ó%>˜ž
ä)Ð*`ÓaÐaØ—Z‘Z“\ SÔ(ß“sÜ%,¨[Ó%9˜ž
ä)Ð*WÓXÐXä-ØJóð ô !Ð!:Ó;Ð;äÐCÓDÐDó    c                ó  € VP                  4       R8X  d*   \        '       d   \        V4      V n        R# \	        R4      hVP                  4       R8X  d*   \
        '       d   \        V4      V n        R# \	        R4      h\        R4      h)au  Converts the given source code to SymPy Expressions

Attributes
==========

src_code : String
    the source code or filename of the source code that is to be
    converted

mode: String
    the mode to determine which parser is to be used according to
    the language of the source code
    f or F for Fortran
    c or C for C/C++

Examples
========

>>> from sympy.parsing.sym_expr import SymPyExpression
>>> src3 = '''
... integer function f(a,b) result(r)
... integer, intent(in) :: a, b
... integer :: x
... r = a + b -x
... end function
... '''
>>> p = SymPyExpression()
>>> p.convert_to_expr(src3, 'f')
>>> p.return_expr()
[FunctionDefinition(integer, name=f, parameters=(Variable(a), Variable(b)), body=CodeBlock(
Declaration(Variable(r, type=integer, value=0)),
Declaration(Variable(x, type=integer, value=0)),
Assignment(Variable(r), a + b - x),
Return(Variable(r))
))]




r   r   r   r   z6Parser for specified language has not been implementedN)r   r   r   r   r   r   r   r   )r   Úsrc_coder    s   &&&r"   Úconvert_to_exprÚSymPyExpression.convert_to_exprx   sk   € ðR �:‰:‹<˜3Ôß‹xÜ)¨(Ó3�–
ä!Ð"XÓYÐYØ�Z‰Z‹\˜SÔ ß‹sÜ$ XÓ.�–
ä!Ð"OÓPÐPä%ØHóð r$   c                ó–   € . V n         V P                   F'  pV P                   P                  \        V4      4       K)  	  V P                   # )a¸  Returns a list with Python code for the SymPy expressions

Examples
========

>>> from sympy.parsing.sym_expr import SymPyExpression
>>> src2 = '''
... integer :: a, b, c, d
... real :: p, q, r, s
... c = a/b
... d = c/a
... s = p/q
... r = q/p
... '''
>>> p = SymPyExpression(src2, 'f')
>>> p.convert_to_python()
['a = 0', 'b = 0', 'c = 0', 'd = 0', 'p = 0.0', 'q = 0.0', 'r = 0.0', 's = 0.0', 'c = a/b', 'd = c/a', 's = p/q', 'r = q/p']

)Ú_pycoder   Úappendr   ©r   Úiters   & r"   Úconvert_to_pythonÚ!SymPyExpression.convert_to_python°   s9   € ð( ˆŒØ—J”JˆDØ�L‰L×Ñ¤ t£Ö-ñ à�|‰|Ðr$   c                ó–   € . V n         V P                   F'  pV P                   P                  \        V4      4       K)  	  V P                   # )a  Returns a list with the c source code for the SymPy expressions


Examples
========

>>> from sympy.parsing.sym_expr import SymPyExpression
>>> src2 = '''
... integer :: a, b, c, d
... real :: p, q, r, s
... c = a/b
... d = c/a
... s = p/q
... r = q/p
... '''
>>> p = SymPyExpression()
>>> p.convert_to_expr(src2, 'f')
>>> p.convert_to_c()
['int a = 0', 'int b = 0', 'int c = 0', 'int d = 0', 'double p = 0.0', 'double q = 0.0', 'double r = 0.0', 'double s = 0.0', 'c = a/b;', 'd = c/a;', 's = p/q;', 'r = q/p;']

)Ú_ccoder   r+   r   r,   s   & r"   Úconvert_to_cÚSymPyExpression.convert_to_cÉ   s9   € ð, ˆŒØ—J”JˆDØ�K‰K×Ñœu T›{Ö+ñ à�{‰{Ðr$   c                ó–   € . V n         V P                   F'  pV P                   P                  \        V4      4       K)  	  V P                   # )a)  Returns a list with the fortran source code for the SymPy expressions

Examples
========

>>> from sympy.parsing.sym_expr import SymPyExpression
>>> src2 = '''
... integer :: a, b, c, d
... real :: p, q, r, s
... c = a/b
... d = c/a
... s = p/q
... r = q/p
... '''
>>> p = SymPyExpression(src2, 'f')
>>> p.convert_to_fortran()
['      integer*4 a', '      integer*4 b', '      integer*4 c', '      integer*4 d', '      real*8 p', '      real*8 q', '      real*8 r', '      real*8 s', '      c = a/b', '      d = c/a', '      s = p/q', '      r = q/p']

)Ú_fcoder   r+   r   r,   s   & r"   Úconvert_to_fortranÚ"SymPyExpression.convert_to_fortranä   s9   € ð( ˆŒØ—J”JˆDØ�K‰K×Ñœu T›{Ö+ñ à�{‰{Ðr$   c                ó   € V P                   # )a>  Returns the expression list

Examples
========

>>> from sympy.parsing.sym_expr import SymPyExpression
>>> src3 = '''
... integer function f(a,b)
... integer, intent(in) :: a, b
... integer :: r
... r = a+b
... f = r
... end function
... '''
>>> p = SymPyExpression()
>>> p.convert_to_expr(src3, 'f')
>>> p.return_expr()
[FunctionDefinition(integer, name=f, parameters=(Variable(a), Variable(b)), body=CodeBlock(
Declaration(Variable(f, type=integer, value=0)),
Declaration(Variable(r, type=integer, value=0)),
Assignment(Variable(f), Variable(r)),
Return(Variable(f))
))]

)r   )r   s   &r"   Úreturn_exprÚSymPyExpression.return_exprý   s   € ð4 �z‰zÐr$   )r1   r   r5   r*   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r'   r.   r2   r6   r9   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r!   Ú__classdict__s   @@r"   r   r      s1   ù‡ € ñM÷^Eò46òpò2ò6÷2ò r$   r   N)Úsympy.printingr   r   r   Úsympy.externalr   Úsympy.utilities.decoratorr   r   r   Ú$sympy.parsing.fortran.fortran_parserr   Úsympy.parsing.c.c_parserr   r   © r$   r"   Ú<module>rJ      s^   ðß /Ñ /Ý (Ý 8á˜Ó$€Ù�N°ZÀ(ÀÐ4LÔM€çÝAßÝ0á˜Z¨Ð8Ô9÷Ið Ió :òIr$   