raesl.compile.typechecking.compdef_builder#

Builder for collecting and building component definitions.

Module Contents#

Classes#

Counter

Class for handing out unique numeric values.

CompDefChildBuilders

Class storing child builders for all sections of a component definition.

ComponentDefBuilder

Builder to construct component definitions of the entire specification. The

class raesl.compile.typechecking.compdef_builder.Counter(first_free_value: int)#

Class for handing out unique numeric values.

Normally, a static class variable would do, except testing more than one specification at a time doesn’t reset the counter, leading to different output depending on what is being tested together.

Parameters:

first_free_value – First free value to set the counter to.

counter#

Next free value.

next() int#

Get a unique number from the counter instance.

class raesl.compile.typechecking.compdef_builder.CompDefChildBuilders(compdef_builder: ComponentDefBuilder, pos_tok: raesl.compile.scanner.Token, name_tok: raesl.compile.scanner.Token | None, varparam_counter: Counter)#

Class storing child builders for all sections of a component definition.

As type checking cannot be done until the entire specification has been parsed (global types, verbs, and relation definitions may not exist at the time of the end of a component definition, and definitions of instantiated component may be defined further down in the specification), child builders for each definition must be kept around until the end.

Parameters:
  • compdef_builder – Parent component definition builder.

  • pos_tok – Position of the start of the component definition.

  • name_tok – Name of the component definition if it exists

  • varparam_counter – Object for handing out unique numbers to elementary var/param nodes.

add_variables(new_vars: List[raesl.compile.ast.components.VarParam])#

Forward call to variable & parameter builder.

add_parameters(new_params: List[raesl.compile.ast.components.VarParam])#

Forward call to variable & parameter builder.

new_vargroup(name_tok: raesl.compile.scanner.Token)#

Forward call to variable group builder.

vgroup_add_vars(varname_toks: List[raesl.compile.scanner.Token])#

Forward call to variable group builder.

add_compinst(inst_name_tok: raesl.compile.scanner.Token, def_name_tok: raesl.compile.scanner.Token, has_arguments: bool)#

Forward call to component instance builder.

add_compinst_arguments(arguments: List[raesl.compile.scanner.Token])#

Forward call to component instance builder.

new_relinst(inst_name_tok: raesl.compile.scanner.Token, def_name_tok: raesl.compile.scanner.Token)#

Forward call to relation instance builder.

relinst_argheader(argkind_tok: raesl.compile.scanner.Token)#

Forward call to relation instance builder.

add_relinst_arguments(name_toks: List[raesl.compile.scanner.Token])#

Forward call to relation instance builder.

new_goal_header(goal_kind: raesl.compile.scanner.Token)#

Forward call to goal builder.

add_goal(goal: raesl.compile.ast.components.Goal)#

Forward call to goal builder.

add_goal_subclause(sub_clause: raesl.compile.ast.components.SubClause)#

Forward call to goal builder.

new_transform_header(transform_kind: raesl.compile.scanner.Token)#

Forward call to transform builder.

add_transform(transform: raesl.compile.ast.components.Transformation)#

Forward call to transform builder.

add_transform_subclause(sub_clause: raesl.compile.ast.components.SubClause)#

Forward call to transform builder.

new_behavior_header(kind_tok: raesl.compile.scanner.Token)#

Forward call to behavior builder.

new_behavior_function(label_tok: raesl.compile.scanner.Token)#

Forward call to behavior builder.

behavior_case(case_label_tok: raesl.compile.scanner.Token)#

Forward call to behavior builder.

behavior_normal_when(when_tok: raesl.compile.scanner.Token)#

Forward call to behavior builder.

behavior_default_when(when_tok: raesl.compile.scanner.Token)#

Forward call to behavior builder.

behavior_when_condition(name_tok: raesl.compile.scanner.Token, condition: raesl.compile.ast.exprs.Disjunction | raesl.compile.ast.exprs.RelationComparison)#

Forward call to behavior builder.

behavior_normal_then(then_tok: raesl.compile.scanner.Token)#

Forward call to behavior builder.

behavior_then_result(name_tok: raesl.compile.scanner.Token, result: raesl.compile.ast.exprs.Comparison)#

Forward call to behavior builder.

new_design_header(kind: raesl.compile.scanner.Token)#

Forward call to design builder.

design_line(design: raesl.compile.ast.components.Design)#

Forward call to design builder.

add_design_subclause(sub: raesl.compile.ast.components.SubClause)#

Forward call to design builder.

add_need(label_tok: raesl.compile.scanner.Token, subject_tok: raesl.compile.scanner.Token, description: str)#

Forward call to need builder.

add_comment(name_tok: raesl.compile.scanner.Token)#

Forward call to comment builder.

get_child_compdefnames() Set[str]#

Get the names of component definitions that are needed for child instances.

Returns:

Names of the components being instantiated in this component.

finish(spec: raesl.compile.ast.specification.Specification, doc_distributor: raesl.compile.ast.comment_storage.DocCommentDistributor)#

Parsing is finished, component child instances have been checked already. Check the collected component data, and add the component definition to the specification.

Parameters:
  • spec – Specification to use as source for types, verbs relation definitions, and other component definitions, and to fill with the type-checked component.

  • doc_distributor – Object that accepts the found doc comments for distributing them to the elements of the specification.

notify_parameter_section(pos_tok: raesl.compile.scanner.Token)#

A parameter section was found, check if it is allowed.

notify_transform_section(pos_tok: raesl.compile.scanner.Token)#

A transform section was found, check if it is allowed.

class raesl.compile.typechecking.compdef_builder.ComponentDefBuilder(ast_builder: raesl.compile.typechecking.ast_builder.AstBuilder)#

Builder to construct component definitions of the entire specification. The builder keeps a list of component child builders, one for each component definition. The latter do all the work for each component definition.

notify_new_section(new_top_section)#

Notification for self and possibly the child builders if a new component definition is under construction.

new_componentdef(pos_tok: raesl.compile.scanner.Token, name_tok: raesl.compile.scanner.Token | None)#

New component definition started.

Parameters:
  • pos_tok – Token defining the start position of the component definition.

  • name_tok – Token with the name of the definition if it exists. Non-existing name means the component represents ‘world’.

finish(spec: raesl.compile.ast.specification.Specification, doc_distributor: raesl.compile.ast.comment_storage.DocCommentDistributor)#

Parsing has finished, complete type checking.

Parameters:
  • spec – Specification already containing types, verb-prepositions, and relation definitions. Must be filled with component definitions and world component.

  • doc_distributor – Object that accepts the found doc comments for distributing them to the elements of the specification.