Skip to content

Commit

Permalink
main: allow specifying alternative parser list
Browse files Browse the repository at this point in the history
Allow applications which use ctags as a library provide their own
list of parsers. This list has to be declared as a define called
EXTERNAL_PARSER_LIST inside an external header. ctags will use the
EXTERNAL_PARSER_LIST_FILE define to detect the presence of such a
header and it should contain path to the header. When not defined,
internal parsers are used.
  • Loading branch information
techee committed May 21, 2019
1 parent ad3548a commit 78d1a3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions main/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ static void uninstallTagXpathTable (const langType language);
*/
static parserDefinition *CTagsSelfTestParser (void);
static parserDefinitionFunc* BuiltInParsers[] = {
#ifdef EXTERNAL_PARSER_LIST
EXTERNAL_PARSER_LIST
#else /* ! EXTERNAL_PARSER_LIST */
CTagsSelfTestParser,
PARSER_LIST,
XML_PARSER_LIST
Expand All @@ -135,6 +138,7 @@ static parserDefinitionFunc* BuiltInParsers[] = {
#ifdef HAVE_PACKCC
,
#endif
#endif /* EXTERNAL_PARSER_LIST */
};
static parserObject* LanguageTable = NULL;
static unsigned int LanguageCount = 0;
Expand Down
7 changes: 7 additions & 0 deletions main/parse_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include "parse.h"
#include "parsers_p.h" /* contains list of parsers */
#include "strlist.h"
#ifdef EXTERNAL_PARSER_LIST_FILE
#include EXTERNAL_PARSER_LIST_FILE
#endif

/*
* MACROS
Expand All @@ -41,6 +44,9 @@ typedef enum {
* return a structure allocated using parserNew(). This structure must,
* at minimum, set the `parser' field.
*/
#ifdef EXTERNAL_PARSER_LIST
extern parserDefinitionFunc EXTERNAL_PARSER_LIST;
#else /* ! EXTERNAL_PARSER_LIST */
extern parserDefinitionFunc PARSER_LIST;
#ifdef HAVE_LIBXML
extern parserDefinitionFunc XML_PARSER_LIST;
Expand All @@ -51,6 +57,7 @@ extern parserDefinitionFunc YAML_PARSER_LIST;
#ifdef HAVE_PACKCC
extern parserDefinitionFunc PEG_PARSER_LIST;
#endif
#endif /* EXTERNAL_PARSER_LIST */

extern bool doesLanguageAllowNullTag (const langType language);
extern bool doesLanguageRequestAutomaticFQTag (const langType language);
Expand Down

0 comments on commit 78d1a3f

Please sign in to comment.