pyGHDL.dom

Document object model (DOM) for pyGHDL.libghdl based on pyVHDLModel.

Submodules

Exceptions

  • DOMException: The exception is raised when an IIR node cannot be translated to a pyVHDLModel object.

Classes

  • Position: Represents the source code position of a IIR node in a source file.

  • DOMMixin: Undocumented.


Exceptions

exception pyGHDL.dom.DOMException(message='')[source]

The exception is raised when an IIR node cannot be translated to a pyVHDLModel object.

It reports a node kind the translation does not handle, or a node whose shape does not match what the surrounding construct expects. The message names the kind and, where available, the source position.

Inheritance

Inheritance diagram of DOMException

Parameters:

message (str)

Return type:

None


Classes

class pyGHDL.dom.Position(filename, line, column)[source]

Represents the source code position of a IIR node in a source file.

Inheritance

Inheritance diagram of Position

Parameters:
__init__(filename, line, column)[source]
Parameters:
Return type:

None

classmethod parse(node)[source]

Return the source code position of a IIR node.

Return type:

Position

Parameters:

node (Iir)

property Filename: Path

Read-only property to access the filename this source code position referres to (_filename).

Returns:

The source code position’s filename.

property Line: int

Read-only property to access the line number this source code position referres to (_line).

Returns:

The source code position’s line.

property Column: int

Read-only property to access the column this source code position referres to (_column).

Returns:

The source code position’s column.

__str__()[source]

Return str(self).

classmethod GetMethodsWithAttributes(predicate: TAttr | Iterable[TAttr] | None = None) Dict[Callable, Tuple[Attribute, ...]]
Parameters:

predicate (TypeVar(TAttr) | Iterable[TypeVar(TAttr)] | None) – An attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

Dict[Callable, Tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

class pyGHDL.dom.DOMMixin(node)[source]

Inheritance

Inheritance diagram of DOMMixin

Parameters:

node (Iir)

classmethod GetMethodsWithAttributes(predicate: TAttr | Iterable[TAttr] | None = None) Dict[Callable, Tuple[Attribute, ...]]
Parameters:

predicate (TypeVar(TAttr) | Iterable[TypeVar(TAttr)] | None) – An attribute class, an iterable of attribute classes, or None to accept every attribute.

Return type:

Dict[Callable, Tuple[Attribute, ...]]

Returns:

Dictionary of methods and the matching attributes attached to them.

Raises:
  • ValueError – If an element of parameter ‘predicate’ is not a sub-class of Attribute.

  • ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.

__init__(node)[source]
Parameters:

node (Iir)

Return type:

None

property Position: <pyTooling.Decorators.readonly object at 0x7c526738b7d0>

Cached read-only property to access an IIR’s position in source code (_position).

If _position is None, resolve the position object from _iirNode

Returns:

The IIR’s position in the source file.