:py:mod:`raesl.compile.ast.nodes` ================================= .. py:module:: raesl.compile.ast.nodes .. autoapi-nested-parse:: Node classes representing elementary and combined flows. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: raesl.compile.ast.nodes.Node raesl.compile.ast.nodes.VarNode raesl.compile.ast.nodes.ElementaryVarNode raesl.compile.ast.nodes.CompoundVarNode raesl.compile.ast.nodes.GroupNode .. py:class:: Node(name_tok: raesl.compile.scanner.Token) Abstract class for nodes. Note that a Node only has a name. The typed sub-tree starts with VarNode. :param name_tok: Name of the node. .. py:class:: VarNode(name_tok: raesl.compile.scanner.Token, the_type: raesl.compile.ast.types.BaseType) Bases: :py:obj:`Node` Abstract base class of a variable or parameter node that can be shared with variable groups and other users such as transformations and goals. :param name_tok: Token with the name/location of the variable or parameter. :param the_type: Type of the variable or parameter. .. py:method:: resolve_node(name: str) -> Optional[VarNode] :abstractmethod: Find the varparam (sub)node that matches the provided dotted 'name'. :param name: Possibly dotted name that should point at an existing sub-node. The empty string denotes 'self'. :returns: The node that matches the name, or None if no such node exists. In the latter case, use 'self.get_error_position(name)' to get an indication where the match fails in the name. .. py:method:: get_error_position(name: str) -> int :abstractmethod: Return the index in the given string where an error occurs in resolving the node. :param name: Name of the element to find. :returns: Approximated index in the string where matching the element fails. Returned value has no meaning if resolving a node succeeds. .. py:method:: add_comment(comment_tok: raesl.compile.scanner.Token) :abstractmethod: Add found documentation comment. :param comment_tok: The raw documentation token to add. .. py:class:: ElementaryVarNode(name_tok: raesl.compile.scanner.Token, the_type: raesl.compile.ast.types.BaseType, counter: raesl.compile.typechecking.compdef_builder.Counter) Bases: :py:obj:`VarNode`, :py:obj:`raesl.compile.ast.comment_storage.DocElement` Elementary variable/parameter node. :param name_tok: Token with the name/position of the variable or parameter. :param the_type: Type of the variable or parameter. :param counter: Object to give out unique identification numbers, yet be resistant against re-use of imported modules. .. attribute:: id Unique number of the node, mostly useful for dumps and debugging. .. attribute:: comments Stored comments of the node. .. py:method:: resolve_node(name: str) -> Optional[VarNode] Find the varparam (sub)node that matches the provided dotted 'name'. :param name: Possibly dotted name that should point at an existing sub-node. The empty string denotes 'self'. :returns: The node that matches the name, or None if no such node exists. In the latter case, use 'self.get_error_position(name)' to get an indication where the match fails in the name. .. py:method:: get_error_position(name: str) -> int Return the index in the given string where an error occurs in resolving the node. :param name: Name of the element to find. :returns: Approximated index in the string where matching the element fails. Returned value has no meaning if resolving a node succeeds. .. py:method:: add_comment(comment_tok: raesl.compile.scanner.Token) Add found documentation comment. :param comment_tok: The raw documentation token to add. .. py:method:: get_comment() Retrieve the stored comments. .. py:method:: __repr__() Return repr(self). .. py:class:: CompoundVarNode(name_tok: raesl.compile.scanner.Token, the_type: raesl.compile.ast.types.BaseType, child_nodes: List[VarNode]) Bases: :py:obj:`VarNode`, :py:obj:`raesl.compile.ast.comment_storage.DocAddElement` Grouped variable/parameter node. :param name_tok: Token with the name/position of the variable or parameter. :param the_type: Type of the variable or parameter. :param child_nodes: Child nodes of the group. .. attribute:: name_index Mapping of name to the associated VarNode instance. .. py:method:: resolve_node(name: str) -> Optional[VarNode] Find the varparam (sub)node that matches the provided dotted 'name'. :param name: Possibly dotted name that should point at an existing sub-node. The empty string denotes 'self'. :returns: The node that matches the name, or None if no such node exists. In the latter case, use 'self.get_error_position(name)' to get an indication where the match fails in the name. .. py:method:: get_error_position(name: str) -> int Return the index in the given string where an error occurs in resolving the node. :param name: Name of the element to find. :returns: Approximated index in the string where matching the element fails. Returned value has no meaning if resolving a node succeeds. .. py:method:: add_comment(comment_tok: raesl.compile.scanner.Token) Compound node doesn't own a store, push comment down to all children. .. py:class:: GroupNode(name_tok: raesl.compile.scanner.Token, child_nodes: List[Node]) Bases: :py:obj:`Node` Class describing content of a variable group. Unlike the VarNode above, a group node has no type of its own. :param name_tok: Name of the group node. :param child_nodes: Elements of the group.