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 - diff --git a/main/entry.c b/main/entry.c index 7ab93e2a94..e96a033a24 100644 --- a/main/entry.c +++ b/main/entry.c @@ -1738,17 +1738,24 @@ 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 markCorkEntryAsPlaceholder (int index, bool placeholder) +{ + tagEntryInfo *e = getEntryInCorkQueue(index); + if (e) + markTagAsPlaceholder(e, placeholder); +} + 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 @@ -2078,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) @@ -2151,14 +2163,14 @@ 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; + markTagAsPlaceholder (e, true); markAllEntriesInScopeAsPlaceholder (index); return true; } 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 e82af681d8..89d5a1ad5d 100644 --- a/main/entry.h +++ b/main/entry.h @@ -155,6 +155,8 @@ 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 void unassignRole(tagEntryInfo *const e, int roleIndex); extern bool isRoleAssigned(const tagEntryInfo *const e, int roleIndex); extern int makeQualifiedTagEntry (const tagEntryInfo *const e); @@ -286,7 +288,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 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..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); } @@ -3333,6 +3337,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) { @@ -3947,7 +4000,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; @@ -4211,6 +4264,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) diff --git a/main/parse.h b/main/parse.h index ec06cf13f0..8656ef1f85 100644 --- a/main/parse.h +++ b/main/parse.h @@ -173,7 +173,9 @@ 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); 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..da01b450db 100644 --- a/main/parse_p.h +++ b/main/parse_p.h @@ -69,10 +69,8 @@ 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 kindDefinition* getLanguageKindForLetter (const langType language, char kindLetter); 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); 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 <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" ;; 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 diff --git a/parsers/asm.c b/parsers/asm.c index 72146263cd..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: @@ -278,6 +278,7 @@ static int makeAsmTag ( break; default: r = makeSimpleTag (operator, kind_for_directive); + break; } } } @@ -655,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) { @@ -719,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); 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. 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; 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); 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 \