pyccel.parser.syntax.headers module#

class pyccel.parser.syntax.headers.FuncType(args, results, **kwargs)[source]#

Bases: BasicStmt

Class representing a FunctionType in the grammar.

Class representing a FunctionType in the grammar. A FunctionType is the type of an argument which describes a function.

Parameters:
  • args (iterable of UnionTypeStmt, optional) – A list of UnionTypeStmts describing the types of the function arguments.

  • results (TypeHeader, optional) – A TypeHeader describing the type of the function result. (This is not a UnionTypeStmt as there cannot be multiple types for a given result).

  • **kwargs (dict) – TextX keyword arguments.

property expr#

Get the Pyccel object equivalent to this grammar object.

Get the Pyccel object equivalent to this grammar object.

class pyccel.parser.syntax.headers.Header(statements=(), **kwargs)[source]#

Bases: object

Class describing a Header in the grammar.

Class describing a Header in the grammar. To be deprecated. See #1487.

Parameters:
  • statements (iterable) – A list of header statements.

  • **kwargs (dict) – TextX keyword arguments.

class pyccel.parser.syntax.headers.MetavarHeaderStmt(**kwargs)[source]#

Bases: BasicStmt

Base class representing a metavar header statement in the grammar.

property expr#
class pyccel.parser.syntax.headers.TrailerSubscriptList(args, order, **kwargs)[source]#

Bases: BasicStmt

Class representing subscripts that appear trailing a type in the grammar.

Class representing subscripts that appear trailing a type in the grammar in the form: [arg1,arg2,arg3] or [arg1,arg2,arg3](order=c)

Parameters:
  • args (iterable) – The arguments that appear in the subscript.

  • order (str) – The order specified in brackets.

  • **kwargs (dict) – TextX keyword arguments.

class pyccel.parser.syntax.headers.Type(dtype, trailer=None, **kwargs)[source]#

Bases: BasicStmt

Class representing a type in the grammar.

Class representing a type in the grammar.

Parameters:
  • dtype (str) – The description of the base datatype.

  • trailer (TrailerSubscriptList, optional) – The subscript that may appear trailing a type definition to augment its description.

  • **kwargs (dict) – TextX keyword arguments.

property expr#

Get the Pyccel object equivalent to this grammar object.

Get the Pyccel object equivalent to this grammar object.

handle_trailer_arg(s)[source]#

Get the Pyccel object equivalent to the argument in the trailing object.

Get the Pyccel object equivalent to the argument in the trailing object.

Parameters:

s (str) – The argument in the trailing section.

Returns:

The Pyccel object being described.

Return type:

PyccelAstNode

class pyccel.parser.syntax.headers.UnionTypeStmt(dtypes, **kwargs)[source]#

Bases: BasicStmt

Class describing a union of possible types.

A class object describing a union of possible types described in a type descriptor. These types are either VariableTypes or FuncTypes.

Parameters:
  • dtypes (list of VariableHeader | FuncHeader) – A list of the possible types described.

  • **kwargs (dict) – TextX keyword arguments.

property expr#

Get the Pyccel equivalent of this object.

Get the Pyccel equivalent of this object. To be removed when header support is deprecated.

pyccel.parser.syntax.headers.parse(filename=None, stmts=None)[source]#

Parse header pragmas

Parameters:
  • filename (str)

  • stmts (list)

  • Results

  • -------

  • stmts