Skip to content

Commit

Permalink
Fix cmake.ctags optlib to use _advanceTo properly
Browse files Browse the repository at this point in the history
  • Loading branch information
hadrielk committed Aug 11, 2018
1 parent 08c4658 commit 66c62e0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Units/parser-cmake.r/cmake-comments.d/expected.tags
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
another_good_target input.cmake /^add_library(another_good_target# <-- target$/;" t
good_target input.cmake /^ good_target# this is legal comment placement I think$/;" t
good_target input.cmake /^ good_target# this is legal comment placement set(NO_TAG foo)$/;" t
tag_this input.cmake /^]]set(tag_this)$/;" v
4 changes: 2 additions & 2 deletions Units/parser-cmake.r/cmake-comments.d/input.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ option(DO_NOT_TAG "foo" OFF)

add_custom_target(# comment set(NO_TAG "foo")
# anothe rline comment
good_target# this is legal comment placement I think
good_target# this is legal comment placement set(NO_TAG foo)
ALL)

add_library(another_good_target# <-- target
SHARED # <-- lib type
SHARED # set(NO_TAG bar)
gmock-all.cc
)
37 changes: 26 additions & 11 deletions optlib/cmake.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,53 +54,68 @@ static void initializeCMakeParser (const langType language CTAGS_ATTR_UNUSED)
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "variable",
"^([A-Za-z0-9_.-]+)([# \t\n\\)])",
"\\1", "v", "{tleave}{advanceTo=2start}", NULL);
"^([A-Za-z0-9_.-]+)[ \t\n\\)]+",
"\\1", "v", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "variable",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "variable",
"^#",
"", "", "{tenter=commentBegin}", NULL);
addLanguageTagMultiTableRegex (language, "variable",
"^([A-Za-z0-9_.-]+)(#)",
"\\1", "v", "{tleave}{_advanceTo=2start}", NULL);
addLanguageTagMultiTableRegex (language, "function",
"^([A-Za-z_][A-Za-z0-9_]*)([# \t\n\\)])",
"\\1", "f", "{tleave}{advanceTo=2start}", NULL);
"^([A-Za-z_][A-Za-z0-9_]*)[ \t\n\\)]+",
"\\1", "f", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "function",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "function",
"^#",
"", "", "{tenter=commentBegin}", NULL);
addLanguageTagMultiTableRegex (language, "function",
"^([A-Za-z_][A-Za-z0-9_]*)(#)",
"\\1", "f", "{tleave}{_advanceTo=2start}", NULL);
addLanguageTagMultiTableRegex (language, "macro",
"^([A-Za-z_][A-Za-z0-9_]*)([# \t\n\\)])",
"\\1", "m", "{tleave}{advanceTo=2start}", NULL);
"^([A-Za-z_][A-Za-z0-9_]*)[ \t\n\\)]+",
"\\1", "m", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "macro",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "macro",
"^#",
"", "", "{tenter=commentBegin}", NULL);
addLanguageTagMultiTableRegex (language, "macro",
"^([A-Za-z_][A-Za-z0-9_]*)(#)",
"\\1", "m", "{tleave}{_advanceTo=2start}", NULL);
addLanguageTagMultiTableRegex (language, "target",
"^([A-Za-z0-9_.-]+)([# \t\n\\)])",
"\\1", "t", "{tleave}{advanceTo=2start}", NULL);
"^([A-Za-z0-9_.-]+)[ \t\n\\)]+",
"\\1", "t", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "target",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "target",
"^#",
"", "", "{tenter=commentBegin}", NULL);
addLanguageTagMultiTableRegex (language, "target",
"^([A-Za-z0-9_.-]+)(#)",
"\\1", "t", "{tleave}{_advanceTo=2start}", NULL);
addLanguageTagMultiTableRegex (language, "option",
"^([A-Za-z0-9_.-]+)([# \t\n\\)])",
"\\1", "D", "{tleave}{advanceTo=2start}", NULL);
"^([A-Za-z0-9_.-]+)[ \t\n\\)]+",
"\\1", "D", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "option",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "option",
"^#",
"", "", "{tenter=commentBegin}", NULL);
addLanguageTagMultiTableRegex (language, "option",
"^([A-Za-z0-9_.-]+)(#)",
"\\1", "D", "{tleave}{_advanceTo=2start}", NULL);
addLanguageTagMultiTableRegex (language, "project",
"^([A-Za-z0-9_.-]+)([# \t\n\\)])",
"\\1", "p", "{tleave}{advanceTo=2start}", NULL);
"\\1", "p", "{tleave}{_advanceTo=2start}", NULL);
addLanguageTagMultiTableRegex (language, "project",
"^[ \t\n]+",
"", "", "", NULL);
Expand Down
29 changes: 19 additions & 10 deletions optlib/cmake.ctags
Original file line number Diff line number Diff line change
Expand Up @@ -115,44 +115,53 @@
#
# Each of the following basically work the same way, and only differ in the
# exact pattern allowed to be their name, and the Kind they add. Note that they
# capture a required trailing '[# \t\n\)]', to verify the full name token matched
# the name's pattern, but then we advanceTo=2start for the next round, so that
# we don't go past a potential '#' comment token but instead match it again in
# the main table as a comment (or whitespace if it was whitespace).
# capture a required trailing '[ \t\n\)]' or '#', to verify the full name token
# matched the name's pattern, but then we advanceTo=2start for the next round,
# so that we don't go past a potential '#' comment token but instead match it
# again in the main table as a comment. The odds of a comment '#' immediately
# following the name is very low, so we split it into its own check and do it
# last in each table - this improves real-world performance ~10%, because in
# the common case we can capture the whitespace at the same time as the name,
# and not have to skip it again in the 'main' table.
#

#
# variable
#
--_mtable-regex-CMake=variable/([A-Za-z0-9_.-]+)([# \t\n\)])/\1/v/{tleave}{advanceTo=2start}
--_mtable-regex-CMake=variable/([A-Za-z0-9_.-]+)[ \t\n\)]+/\1/v/{tleave}
--_mtable-extend-CMake=variable+skipToName
--_mtable-regex-CMake=variable/([A-Za-z0-9_.-]+)(#)/\1/v/{tleave}{_advanceTo=2start}

#
# function
#
--_mtable-regex-CMake=function/([A-Za-z_][A-Za-z0-9_]*)([# \t\n\)])/\1/f/{tleave}{advanceTo=2start}
--_mtable-regex-CMake=function/([A-Za-z_][A-Za-z0-9_]*)[ \t\n\)]+/\1/f/{tleave}
--_mtable-extend-CMake=function+skipToName
--_mtable-regex-CMake=function/([A-Za-z_][A-Za-z0-9_]*)(#)/\1/f/{tleave}{_advanceTo=2start}

#
# macro
#
--_mtable-regex-CMake=macro/([A-Za-z_][A-Za-z0-9_]*)([# \t\n\)])/\1/m/{tleave}{advanceTo=2start}
--_mtable-regex-CMake=macro/([A-Za-z_][A-Za-z0-9_]*)[ \t\n\)]+/\1/m/{tleave}
--_mtable-extend-CMake=macro+skipToName
--_mtable-regex-CMake=macro/([A-Za-z_][A-Za-z0-9_]*)(#)/\1/m/{tleave}{_advanceTo=2start}

#
# target
#
--_mtable-regex-CMake=target/([A-Za-z0-9_.-]+)([# \t\n\)])/\1/t/{tleave}{advanceTo=2start}
--_mtable-regex-CMake=target/([A-Za-z0-9_.-]+)[ \t\n\)]+/\1/t/{tleave}
--_mtable-extend-CMake=target+skipToName
--_mtable-regex-CMake=target/([A-Za-z0-9_.-]+)(#)/\1/t/{tleave}{_advanceTo=2start}

#
# option
#
--_mtable-regex-CMake=option/([A-Za-z0-9_.-]+)([# \t\n\)])/\1/D/{tleave}{advanceTo=2start}
--_mtable-regex-CMake=option/([A-Za-z0-9_.-]+)[ \t\n\)]+/\1/D/{tleave}
--_mtable-extend-CMake=option+skipToName
--_mtable-regex-CMake=option/([A-Za-z0-9_.-]+)(#)/\1/D/{tleave}{_advanceTo=2start}

#
# project
#
--_mtable-regex-CMake=project/([A-Za-z0-9_.-]+)([# \t\n\)])/\1/p/{tleave}{advanceTo=2start}
--_mtable-regex-CMake=project/([A-Za-z0-9_.-]+)([# \t\n\)])/\1/p/{tleave}{_advanceTo=2start}
--_mtable-extend-CMake=project+skipToName

0 comments on commit 66c62e0

Please sign in to comment.