Ejemplo n.º 1
0
    def organize_collection(self):
        tokens = []

        for file_item in self.vhdl_source_file_list:

            vhdl_object = VHD(file_item)

            with open(file_item, 'r') as file:
                content = file.read()

            # Lexer
            lex = Lexer(content)
            tokens = lex.tokenize()

            # Parser
            parser = Parser(tokens)
            # Get the vhdl objects dependencies
            dep_list = parser.get_dependency()
            # Get the type of vhdl object
            vhdl_type = parser.get_type()

            # vhdl object
            # Set the name of vhdl object
            vhdl_object.set_name(vhdl_type)
            # Set the type of vhdl object
            vhdl_object.set_type(vhdl_type)
            # Set the vhdl object dependencies
            vhdl_object.add_dependency(dep_list)

            # Add vhdl object to list
            self.vhdl_obj_list.append(vhdl_object)

            vhdl_object.get_generics(tokens)

        self._sort_compile_order(self.vhdl_obj_list)
Ejemplo n.º 2
0
    def organize_collection(self) -> list :
        """
        With all files in collection do:
        1. Create a vhdl_object() object
        2. Tokenize file
        3. Parse file
        4. Read file dependencies
        5. Read type of file
        6. Set vhdl_object name, type and dependencies.
        7. Add vhdl_object to vhdl_object_list
        8. Detect vhdl_object generics

        -> Final, sort vhdl_objects by dependency.
        """

        for file_item in self.vhdl_source_file_list:
            # Get new VHDL object
            vhdl_object = VHD(file_item)

            # Read file content
            with open(file_item, 'r') as file:
                content = file.read()

            # Get tokens from Lexer
            lexer = Lexer(content)
            tokens = lexer.get_tokens()

            # Parser
            parser      = Parser(tokens)
            # Get the vhdl objects dependencies
            dep_list    = parser.get_dependency()

            # Get the type of vhdl object
            vhdl_type    = parser.get_type()

            # VHDL object
            # Set the name of vhdl object
            vhdl_object.set_name(vhdl_type)
            # Set the type of vhdl object
            vhdl_object.set_type(vhdl_type)
            # Set the vhdl object dependencies
            vhdl_object.add_dependency(dep_list)

            # Add vhdl object to list
            self.vhdl_obj_list.append(vhdl_object)

            #vhdl_object.get_generics(tokens)

        # Organize VHDL objects by internal dependeny
        return self._sort_compile_order(self.vhdl_obj_list)