xref: /Universal-ctags/optlib/lex.ctags (revision f5bca49f0fb19a17234ca12bb951408ea64a0685)
1*f5bca49fSMasatake YAMATO#
2*f5bca49fSMasatake YAMATO# lex.ctags --- multitable regex parser for lex/flex input
3*f5bca49fSMasatake YAMATO#
4*f5bca49fSMasatake YAMATO# Copyright (c) 2021, Red Hat, Inc.
5*f5bca49fSMasatake YAMATO# Copyright (c) 2021, Masatake YAMATO
6*f5bca49fSMasatake YAMATO#
7*f5bca49fSMasatake YAMATO# Author: Masatake YAMATO <yamato@redhat.com>
8*f5bca49fSMasatake YAMATO#
9*f5bca49fSMasatake YAMATO# This program is free software; you can redistribute it and/or
10*f5bca49fSMasatake YAMATO# modify it under the terms of the GNU General Public License
11*f5bca49fSMasatake YAMATO# as published by the Free Software Foundation; either version 2
12*f5bca49fSMasatake YAMATO# of the License, or (at your option) any later version.
13*f5bca49fSMasatake YAMATO#
14*f5bca49fSMasatake YAMATO# This program is distributed in the hope that it will be useful,
15*f5bca49fSMasatake YAMATO# but WITHOUT ANY WARRANTY; without even the implied warranty of
16*f5bca49fSMasatake YAMATO# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17*f5bca49fSMasatake YAMATO# GNU General Public License for more details.
18*f5bca49fSMasatake YAMATO#
19*f5bca49fSMasatake YAMATO# You should have received a copy of the GNU General Public License
20*f5bca49fSMasatake YAMATO# along with this program; if not, write to the Free Software
21*f5bca49fSMasatake YAMATO# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22*f5bca49fSMasatake YAMATO# USA.
23*f5bca49fSMasatake YAMATO#
24*f5bca49fSMasatake YAMATO# Reference:
25*f5bca49fSMasatake YAMATO#
26*f5bca49fSMasatake YAMATO# - https://github.com/westes/flex/blob/master/doc/flex.texi
27*f5bca49fSMasatake YAMATO#
28*f5bca49fSMasatake YAMATO
29*f5bca49fSMasatake YAMATO--langdef=LEX
30*f5bca49fSMasatake YAMATO
31*f5bca49fSMasatake YAMATO#
32*f5bca49fSMasatake YAMATO# Map definitions
33*f5bca49fSMasatake YAMATO#
34*f5bca49fSMasatake YAMATO--map-LEX=+.lex
35*f5bca49fSMasatake YAMATO
36*f5bca49fSMasatake YAMATO# Lisp parser also expects ".l" file extension.
37*f5bca49fSMasatake YAMATO--map-LEX=+.l
38*f5bca49fSMasatake YAMATO--__selector-LEX=selectLispOrLEXByLEXMarker
39*f5bca49fSMasatake YAMATO
40*f5bca49fSMasatake YAMATO
41*f5bca49fSMasatake YAMATO#
42*f5bca49fSMasatake YAMATO# Kind definitions
43*f5bca49fSMasatake YAMATO#
44*f5bca49fSMasatake YAMATO
45*f5bca49fSMasatake YAMATO--kinddef-LEX=r,regex,named regular expression
46*f5bca49fSMasatake YAMATO--kinddef-LEX=c,cond,start or exclusive condition
47*f5bca49fSMasatake YAMATO
48*f5bca49fSMasatake YAMATO#
49*f5bca49fSMasatake YAMATO# Table declarations
50*f5bca49fSMasatake YAMATO#
51*f5bca49fSMasatake YAMATO
52*f5bca49fSMasatake YAMATO--_tabledef-LEX=main
53*f5bca49fSMasatake YAMATO--_tabledef-LEX=comment
54*f5bca49fSMasatake YAMATO--_tabledef-LEX=codeblock
55*f5bca49fSMasatake YAMATO--_tabledef-LEX=rulesec
56*f5bca49fSMasatake YAMATO--_tabledef-LEX=usercode
57*f5bca49fSMasatake YAMATO--_tabledef-LEX=cond
58*f5bca49fSMasatake YAMATO
59*f5bca49fSMasatake YAMATO#
60*f5bca49fSMasatake YAMATO# Table definitions
61*f5bca49fSMasatake YAMATO#
62*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=comment/[^*]+//
63*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=comment/\*\///{tleave}
64*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=comment/.//
65*f5bca49fSMasatake YAMATO
66*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=codeblock/[^%]+//
67*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=codeblock/%\}//{tleave}{_guest=,,0start}
68*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=codeblock/.//
69*f5bca49fSMasatake YAMATO
70*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=rulesec/[^%]+//
71*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=rulesec/%%//{tjump=usercode}{_guest=C,0end,}
72*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=rulesec/.//
73*f5bca49fSMasatake YAMATO
74*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=usercode/.+//{_guest=,,0end}
75*f5bca49fSMasatake YAMATO
76*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=cond/([_a-zA-Z][_a-zA-Z0-9]*)[ \t]*/\1/c/
77*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=cond/\n//{tleave}
78*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=cond/.//
79*f5bca49fSMasatake YAMATO
80*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=main/\/\*//{tenter=comment}
81*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=main/%[sx][ \t]+//{tenter=cond}
82*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=main/%(top)?\{//{tenter=codeblock}{_guest=C,0end,}
83*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=main/%%//{tjump=rulesec}
84*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=main/([a-zA-Z_][-a-zA-Z0-9_]*)[^\n]+\n/\1/r/
85*f5bca49fSMasatake YAMATO--_mtable-regex-LEX=main/[^\n]*\n//
86