Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra mtable regex #2796

Merged
merged 2 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Tmain/option-extradef-in-mtable.d/input.mtextra
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(def a)
{def b}
[def c]
23 changes: 23 additions & 0 deletions Tmain/option-extradef-in-mtable.d/mtextra.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--langdef=MTExtra
--map-MTExtra=+.mtextra

--kinddef-MTExtra=d,def,definitions

# []
--_extradef-MTExtra=acceptSquareBracket,accept square bracket
# {}
--_extradef-MTExtra=acceptCurlyBracket,accept curly bracket


--_tabledef-MTExtra=main
--_tabledef-MTExtra=body

--_mtable-regex-MTExtra=main/\(def +//{tenter=body}
--_mtable-regex-MTExtra=main/\[def +//{tenter=body}{_extra=acceptSquareBracket}
--_mtable-regex-MTExtra=main/\{def +//{tenter=body}{_extra=acceptCurlyBracket}
--_mtable-regex-MTExtra=main/.//

--_mtable-regex-MTExtra=body/([_a-z]+)\)/\1/d/{tleave}
--_mtable-regex-MTExtra=body/([_a-z]+)\]/\1/d/{tleave}{_extra=acceptSquareBracket}
--_mtable-regex-MTExtra=body/([_a-z]+)\}/\1/d/{tleave}{_extra=acceptCurlyBracket}
--_mtable-regex-MTExtra=body/.//
29 changes: 29 additions & 0 deletions Tmain/option-extradef-in-mtable.d/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright: 2020 Masatake YAMATO
# License: GPL-2

CTAGS="$1"

msgstr ()
{
if [ $1 = '+' ]; then
echo "enabled"
else
echo "disabled"
fi
}

run_ctags ()
{
printf '# []: %s, {}: %s\n' $(msgstr $1) $(msgstr $2)
${CTAGS} --quiet --options=NONE --options=mtextra.ctags \
--fields=+'{extras}' \
--extras-MTExtra=${1}'{acceptSquareBracket}' \
--extras-MTExtra=${2}'{acceptCurlyBracket}' \
-o - \
input.mtextra
}

run_ctags + +
run_ctags - -
run_ctags + -
run_ctags - +
Empty file.
12 changes: 12 additions & 0 deletions Tmain/option-extradef-in-mtable.d/stdout-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# []: enabled, {}: enabled
a input.mtextra /^(def a)$/;" d
b input.mtextra /^{def b}$/;" d extras:acceptCurlyBracket
c input.mtextra /^[def c]$/;" d extras:acceptSquareBracket
# []: disabled, {}: disabled
a input.mtextra /^(def a)$/;" d
# []: enabled, {}: disabled
a input.mtextra /^(def a)$/;" d
c input.mtextra /^[def c]$/;" d extras:acceptSquareBracket
# []: disabled, {}: enabled
a input.mtextra /^(def a)$/;" d
b input.mtextra /^{def b}$/;" d extras:acceptCurlyBracket
4 changes: 4 additions & 0 deletions main/lregex.c
Original file line number Diff line number Diff line change
Expand Up @@ -2406,6 +2406,10 @@ static struct regexTable * matchMultitableRegexTable (struct lregexControlBlock
for (unsigned int i = 0; i < ptrArrayCount(table->entries); i++)
{
regexTableEntry *entry = ptrArrayItem(table->entries, i);
if ((entry->pattern->xtagType != XTAG_UNKNOWN)
&& (!isXtagEnabled (entry->pattern->xtagType)))
continue;

regexPattern *ptrn = entry->pattern;
struct guestSpec *guest = &ptrn->guest;

Expand Down