用c++解析旺盛的标签

Parsing Exuberant Ctags with C++

本文关键字:标签 c++      更新时间:2023-10-16

我需要用符号浏览器制作一个编辑器,我说我会玩标签。好吧,我读标签格式,并试图谷歌和搜索这里在SO。我只发现了关于标签和vim的问题,我对vim一窍不通。所以我决定自己玩。所以我拿了一个标签文件,我完全困惑了!

在这里我已经把PHP文件及其相应的标签,我需要你的帮助,我怎么知道如果行代表类属性或方法?也我怎么能知道PHP函数/方法的返回值?

我还没有找到任何好的教程处理PHP(或任何其他语言)标签以外的vi/vim连接的标签!由于

PHP文件

<?php
$teachers = array("standard one"=>"Celina Stephen", "Standard Two"=>"Emanyor Dickson");
function set_teachers($teacher_array){
    $teachers = $teacher_array;
    return $teacher_array;
}
class School{
    $teachers;
    $students;
    public function __construct(){
    }
    public function get_all(){
        return array($this->teachers,$this->students);
    }
}
class ManySchools extends School{
    public __construct(){
        parent::construct();
    }
    private do_selection($teacher, $student=null){
        return false;
    }
}

标记文件
!_TAG_FILE_FORMAT   2   /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED   1   /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR    Darren Hiebert  /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME  Exuberant Ctags //
!_TAG_PROGRAM_URL   http://ctags.sourceforge.net    /official site/
!_TAG_PROGRAM_VERSION   5.9~svn20110310 //
ManySchools test.php    /^class ManySchools extends School{$/;" c
School  test.php    /^class School{$/;" c
__construct test.php    /^    public function __construct(){$/;"    f
get_all test.php    /^    public function get_all(){$/;"    f
set_teachers    test.php    /^function set_teachers($teacher_array){$/;"    f
teachers    test.php    /^    $teachers = $teacher_array;$/;"   v
teachers    test.php    /^$teachers = array("standard one"=>"Celina Stephen", "Standard Two"=>"Emanyor Dickson");$/;"   v

每行;"后第一项描述标签的kind,即是否为类、函数等。在你的例子中,c代表类,f代表函数,以此类推。您可以使用ctags --list-kinds=php获得完整的列表。

返回类型(不幸的是)不由标签报告。

你一定要看一下标签手册,所有的东西都解释得很好,例如除了默认报告的信息之外,它还可以报告哪些其他信息

我读标签格式

Exuberant标签文件格式有很好的文档。