:py:mod:`raesl.compile.typechecking.compdef_behavior_builder` ============================================================= .. py:module:: raesl.compile.typechecking.compdef_behavior_builder .. autoapi-nested-parse:: Code for collecting and adding behavior sections to component definitions. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: raesl.compile.typechecking.compdef_behavior_builder.ParsedBehavior raesl.compile.typechecking.compdef_behavior_builder.ParsedCase raesl.compile.typechecking.compdef_behavior_builder.CompDefBehaviorBuilder Attributes ~~~~~~~~~~ .. autoapisummary:: raesl.compile.typechecking.compdef_behavior_builder.WhensType raesl.compile.typechecking.compdef_behavior_builder.ThensType .. py:class:: ParsedBehavior(name: raesl.compile.scanner.Token, kind: str, cases: List[ParsedCase]) Temporary storage of a behavior. This allows catching multiple default cases (these cannot be expressed in the AST). Also, it allows checking for receiving a sane order of calls from the parser. .. py:data:: WhensType .. py:data:: ThensType .. py:class:: ParsedCase(name: raesl.compile.scanner.Token, when_tok: Optional[raesl.compile.scanner.Token], then_tok: Optional[raesl.compile.scanner.Token], whens: WhensType, thens: ThensType) Temporary storage for storing a case in a behavior while collecting the cases. :param name: Name of the case. :param when_tok: Position of the 'when' line. :param then_tok: Position of the 'then' line. :param whens: Collected conditions. Will be empty for the default behavior. None means the variable should not be accessed at all. :param thens: Collected results. .. py:class:: CompDefBehaviorBuilder(comp_child_builders: raesl.compile.typechecking.compdef_builder.CompDefChildBuilders) Class for constructing and checking behavior functions. :param comp_child_builders: Storage of child builders for a component definition. .. attribute:: behavior_kind Last seen kind of behavior ('requirement' or 'constraint'). .. attribute:: expect_conds Whether the builder should allow conditions to be received from the parser. .. attribute:: expect_results Whether the builder should allow results to be received from the parser. .. attribute:: pbehaviors Collected behaviors. .. py:method:: new_behavior_header(kind_tok: raesl.compile.scanner.Token) A new 'behavior' section header was found. .. py:method:: new_behavior_function(label_tok: raesl.compile.scanner.Token) A new behavior functionality was found. :param label_tok: Name of the new behavior. .. py:method:: behavior_case(case_label_tok: raesl.compile.scanner.Token) A new case of the last started behavior functionality was found. :param case_label_tok: Name of the case. .. py:method:: behavior_normal_when(when_tok: raesl.compile.scanner.Token) The start of a normal 'when' condition block was found. :param when_tok: Position of the start of the new block. .. py:method:: behavior_default_when(when_tok: raesl.compile.scanner.Token) The start of a default condition block was found. :param when_tok: Position of the start of the new block. .. py:method:: behavior_when_condition(name_tok: raesl.compile.scanner.Token, condition: Union[raesl.compile.ast.exprs.Disjunction, raesl.compile.ast.exprs.RelationComparison]) A new condition was found, add it to the last 'when' block. :param name_tok: Name of the condition. :param condition: Condition to add. .. py:method:: behavior_normal_then(then_tok: raesl.compile.scanner.Token) The start of a 'then' result block was found. :param then_tok: Position of the start of the new block. .. py:method:: behavior_then_result(name_tok: raesl.compile.scanner.Token, result: raesl.compile.ast.exprs.Comparison) A new result was found, add it to the last 'then' block. :param name_tok: Name of the result. :param result: Result to add. .. py:method:: finish_comp(comp_def: raesl.compile.ast.components.ComponentDefinition, _spec: raesl.compile.ast.specification.Specification) Verify correctness of the collected behavior and store good behavior in :obj:`comp_def`. :param comp_def: Surrounding component definition supplying variables and parameters. Checked designs should be added to it after checking. :param _spec: Specification being constructed, source for types and verbs. .. py:method:: _convert_conditions(whens: WhensType, expr_checker: raesl.compile.typechecking.expr_checker.ExprChecker) -> List[raesl.compile.ast.components.BehaviorCondition] Check the conditions of a case, and convert them to :obj:`BehaviorCondition` instances. .. py:method:: _convert_results(thens: ThensType, expr_checker: raesl.compile.typechecking.expr_checker.ExprChecker) -> List[raesl.compile.ast.components.BehaviorResult] Check the results of a case, and convert them to :obj:`BehaviorResult` instances.