2017年5月22日星期一

编译器的选用

编译器用着很不顺手,都是自利啊!!!
都不利!
我想,那就只能利用现有的好好改进吧!
notepad+++ctags还是比较好用的,但是无奈默认的ctags插件都很恶心,可以供调节的选项几乎没有!!!
而且几乎不公开源码,就算公开,也几乎都是过时,BUG一大堆的!
所以,先从ctags爬起吧,终于有了一点眉目了,ctags支持各种变量检索的!
```
C:\Users\sc\Downloads\npp.6.6.9.bin\plugins>ctags  --help
Exuberant Ctags 5.7, Copyright (C) 1996-2007 Darren Hiebert
  Compiled: Sep  4 2007, 23:24:26
  Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
  Optional compiled features: +win32, +regex, +internal-sort
Usage: ctags [options] [file(s)]
  -a   Append the tags to an existing tag file.
  -B   Use backward searching patterns (?...?).
  -e   Output tag file for use with Emacs.
  -f <name>
       Write tags to specified file. Value of "-" writes tags to stdout
       ["tags"; or "TAGS" when -e supplied].
  -F   Use forward searching patterns (/.../) (default).
  -h <list>
       Specify list of file extensions to be treated as include files.
       [".h.H.hh.hpp.hxx.h++"].
  -I <list|@file>
       A list of tokens to be specially handled is read from either the
       command line or the specified file.
  -L <file>
       A list of source file names are read from the specified file.
       If specified as "-", then standard input is read.
  -n   Equivalent to --excmd=number.
  -N   Equivalent to --excmd=pattern.
  -o   Alternative for -f.
  -R   Equivalent to --recurse.
  -u   Equivalent to --sort=no.
  -V   Equivalent to --verbose.
  -x   Print a tabular cross reference file to standard output.
  --append=[yes|no]
       Should tags should be appended to existing tag file [no]?
  --etags-include=file
      Include reference to 'file' in Emacs-style tag file (requires -e).
  --exclude=pattern
      Exclude files and directories matching 'pattern'.
  --excmd=number|pattern|mix
       Uses the specified type of EX command to locate tags [mix].
  --extra=[+|-]flags
      Include extra tag entries for selected information (flags: "fq").
  --fields=[+|-]flags
      Include selected extension fields (flags: "afmikKlnsStz") [fks].
  --file-scope=[yes|no]
       Should tags scoped only for a single file (e.g. "static" tags
       be included in the output [yes]?
  --filter=[yes|no]
       Behave as a filter, reading file names from standard input and
       writing tags to standard output [no].
  --filter-terminator=string
       Specify string to print to stdout following the tags for each file
       parsed when --filter is enabled.
  --format=level
       Force output of specified tag file format [2].
  --help
       Print this option summary.
  --if0=[yes|no]
       Should C code within #if 0 conditional branches be parsed [no]?
  --<LANG>-kinds=[+|-]kinds
       Enable/disable tag kinds for language <LANG>.
  --langdef=name
       Define a new language to be parsed with regular expressions.
  --langmap=map(s)
       Override default mapping of language to source file extension.
  --language-force=language
       Force all files to be interpreted using specified language.
  --languages=[+|-]list
       Restrict files scanned for tags to those mapped to langauges
       specified in the comma-separated 'list'. The list can contain any
       built-in or user-defined language [all].
  --license
       Print details of software license.
  --line-directives=[yes|no]
       Should #line directives be processed [no]?
  --links=[yes|no]
       Indicate whether symbolic links should be followed [yes].
  --list-kinds=[language|all]
       Output a list of all tag kinds for specified language or all.
  --list-languages
       Output list of supported languages.
  --list-maps=[language|all]
       Output list of language mappings.
  --options=file
       Specify file from which command line options should be read.
  --recurse=[yes|no]
       Recurse into directories supplied on command line [no].
  --regex-<LANG>=/line_pattern/name_pattern/[flags]
       Define regular expression for locating tags in specific language.
  --sort=[yes|no|foldcase]
       Should tags be sorted (optionally ignoring case) [yes]?.
  --tag-relative=[yes|no]
       Should paths be relative to location of tag file [no; yes when -e]?
  --totals=[yes|no]
       Print statistics about source and tag files [no].
  --verbose=[yes|no]
       Enable verbose messages describing actions on each source file.
  --version
       Print version identifier to standard output.
```
一大堆参数,看着头疼!!!
终于谷歌了一个,容易看:
ctags默认是不支持局部/自动变量的,虽然vim自带的gd、[Tab快捷键可以跳转局部变量,但是跳过去就不能按Ctrl+t跳回来了,有点麻烦。但实际上,其实ctags是可以支持局部变量的,只是默认没有开启。在终端中输入ctags --list-kinds就可以查看可以支持的语法元素:
silence@codeplayer:~$ ctags --list-kinds=c
c  classes
d  macro definitions
e  enumerators (values inside an enumeration)
f  function definitions
g  enumeration names
l  local variables [off]
m  class, struct, and union members
n  namespaces
p  function prototypes [off]
s  structure names
t  typedefs
u  union names
v  variable definitions
x  external and forward variable declarations [off]
我们可以看到在默认情况下,局部变量、函数原型、外部和前向变量声明都是关闭的,在生成tags标签文件的时,如果在命令中加入--c-kinds=+lpx,就可以将他们都开启了。然后再进入vim里用Ctrl+]试试?都可以使用了吧:)

另外还可以使用ctags --list-languages命令查看ctags支持的语言,一共支持41种语言呢。使用ctags --list-maps命令还可以查看每种语言默认对应的扩展名。
###就是说啊,说了半天,直接用这个:--c-kinds=+lpx 参数,就可以了~~~
随手一想,CTags支持41种语言,为啥不用他搞各种语言的支持,不甘心,又在sourceforge上找,终于看到这了目前最完美的sourcecookifier,唯一不足就是没有源码。。。
可以说什么都支持,甚至可以自定义语言吧

没有评论:

发表评论