#
#  meson.ctags --- multitable regex parser for meson.build files
#
#  Copyright (c) 2020 Masatake YAMATO
#  Copyright (c) 2020 Red Hat, Inc.
#
#  This source code is released for free distribution under the terms of the
#  GNU General Public License version 2 or (at your option) any later version.
#
# References:
#
# - https://mesonbuild.com/Syntax.html
#

--langdef=Meson
--map-Meson=+(meson.build)

#
# Kind definitions
#
--kinddef-Meson=P,project,projects
--kinddef-Meson=V,variable,variables
--kinddef-Meson=S,subdir,subdirs
--kinddef-Meson=B,build,build targets
--kinddef-Meson=c,custom,custom targets
--kinddef-Meson=t,test,tests
--kinddef-Meson=b,benchmark,benchmark targets
--kinddef-Meson=r,run,run targets
--kinddef-Meson=m,module,modules

#
# Role definitions
#
--_roledef-Meson.{module}=imported,imported

#
# Tables declaration
#
--_tabledef-Meson=main
--_tabledef-Meson=mline_string
--_tabledef-Meson=string
--_tabledef-Meson=comment
--_tabledef-Meson=skipPair
--_tabledef-Meson=common
--_tabledef-Meson=skipToArgEnd

#
# Tables definitions
#
--_mtable-regex-Meson=comment/[^\n]+//
--_mtable-regex-Meson=comment/\n//{tleave}

--_mtable-regex-Meson=string/\\'//
--_mtable-regex-Meson=string/[^\\']+//
--_mtable-regex-Meson=string/'//{tleave}

--_mtable-regex-Meson=mline_string/'''//{tleave}
--_mtable-regex-Meson=mline_string/[^']+//
--_mtable-regex-Meson=mline_string/.//

--_mtable-regex-Meson=common/[ \t\n]+//
--_mtable-regex-Meson=common/#//{tenter=comment}
--_mtable-regex-Meson=common/'''//{tenter=mline_string}
--_mtable-regex-Meson=common/'//{tenter=string}
--_mtable-regex-Meson=common/[[({]//{tenter=skipPair}
--_mtable-regex-Meson=common/(jar|executable|shared_module|(both_|shared_|static_)?library)[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*/\3/B/{tenter=skipToArgEnd}
--_mtable-regex-Meson=common/custom_target[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*/\1/c/{tenter=skipToArgEnd}
--_mtable-regex-Meson=common/(alias|run)_target[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*/\2/r/{tenter=skipToArgEnd}
--_mtable-regex-Meson=common/bench_mark[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*/\1/b/{tenter=skipToArgEnd}
--_mtable-regex-Meson=common/import[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*/\1/m/{tenter=skipToArgEnd}{_role=imported}

--_mtable-extend-Meson=skipPair+common
--_mtable-regex-Meson=skipPair/[])}]//{tleave}
--_mtable-regex-Meson=skipPair/.//

--_mtable-extend-Meson=skipToArgEnd+skipPair

--_mtable-extend-Meson=main+common
--_mtable-regex-Meson=main/project[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*/\1/P/{tenter=skipToArgEnd}
--_mtable-regex-Meson=main/subdir[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*/\1/S/{tenter=skipToArgEnd}
--_mtable-regex-Meson=main/test[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*/\1/t/{tenter=skipToArgEnd}
--_mtable-regex-Meson=main/([a-zA-Z_][a-zA-Z_0-9]*)[ \t\n]*=[ \t\n]*/\1/V/
--_mtable-regex-Meson=main/.//
