From 247a05b853591685510af9e5bdf68ba4720ba1f9 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 3 Jan 2023 05:42:36 +0900 Subject: [PATCH 01/18] misc/review: add a command to show differences in Tmain Signed-off-by: Masatake YAMATO --- misc/review | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/misc/review b/misc/review index 8292440e76..889f449222 100755 --- a/misc/review +++ b/misc/review @@ -276,17 +276,43 @@ function tmain_inspect_run make tmain UNITS=$(basename $t .d) } + +tmain_inspect_cmd_show_diff_generic() +{ + local prefix=$1 + local t=$2 + local c=$3 + cat $prefix/$t/$c-diff.txt | diff_post_processor +} + +tmain_inspect_cmd_show_diff_all() +{ + local prefix=$1 + local t=$2 + local c + + for c in stdout stderr exit; do + if [[ -e "$prefix/$t/$c-diff.txt" ]]; then + echo '### ' "$c" + tmain_inspect_cmd_show_diff_generic "$prefix" "$t" "$c" + fi + done +} + do_tmain_inspect() { local next=0 local r local t=$1 - select r in 'ext' 'hell' 'un' 'uit'; do + select r in 'ext' 'iff' 'hell' 'un' 'uit'; do case $r-$REPLY in ("ext"-*|-n) next=1 ;; + ("iff"-*|-d) + tmain_inspect_cmd_show_diff_all Tmain "$t" + ;; ("hell"-*|-S) inspect_cmd_shell Tmain "$t" ;; From c972f7960bcaa4036575ddf987b4eac7a9086682 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 3 Jan 2023 04:58:13 +0900 Subject: [PATCH 02/18] main: allow parsers to use getLanguageKindForName and getLanguageRoleForName to make foreign tags Signed-off-by: Masatake YAMATO --- main/parse.h | 3 +++ main/parse_p.h | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main/parse.h b/main/parse.h index ec06cf13f0..45eb7c6d91 100644 --- a/main/parse.h +++ b/main/parse.h @@ -174,6 +174,9 @@ extern bool isLanguageKindEnabled (const langType language, int kindIndex); extern bool isLanguageRoleEnabled (const langType language, int kindIndex, int roleIndex); extern kindDefinition* getLanguageKindForLetter (const langType language, char kindLetter); +extern kindDefinition* getLanguageKindForName (const langType language, const char *kindName); +extern roleDefinition* getLanguageRoleForName (const langType language, int kindIndex, + const char *roleName); extern void initializeParser (langType language); extern unsigned int getLanguageCorkUsage (langType language); diff --git a/main/parse_p.h b/main/parse_p.h index 9fb9c10cb8..26bc3dc403 100644 --- a/main/parse_p.h +++ b/main/parse_p.h @@ -69,10 +69,7 @@ extern bool doesLanguageRequestAutomaticFQTag (const langType language); extern langType getNamedLanguageFull (const char *const name, size_t len, bool noPretending, bool include_aliases); extern kindDefinition* getLanguageKind(const langType language, int kindIndex); -extern kindDefinition* getLanguageKindForName (const langType language, const char *kindName); extern roleDefinition* getLanguageRole(const langType language, int kindIndex, int roleIndex); -extern roleDefinition* getLanguageRoleForName (const langType language, int kindIndex, - const char *roleName); extern unsigned int getLanguageVersionCurrent (const langType language); extern unsigned int getLanguageVersionAge (const langType language); From 95c744e2da78c1573e8168e1959676e9545172d5 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 3 Jan 2023 05:04:44 +0900 Subject: [PATCH 03/18] main: hide getLanguageKindForLetter() from parsers Signed-off-by: Masatake YAMATO --- main/parse.h | 1 - main/parse_p.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/main/parse.h b/main/parse.h index 45eb7c6d91..8656ef1f85 100644 --- a/main/parse.h +++ b/main/parse.h @@ -173,7 +173,6 @@ extern bool isLanguageEnabled (const langType language); extern bool isLanguageKindEnabled (const langType language, int kindIndex); extern bool isLanguageRoleEnabled (const langType language, int kindIndex, int roleIndex); -extern kindDefinition* getLanguageKindForLetter (const langType language, char kindLetter); extern kindDefinition* getLanguageKindForName (const langType language, const char *kindName); extern roleDefinition* getLanguageRoleForName (const langType language, int kindIndex, const char *roleName); diff --git a/main/parse_p.h b/main/parse_p.h index 26bc3dc403..da01b450db 100644 --- a/main/parse_p.h +++ b/main/parse_p.h @@ -69,6 +69,7 @@ extern bool doesLanguageRequestAutomaticFQTag (const langType language); extern langType getNamedLanguageFull (const char *const name, size_t len, bool noPretending, bool include_aliases); extern kindDefinition* getLanguageKind(const langType language, int kindIndex); +extern kindDefinition* getLanguageKindForLetter (const langType language, char kindLetter); extern roleDefinition* getLanguageRole(const langType language, int kindIndex, int roleIndex); extern unsigned int getLanguageVersionCurrent (const langType language); extern unsigned int getLanguageVersionAge (const langType language); From cc6d77c41bb651073c26e6a3a07d4f346c80fea6 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 3 Jan 2023 07:17:16 +0900 Subject: [PATCH 04/18] Asm: add missing "break;" in a default block in a switch statement Signed-off-by: Masatake YAMATO --- parsers/asm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/parsers/asm.c b/parsers/asm.c index 72146263cd..8d8b224d4c 100644 --- a/parsers/asm.c +++ b/parsers/asm.c @@ -278,6 +278,7 @@ static int makeAsmTag ( break; default: r = makeSimpleTag (operator, kind_for_directive); + break; } } } From 52e649cab8eb3ed483aa6284cbceaa6129401dd8 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 3 Jan 2023 07:18:22 +0900 Subject: [PATCH 05/18] Units: delete an empty line at the EOF Signed-off-by: Masatake YAMATO --- Units/parser-asm.r/gas-section.d/args.ctags | 1 - 1 file changed, 1 deletion(-) diff --git a/Units/parser-asm.r/gas-section.d/args.ctags b/Units/parser-asm.r/gas-section.d/args.ctags index ff95c547e4..41f6dbed62 100644 --- a/Units/parser-asm.r/gas-section.d/args.ctags +++ b/Units/parser-asm.r/gas-section.d/args.ctags @@ -1,4 +1,3 @@ --sort=no --extras=+r --fields=+r - From f2cbdbb79d686f6d400178ac39c73e16b2b145db Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 3 Jan 2023 07:32:09 +0900 Subject: [PATCH 06/18] Asm,refactor: rename a local variable and a parameter related to scope Signed-off-by: Masatake YAMATO --- parsers/asm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/parsers/asm.c b/parsers/asm.c index 8d8b224d4c..66755a8bd7 100644 --- a/parsers/asm.c +++ b/parsers/asm.c @@ -218,7 +218,7 @@ static int makeAsmTag ( const bool labelCandidate, const bool nameFollows, const bool directive, - int *scope) + int *macroScope) { int r = CORK_NIL; @@ -258,17 +258,17 @@ static int makeAsmTag ( macro_tag = getEntryInCorkQueue (r); if (macro_tag) { - macro_tag->extensionFields.scopeIndex = *scope; + macro_tag->extensionFields.scopeIndex = *macroScope; registerEntry (r); - *scope = r; + *macroScope = r; } break; case K_PSUEDO_MACRO_END: - macro_tag = getEntryInCorkQueue (*scope); + macro_tag = getEntryInCorkQueue (*macroScope); if (macro_tag) { macro_tag->extensionFields.endLine = getInputLineNumber (); - *scope = macro_tag->extensionFields.scopeIndex; + *macroScope = macro_tag->extensionFields.scopeIndex; } break; case K_SECTION: @@ -656,7 +656,7 @@ static void findAsmTagsCommon (bool useCpp) KIND_GHOST_INDEX, 0, 0, KIND_GHOST_INDEX, KIND_GHOST_INDEX, 0, 0, FIELD_UNKNOWN); - int scope = CORK_NIL; + int macroScope = CORK_NIL; while ((line = asmReadLineFromInputFile (commentCharsInMOL, useCpp)) != NULL) { @@ -720,7 +720,7 @@ static void findAsmTagsCommon (bool useCpp) cp = readSymbol (cp, name); nameFollows = true; } - int r = makeAsmTag (name, operator, labelCandidate, nameFollows, directive, &scope); + int r = makeAsmTag (name, operator, labelCandidate, nameFollows, directive, ¯oScope); tagEntryInfo *e = getEntryInCorkQueue (r); if (e && e->kindIndex == K_MACRO && isRoleAssigned(e, ROLE_DEFINITION_INDEX)) readMacroParameters (r, e, cp); From 184bc0ba41f28c9225478f2ffec9fe1d9b595cdd Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Sun, 20 Nov 2022 20:39:36 +0900 Subject: [PATCH 07/18] main: add a new funciton, markCorkEntryPlaceholder() Signed-off-by: Masatake YAMATO --- main/entry.c | 7 +++++++ main/entry.h | 1 + 2 files changed, 8 insertions(+) diff --git a/main/entry.c b/main/entry.c index 7ab93e2a94..8301843171 100644 --- a/main/entry.c +++ b/main/entry.c @@ -1743,6 +1743,13 @@ extern void markTagPlaceholder (tagEntryInfo *e, bool placeholder) e->placeholder = placeholder; } +extern void markCorkEntryPlaceholder (int index, bool placeholder) +{ + tagEntryInfo *e = getEntryInCorkQueue(index); + if (e) + markTagPlaceholder(e, placeholder); +} + extern int makePlaceholder (const char *const name) { tagEntryInfo e; diff --git a/main/entry.h b/main/entry.h index e82af681d8..f4c2053753 100644 --- a/main/entry.h +++ b/main/entry.h @@ -287,6 +287,7 @@ extern const char* getParserFieldValueForType (tagEntryInfo *const tag, fieldTyp extern int makePlaceholder (const char *const name); extern void markTagPlaceholder (tagEntryInfo *e, bool placeholder); +extern void markCorkEntryPlaceholder (int index, bool placeholder); /* Marking all tag entries entries under the scope specified * with index recursively. From 4d2f4a4c461ec1a41efc93a31b4af99f59c35625 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 22 Nov 2022 06:48:54 +0900 Subject: [PATCH 08/18] main,refactor: rename functions for marking a tag as a placeholder --- main/entry.c | 12 ++++++------ main/entry.h | 4 ++-- main/lregex.c | 2 +- parsers/jscript.c | 2 +- parsers/rst.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/main/entry.c b/main/entry.c index 8301843171..4217a13e4f 100644 --- a/main/entry.c +++ b/main/entry.c @@ -1738,16 +1738,16 @@ extern size_t countEntryInCorkQueue (void) return ptrArrayCount (TagFile.corkQueue); } -extern void markTagPlaceholder (tagEntryInfo *e, bool placeholder) +extern void markTagAsPlaceholder (tagEntryInfo *e, bool placeholder) { e->placeholder = placeholder; } -extern void markCorkEntryPlaceholder (int index, bool placeholder) +extern void markCorkEntryAsPlaceholder (int index, bool placeholder) { tagEntryInfo *e = getEntryInCorkQueue(index); if (e) - markTagPlaceholder(e, placeholder); + markTagAsPlaceholder(e, placeholder); } extern int makePlaceholder (const char *const name) @@ -1755,7 +1755,7 @@ extern int makePlaceholder (const char *const name) tagEntryInfo e; initTagEntry (&e, name, KIND_GHOST_INDEX); - markTagPlaceholder(&e, true); + markTagAsPlaceholder(&e, true); /* * makePlaceholder may be called even before reading any bytes @@ -2158,7 +2158,7 @@ extern const char* getTagFileDirectory (void) return TagFile.directory; } -static bool markAsPlaceholder (int index, tagEntryInfo *e, void *data CTAGS_ATTR_UNUSED) +static bool markAsPlaceholderRecursively (int index, tagEntryInfo *e, void *data CTAGS_ATTR_UNUSED) { e->placeholder = 1; markAllEntriesInScopeAsPlaceholder (index); @@ -2167,5 +2167,5 @@ static bool markAsPlaceholder (int index, tagEntryInfo *e, void *data CTAGS_ATT extern void markAllEntriesInScopeAsPlaceholder (int index) { - foreachEntriesInScope (index, NULL, markAsPlaceholder, NULL); + foreachEntriesInScope (index, NULL, markAsPlaceholderRecursively, NULL); } diff --git a/main/entry.h b/main/entry.h index f4c2053753..6bd64035d2 100644 --- a/main/entry.h +++ b/main/entry.h @@ -286,8 +286,8 @@ extern void attachParserFieldToCorkEntry (int index, fieldType ftype, const char extern const char* getParserFieldValueForType (tagEntryInfo *const tag, fieldType ftype); extern int makePlaceholder (const char *const name); -extern void markTagPlaceholder (tagEntryInfo *e, bool placeholder); -extern void markCorkEntryPlaceholder (int index, bool placeholder); +extern void markTagAsPlaceholder (tagEntryInfo *e, bool placeholder); +extern void markCorkEntryAsPlaceholder (int index, bool placeholder); /* Marking all tag entries entries under the scope specified * with index recursively. diff --git a/main/lregex.c b/main/lregex.c index b47a891634..fb49abfd27 100644 --- a/main/lregex.c +++ b/main/lregex.c @@ -3947,7 +3947,7 @@ static EsObject *lrop_markplaceholder (OptVM *vm, EsObject *name) if (e == NULL) return OPTSCRIPT_ERR_NOTAGENTRY; - markTagPlaceholder (e, true); + markTagAsPlaceholder (e, true); opt_vm_ostack_pop (vm); return es_false; diff --git a/parsers/jscript.c b/parsers/jscript.c index 9bb3601b4d..90401cddcd 100644 --- a/parsers/jscript.c +++ b/parsers/jscript.c @@ -1372,7 +1372,7 @@ static int parseMethodsInAnonymousObject (tokenInfo *const token) */ tagEntryInfo *e = getEntryInCorkQueue (index); if (e) - markTagPlaceholder (e, true); + markTagAsPlaceholder (e, true); index = CORK_NIL; } diff --git a/parsers/rst.c b/parsers/rst.c index 11d81ecf69..8ed7e78877 100644 --- a/parsers/rst.c +++ b/parsers/rst.c @@ -359,7 +359,7 @@ static void shiftKinds(int shift, rstKind baseKind) e->kindIndex += shift; if (e->kindIndex >= SECTION_COUNT) { - markTagPlaceholder(e, true); + markTagAsPlaceholder(e, true); int foster_parent = getFosterEntry(e, shift); Assert (foster_parent != CORK_NIL); From 0b1b915538d91bf2e00b13400f5f04acb3bd99aa Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 22 Nov 2022 06:49:35 +0900 Subject: [PATCH 09/18] main,refactor: use markTagAsPlaceholder in markAsPlaceholderRecursively --- main/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/entry.c b/main/entry.c index 4217a13e4f..b23ccb05c2 100644 --- a/main/entry.c +++ b/main/entry.c @@ -2160,7 +2160,7 @@ extern const char* getTagFileDirectory (void) static bool markAsPlaceholderRecursively (int index, tagEntryInfo *e, void *data CTAGS_ATTR_UNUSED) { - e->placeholder = 1; + markTagAsPlaceholder (e, true); markAllEntriesInScopeAsPlaceholder (index); return true; } From 60a048dff7e62b170aa91552170cbad6fa8172b8 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Sat, 3 Dec 2022 03:15:10 +0900 Subject: [PATCH 10/18] main: add a new macro clearRole Signed-off-by: Masatake YAMATO --- main/entry.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main/entry.h b/main/entry.h index 6bd64035d2..5926c719e8 100644 --- a/main/entry.h +++ b/main/entry.h @@ -155,6 +155,7 @@ extern void initForeignRefTagEntry (tagEntryInfo *const e, const char *const nam langType type, int kindIndex, int roleIndex); extern void assignRole(tagEntryInfo *const e, int roleIndex); +#define clearRoles(E) assignRole((E), ROLE_DEFINITION_INDEX) extern bool isRoleAssigned(const tagEntryInfo *const e, int roleIndex); extern int makeQualifiedTagEntry (const tagEntryInfo *const e); From 77ffe435114a2f5a5271435698580e3858b1f78d Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Sun, 4 Dec 2022 02:00:43 +0900 Subject: [PATCH 11/18] Cxx: add cxxTagRoleEnabled() Signed-off-by: Masatake YAMATO --- parsers/cxx/cxx_tag.c | 15 +++++++++++++++ parsers/cxx/cxx_tag.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/parsers/cxx/cxx_tag.c b/parsers/cxx/cxx_tag.c index ede48312a9..63b8a382b3 100644 --- a/parsers/cxx/cxx_tag.c +++ b/parsers/cxx/cxx_tag.c @@ -202,6 +202,21 @@ bool cxxTagKindEnabled(unsigned int uKind) return g_cxx.pKindDefinitions[uKind].enabled; } +bool cxxTagRoleEnabled(unsigned int uKind, int iRole) +{ + if(!cxxTagKindEnabled(uKind)) + return true; + if(iRole == ROLE_DEFINITION_INDEX) + return true; + + CXX_DEBUG_ASSERT( + (ROLE_DEFINITION_INDEX < iRole + && iRole < g_cxx.pKindDefinitions[uKind].nRoles), + "The role must be associated to the kind (%u)", uKind + ); + return g_cxx.pKindDefinitions[uKind].roles[iRole].enabled; +} + fieldDefinition * cxxTagGetCPPFieldDefinitionifiers(void) { return g_aCXXCPPFields; diff --git a/parsers/cxx/cxx_tag.h b/parsers/cxx/cxx_tag.h index 0894e99f0b..64e78bdd33 100644 --- a/parsers/cxx/cxx_tag.h +++ b/parsers/cxx/cxx_tag.h @@ -92,6 +92,9 @@ int cxxTagGetCPPKindDefinitionCount(void); // Returns true if the specified tag kind is enabled in the current language bool cxxTagKindEnabled(unsigned int uTagKind); +// Returns true if the specified tag role is enabled in the current language +bool cxxTagRoleEnabled(unsigned int uTagKind, int iTagRole); + // Begin composing a tag. The tag kind must correspond to the current language. // Returns NULL if the tag should *not* be included in the output // or the tag entry info that can be filled up with extension fields. From 99bc13cd7eaa5e35d07173c9f43c4f1a205597a2 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Thu, 1 Dec 2022 03:40:46 +0900 Subject: [PATCH 12/18] Cxx,refactor: convert a bool field to a bit field Signed-off-by: Masatake YAMATO --- parsers/cxx/cxx_token.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsers/cxx/cxx_token.h b/parsers/cxx/cxx_token.h index 76fe3afe6b..573e64b6a1 100644 --- a/parsers/cxx/cxx_token.h +++ b/parsers/cxx/cxx_token.h @@ -73,7 +73,7 @@ typedef struct _CXXToken vString * pszWord; CXXKeyword eKeyword; CXXTokenChain * pChain; // this is NOT the parent chain! - bool bFollowedBySpace; + unsigned int bFollowedBySpace: 1; int iLineNumber; MIOPos oFilePosition; From 0775dc5618950ff18036a100bfae06faf1c6588f Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 4 Jan 2023 04:36:39 +0900 Subject: [PATCH 13/18] build-sys,refactor: sort PARSER_SRCS --- source.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source.mak b/source.mak index 6347483728..9d54ca38fe 100644 --- a/source.mak +++ b/source.mak @@ -332,9 +332,9 @@ PARSER_SRCS = \ parsers/cxx/cxx_parser_typedef.c \ parsers/cxx/cxx_parser_using.c \ parsers/cxx/cxx_parser_variable.c \ - parsers/cxx/cxx_subparser.c \ parsers/cxx/cxx_qtmoc.c \ parsers/cxx/cxx_scope.c \ + parsers/cxx/cxx_subparser.c \ parsers/cxx/cxx_tag.c \ parsers/cxx/cxx_token.c \ parsers/cxx/cxx_token_chain.c \ From 1334099038f2013900638b5847404788466da3e3 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 1 Mar 2022 14:50:32 +0900 Subject: [PATCH 14/18] main: add a API function for unassigning a role from a tagEntry Signed-off-by: Masatake YAMATO --- main/entry.c | 5 +++++ main/entry.h | 1 + 2 files changed, 6 insertions(+) diff --git a/main/entry.c b/main/entry.c index b23ccb05c2..e96a033a24 100644 --- a/main/entry.c +++ b/main/entry.c @@ -2085,6 +2085,11 @@ extern void assignRole(tagEntryInfo *const e, int roleIndex) assignRoleFull(e, roleIndex, true); } +extern void unassignRole(tagEntryInfo *const e, int roleIndex) +{ + assignRoleFull(e, roleIndex, false); +} + extern bool isRoleAssigned(const tagEntryInfo *const e, int roleIndex) { if (roleIndex == ROLE_DEFINITION_INDEX) diff --git a/main/entry.h b/main/entry.h index 5926c719e8..89d5a1ad5d 100644 --- a/main/entry.h +++ b/main/entry.h @@ -156,6 +156,7 @@ extern void initForeignRefTagEntry (tagEntryInfo *const e, const char *const nam int kindIndex, int roleIndex); extern void assignRole(tagEntryInfo *const e, int roleIndex); #define clearRoles(E) assignRole((E), ROLE_DEFINITION_INDEX) +extern void unassignRole(tagEntryInfo *const e, int roleIndex); extern bool isRoleAssigned(const tagEntryInfo *const e, int roleIndex); extern int makeQualifiedTagEntry (const tagEntryInfo *const e); From 4940d49c7075dc7258bd3a701d0a10d64d8adc9a Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 1 Mar 2022 14:51:49 +0900 Subject: [PATCH 15/18] operator: add operators for assigning/unasigning a role to/from a tag Signed-off-by: Masatake YAMATO --- main/lregex.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/main/lregex.c b/main/lregex.c index fb49abfd27..996e4e6708 100644 --- a/main/lregex.c +++ b/main/lregex.c @@ -3333,6 +3333,55 @@ static EsObject* lrop_make_reftag (OptVM *vm, EsObject *name) return es_false; } +static EsObject* lrop_assign_role_common (OptVM *vm, EsObject *name, bool assign) +{ + EsObject *tag = opt_vm_ostack_peek (vm, 1); + tagEntryInfo *e; + if (es_integer_p (tag)) + { + int n = es_integer_get (tag); + if (! (CORK_NIL < n && n < countEntryInCorkQueue())) + return OPT_ERR_RANGECHECK; + e = getEntryInCorkQueue (n); + } + else if (es_object_get_type (tag) == OPT_TYPE_TAG) + e = es_pointer_get (tag); + else + return OPT_ERR_TYPECHECK; + + if (e == NULL) + return OPTSCRIPT_ERR_NOTAGENTRY; + + langType lang = e->langType; + int kind_index = e->kindIndex; + EsObject *role = opt_vm_ostack_top (vm); + if (es_object_get_type (role) != OPT_TYPE_NAME) + return OPT_ERR_TYPECHECK; + EsObject *role_sym = es_pointer_get (role); + const char *role_str = es_symbol_get (role_sym); + roleDefinition* role_def = getLanguageRoleForName (lang, kind_index, role_str); + if (!role_def) + return OPTSCRIPT_ERR_UNKNOWNROLE; + int role_index = role_def->id; + + (assign? assignRole: unassignRole) (e, role_index); + + opt_vm_ostack_pop (vm); + opt_vm_ostack_pop (vm); + + return es_false; +} + +static EsObject* lrop_assign_role (OptVM *vm, EsObject *name) +{ + return lrop_assign_role_common (vm, name, true); +} + +static EsObject* lrop_unassign_role (OptVM *vm, EsObject *name) +{ + return lrop_assign_role_common (vm, name, false); +} + /* tag COMMIT int */ static EsObject* lrop_commit_tag (OptVM *vm, EsObject *name) { @@ -4211,6 +4260,18 @@ static struct optscriptOperatorRegistration lropOperators [] = { .help_str = "param:name _PARAM value:string true%" "param:name _PARAM false", }, + { + .name = "_assignrole", + .fn = lrop_assign_role, + .arity = 2, + .help_str = "tag:int|tag:tag role:name _ASSIGNROLE -", + }, + { + .name = "_unassignrole", + .fn = lrop_unassign_role, + .arity = 2, + .help_str = "tag:int|tag:tag role:name _UNASSIGNROLE -", + }, }; extern void initRegexOptscript (void) From b8f4d43b19314e2c86545aaa9e91f73da252078b Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 28 Dec 2022 07:27:35 +0900 Subject: [PATCH 16/18] main: show the information about input when failed in evaluation Signed-off-by: Masatake YAMATO --- main/lregex.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main/lregex.c b/main/lregex.c index 996e4e6708..5f6e972a1a 100644 --- a/main/lregex.c +++ b/main/lregex.c @@ -1733,7 +1733,9 @@ static void matchTagPattern (struct lregexControlBlock *lcb, scriptSetup (optvm, lcb, n, window); EsObject *e = scriptEval (optvm, patbuf->optscript); if (es_error_p (e)) - error (WARNING, "error when evaluating: %s", patbuf->optscript_src); + error (WARNING, "error when evaluating: %s %% input: %s, line:%lu", patbuf->optscript_src, + getInputFileName (), + getInputLineNumberInRegPType(patbuf->regptype, offset)); es_object_unref (e); scriptTeardown (optvm, lcb); } @@ -1886,7 +1888,8 @@ static bool matchRegexPattern (struct lregexControlBlock *lcb, scriptSetup (optvm, lcb, CORK_NIL, &window); EsObject *e = scriptEval (optvm, patbuf->optscript); if (es_error_p (e)) - error (WARNING, "error when evaluating: %s", patbuf->optscript_src); + error (WARNING, "error when evaluating: %s %% input: %s", patbuf->optscript_src, + getInputFileName ()); es_object_unref (e); scriptTeardown (optvm, lcb); } @@ -1978,7 +1981,8 @@ static bool matchMultilineRegexPattern (struct lregexControlBlock *lcb, scriptSetup (optvm, lcb, CORK_NIL, &window); EsObject *e = scriptEval (optvm, patbuf->optscript); if (es_error_p (e)) - error (WARNING, "error when evaluating: %s", patbuf->optscript_src); + error (WARNING, "error when evaluating: %s %% input: %s", patbuf->optscript_src, + getInputFileName ()); es_object_unref (e); scriptTeardown (optvm, lcb); } From b823933f84c7cdcec39f08de41330376d46e752c Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 28 Dec 2022 07:28:26 +0900 Subject: [PATCH 17/18] Pod,comment: add description about depthForCork procedure Signed-off-by: Masatake YAMATO --- optlib/pod.c | 1 + optlib/pod.ctags | 1 + 2 files changed, 2 insertions(+) diff --git a/optlib/pod.c b/optlib/pod.c index 4112ed1671..62092a5f59 100644 --- a/optlib/pod.c +++ b/optlib/pod.c @@ -28,6 +28,7 @@ static void initializePodParser (const langType language CTAGS_ATTR_UNUSED) " 0 get ?1 sub\n" " } def\n" "\n" + " % cork:int DEPTHFORCORK depth:int\n" " /depthForCork {\n" " :kind kindTable exch _aindex pop\n" " } def\n" diff --git a/optlib/pod.ctags b/optlib/pod.ctags index e24fbf4352..6c9b7f613c 100644 --- a/optlib/pod.ctags +++ b/optlib/pod.ctags @@ -48,6 +48,7 @@ 0 get ?1 sub } def + % cork:int DEPTHFORCORK depth:int /depthForCork { :kind kindTable exch _aindex pop } def From 8be217188f7bec8803ac94daa4467e5f7d1a30ab Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Fri, 30 Dec 2022 07:14:10 +0900 Subject: [PATCH 18/18] optlib2c: fix wrongly generated code for --_paramdef - param.h was not included. - the field for description was wrong. Signed-off-by: Masatake YAMATO --- misc/optlib2c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/misc/optlib2c b/misc/optlib2c index 4fb5038270..e58f387b8d 100755 --- a/misc/optlib2c +++ b/misc/optlib2c @@ -620,6 +620,11 @@ EOF if (defined $opts->{'selector'}) { print <{'paramdefs'}}) > 0) { + print <