# inko.ctags --- regex parser for the Inko programming language
# (https://inko-lang.org/)
#
#  Copyright (c) 2019, Yorick Peterse
#
#  Author: Yorick Peterse <yorick@yorickpeterse.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.

--langdef=Inko
--map-Inko=+.inko
--kinddef-Inko=o,class,Class definition
--kinddef-Inko=m,method,Method definition
--kinddef-Inko=t,trait,Trait definition
--kinddef-Inko=a,attribute,Attribute definition
--kinddef-Inko=c,constant,Constant definition
--kinddef-Inko=r,reopen,Reopen class

--_fielddef-Inko=implements,Trait being implemented

--fields-Inko=+{implements}

--_tabledef-Inko=toplevel
--_tabledef-Inko=class
--_tabledef-Inko=trait
--_tabledef-Inko=method
--_tabledef-Inko=comment
--_tabledef-Inko=impl
--_tabledef-Inko=let
--_tabledef-Inko=sstring
--_tabledef-Inko=dstring
--_tabledef-Inko=tstring

# Handle and ignore the bodies of strings
--_mtable-regex-Inko=toplevel/'//{tenter=sstring}
--_mtable-regex-Inko=toplevel/"//{tenter=dstring}
--_mtable-regex-Inko=toplevel/`//{tenter=tstring}

--_mtable-regex-Inko=sstring/'//{tleave}
--_mtable-regex-Inko=sstring/\\'//
--_mtable-regex-Inko=sstring/.//

--_mtable-regex-Inko=dstring/"//{tleave}
--_mtable-regex-Inko=dstring/\\"//
--_mtable-regex-Inko=dstring/.//

--_mtable-regex-Inko=tstring/`//{tleave}
--_mtable-regex-Inko=tstring/\\`//
--_mtable-regex-Inko=tstring/.//

--_mtable-regex-Inko=toplevel/#//{tenter=comment}
--_mtable-regex-Inko=toplevel/[[:blank:]]*class[[:blank:]]+//{tenter=class}
--_mtable-regex-Inko=toplevel/[[:blank:]]*trait[[:blank:]]+//{tenter=trait}
--_mtable-regex-Inko=toplevel/[[:blank:]]*def[[:blank:]]+//{tenter=method}
--_mtable-regex-Inko=toplevel/[[:blank:]]*impl[[:blank:]]+//{tenter=impl}
--_mtable-regex-Inko=toplevel/[[:blank:]]*let[[:blank:]]+//{tenter=let}
--_mtable-regex-Inko=toplevel/\{//{placeholder}{scope=push}
--_mtable-regex-Inko=toplevel/\}//{scope=pop}
--_mtable-regex-Inko=toplevel/(@[a-zA-Z0-9_]+):/\1/a/{scope=ref}
--_mtable-regex-Inko=toplevel/.//

--_mtable-regex-Inko=class/([A-Z][a-zA-Z0-9_?]*)[^{]*/\1/o/{scope=push}
--_mtable-regex-Inko=class/\{//{tleave}
--_mtable-regex-Inko=class/.//

--_mtable-regex-Inko=trait/([A-Z][a-zA-Z0-9_?]*)[^{]*/\1/t/{scope=push}
--_mtable-regex-Inko=trait/\{//{tleave}
--_mtable-regex-Inko=trait/.//

--_mtable-regex-Inko=method/([a-zA-Z0-9_?]+|\[\]=?|\^|&|\||\*|\+|\-|\/|>>|<<|%)/\1/m/{scope=push}
--_mtable-regex-Inko=method/\{|\n//{scope=pop}{tleave}
--_mtable-regex-Inko=method/.//

--_mtable-regex-Inko=impl/([A-Z][a-zA-Z0-9_?]*)[[:blank:]]+for[[:blank:]]+([A-Z][a-zA-Z0-9_?]*)[^{]*/\2/r/{scope=push}{_field=implements:\1}
--_mtable-regex-Inko=impl/([A-Z][a-zA-Z0-9_?]*)[^{]*/\1/r/{scope=push}
--_mtable-regex-Inko=impl/\{//{tleave}
--_mtable-regex-Inko=impl/.//

--_mtable-regex-Inko=let/([A-Z][a-zA-Z0-9_]+)/\1/c/{scope=ref}{tleave}

--_mtable-regex-Inko=comment/\n//{tleave}
--_mtable-regex-Inko=comment/.//
