raesl.compile.typechecking.compdef_behavior_builder
#
Code for collecting and adding behavior sections to component definitions.
Module Contents#
Classes#
Temporary storage of a behavior. This allows catching multiple default cases |
|
Temporary storage for storing a case in a behavior while collecting the cases. |
|
Class for constructing and checking behavior functions. |
Attributes#
- class raesl.compile.typechecking.compdef_behavior_builder.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.
- raesl.compile.typechecking.compdef_behavior_builder.WhensType#
- raesl.compile.typechecking.compdef_behavior_builder.ThensType#
- class raesl.compile.typechecking.compdef_behavior_builder.ParsedCase(name: raesl.compile.scanner.Token, when_tok: raesl.compile.scanner.Token | None, then_tok: raesl.compile.scanner.Token | None, whens: WhensType, thens: ThensType)#
Temporary storage for storing a case in a behavior while collecting the cases.
- Parameters:
name – Name of the case.
when_tok – Position of the ‘when’ line.
then_tok – Position of the ‘then’ line.
whens – Collected conditions. Will be empty for the default behavior. None means the variable should not be accessed at all.
thens – Collected results.
- class raesl.compile.typechecking.compdef_behavior_builder.CompDefBehaviorBuilder(comp_child_builders: raesl.compile.typechecking.compdef_builder.CompDefChildBuilders)#
Class for constructing and checking behavior functions.
- Parameters:
comp_child_builders – Storage of child builders for a component definition.
- behavior_kind#
Last seen kind of behavior (‘requirement’ or ‘constraint’).
- expect_conds#
Whether the builder should allow conditions to be received from the parser.
- expect_results#
Whether the builder should allow results to be received from the parser.
- pbehaviors#
Collected behaviors.
- new_behavior_header(kind_tok: raesl.compile.scanner.Token)#
A new ‘behavior’ section header was found.
- new_behavior_function(label_tok: raesl.compile.scanner.Token)#
A new behavior functionality was found.
- Parameters:
label_tok – Name of the new behavior.
- behavior_case(case_label_tok: raesl.compile.scanner.Token)#
A new case of the last started behavior functionality was found.
- Parameters:
case_label_tok – Name of the case.
- behavior_normal_when(when_tok: raesl.compile.scanner.Token)#
The start of a normal ‘when’ condition block was found.
- Parameters:
when_tok – Position of the start of the new block.
- behavior_default_when(when_tok: raesl.compile.scanner.Token)#
The start of a default condition block was found.
- Parameters:
when_tok – Position of the start of the new block.
- behavior_when_condition(name_tok: raesl.compile.scanner.Token, condition: raesl.compile.ast.exprs.Disjunction | raesl.compile.ast.exprs.RelationComparison)#
A new condition was found, add it to the last ‘when’ block.
- Parameters:
name_tok – Name of the condition.
condition – Condition to add.
- behavior_normal_then(then_tok: raesl.compile.scanner.Token)#
The start of a ‘then’ result block was found.
- Parameters:
then_tok – Position of the start of the new block.
- 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.
- Parameters:
name_tok – Name of the result.
result – Result to add.
- 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
comp_def
.- Parameters:
comp_def – Surrounding component definition supplying variables and parameters. Checked designs should be added to it after checking.
_spec – Specification being constructed, source for types and verbs.
- _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
BehaviorCondition
instances.
- _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
BehaviorResult
instances.