:py:mod:`raesl.compile.typechecking.type_builder` ================================================= .. py:module:: raesl.compile.typechecking.type_builder .. autoapi-nested-parse:: Class for constructing types. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: raesl.compile.typechecking.type_builder.TempTypeDef raesl.compile.typechecking.type_builder.TempFieldDef raesl.compile.typechecking.type_builder.TempBundleDef raesl.compile.typechecking.type_builder.TypeBuilder Attributes ~~~~~~~~~~ .. autoapisummary:: raesl.compile.typechecking.type_builder.STANDARD_TYPE_NAMES .. py:data:: STANDARD_TYPE_NAMES :value: ('real', 'integer', 'string', 'boolean') .. py:class:: TempTypeDef(type_name: raesl.compile.scanner.Token, parent_name: Optional[raesl.compile.scanner.Token], enum_spec: Optional[List[raesl.compile.ast.exprs.Value]], unit_spec: Optional[List[raesl.compile.scanner.Token]], ival_spec: Optional[List[Tuple[Optional[raesl.compile.ast.exprs.Value], Optional[raesl.compile.ast.exprs.Value]]]], cons_spec: Optional[raesl.compile.ast.exprs.Value]) Temporary storage of a type definition. .. py:class:: TempFieldDef(field_name: raesl.compile.scanner.Token, type_name: Optional[raesl.compile.scanner.Token]) Temporary storage of a field in a bundle. .. py:class:: TempBundleDef(bundle_name: raesl.compile.scanner.Token) Temporary storage of a bundle definition. .. py:class:: TypeBuilder(ast_builder: raesl.compile.typechecking.ast_builder.AstBuilder) Builder to construct types of the specification. :param ast_builder: AST builder instance. .. attribute:: diag_store Storage for found diagnostics. .. attribute:: type_defs Found type definitions in the specification, temporarily stored until all type information is available. .. attribute:: bundle_defs Found bundle definitions in the specification, temporarily stored until all type information is available. .. attribute:: current_bundle If not None, reference to the last opened bundle definition for adding additional fields to it. .. py:method:: notify_new_section(_new_top_section: bool) Notification that type additions have finished. .. py:method:: get_entry_location(entry: raesl.compile.typechecking.orderer.OrdererEntry) -> raesl.types.Location :staticmethod: Retrieve position information from a type entry. :param entry: Entry to use. :returns: Position information of the entry. .. py:method:: add_standard_types(resolved_types: Dict[str, raesl.compile.ast.types.TypeDef]) :staticmethod: Add all standard types to the resolved types. .. py:method:: finish(spec) Check the collected types and bundles, report any errors, and add them to the specification. :param spec: Specification to extend with the found types. .. py:method:: _construct_type(parent_name: Optional[raesl.compile.scanner.Token], enum_spec: Optional[List[raesl.compile.ast.exprs.Value]], unit_spec: Optional[List[raesl.compile.scanner.Token]], ival_spec: Optional[List[Tuple[Optional[raesl.compile.ast.exprs.Value], Optional[raesl.compile.ast.exprs.Value]]]], cons_spec: Optional[raesl.compile.ast.exprs.Value], prefer_parent: bool, resolved_types: Dict[str, raesl.compile.ast.types.TypeDef]) -> Optional[raesl.compile.ast.types.BaseType] Construct a new type from the given parameters. :param prefer_parent: If possible, don't make a new type. :returns: The parent type if nothing changed, the constructed ElementaryType if something was extended, or None if construction failed. .. py:method:: _check_override_standard_type(type_name: raesl.compile.scanner.Token) -> bool Check whether the new type tries to override a standard type. Give an error if it does. :returns: True if the new type is a standard type, else False. .. py:method:: _make_typedef(tdef: TempTypeDef, resolved_types: Dict[str, raesl.compile.ast.types.TypeDef]) Add the type definition to the resolved collection. It is assumed the dependencies are already available (as ensured by the Orderer). .. py:method:: _make_bundledef(bdef: TempBundleDef, resolved_types: Dict[str, raesl.compile.ast.types.TypeDef]) Add the bundle definition to the resolved collection. It is assumed the dependencies are already available (as ensured by the Orderer). .. py:method:: add_typedef(type_name: raesl.compile.scanner.Token, parent_name: Optional[raesl.compile.scanner.Token], enum_spec: Optional[List[raesl.compile.ast.exprs.Value]], unit_spec: Optional[List[raesl.compile.scanner.Token]], ival_spec: Optional[List[Tuple[Optional[raesl.compile.ast.exprs.Value], Optional[raesl.compile.ast.exprs.Value]]]], cons_spec: Optional[raesl.compile.ast.exprs.Value]) The parser found a new type definition entry, store it. .. py:method:: new_bundle_type(bundle_name: raesl.compile.scanner.Token) The parser found a new bundle in the source code, create it. .. py:method:: add_bundle_field(field_name: raesl.compile.scanner.Token, type_name: Optional[raesl.compile.scanner.Token]) A new field in the current bundle has been found by the parser, add it. .. py:method:: check_unit(value: Optional[raesl.compile.ast.exprs.Value], available_units: Dict[str, raesl.compile.scanner.Token]) -> None Check whether the unit possibly specified in 'value' is available for use. Report an error if it is not available.