:py:mod:`raesl.compile.instantiating.node_building` =================================================== .. py:module:: raesl.compile.instantiating.node_building .. autoapi-nested-parse:: Methods for casting ESL AST into ragraph.node.Node objects. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: raesl.compile.instantiating.node_building.NodeStore raesl.compile.instantiating.node_building.NodeFactory Functions ~~~~~~~~~ .. autoapisummary:: raesl.compile.instantiating.node_building.make_variable_instmap raesl.compile.instantiating.node_building.make_parameter_instmap raesl.compile.instantiating.node_building.make_type_node raesl.compile.instantiating.node_building._make_type_annotations raesl.compile.instantiating.node_building.make_variable_node raesl.compile.instantiating.node_building._make_variable_annotations raesl.compile.instantiating.node_building.make_component_node raesl.compile.instantiating.node_building._make_component_annotations raesl.compile.instantiating.node_building.make_need_node raesl.compile.instantiating.node_building._make_need_annotations raesl.compile.instantiating.node_building.make_goal_node raesl.compile.instantiating.node_building._make_goal_annotations raesl.compile.instantiating.node_building.make_transform_node raesl.compile.instantiating.node_building._unfold_compound_var raesl.compile.instantiating.node_building._get_variable_inst_names raesl.compile.instantiating.node_building._make_transform_annotations raesl.compile.instantiating.node_building.make_design_node raesl.compile.instantiating.node_building._make_design_annotations raesl.compile.instantiating.node_building._make_subclause_annotations raesl.compile.instantiating.node_building._make_design_rule_annotation raesl.compile.instantiating.node_building.make_behavior_node raesl.compile.instantiating.node_building._make_behavior_annotations raesl.compile.instantiating.node_building._make_case_annotations raesl.compile.instantiating.node_building.make_relation_node raesl.compile.instantiating.node_building._get_arg_inst_names raesl.compile.instantiating.node_building._make_relation_annotations raesl.compile.instantiating.node_building._make_bound_annotation raesl.compile.instantiating.node_building.post_process_comments Attributes ~~~~~~~~~~ .. autoapisummary:: raesl.compile.instantiating.node_building.comparison_dict raesl.compile.instantiating.node_building.aux_dict raesl.compile.instantiating.node_building.TAG_COMMENT_PAT .. py:class:: NodeStore Node storage with multiple catagories for quicker access to specific subsets. .. py:attribute:: categories :value: ['nodes', 'types', 'components', 'variables', 'needs', 'goals', 'transforms', 'designs',... .. py:method:: clear() Clear all node categories. .. py:method:: add(node: ragraph.node.Node, *args) Add node to :obj:`self.nodes` and any other specified categories in args. .. py:class:: NodeFactory(diag_store: raesl.compile.diagnostics.DiagnosticStore, spec: Optional[raesl.compile.ast.specification.Specification] = None) Node factory. Creates :obj:`Node` objects from a :obj:`Specification`. .. py:method:: _add(node: Optional[ragraph.node.Node], *args) Proxy for :obj:`NodeStore.add`. .. py:method:: make_nodes(spec: Optional[raesl.compile.ast.specification.Specification] = None) -> Dict[str, ragraph.node.Node] Instantiate AST and create :obj:`Node` objects accordingly. .. py:method:: _instantiate_component(comp_def: raesl.compile.ast.components.ComponentDefinition, inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode], inst_name: str) Instantiate a component definition. Arguments comp_def: Component definition to instantiate. inst_map: Mapping of parameter VarNodes of the component definition to InstNodes of the parent. Is not used by the parent afterwards. inst_name: Dotted name of the component instance. .. py:function:: make_variable_instmap(var: raesl.compile.ast.components.VarParam, varname: List[str], node: raesl.compile.ast.nodes.VarNode) -> Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode] Construct instance nodes for the provided variable. :param var: Variable represented by the node. :param varname: Collected prefixes of the dotted name so far. :param node: Node to associate with one or more inst nodes. :returns: Map of the elementary variable nodes to their associated instance nodes. .. py:function:: make_parameter_instmap(param: raesl.compile.ast.components.VarParam, param_node: raesl.compile.ast.nodes.VarNode, arg_node: raesl.compile.ast.nodes.VarNode, parent_inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode] Construct an inst node map for a parameter of a child component instance. :param param: Parameter definition in the child component definition. :param param_node: VarNode within the parameter in the child component definition. Note these are like variables in the child. :param arg_node: Node in the parent that must match with param_node. These nodes exist in the parent component, and may contain part of a variable group. :param parent_inst_map: Variable instance map of the parent. As component instantiation is recursive, this may also include nodes from the grand-parent or higher. Should not be modified. :returns: Instance node map for a parameter. .. py:function:: make_type_node(tdef: raesl.compile.ast.types.TypeDef) -> ragraph.node.Node Node creation for a type definition. :param tdef: Type definition for which a node most be created. :returns: Node of kind `variabel_type` .. py:function:: _make_type_annotations(tdef: raesl.compile.ast.types.TypeDef) -> Dict[str, Dict[str, Any]] Creating dictionary to annotate `variable_type` nodes. :param tdef: The type definition for which an annotation dictionary most be created. :returns: See YAML output spec /components/schemas/VariableTypeAnnotation .. py:function:: make_variable_node(v: raesl.compile.instantiating.graph_data.InstNode, type_inst_map: Dict[raesl.compile.ast.types.ElementaryType, raesl.compile.ast.types.TypeDef]) -> ragraph.node.Node Node creation for a variable. :param v: The variable for which a nodes must be created. :returns: Node of kind "variable". .. py:function:: _make_variable_annotations(v: raesl.compile.instantiating.graph_data.InstNode, type_inst_map: Dict[raesl.compile.ast.types.ElementaryType, raesl.compile.ast.types.TypeDef], comments: Optional[List[str]] = []) -> Dict[str, Dict[str, Any]] Creating dictionary for variable annotations. :param v: The variable for which the annotation dict must be created. :param comments: List of comments attached to the nodes. :returns: See YAML output spec /components/schemas/VariableAnnotation .. py:function:: make_component_node(c: raesl.compile.ast.components.ComponentInstance, inst_name: str, params: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> ragraph.node.Node Node creation for a component. :param c: The component for which a node is created. :param name: The instantiation name of the node. :param params: List of parameters of the component. :returns: Node of kind "component" .. py:function:: _make_component_annotations(c: raesl.compile.ast.components.ComponentInstance, params: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> Dict[str, Dict[str, Any]] Component annotation creation. :param c: The component for which the annotations must be created. :param params: List of parameters of the component. :returns: See YAML output spec /components/schemas/ComponentAnnotation .. py:function:: make_need_node(n: raesl.compile.ast.components.Need, inst_name: str) -> ragraph.node.Node Node creation for a component. :param n: The need for which a node must be created. :param name: The instation name of the need. :param inst_prefix: Instantiation prefix :returns: Node of kind "need" .. py:function:: _make_need_annotations(n: raesl.compile.ast.components.Need, inst_prefix: str) -> Dict[str, Dict[str, Any]] Need annotation creation. :param n: The need for which the annotations dict must be created. :param inst_prefix: The instantiation prefix. :returns: See YAML output spec /components/schemas/ComponentAnnotation. .. py:function:: make_goal_node(g: raesl.compile.ast.components.Goal, inst_name: str, inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> ragraph.node.Node Goal node creation. :param g: The goal for which a node must be created. :param inst_name: The instantiation name of the component. :param inst_map: Dictionary containing the instantiated variables. :returns: Node of kind "function". .. py:function:: _make_goal_annotations(g: raesl.compile.ast.components.Goal, inst_name: str, inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> Dict[str, Dict[str, Any]] Goal annotation creation. :param g: The goal for which a node must be created. :param inst_name: The instantiation name of the component. :param inst_map: Dictionary containing the instantiated variables. :returns: See YAML output spec /components/schemas/FunctionSpecAnnotation. .. py:function:: make_transform_node(t: raesl.compile.ast.components.Transformation, inst_name: str, inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> ragraph.node.Node Transformation node creation. :param t: The transformation for which a node must be created. :param inst_name: The instantiation name of the component. :param inst_map: Dictionary containing the instantiated variables. :returns: Node of kind "function_spec". .. py:function:: _unfold_compound_var(v: raesl.compile.ast.nodes.CompoundVarNode) -> List[raesl.compile.ast.nodes.ElementaryVarNode] Unfolding CompoundVarNode into a list of ElementartyVarNode .. py:function:: _get_variable_inst_names(inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode], flows: List[raesl.compile.ast.components.Flow]) -> List[str] Converting list of Flow objects into a list of instantiated variable names. .. py:function:: _make_transform_annotations(t: raesl.compile.ast.components.Transformation, inst_name: str, inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> Dict[str, Dict[str, Any]] Transform annotation creation. :param t: The transformation for which a node must be created. :param inst_name: The instantiation name of the component. :param inst_map: Dictionary containing the instantiated variables. :returns: See YAML output spec /components/schemas/FunctionSpecAnnotation. .. py:function:: make_design_node(d: raesl.compile.ast.components.Design, inst_name: str, inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> ragraph.node.Node Design spec node creation. :param d: The design specification for which a node must be created. :param inst_name: The instantiation name of the component. :param inst_map: Dictionary containing the instantiated variables. :returns: Node of kind "design_spec". .. py:function:: _make_design_annotations(d: raesl.compile.ast.components.Design, inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> Dict[str, Dict[str, any]] Design spec annotation creation. :param d: The design spec for which a node must be created. :param inst_map: Dictionary containing the instantiated variables. :returns: See YAML output spec /components/schemas/DesignSpecAnotation. .. py:function:: _make_subclause_annotations(e: Union[raesl.compile.ast.components.Goal, raesl.compile.ast.components.Transformation, raesl.compile.ast.components.Design], inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> List[Dict[str, Any]] Subclause spec annotation creation. :param e: The relation for which annotations must be created. :param inst_map: Dictionary containing the instantiated variables. :returns: List of YAML output spec /components/schemas/SubclauseSpecAnnotation. .. py:data:: comparison_dict .. py:data:: aux_dict .. py:function:: _make_design_rule_annotation(expr: Union[raesl.compile.ast.exprs.RelationComparison, raesl.compile.ast.exprs.Disjunction, raesl.compile.ast.exprs.ObjectiveComparison], inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> List[Dict[str, Any]] Design rule spec annotation creation. :param expr: The the expression for which the annotations must be created. :param inst_map: Dictionary containing the instantiated variables. :returns: See YAML output spec /components/schemas/DesignRuleSpecArray. .. py:function:: make_behavior_node(b: raesl.compile.ast.components.BehaviorFunction, inst_name: str, inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> ragraph.node.Node Behavior spec node creation. :param d: The behavior specification for which a node must be created. :param inst_name: The instantiation name of the component. :param inst_map: Dictionary containing the instantiated variables. :returns: Node of kind "behavior_spec". .. py:function:: _make_behavior_annotations(b: raesl.compile.ast.components.BehaviorFunction, inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> Dict[str, Dict[str, Any]] Behavior spec annotation creation. :param h: The behavior spec for which the annotations must be created. :param inst_map: Dictionary containing the instantiated variables. :returns: See YAML output spec /components/schemas/BehaviorSpecAnnotation. .. py:function:: _make_case_annotations(c: raesl.compile.ast.components.BehaviorFunction, inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> Dict[str, Any] Case spec annotation creation. :param r: The behavior specication for which the case annotations must be created. :param inst_map: Dictionary containing the instantiated variables. :returns: See YAML output spec /components/schemas/CaseSpec. .. py:function:: make_relation_node(r: raesl.compile.ast.components.RelationInstance, inst_name: str, inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> ragraph.node.Node Relation spec node creation. :param d: The relation specification for which a node must be created. :param inst_name: The instantiation name of the component. :param inst_map: Dictionary containing the instantiated variables. :returns: Node of kind "relation_spec". .. py:function:: _get_arg_inst_names(inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode], args: List[raesl.compile.ast.components.InstanceArgument]) -> List[str] Converting list of InstanceArgument objects into a list of instantiated variable names. .. py:function:: _make_relation_annotations(r: raesl.compile.ast.components.RelationInstance, inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> Dict[str, Dict[str, Any]] Relation spec annotation creation. :param r: The relation for which a node must be created. :param inst_map: Dictionary containing the instantiated variables. :returns: See YAML output spec /components/schemas/RelationSpecAnnotation. .. py:function:: _make_bound_annotation(varval: Union[raesl.compile.ast.exprs.Value, raesl.compile.ast.exprs.VariableValue], inst_map: Dict[raesl.compile.ast.nodes.ElementaryVarNode, raesl.compile.instantiating.graph_data.InstNode]) -> Dict[str, str] Bound annotation creation :param varval: The value or variable that denotes the bound. :param inst_map: Dictionary containing the instantiated variables. :returns: See YAML output spec /components/schemas/Bound. .. py:data:: TAG_COMMENT_PAT .. py:function:: post_process_comments(nodes: List[ragraph.node.Node]) -> None Post-processing comments attached to nodes. :param nodes: List of nodes for which the comments must be post-processed. .. note:: This is a simple implementation to process documentation tags as described in LEP0008.