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