Ejemplo n.º 1
0
 def parse_document(self):
     """Parse a document and put the units in the library"""
     assert self._tree == nodes.Null_Iir
     tree = sem_lib.Load_File(self._fe)
     if tree == nodes.Null_Iir:
         return
     self._tree = Document.add_to_library(tree)
     log.debug("add_to_library(%u) -> %u", tree, self._tree)
     if self._tree == nodes.Null_Iir:
         return
     nodes.Set_Design_File_Source(self._tree, self._fe)
Ejemplo n.º 2
0
def list_units(filename):
    # Load the file
    file_id = name_table.Get_Identifier(filename.encode('utf_8'))
    sfe = files_map.Read_Source_File(name_table.Null_Identifier, file_id)
    if sfe == files_map.No_Source_File_Entry:
        print("cannot open file '{}'".format(filename))
        return

    # Parse and analyze
    file = sem_lib.Load_File(sfe)

    # Display all design units
    unit = nodes.Get_First_Design_Unit(file)
    while unit != nodes.Null_Iir:
        lib_unit = nodes.Get_Library_Unit(unit)
        if nodes.Get_Kind(lib_unit) == nodes.Iir_Kind.Entity_Declaration:
            print('entity {}'.format(get_identifier_ptr(lib_unit)))
        elif nodes.Get_Kind(lib_unit) == nodes.Iir_Kind.Architecture_Body:
            print('architecture {}'.format(get_identifier_ptr(lib_unit)))
        else:
            print('unknown unit!')
        unit = nodes.Get_Chain(unit)
Ejemplo n.º 3
0
 def parse_document(sfe):
     return sem_lib.Load_File(sfe)