Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 63 lines (52 sloc) 1.712 kb
b933fc2 Rudi Grinberg otags
authored
1 #!/usr/bin/perl
2 use Switch;
3 use Cwd;
4
5 # take an emacs-style tags file
6 # from 'otags' and put it in
7 # for for taglist vim module
8 # Note: 'ocamltags' might provide nicer output
9
10 $sep = "\t";
11 $newsection = 1;
12
13 while (<>) {
14 # skip blank lines or ^L mean new section
15 #if ( m/^\s+$/ ) { print "#"; next; }
16 $line = $_ ;
17
18 # section begins with ^L
19 if ( $line =~ m/^\x0C$/ ) { # \x0c = ^L
20 $newsection = 1;
21 #print STDERR "==> New section\n";
22 next;
23 }
24
25 # first line of each section has a filename
26 if ( $newsection && ($line =~ m/^([^,]+),[0-9]+$/ ) ) {
27 $fname = getcwd().'/'.$1 ;
28 #print STDERR "==> New file $fname\n";
29 $newsection = 0;
30 next;
31 }
32
33 $newsection = 0;
34 # original:
35 # (stmt pattern)^?(symbol)^A(linenum),(symbol idnum)
36 if ( $line =~ /^(.*)(.*)(.*)\,(.*)$/ ) {
37 ($pat, $sym, $lnum, $idnum) = ( $1, $2, $3, $4 );
38 #print STDERR "==> New symbol $sym\n";
39
40 # added to taglist.vim :
41 # " ocaml language
42 # let s:tlist_def_ocaml_settings = 'ocaml;m:module;t:type;d:definition'
43 #
44 # get type from 1st match in pattern, if type "and"
45 # use the type from last entry
46 $pat =~ m/\b(.+)\b\s+\b$sym\b/;
47 $rawtype = $1;
48
49 switch ( $rawtype ) {
50 case "and" { $type = $lasttype ; }
51 case "let" { $type = "d" ; }
52 case "type" { $type = "t" ; }
53 case "module" { $type = "m" ; }
54 }
55
56 # target:
57 # (symbol)\t/(pattern)/\t(file)\t(type)\tline:(line)
58 print $sym.$sep.$fname.$sep.'/^'.$pat.'/;"'.$sep.$type.$sep.'line:'.$lnum."\n" if $pat;
59
60 $lasttype = $type ;
61 }
62 }
Something went wrong with that request. Please try again.