:py:mod:`raesl.compile.typechecking.compdef_builder` ==================================================== .. py:module:: raesl.compile.typechecking.compdef_builder .. autoapi-nested-parse:: Builder for collecting and building component definitions. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: raesl.compile.typechecking.compdef_builder.Counter raesl.compile.typechecking.compdef_builder.CompDefChildBuilders raesl.compile.typechecking.compdef_builder.ComponentDefBuilder .. py:class:: 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. :param first_free_value: First free value to set the counter to. .. attribute:: counter Next free value. .. py:method:: next() -> int Get a unique number from the counter instance. .. py:class:: CompDefChildBuilders(compdef_builder: ComponentDefBuilder, pos_tok: raesl.compile.scanner.Token, name_tok: Optional[raesl.compile.scanner.Token], 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. :param compdef_builder: Parent component definition builder. :param pos_tok: Position of the start of the component definition. :param name_tok: Name of the component definition if it exists :param varparam_counter: Object for handing out unique numbers to elementary var/param nodes. .. py:method:: add_variables(new_vars: List[raesl.compile.ast.components.VarParam]) Forward call to variable & parameter builder. .. py:method:: add_parameters(new_params: List[raesl.compile.ast.components.VarParam]) Forward call to variable & parameter builder. .. py:method:: new_vargroup(name_tok: raesl.compile.scanner.Token) Forward call to variable group builder. .. py:method:: vgroup_add_vars(varname_toks: List[raesl.compile.scanner.Token]) Forward call to variable group builder. .. py:method:: 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. .. py:method:: add_compinst_arguments(arguments: List[raesl.compile.scanner.Token]) Forward call to component instance builder. .. py:method:: new_relinst(inst_name_tok: raesl.compile.scanner.Token, def_name_tok: raesl.compile.scanner.Token) Forward call to relation instance builder. .. py:method:: relinst_argheader(argkind_tok: raesl.compile.scanner.Token) Forward call to relation instance builder. .. py:method:: add_relinst_arguments(name_toks: List[raesl.compile.scanner.Token]) Forward call to relation instance builder. .. py:method:: new_goal_header(goal_kind: raesl.compile.scanner.Token) Forward call to goal builder. .. py:method:: add_goal(goal: raesl.compile.ast.components.Goal) Forward call to goal builder. .. py:method:: add_goal_subclause(sub_clause: raesl.compile.ast.components.SubClause) Forward call to goal builder. .. py:method:: new_transform_header(transform_kind: raesl.compile.scanner.Token) Forward call to transform builder. .. py:method:: add_transform(transform: raesl.compile.ast.components.Transformation) Forward call to transform builder. .. py:method:: add_transform_subclause(sub_clause: raesl.compile.ast.components.SubClause) Forward call to transform builder. .. py:method:: new_behavior_header(kind_tok: raesl.compile.scanner.Token) Forward call to behavior builder. .. py:method:: new_behavior_function(label_tok: raesl.compile.scanner.Token) Forward call to behavior builder. .. py:method:: behavior_case(case_label_tok: raesl.compile.scanner.Token) Forward call to behavior builder. .. py:method:: behavior_normal_when(when_tok: raesl.compile.scanner.Token) Forward call to behavior builder. .. py:method:: behavior_default_when(when_tok: raesl.compile.scanner.Token) Forward call to behavior builder. .. py:method:: behavior_when_condition(name_tok: raesl.compile.scanner.Token, condition: Union[raesl.compile.ast.exprs.Disjunction, raesl.compile.ast.exprs.RelationComparison]) Forward call to behavior builder. .. py:method:: behavior_normal_then(then_tok: raesl.compile.scanner.Token) Forward call to behavior builder. .. py:method:: behavior_then_result(name_tok: raesl.compile.scanner.Token, result: raesl.compile.ast.exprs.Comparison) Forward call to behavior builder. .. py:method:: new_design_header(kind: raesl.compile.scanner.Token) Forward call to design builder. .. py:method:: design_line(design: raesl.compile.ast.components.Design) Forward call to design builder. .. py:method:: add_design_subclause(sub: raesl.compile.ast.components.SubClause) Forward call to design builder. .. py:method:: add_need(label_tok: raesl.compile.scanner.Token, subject_tok: raesl.compile.scanner.Token, description: str) Forward call to need builder. .. py:method:: add_comment(name_tok: raesl.compile.scanner.Token) Forward call to comment builder. .. py:method:: 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. .. py:method:: 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. :param spec: Specification to use as source for types, verbs relation definitions, and other component definitions, and to fill with the type-checked component. :param doc_distributor: Object that accepts the found doc comments for distributing them to the elements of the specification. .. py:method:: notify_parameter_section(pos_tok: raesl.compile.scanner.Token) A parameter section was found, check if it is allowed. .. py:method:: notify_transform_section(pos_tok: raesl.compile.scanner.Token) A transform section was found, check if it is allowed. .. py:class:: 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. .. py:method:: notify_new_section(new_top_section) Notification for self and possibly the child builders if a new component definition is under construction. .. py:method:: new_componentdef(pos_tok: raesl.compile.scanner.Token, name_tok: Optional[raesl.compile.scanner.Token]) New component definition started. :param pos_tok: Token defining the start position of the component definition. :param name_tok: Token with the name of the definition if it exists. Non-existing name means the component represents 'world'. .. py:method:: finish(spec: raesl.compile.ast.specification.Specification, doc_distributor: raesl.compile.ast.comment_storage.DocCommentDistributor) Parsing has finished, complete type checking. :param spec: Specification already containing types, verb-prepositions, and relation definitions. Must be filled with component definitions and world component. :param doc_distributor: Object that accepts the found doc comments for distributing them to the elements of the specification.