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 pycode from psydac.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:
object
A 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 calls Parser._visit which starts a recursive tree traversal through specialized Parser._visit_<NODE_TYPE> methods. If successful, Parser.doit generally returns a PyccelAstNode object (from psydac.pyccel.ast.basic). If the input object is a DefNode (representing a function definition) it returns a FunctionDef object (from psydac.pyccel.ast.core). The resulting Pyccel AST can be printed to Python code using the function pycode from psydac.pyccel.codegen.printing.pycode.
By “supported types” we mean any <NODE_TYPE> type for which a method Parser._visit_<NODE_TYPE> 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) and nderiv (maximum number of derivatives), required argument target (symbolic domain of expression, of type BasicDomain from sympde.topology.basic), and optional argument mapping (domain Mapping from sympde.topology.mapping).
- backenddict[str, Any]
The backend dictionary as defined in psydac.api.settings.
- property settings#
- property dim#
- property nderiv#
- property mapping#
- property target#