api.ast.parser#
Functions#
|
|
|
A function which takes a PSYDAC AST and transforms it to a Pyccel AST. |
Classes#

Details#
- parse(expr, settings, backend=None)[source]#
A function which takes a PSYDAC AST and transforms it to a Pyccel AST.
This function takes a PSYDAC abstract syntax tree (AST) and returns a Pyccel AST. In turn, this can be translated to Python code through a call to the function
pycodefrompsydac.pyccel.codegen.printing.pycode.- Parameters:
- exprAny
PSYDAC AST, of any type supported by the Parser class.
- settingsdict
Dictionary that contains number of dimension, mappings and target if provided
- Returns:
- astpsydac.pyccel.ast.basic.PyccelAstNode | psydac.pyccel.ast.core.FunctionDef
Pyccel abstract syntax tree that can be translated into a Python code.
- class Parser(settings, backend=None)[source]#
Bases:
objectA Parser which takes a PSYDAC AST and transforms it to a Pyccel AST.
This class takes a PSYDAC AST and transforms it to the AST of an old and reduced version of Pyccel, which is shipped as
psydac.pyccel. This “mini-Pyccel” is then used for printing the Python code.The parsing is performed by passing any object of a “supported type” to the method
Parser.doit. This in turn callsParser._visitwhich starts a recursive tree traversal through specializedParser._visit_methods. If successful,Parser.doitgenerally returns aPyccelAstNodeobject (frompsydac.pyccel.ast.basic). If the input object is aDefNode(representing a function definition) it returns aFunctionDefobject (frompsydac.pyccel.ast.core). The resulting Pyccel AST can be printed to Python code using the functionpycodefrompsydac.pyccel.codegen.printing.pycode.By “supported types” we mean any
<NODE_TYPE>type for which a methodParser._visit_is provided. The matching is done by name, and it also checks any superclasses listed in<NODE_TYPE>.__mro__in the given order.- Parameters:
- settingsdict[str, Any]
A dictionary with required integer arguments
dim(number of dimensions) andnderiv(maximum number of derivatives), required argumenttarget(symbolic domain of expression, of typeBasicDomainfromsympde.topology.basic), and optional argumentmapping(domainMappingfromsympde.topology.mapping).- backenddict[str, Any]
The backend dictionary as defined in
psydac.api.settings.
- property settings#
- property dim#
- property nderiv#
- property mapping#
- property target#