Пример #1
0
    def parse(cls, typeName: str, typeDefinitionNode: Iir) -> "RecordType":
        from pyGHDL.dom._Utils import GetNameOfNode

        elements = []
        elementDeclarations = nodes.Get_Elements_Declaration_List(
            typeDefinitionNode)

        elementCount = flists.Flast(elementDeclarations) + 1
        index = 0
        while index < elementCount:
            elementDeclaration = flists.Get_Nth_Element(
                elementDeclarations, index)

            element = RecordTypeElement.parse(elementDeclaration)

            # Lookahead for elements with multiple identifiers at once
            if nodes.Get_Has_Identifier_List(elementDeclaration):
                index += 1
                while index < elementCount:
                    nextNode: Iir = flists.Get_Nth_Element(
                        elementDeclarations, index)
                    # Consecutive identifiers are found, if the subtype indication is Null
                    if nodes.Get_Subtype_Indication(
                            nextNode) == nodes.Null_Iir:
                        element.Identifiers.append(GetNameOfNode(nextNode))
                    else:
                        break
                    index += 1

                    # The last consecutive identifiers has no Identifier_List flag
                    if not nodes.Get_Has_Identifier_List(nextNode):
                        break
            else:
                index += 1

            elements.append(element)

        return cls(typeDefinitionNode, typeName, elements)
Пример #2
0
def flist_iter(lst) -> Generator[Any, None, None]:
    """Iterate all element of Iir_List :obj:`lst`."""
    if lst <= nodes.Iir_Flist_All:
        return
    for i in range(flists.Flast(lst) + 1):
        yield flists.Get_Nth_Element(lst, i)