raesl.compile.typechecking.utils#

Support functions.

Module Contents#

Functions#

split_arguments(→ List[List[raesl.compile.scanner.Token]])

Given a list arguments, split them into 'params_length' pieces, where each piece

construct_var_param_map(→ Dict[str, ...)

Construct a dict of variable / parameter names to their definitions.

construct_vargroup_map(→ Dict[str, ...)

Construct a dict of variable groups names to their definitions.

construct_comp_instances_map(→ Dict[str, ...)

Construct a dict of child component instance names of the given

construct_verb_prepos_combis(→ Set[Tuple[str, str]])

Construct a set with all defined verb/prepos combinations.

construct_relinst_goal_transform_design_behavior_map(...)

Construct a dict to quickly find goals, transformations, designs, and behaviors

resolve_var_param_node(...)

Resolve the (possibly sub)node of a variable or parameter indicated by 'name'.

resolve_var_param_group_node(...)

Resolve the provided (possibly dotted) name to a node from a variable, parameter

raesl.compile.typechecking.utils.split_arguments(params_length: int, multiple_index: int | None, arguments: List[raesl.compile.scanner.Token]) List[List[raesl.compile.scanner.Token]]#

Given a list arguments, split them into ‘params_length’ pieces, where each piece has length 1, except piece ‘multiple_index’ if not None, which takes all the slack.

Parameters:
  • params_length – Number of pieces in the result.

  • multiple_index – Index in ‘arguments’ where the multi-piece starts, only if multiple_index is not None.

  • arguments – Actual arguments to split in pieces.

raesl.compile.typechecking.utils.construct_var_param_map(comp_def: raesl.compile.ast.components.ComponentDefinition) Dict[str, raesl.compile.ast.components.VarParam]#

Construct a dict of variable / parameter names to their definitions.

Parameters:

comp_def – Definition to search for available variables and parameters.

Returns:

Dictionary of names to their definitions.

raesl.compile.typechecking.utils.construct_vargroup_map(comp_def: raesl.compile.ast.components.ComponentDefinition) Dict[str, raesl.compile.ast.components.VariableGroup]#

Construct a dict of variable groups names to their definitions.

Parameters:

comp_def – Definition to search for available variables and parameters.

Returns:

Dictionary of group names to their definitions.

raesl.compile.typechecking.utils.construct_comp_instances_map(comp_def: raesl.compile.ast.components.ComponentDefinition) Dict[str, raesl.compile.ast.components.ComponentInstance]#

Construct a dict of child component instance names of the given component definition.

Parameters:

comp_def – Definition to search for available component instances.

Returns:

Dictionary of component instance names to their instances.

raesl.compile.typechecking.utils.construct_verb_prepos_combis(spec: raesl.compile.ast.specification.Specification) Set[Tuple[str, str]]#

Construct a set with all defined verb/prepos combinations.

raesl.compile.typechecking.utils.construct_relinst_goal_transform_design_behavior_map(comp_def: raesl.compile.ast.components.ComponentDefinition) Dict[str, raesl.compile.ast.components.RelationInstance | raesl.compile.ast.components.Goal | raesl.compile.ast.components.Transformation | raesl.compile.ast.components.Design | raesl.compile.ast.components.BehaviorFunction]#

Construct a dict to quickly find goals, transformations, designs, and behaviors by their label name.

Parameters:

comp_def – Definition to search.

Returns:

Dictionary of labels to their goals, transformations, designs, and behaviors.

raesl.compile.typechecking.utils.resolve_var_param_node(name_tok: raesl.compile.scanner.Token, avail_vps: Dict[str, raesl.compile.ast.components.VarParam], reported_names: Set[str], diag_store: raesl.compile.diagnostics.DiagnosticStore) raesl.compile.ast.nodes.VarNode | None#

Resolve the (possibly sub)node of a variable or parameter indicated by ‘name’. If it fails, report an error if necessary.

Parameters:
  • name_tok – Name of the node to obtain, may contain a dotted name.

  • avail_vps – Variables and parameters available in the context.

  • reported_names – Non-existing names and prefixes that are reported already.

  • diag_store – Storage for found diagnostics.

Returns:

The node represented by the name, or None if it could not be found.

In the latter case, an problem exists indicating failure to find the node.

raesl.compile.typechecking.utils.resolve_var_param_group_node(name_tok: raesl.compile.scanner.Token, avail_vps: Dict[str, raesl.compile.ast.components.VarParam] | None, avail_vgroups: Dict[str, raesl.compile.ast.components.VariableGroup] | None, reported_names: Set[str], diag_store: raesl.compile.diagnostics.DiagnosticStore) raesl.compile.ast.nodes.Node | None#

Resolve the provided (possibly dotted) name to a node from a variable, parameter or variable group.

Parameters:
  • name_tok – Name of the node to obtain, may contain a dotted name.

  • avail_vps – Available variables and parameters, may be None.

  • avail_vgroups – Available variable groups, may be None.

  • reported_names – Non-existing variables, parameters, and groups that are reported already.

  • diag_store – Destination for found diagnostics.

Returns:

The node represented by the name. It can be a Node if the name points at a

variable groups. It is always a VarNode if the nam points at a variable or parameter.