vhdl_util.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:VHDL-Mode 作者: Remillard 项目源码 文件源码
def scan_instantiations(cmd_obj):
    '''
    Obtaining a list of all regions that contain instantiation labels
    and then creating a dictionary of instantiated components and their
    associated labels.
    '''
    instances = {}
    selector = 'meta.block.instantiation entity.name.label'
    regions = cmd_obj.view.find_by_selector(selector)
    for region in regions:
        line = cmd_obj.view.substr(cmd_obj.view.full_line(region))
        line = re.sub(r'\n', '', line)
        row, col = cmd_obj.view.rowcol(region.begin())
        pattern = r'^\s*(?P<label>\w+)\s*:\s*(?:entity)?\s*((?P<lib>\w+)\.)?(?P<entity>[\w\.]+)'
        s = re.search(pattern, line, re.I)
        if s:
            if s.group('entity') in instances:
                instances[s.group('entity')].append(s.group('label'))
            else:
                instances[s.group('entity')] = [s.group('label')]
        else:
            print('vhdl-mode: Could not match instantiation on line {}'.format(row+1))
    return instances
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号