From 54f48b5c8d0a827a246b483a559ac1ec6f83c84a Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Sun, 23 May 2021 01:55:32 +0900 Subject: [PATCH 1/5] prelude: add _endwith procedure Signed-off-by: Masatake YAMATO --- Tmain/common-prelude.d/endwith.expected | 7 ++++++ Tmain/common-prelude.d/endwith.ps | Bin 0 -> 191 bytes Tmain/common-prelude.d/stdout-expected.txt | 1 + main/CommonPrelude.c | 24 +++++++++++++++++++++ main/CommonPrelude.ps | Bin 5644 -> 6232 bytes 5 files changed, 32 insertions(+) create mode 100644 Tmain/common-prelude.d/endwith.expected create mode 100644 Tmain/common-prelude.d/endwith.ps diff --git a/Tmain/common-prelude.d/endwith.expected b/Tmain/common-prelude.d/endwith.expected new file mode 100644 index 0000000000..92f9b6a4e5 --- /dev/null +++ b/Tmain/common-prelude.d/endwith.expected @@ -0,0 +1,7 @@ +true +false +false +false +true +true +true diff --git a/Tmain/common-prelude.d/endwith.ps b/Tmain/common-prelude.d/endwith.ps new file mode 100644 index 0000000000000000000000000000000000000000..cf6a5ec388e16e7a78996a7a1a87d9d850517862 GIT binary patch literal 191 zcmdPM%qu7@(aTNIRL}sE@u_(!<(VZJ3bwXf8px7)KqV-W5KRarD3UOm7hQj1_B+XDbU1UoPQ literal 0 HcmV?d00001 diff --git a/Tmain/common-prelude.d/stdout-expected.txt b/Tmain/common-prelude.d/stdout-expected.txt index 54eecbf12b..ba3cd0d935 100644 --- a/Tmain/common-prelude.d/stdout-expected.txt +++ b/Tmain/common-prelude.d/stdout-expected.txt @@ -4,6 +4,7 @@ buildstring.ps...0 chop.ps...0 dedup.ps...0 dedup_spaces.ps...0 +endwith.ps...0 ndup.ps...0 normalize_spaces.ps...0 putlast.ps...0 diff --git a/main/CommonPrelude.c b/main/CommonPrelude.c index 4e74e93dc5..d64def8c21 100644 --- a/main/CommonPrelude.c +++ b/main/CommonPrelude.c @@ -265,4 +265,28 @@ const char ctagsCommonPrelude []= " _foreignreftag\n" " } ifelse\n" "} __bddef\n" +"\n" +"(string end:string _ENDWITH boolean)\n" +"/_endwith {\n" +" 2 copy length exch length exch\n" +" % str endstr strlen endstrlen\n" +" 2 copy\n" +" ge {\n" +" % str endstr strlen endstrlen\n" +" dup 3 1 roll\n" +" % str endstr endstrlen strlen endstrlen\n" +" sub\n" +" % str endstr endstrlen offset\n" +" exch\n" +" % str endstr offset endstrlen\n" +" 4 -1 roll\n" +" % endstr offset endstrlen str\n" +" 3 1 roll\n" +" % str endstr str offset endstrlen\n" +" 0 string _copyinterval eq\n" +" } {\n" +" pop pop pop pop false\n" +" } ifelse\n" +"} __bddef\n" +"% (input.md) (.md) _endwith ==\n" ; diff --git a/main/CommonPrelude.ps b/main/CommonPrelude.ps index c092332588d011bebb3bf4e68315ede9a4add208..b419c88398d7f2aba29ec77a8a57ab5448e66038 100644 GIT binary patch delta 567 zcmeCtxnZz@N35Ppqqw9fGcR2sH7~^q%8YmQa|!nh@lZ(0&(BFs%+uu3j|WPZXO?6r zRC6f+fssOTenF)|PHJ8{P%O0~IRlvuR-&o^G!0}bhyr4uS||_5f*Vp_Pzh$Ir$S8z znNC Date: Sun, 23 May 2021 03:01:59 +0900 Subject: [PATCH 2/5] optscript: introduce _strrpbrk operator Signed-off-by: Masatake YAMATO --- .../error-undefined-if-if.expected | 2 +- Tmain/optscript.d/error-undefined-if.expected | 2 +- Tmain/optscript.d/string.expected | 37 ++++++++++++++++++ Tmain/optscript.d/string.ps | Bin 1345 -> 1875 bytes dsl/optscript.c | 19 ++++++++- main/routines.c | 19 +++++++++ main/routines.h | 1 + 7 files changed, 76 insertions(+), 4 deletions(-) diff --git a/Tmain/optscript.d/error-undefined-if-if.expected b/Tmain/optscript.d/error-undefined-if-if.expected index bd92d0202e..d9e18863a5 100644 --- a/Tmain/optscript.d/error-undefined-if-if.expected +++ b/Tmain/optscript.d/error-undefined-if-if.expected @@ -4,4 +4,4 @@ top| |bottom Execution stack: top| a {a} --if-- {true {a} if} --if-- |bottom Dictionary stack: -top| -dict:1- -dict:89- |bottom +top| -dict:1- -dict:90- |bottom diff --git a/Tmain/optscript.d/error-undefined-if.expected b/Tmain/optscript.d/error-undefined-if.expected index daed401f05..dcfdc2e190 100644 --- a/Tmain/optscript.d/error-undefined-if.expected +++ b/Tmain/optscript.d/error-undefined-if.expected @@ -4,4 +4,4 @@ top| |bottom Execution stack: top| a {a} --if-- |bottom Dictionary stack: -top| -dict:1- -dict:89- |bottom +top| -dict:1- -dict:90- |bottom diff --git a/Tmain/optscript.d/string.expected b/Tmain/optscript.d/string.expected index 83bb32cf94..265ba261d8 100644 --- a/Tmain/optscript.d/string.expected +++ b/Tmain/optscript.d/string.expected @@ -74,3 +74,40 @@ true false (a.b;c) (\(a.b;c\) false ->) +(--------------- _strrpbrk ---------------) +x/abc.d|./ +true +5 +(x/abc.d) +x/abc.|./ +true +5 +(x/abc.) +x.abc/d|./ +true +5 +(x.abc/d) +x.abc/|./ +true +5 +(x.abc/) +x.abc.d|./ +true +5 +(x.abc.d) +x.abc.|./ +true +5 +(x.abc.) +abc|./ +false +(abc) +|./ +false +() +abc| +false +(abc) +| +false +() diff --git a/Tmain/optscript.d/string.ps b/Tmain/optscript.d/string.ps index cd96eda9d8f12b2af1eeb8feaa702b62a616b911..feaa753611863447e1f0d6a557f3b9b5aac31165 100644 GIT binary patch literal 1875 zcmbu9-A;rs5QXpi6mwY;DY_f=Vza)ADdlI)65SL`jH~bNv?EBNv`yTwNg3vwGn@|P zx%-2D&@ZnoxY0a=gxeGL0Sk`+E@RnaYAnxG QwYxzz1N%T}SZ_1u2l^)^Qvd(} delta 7 Ocmcc2caUp?BP#$5qynP= diff --git a/dsl/optscript.c b/dsl/optscript.c index 2a8833d171..02f322dbc3 100644 --- a/dsl/optscript.c +++ b/dsl/optscript.c @@ -338,6 +338,7 @@ declop(_strrstr); declop(_strchr); declop(_strrchr); declop(_strpbrk); +declop(_strrpbrk); /* Relation, logical, and bit operators tested in relalogbit.ps */ @@ -554,6 +555,8 @@ opt_init (void) "string chr _STRRCHR string false"); defop (opt_system_dict, _strpbrk, 2, "string accept _STRPBRK string offset true%" "string accept _STRPBRK string false"); + defop (opt_system_dict, _strrpbrk, 2, "string accept _STRRPBRK string offset true%" + "string accept _STRRPBRK string false"); defop (opt_system_dict, exec, 1, "any EXEC -"); defop (opt_system_dict, if, 2, "bool proc IF -"); @@ -3388,7 +3391,7 @@ op__strrchr (OptVM *vm, EsObject *name) } static EsObject* -op__strpbrk (OptVM *vm, EsObject *name) +op__strpbrk_common (OptVM *vm, EsObject *name, bool from_tail) { EsObject *acceptobj = ptrArrayLast (vm->ostack); EsObject *strobj = ptrArrayItemFromLast (vm->ostack, 1); @@ -3402,7 +3405,7 @@ op__strpbrk (OptVM *vm, EsObject *name) vString *acceptv = es_pointer_get (acceptobj); const char *str = vStringValue (strv); - char *p = strpbrk (str, vStringValue (acceptv)); + char *p = (from_tail? strrpbrk: strpbrk) (str, vStringValue (acceptv)); if (p) { int d = p - str; @@ -3423,6 +3426,18 @@ op__strpbrk (OptVM *vm, EsObject *name) } } +static EsObject* +op__strpbrk (OptVM *vm, EsObject *name) +{ + return op__strpbrk_common (vm, name, false); +} + +static EsObject* +op__strrpbrk (OptVM *vm, EsObject *name) +{ + return op__strpbrk_common (vm, name, true); +} + /* * Relation, logical, and bit operators diff --git a/main/routines.c b/main/routines.c index 10150742bb..e2c51b93f7 100644 --- a/main/routines.c +++ b/main/routines.c @@ -311,6 +311,25 @@ extern char* strrstr (const char *str, const char *substr) return NULL; } +extern char* strrpbrk (const char *str, const char *accept) +{ + char *last, *tmp; + + tmp = (char *)str; + last = NULL; + + while (1) + { + tmp = strpbrk (tmp, accept); + if (tmp == NULL) + break; + last = tmp; + if (*++tmp == '\0') + break; + } + return last; +} + extern char* eStrdup (const char* str) { char* result = xMalloc (strlen (str) + 1, char); diff --git a/main/routines.h b/main/routines.h index a95ef01015..d5011edb00 100644 --- a/main/routines.h +++ b/main/routines.h @@ -58,6 +58,7 @@ extern void eFreeIndirect(void **ptr); extern int struppercmp (const char *s1, const char *s2); extern int strnuppercmp (const char *s1, const char *s2, size_t n); extern char* strrstr (const char *str, const char *substr); +extern char* strrpbrk (const char *str, const char *accept); extern char* eStrdup (const char* str); extern char* eStrndup (const char* str, size_t len); extern void toLowerString (char* str); From 82561b0555cdf18b921742a44f6807c10c2ed48e Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Sun, 23 May 2021 15:19:53 +0900 Subject: [PATCH 3/5] optscript: introduce opt_dict_known_and_get as new C API Signed-off-by: Masatake YAMATO --- dsl/optscript.c | 6 ++++++ dsl/optscript.h | 1 + 2 files changed, 7 insertions(+) diff --git a/dsl/optscript.c b/dsl/optscript.c index 02f322dbc3..55c5c263d4 100644 --- a/dsl/optscript.c +++ b/dsl/optscript.c @@ -690,6 +690,12 @@ opt_dict_known_and_get_cstr (EsObject *dict, const char* name, EsObject **val) return dict_op_known_and_get (dict, sym, val); } +bool +opt_dict_known_and_get (EsObject *dict, EsObject *key, EsObject **val) +{ + return dict_op_known_and_get (dict, key, val); +} + bool opt_dict_foreach (EsObject *dict, bool (* fn) (EsObject *, EsObject *, void*), void *data) { diff --git a/dsl/optscript.h b/dsl/optscript.h index 6176779377..f1a3d56727 100644 --- a/dsl/optscript.h +++ b/dsl/optscript.h @@ -53,6 +53,7 @@ unsigned int opt_vm_ostack_count (OptVM *vm); EsObject *opt_dict_new (unsigned int size); bool opt_dict_known_and_get_cstr (EsObject *dict, const char* name, EsObject **val); +bool opt_dict_known_and_get (EsObject *dict, EsObject *key, EsObject **val); bool opt_dict_foreach (EsObject *dict, bool (* fn) (EsObject *, EsObject *, void*), void *data); void opt_dict_def (EsObject *dict, EsObject *sym, EsObject *val); bool opt_dict_undef (EsObject *dict, EsObject *sym); From cd7e27388a0ff4defb2b68b828e0900eebc6c24b Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Sun, 23 May 2021 15:47:00 +0900 Subject: [PATCH 4/5] main: make optscript{Setup,Teardown} reentrant Signed-off-by: Masatake YAMATO --- main/script.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/main/script.c b/main/script.c index 5c81da8560..d8accdbea1 100644 --- a/main/script.c +++ b/main/script.c @@ -289,27 +289,37 @@ extern void optscriptInstallProcs (EsObject *dict, } static EsObject *optscript_CorkIndex_sym = es_nil; +static ptrArray *corkIndexStack; extern void optscriptSetup (OptVM *vm, EsObject *dict, int corkIndex) { + if (es_null (optscript_CorkIndex_sym)) + optscript_CorkIndex_sym = es_symbol_intern ("."); + if (corkIndexStack == NULL) + corkIndexStack = ptrArrayNew ((ptrArrayDeleteFunc)es_object_unref); + + /* Push the last '.' to corkIndexStack. */ + EsObject *last = es_false; + opt_dict_known_and_get (dict, optscript_CorkIndex_sym, &last); + ptrArrayAdd (corkIndexStack, es_object_ref (last)); + if (corkIndex != CORK_NIL) { - static EsObject *corkIndex_sym = es_nil; - if (es_null (corkIndex_sym)) - corkIndex_sym = es_symbol_intern ("."); EsObject *corkIndex_val = es_integer_new (corkIndex); - opt_dict_def (dict, corkIndex_sym, corkIndex_val); + opt_dict_def (dict, optscript_CorkIndex_sym, corkIndex_val); es_object_unref (corkIndex_val); - optscript_CorkIndex_sym = corkIndex_sym; } } extern void optscriptTeardown (OptVM *vm, EsObject *dict) { - if (!es_null (optscript_CorkIndex_sym)) - { + if (opt_dict_known_and_get (dict, optscript_CorkIndex_sym, NULL)) opt_dict_undef (dict, optscript_CorkIndex_sym); - optscript_CorkIndex_sym = es_nil; - } + + /* Pop the last '.'. */ + EsObject *index = ptrArrayLast (corkIndexStack); + if (!es_object_equal (index, es_false)) + opt_dict_def (dict, optscript_CorkIndex_sym, index); + ptrArrayDeleteLast(corkIndexStack); } extern EsObject *optscriptRead (OptVM *vm, const char *src, size_t len) From ff6417f28935162dd711e8ac93869b5de854d826 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Fri, 14 May 2021 10:33:35 +0900 Subject: [PATCH 5/5] lregex: provide the way to intercept a parser making a tag TODO: - write about the new option in docs/optlib.rst. - add --_makeTagEntryNotification-={{...}}. Signed-off-by: Masatake YAMATO --- .../args.ctags | 79 +++++++++++++++++++ .../expected.tags | 7 ++ .../option-makeTagEntryReflection.d/input.md | 13 +++ main/dependency.c | 13 ++- main/dependency.h | 5 ++ main/lregex.c | 11 +++ main/lregex_p.h | 1 + main/options.c | 4 + main/options_p.h | 1 + main/parse.c | 10 +++ main/parse.h | 1 + main/parse_p.h | 1 + main/subparser_p.h | 2 - parsers/cpreprocessor.c | 17 ++++ 14 files changed, 159 insertions(+), 6 deletions(-) create mode 100644 Units/option-makeTagEntryReflection.d/args.ctags create mode 100644 Units/option-makeTagEntryReflection.d/expected.tags create mode 100644 Units/option-makeTagEntryReflection.d/input.md diff --git a/Units/option-makeTagEntryReflection.d/args.ctags b/Units/option-makeTagEntryReflection.d/args.ctags new file mode 100644 index 0000000000..6eacc2a14e --- /dev/null +++ b/Units/option-makeTagEntryReflection.d/args.ctags @@ -0,0 +1,79 @@ +# See #3020 and #3027. + +--sort=no +--extras=+q + +--_extradef-Markdown=withfname,appending input filename +--extras-Markdown=+{withfname} + +--_prelude-Markdown={{ + % You can customize the string combining the original name + % and the basen name of input file. + /SEP (@) def + + % dict + /scope-remapping-table 31 dict def + + % (abc/input.d) dropext => (abc/input) + % (abc.d/input) dropext => (abc.d/input) + /dropext { + (/.) _strrpbrk { + % string offset + 2 copy get ?/ eq { + pop + } { + 0 exch 0 string _copyinterval + } ifelse + } if + } def + + % (abc/efg) basename => (efg) + /basename { + ?/ _strrchr { + 1 add dup 2 index length exch sub + 0 string _copyinterval + } if + } def +}} + +--_sequel-Markdown={{ + % Fill the scope field of withfname extra tags. + scope-remapping-table { + % Make the original tag invisible + exch dup _markplaceholder + :scope dup + % withfname-index:int original-scope:int original-scope:int + 0 eq { + pop pop + } { + % withfname-index:int original-scope:int + scope-remapping-table exch get + % withfname-index:int withfname-scope:int + scope: + } ifelse + } forall +}} + +--_makeTagEntryReflection-Markdown={{ + /Markdown.withfname _extraenabled { + . :extras { + /Markdown.withfname _amember not + } { + true + } ifelse + { + mark + . :name + SEP + . :input dropext basename + _buildstring + + . :kind + . _tagloc _tag dup /Markdown.withfname _markextra + _commit + % Record the pair of original-index:int and withfname-index:int. + scope-remapping-table . 3 -1 roll put + } if + + } if +}} diff --git a/Units/option-makeTagEntryReflection.d/expected.tags b/Units/option-makeTagEntryReflection.d/expected.tags new file mode 100644 index 0000000000..4fe40c6dcf --- /dev/null +++ b/Units/option-makeTagEntryReflection.d/expected.tags @@ -0,0 +1,7 @@ +ABC@input input.md /^# ABC$/;" c +DEF@input input.md /^## DEF$/;" s chapter:ABC@input +GHI@input input.md /^### GHI$/;" S section:ABC@input""DEF@input +HIJ@input input.md /^### HIJ$/;" S section:ABC@input""DEF@input +KLM@input input.md /^## KLM$/;" s chapter:ABC@input +OPQ@input input.md /^# OPQ$/;" c +RST@input input.md /^### RST$/;" S chapter:OPQ@input diff --git a/Units/option-makeTagEntryReflection.d/input.md b/Units/option-makeTagEntryReflection.d/input.md new file mode 100644 index 0000000000..9e796c61e6 --- /dev/null +++ b/Units/option-makeTagEntryReflection.d/input.md @@ -0,0 +1,13 @@ +# ABC + +## DEF + +### GHI + +### HIJ + +## KLM + +# OPQ + +### RST diff --git a/main/dependency.c b/main/dependency.c index ecb5a9e60c..5020090075 100644 --- a/main/dependency.c +++ b/main/dependency.c @@ -14,6 +14,7 @@ #include "debug.h" #include "dependency.h" +#include "entry.h" #include "options.h" #include "parse_p.h" #include "read.h" @@ -184,14 +185,18 @@ extern void notifyMakeTagEntry (const tagEntryInfo *tag, int corkIndex) { subparser *s; + /* running optscript code attaching to --makeTagEntryReflection- */ + langType lang = tag->langType; + notifyLanguageRegexMakeTagEntry (lang, corkIndex); + foreachSubparser(s, false) { + enterSubparser(s); if (s->makeTagEntryNotify) - { - enterSubparser(s); s->makeTagEntryNotify (s, tag, corkIndex); - leaveSubparser(); - } + /* propagate the event recursively */ + notifyMakeTagEntry (tag, corkIndex); + leaveSubparser(); } } diff --git a/main/dependency.h b/main/dependency.h index bdeb71ab92..a485fb152a 100644 --- a/main/dependency.h +++ b/main/dependency.h @@ -43,4 +43,9 @@ struct sSlaveParser { slaveParser *next; }; +/* These are for CPreProcessor. + * Don't use in the other parsers. */ +extern void notifyInputStart (void); +extern void notifyInputEnd (void); + #endif /* CTAGS_MAIN_DEPENDENCY_H */ diff --git a/main/lregex.c b/main/lregex.c index 2d6c84f509..015c9c681f 100644 --- a/main/lregex.c +++ b/main/lregex.c @@ -2249,6 +2249,17 @@ extern void notifyRegexInputEnd (struct lregexControlBlock *lcb) fillEndLineFieldOfUpperScopes (lcb, endline); } +extern void notifyRegexMakeTagEntry (struct lregexControlBlock *lcb, + int corkIndex) +{ + if (ptrArrayCount (lcb->hook[SCRIPT_HOOK_MAKE_TAG_ENTRY_REFLECTION]) > 0) + { + optscriptSetup (optvm, lcb->local_dict, corkIndex); + scriptEvalHook (optvm, lcb, SCRIPT_HOOK_MAKE_TAG_ENTRY_REFLECTION); + optscriptTeardown (optvm, lcb->local_dict); + } +} + extern void findRegexTagsMainloop (int (* driver)(void)) { /* merely read all lines of the file */ diff --git a/main/lregex_p.h b/main/lregex_p.h index 103944f2f1..d90f2191ca 100644 --- a/main/lregex_p.h +++ b/main/lregex_p.h @@ -107,6 +107,7 @@ extern bool matchMultitableRegex (struct lregexControlBlock *lcb, const vString* extern void notifyRegexInputStart (struct lregexControlBlock *lcb); extern void notifyRegexInputEnd (struct lregexControlBlock *lcb); +extern void notifyRegexMakeTagEntry (struct lregexControlBlock *lcb, int corkIndex); extern void addRegexTable (struct lregexControlBlock *lcb, const char *name); extern void extendRegexTable (struct lregexControlBlock *lcb, const char *src, const char *dist); diff --git a/main/options.c b/main/options.c index 7888250dd7..4173448b85 100644 --- a/main/options.c +++ b/main/options.c @@ -378,6 +378,8 @@ static optionDescription LongOptionDescription [] = { {1,1," Define new extra for . --extras-=+{name} enables it."}, {1,1," --_fielddef-=,"}, {1,1," Define new field for ."}, + {1,1," --_makeTagEntryReflection-={{ optscript-code }}"}, + {1,1," Specify code run when parser makes a tag."}, {1,1," --_mtable-extend-=disttable+srctable."}, {1,1," Copy patterns of a regex table to another regex table."}, {1,1," --_mtable-regex-=///[]"}, @@ -3363,6 +3365,8 @@ static void processLongOption ( ; else if (processSequelOption (option, parameter)) ; + else if (processMakeTagEntryReflectionOption (option, parameter)) + ; else if (processPretendOption (option, parameter)) ; else if (processRolesOption (option, parameter)) diff --git a/main/options_p.h b/main/options_p.h index b8ada160bc..46665063b6 100644 --- a/main/options_p.h +++ b/main/options_p.h @@ -177,6 +177,7 @@ extern bool processRoledefOption (const char *const option, const char *const pa extern bool processScopesepOption (const char *const option, const char *const parameter); extern bool processPreludeOption (const char *const option, const char *const parameter); extern bool processSequelOption (const char *const option, const char *const parameter); +extern bool processMakeTagEntryReflectionOption (const char *const option, const char *const parameter); extern bool processPretendOption (const char *const option, const char *const parameter); extern bool processRolesOption (const char *const option, const char *const parameter); diff --git a/main/parse.c b/main/parse.c index eb3becae64..c12b21cae9 100644 --- a/main/parse.c +++ b/main/parse.c @@ -4110,6 +4110,11 @@ extern void notifyLanguageRegexInputEnd (langType language) notifyRegexInputEnd(pobj->lregexControlBlock); } +extern void notifyLanguageRegexMakeTagEntry (langType language, int corkIndex) +{ + notifyRegexMakeTagEntry((LanguageTable + language)->lregexControlBlock, corkIndex); +} + static unsigned int parserCorkFlags (parserDefinition *parser) { subparser *tmp; @@ -5418,6 +5423,11 @@ extern bool processSequelOption (const char *const option, const char *const par return processHookOption (option, parameter, "_sequel-", SCRIPT_HOOK_SEQUEL); } +extern bool processMakeTagEntryReflectionOption (const char *const option, const char *const parameter) +{ + return processHookOption (option, parameter, "_makeTagEntryReflection-", SCRIPT_HOOK_MAKE_TAG_ENTRY_REFLECTION); +} + extern bool processPretendOption (const char *const option, const char *const parameter) { langType new_language, old_language; diff --git a/main/parse.h b/main/parse.h index 6f3051b619..ea8d12315c 100644 --- a/main/parse.h +++ b/main/parse.h @@ -74,6 +74,7 @@ typedef enum { enum scriptHook { SCRIPT_HOOK_PRELUDE, SCRIPT_HOOK_SEQUEL, + SCRIPT_HOOK_MAKE_TAG_ENTRY_REFLECTION, SCRIPT_HOOK_MAX, }; diff --git a/main/parse_p.h b/main/parse_p.h index b841cce41b..2b7e734d72 100644 --- a/main/parse_p.h +++ b/main/parse_p.h @@ -152,6 +152,7 @@ extern bool doesLanguageHaveForeignDependency (const langType language, const la extern bool processLanguageRegexOption (langType language, enum regexParserType regptype, const char *const parameter); extern void notifyLanguageRegexInputStart (langType language); extern void notifyLanguageRegexInputEnd (langType language); +extern void notifyLanguageRegexMakeTagEntry (langType language, int corkIndex); extern bool hasLanguagePostRunRegexPatterns (const langType language); extern void matchLanguageRegex (const langType language, const vString* const line, bool postrun); diff --git a/main/subparser_p.h b/main/subparser_p.h index 375c6de188..6d23e3f861 100644 --- a/main/subparser_p.h +++ b/main/subparser_p.h @@ -28,8 +28,6 @@ extern subparser *getFirstSubparser(struct slaveControlBlock *controlBlock); /* A base parser doesn't have to call the following three functions. The main part calls them internally. */ -extern void notifyInputStart (void); -extern void notifyInputEnd (void); extern void notifyMakeTagEntry (const tagEntryInfo *info, int corkIndex); extern void setupSubparsersInUse (struct slaveControlBlock *controlBlock); diff --git a/parsers/cpreprocessor.c b/parsers/cpreprocessor.c index b60c191e57..b3a653836b 100644 --- a/parsers/cpreprocessor.c +++ b/parsers/cpreprocessor.c @@ -16,6 +16,7 @@ #include #include "debug.h" +#include "dependency.h" /* notifyInputStart, notifyInputEnd */ #include "entry.h" #include "htable.h" #include "x-cpreprocessor.h" @@ -392,6 +393,14 @@ static void cppInitCommon(langType clientLang, : clientLang) & CORK_SYMTAB)) ? makeMacroTable () : NULL; + + if (Cpp.lang != Cpp.clientLang + && Cpp.clientLang != LANG_IGNORE) + { + pushLanguage (Cpp.lang); + notifyInputStart (); + popLanguage (); + } } extern void cppInit (const bool state, const bool hasAtLiteralStrings, @@ -427,6 +436,14 @@ static void cppClearMacroInUse (cppMacroInfo **pM) extern void cppTerminate (void) { + if (Cpp.lang != Cpp.clientLang + && Cpp.clientLang != LANG_IGNORE) + { + pushLanguage (Cpp.lang); + notifyInputEnd (); + popLanguage (); + } + if (Cpp.directive.name != NULL) { vStringDelete (Cpp.directive.name);