xref: /Universal-ctags/optlib/man.ctags (revision a2073a83ebac9c08123fa77aaa3de27c5ea1b00f)
1#
2#
3#  Copyright (c) 2016, Red Hat, Inc.
4#  Copyright (c) 2016, Masatake YAMATO
5#
6#  Author: Masatake YAMATO <yamato@redhat.com>
7#
8# This program is free software; you can redistribute it and/or
9# modify it under the terms of the GNU General Public License
10# as published by the Free Software Foundation; either version 2
11# of the License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21# USA.
22#
23#
24--langdef=Man
25--map-Man=+.1
26--map-Man=+.2
27--map-Man=+.3
28--map-Man=+.4
29--map-Man=+.5
30--map-Man=+.6
31--map-Man=+.7
32--map-Man=+.8
33--map-Man=+.9
34
35# For perl modules
36--map-Man=+.3pm
37
38# For systemtap
39--map-Man=+.3stap
40--map-Man=+.7stap
41
42--kinddef-Man=t,title,titles
43--kinddef-Man=s,section,sections
44--kinddef-Man=S,subsection,sub sections
45
46--_scopesep-Man=*/*:""
47
48--_tabledef-Man=main
49--_tabledef-Man=section
50--_tabledef-Man=sectionheading
51--_tabledef-Man=subsection
52--_tabledef-Man=subsectionheading
53
54--_prelude-Man={{
55    % adjustment:int FILL-END-OF-SCOPE -
56    %
57    % Note: The group 1 of a regex matching is assumed.
58    %       An entry on the scope stack is assumed.
59    /fill-end-of-scope {
60         _scopetop pop exch
61         % scope-top:int adjustment:int
62         1 /start _matchloc _matchloc2line exch
63         % scope-top:int line adjustment:int
64         2 copy gt {
65             sub end:
66         } {
67             pop pop pop
68         } ifelse
69    } def
70    % adjustment:int /replace HEADING-ACTION -
71    % /push HEADING-ACTION -
72    /heading-action {
73        /replace eq {
74             %
75             % Before removing the tag at the top of the scope stack,
76             % fill the end field of the tag.
77             %
78             % input0.man
79             % ----------------------------------------------------
80             %   .SH SEC1
81             %   ...
82             %E: This is the end of the SEC1.
83             %   .SH
84             %C: SEC2
85             %
86             % ----------------------------------------------------
87             %
88             % C represents the current input line. The parser must
89             % fill the end field of "SEC1", the tag at the top,
90             % with the line number of E.
91             %
92             %    E = C - 2
93             %
94             % input1.man
95             % ----------------------------------------------------
96             %   .SH SEC3
97             %   ...
98             %E: This is the end of the SEC1.
99             %C:  .SH SEC4
100             %
101             % ----------------------------------------------------
102             %
103             % In this case
104             %
105             %    E = C - 1
106             %
107             % The offset for the adjustment depends on the conctxt.
108             %
109             fill-end-of-scope
110             _scopepop
111        } if
112
113        _scopetop {
114            . exch scope:
115        } if
116        . _scopepush
117    } def
118}}
119
120--_tabledef-Man=EOF
121--_tabledef-Man=SKIP
122--_tabledef-Man=REST
123--_tabledef-Man=GUARD
124
125#
126# helper tables
127#
128--_mtable-regex-Man=GUARD/([^\n.]|\.[^\nst])[^\n]*\n//{icase}
129--_mtable-regex-Man=SKIP/[^\n]*\n|[^\n]+//
130--_mtable-regex-Man=EOF///{scope=clear}{tquit}
131--_mtable-extend-Man=REST+SKIP
132--_mtable-extend-Man=REST+EOF
133
134#
135# main table
136#
137--_mtable-extend-Man=main+GUARD
138--_mtable-regex-Man=main/\.TH[\t ]+"([^"]+)"[^\n]*\n/\1/t/{icase}{scope=set}
139--_mtable-regex-Man=main/\.TH[\t ]+([^\t \n]+)[^\n]*\n/\1/t/{icase}{scope=set}
140--_mtable-regex-Man=main/\.SH[\t ]+"([^"\n]+)"[^\n]*\n/\1/s/{icase}{scope=push}{tenter=section}
141--_mtable-regex-Man=main/\.SH[\t ]+([^\n]+)\n/\1/s/{icase}{scope=push}{tenter=section}
142--_mtable-regex-Man=main/\.SH[\t ]*\n//{icase}{tenter=sectionheading}{{
143    /push
144}}
145--_mtable-extend-Man=main+REST
146
147#
148# section table
149#
150--_mtable-extend-Man=section+GUARD
151--_mtable-regex-Man=section/\.SH[\t ]+"([^"\n]+)"[^\n]*\n/\1/s/{icase}{scope=replace}
152--_mtable-regex-Man=section/\.SH[\t ]+([^\n]+)\n/\1/s/{icase}{scope=replace}
153--_mtable-regex-Man=section/(\.SH)[\t ]*\n//{icase}{tjump=sectionheading}{{
154    2 /replace
155}}
156--_mtable-regex-Man=section/\.SS[\t ]+"([^"\n]+)"[^\n]*\n/\1/S/{icase}{scope=push}{tenter=subsection}
157--_mtable-regex-Man=section/\.SS[\t ]+([^\n]+)\n/\1/S/{icase}{scope=push}{tenter=subsection}
158--_mtable-regex-Man=section/\.SS[\t ]*\n//{icase}{tenter=subsectionheading}{{
159    /push
160}}
161--_mtable-extend-Man=section+REST
162
163#
164# sectionheading
165#
166--_mtable-regex-Man=sectionheading/[ \t]*([^\n]+)\n/\1/s/{tjump=section}{{
167    heading-action
168}}
169--_mtable-extend-Man=sectionheading+REST
170
171#
172# subsection
173#
174--_mtable-extend-Man=subsection+GUARD
175--_mtable-regex-Man=subsection/\.SS[\t ]+"([^"\n]+)"[^\n]*\n/\1/S/{icase}{scope=replace}
176--_mtable-regex-Man=subsection/\.SS[\t ]+([^\n]+)\n/\1/S/{icase}{scope=replace}
177--_mtable-regex-Man=subsection/\.SS[\t ]*\n//{icase}{tjump=subsectionheading}{{
178    2 /replace
179}}
180--_mtable-regex-Man=subsection/(\.SH)///{icase}{_advanceTo=0start}{tleave}{{
181    1 fill-end-of-scope
182    _scopepop
183}}
184--_mtable-extend-Man=subsection+REST
185
186#
187# subsectionheading
188#
189--_mtable-regex-Man=subsectionheading/[ \t]*([^\n]+)\n/\1/S/{tjump=subsection}{{
190    heading-action
191}}
192--_mtable-extend-Man=subsectionheading+REST
193