[geany/geany] 808b7a: Sync ctags parsers with small changes with Geany (#2990)

Jiří Techet git-noreply at xxxxx
Thu Dec 2 10:39:16 UTC 2021


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   GitHub <noreply at github.com>
Date:        Thu, 02 Dec 2021 10:39:16 UTC
Commit:      808b7a30cba153e91fdb56b8b7af92f0f55a8ee5
             https://github.com/geany/geany/commit/808b7a30cba153e91fdb56b8b7af92f0f55a8ee5

Log Message:
-----------
Sync ctags parsers with small changes with Geany (#2990)

* Remove the geany_ prefix from parsers with trivial changes against ctags

This will allow the update-ctags.py script to replace these parsers
with parsers from uctags.

* Update parsers to the uctags versions and update Geany where needed

This patch copies over parsers without the geany_ prefix from uctags
tag p5.9.20211031.0.

Next, it updates our mapping of kinds to tag types when there was
a change. The deleted kind in ABC mapping was never generated by the
ABC parser and was removed in the upstream version. The new 'C' and 'd'
kinds of HAXE parser were mapped to tm_tag_undef_t.

Finally, txt2tags uses a different context separator (\"\" instead of \x03)
so tm_parser_context_separator() was updated accordingly and so were
the unit tests. At the same time I removed TM_PARSER_ASCIIDOC from
tm_parser_context_separator() because the parser doesn't use context
separator at all and it's unnecessary there.

* Add julia test to Makefile.am

This test was missing and the unit test wasn't performed.

* Remove REST from tm_parser_context_separator()

The mentioned scope separator ":::" isn't used in the REST parser. The
parser only includes one-level scope (only immediate parent) so
scope separators aren't used for it.

* Undo previous commit removing REST scope separator and improve comment

* Add asciidoc among languages without nested scope

It was removed in the initial commit but even though it doesn't use
nested scope, '.' could appear in the title so use something less probable.

* Use "\x3" as the improbable character for scope separator

It was used previously as a txt2tags scope separator and since it's
unprintable, it's better than ::: that could be written in the title.

On the way, move the real "\"\"" scope separator above in the switch
list so the special "\x3" case is listed last.


Modified Paths:
--------------
    ctags/Makefile.am
    ctags/parsers/abaqus.c
    ctags/parsers/abc.c
    ctags/parsers/asciidoc.c
    ctags/parsers/bibtex.c
    ctags/parsers/cobol.c
    ctags/parsers/css.c
    ctags/parsers/erlang.c
    ctags/parsers/flex.c
    ctags/parsers/haskell.c
    ctags/parsers/haxe.c
    ctags/parsers/json.c
    ctags/parsers/julia.c
    ctags/parsers/powershell.c
    ctags/parsers/rst.c
    ctags/parsers/txt2tags.c
    src/tagmanager/tm_parser.c
    tests/ctags/Makefile.am
    tests/ctags/julia-corner_cases.jl.tags
    tests/ctags/rules.t2t.tags
    tests/ctags/titles.t2t.tags

Modified: ctags/Makefile.am
30 lines changed, 15 insertions(+), 15 deletions(-)
===================================================================
@@ -11,28 +11,28 @@ AM_CFLAGS = \
 noinst_LTLIBRARIES = libctags.la
 
 parsers = \
-	parsers/geany_abaqus.c \
-	parsers/geany_abc.c \
-	parsers/geany_asciidoc.c \
+	parsers/abaqus.c \
+	parsers/abc.c \
+	parsers/asciidoc.c \
 	parsers/geany_asm.c \
 	parsers/geany_basic.c \
-	parsers/geany_bibtex.c \
+	parsers/bibtex.c \
 	parsers/geany_c.c \
-	parsers/geany_cobol.c \
+	parsers/cobol.c \
 	parsers/geany_iniconf.c \
-	parsers/geany_css.c \
+	parsers/css.c \
 	parsers/geany_diff.c \
 	parsers/geany_docbook.c \
-	parsers/geany_erlang.c \
-	parsers/geany_flex.c \
+	parsers/erlang.c \
+	parsers/flex.c \
 	parsers/geany_fortran.c \
 	parsers/geany_go.c \
-	parsers/geany_haskell.c \
-	parsers/geany_haxe.c \
+	parsers/haskell.c \
+	parsers/haxe.c \
 	parsers/geany_html.c \
 	parsers/geany_jscript.c \
-	parsers/geany_json.c \
-	parsers/geany_julia.c \
+	parsers/json.c \
+	parsers/julia.c \
 	parsers/geany_lcpp.c \
 	parsers/geany_lcpp.h \
 	parsers/geany_lua.c \
@@ -44,17 +44,17 @@ parsers = \
 	parsers/geany_pascal.c \
 	parsers/geany_perl.c \
 	parsers/geany_php.c \
-	parsers/geany_powershell.c \
+	parsers/powershell.c \
 	parsers/geany_python.c \
 	parsers/geany_r.c \
-	parsers/geany_rst.c \
+	parsers/rst.c \
 	parsers/geany_ruby.c \
 	parsers/geany_rust.c \
 	parsers/geany_sh.c \
 	parsers/geany_sql.c \
 	parsers/geany_tcl.c \
 	parsers/geany_tex.c \
-	parsers/geany_txt2tags.c \
+	parsers/txt2tags.c \
 	parsers/geany_verilog.c \
 	parsers/geany_vhdl.c
 


Modified: ctags/parsers/abaqus.c
12 lines changed, 7 insertions(+), 5 deletions(-)
===================================================================
@@ -1,9 +1,11 @@
 /*
+ *   Copyright (c) 2013, Baptiste Pierrat
+ *
  *   This source code is released for free distribution under the terms of the
- *   GNU General Public License.
+ *   GNU General Public License version 2 or (at your opinion) any later version.
  *
  *   This module contains functions for generating tags for source files
- *   for inp files (Abaqus).
+ *   for Abaqus inp files (https://en.wikipedia.org/wiki/Abaqus).
  */
 
 /*
@@ -29,9 +31,9 @@ typedef enum {
 } AbaqusKind;
 
 static kindDefinition AbaqusKinds[] = {
-     { true, 'c', "class",      "Parts" },
-     { true, 'm', "member",      "Assembly" },
-     { true, 'n', "namespace",      "Steps" }
+     { true, 'p', "part",     "Parts" },
+     { true, 'a', "assembly", "Assembly" },
+     { true, 's', "step",     "Steps" }
 };
 
 /*


Modified: ctags/parsers/abc.c
65 lines changed, 9 insertions(+), 56 deletions(-)
===================================================================
@@ -4,9 +4,10 @@
 *   Based on work by Jon Strait
 *
 *   This source code is released for free distribution under the terms of the
-*   GNU General Public License.
+*   GNU General Public License version 2 or (at your opinion) any later version.
 *
-*   This module contains functions for generating tags for Abc files.
+*   This module contains functions for generating tags for Abc files
+*   (https://en.wikipedia.org/wiki/ABC_notation).
 */
 
 /*
@@ -27,77 +28,29 @@
 *   DATA DEFINITIONS
 */
 
+typedef enum {
+   K_SECTION,
+} AbcKind;
+
 static kindDefinition AbcKinds[] = {
-	{ true, 'm', "member", "sections" },
-	{ true, 's', "struct",  "header1"}
+	{ true, 's', "section", "sections" },
 };
 
 /*
 *   FUNCTION DEFINITIONS
 */
 
-/* checks if str is all the same character */
-/*static bool issame(const char *str)
-{
-	char first = *str;
-
-	while (*(++str))
-	{
-		if (*str && *str != first)
-			return false;
-	}
-	return true;
-}*/
-
-
-static void makeAbcTag (const vString* const name, bool name_before)
-{
-	tagEntryInfo e;
-	initTagEntry (&e, vStringValue(name), 0);
-
-	if (name_before)
-		e.lineNumber--;	/* we want the line before the underline chars */
-
-	makeTagEntry(&e);
-}
-
-/*static void makeAbcTag2 (const vString* const name, bool name_before)
-{
-	tagEntryInfo e;
-	initTagEntry (&e, vStringValue(name));
-
-	if (name_before)
-		e.lineNumber--;
-	e.kindName = "struct";
-	e.kind = 's';
-
-	makeTagEntry(&e);
-}*/
-
 static void findAbcTags (void)
 {
 	vString *name = vStringNew();
 	const unsigned char *line;
 
 	while ((line = readLineFromInputFile()) != NULL)
 	{
-		/*int name_len = vStringLength(name);*/
-
-		/* underlines must be the same length or more */
-		/*if (name_len > 0 &&	(line[0] == '=' || line[0] == '-') && issame((const char*) line))
-		{
-			makeAbcTag(name, true);
-		}*/
-/*		if (line[1] == '%') {
-			vStringClear(name);
-			vStringCatS(name, (const char *) line);
-			makeAbcTag(name, false);
-		}*/
 		if (line[0] == 'T') {
-			/*vStringClear(name);*/
 			vStringCatS(name, " / ");
 			vStringCatS(name, (const char *) line);
-			makeAbcTag(name, false);
+			makeSimpleTag(name, K_SECTION);
 		}
 		else {
 			vStringClear (name);


Modified: ctags/parsers/asciidoc.c
6 lines changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -103,7 +103,7 @@ static int makeAsciidocTag (const vString* const name, const int kind, const boo
 			Assert (line > 0);
 			if (line > 0)
 			{
-				e.lineNumber--;	
+				e.lineNumber--;
 				e.filePosition = getInputFilePositionForLine(line - 1);
 			}
 		}
@@ -179,7 +179,7 @@ static int capture_anchor(const unsigned char *const orig, int* captured_len)
 				else line += 2;
 				break;
 			}
-			/* otherwise it's not the end, keep going */			
+			/* otherwise it's not the end, keep going */
 		}
 
 		if (*line == ',')
@@ -272,7 +272,7 @@ static void process_name(vString *const name, const int kind,
 
 	while (isspace(line[end])) --end;
 
-	if (start < end)
+	if (start <= end)
 		vStringNCatS(name, (const char*)(&(line[start])), end - start + 1);
 }
 


Modified: ctags/parsers/bibtex.c
22 lines changed, 11 insertions(+), 11 deletions(-)
===================================================================
@@ -1,14 +1,15 @@
 /*
- *   Copyright (c) 2000-2001, Jérôme Plût
- *   Copyright (c) 2006, Enrico Tröger
- *   Copyright (c) 2019, Mirco Schönfeld
+ *	 Copyright (c) 2008, David Fishburn
+ *	 Copyright (c) 2012, Jan Larres
+ *	 Copyright (c) 2019, Mirco Schönfeld
  *
- *   This source code is released for free distribution under the terms of the
- *   GNU General Public License.
+ *	 This source code is released for free distribution under the terms of the
+ *	 GNU General Public License version 2 or (at your option) any later version.
  *
- *   This module contains functions for generating tags for source files
- *   for the BibTex formatting system. 
- *   https://en.wikipedia.org/wiki/BibTeX
+ *	 This module contains functions for generating identifiers of entries of Bibtex language files.
+ *
+ *	 BibTex language "reference":
+ *		 https://en.wikipedia.org/wiki/BibTeX
  */
 
 /*
@@ -32,7 +33,7 @@
 #define isType(token,t)		(bool) ((token)->type == (t))
 #define isKeyword(token,k)	(bool) ((token)->keyword == (k))
 #define isIdentChar(c) \
-	(isalpha (c) || isdigit (c) || (c) == '_' || (c) == '-' || (c) == '+')
+	(isalpha (c) || isdigit (c) || (c) == '_' || (c) == '-' || (c) == '+' || (c) == ':')
 
 /*
  *	 DATA DECLARATIONS
@@ -139,7 +140,7 @@ static const keywordTable BibKeywordTable [] = {
 	{ "techreport",	  KEYWORD_techreport		},
 	{ "unpublished",	KEYWORD_unpublished		}
 };
-  
+
 /*
  *	 FUNCTION DEFINITIONS
  */
@@ -322,7 +323,6 @@ static bool parseTag (tokenInfo *const token, bibKind kind)
 			goto out;
 		}
 	}
-  
 
  out:
 	deleteToken (name);


Modified: ctags/parsers/cobol.c
0 lines changed, 0 insertions(+), 0 deletions(-)
===================================================================
No diff available, check online


Modified: ctags/parsers/css.c
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -21,6 +21,7 @@
 		(c) == '-' || /* allowed char */ \
 		(c) == '+' || /* allow all sibling in a single tag */ \
 		(c) == '>' || /* allow all child in a single tag */ \
+		(c) == '~' || /* allow general sibling combinator */ \
 		(c) == '|' || /* allow namespace separator */ \
 		(c) == '(' || /* allow pseudo-class arguments */ \
 		(c) == ')' || \


Modified: ctags/parsers/erlang.c
3 lines changed, 1 insertions(+), 2 deletions(-)
===================================================================
@@ -16,7 +16,6 @@
 #include <string.h>
 
 #include "entry.h"
-#include "options.h"
 #include "read.h"
 #include "parse.h"
 #include "routines.h"
@@ -149,7 +148,7 @@ static void parseDirective (const unsigned char *cp, vString *const module)
 	else if (strcmp (drtv, "module") == 0)
 		parseModuleTag (cp, module);
 	/* Otherwise, it was an import, export, etc. */
-	
+
 	vStringDelete (directive);
 }
 


Modified: ctags/parsers/flex.c
16 lines changed, 3 insertions(+), 13 deletions(-)
===================================================================
@@ -189,7 +189,7 @@ static kindDefinition FlexKinds [] = {
 	{ true,  'm', "method",		  "methods"			   },
 	{ true,  'p', "property",	  "properties"		   },
 	{ true,  'v', "variable",	  "global variables"   },
-	{ /*false*/ true, 'l', "localvar",	  "local variables"   },
+	{ false, 'l', "localvar",	  "local variables"   },
 	{ true,  'C', "constant",	  "constants"		   },
 	{ true,  'I', "import",		  "imports",
 	  .referenceOnly = true, ATTACH_ROLES (FlexImportRoles) },
@@ -322,10 +322,8 @@ static void makeConstTag (tokenInfo *const token, const flexKind kind)
 		tagEntryInfo e;
 		int role = ROLE_DEFINITION_INDEX;
 
-		/* Geany diff: reftags are not enabled but should be
 		if (kind == FLEXTAG_IMPORT)
 			role = FLEX_IMPORT_ROLE_IMPORTED;
-		*/
 
 		initRefTagEntry (&e, name, kind, role);
 
@@ -569,15 +567,7 @@ static void readTokenFull (tokenInfo *const token, bool include_newlines)
 					  {
 						  if (d == '*')
 						  {
-							  do
-							  {
-								  skipToCharacterInInputFile ('*');
-								  c = getcFromInputFile ();
-								  if (c == '/')
-									  break;
-								  else
-									  ungetcToInputFile (c);
-							  } while (c != EOF);
+							  skipToCharacterInInputFile2('*', '/');
 							  goto getNextChar;
 						  }
 						  else if (d == '/')	/* is this the start of a comment?  */
@@ -1310,7 +1300,7 @@ static void parseFunction (tokenInfo *const token)
 
 	deleteToken (name);
 }
- 
+
 /* Parses a block surrounded by curly braces.
  * @p parentScope is the scope name for this block, or NULL for unnamed scopes */
 static bool parseBlock (tokenInfo *const token, const vString *const parentScope)


Modified: ctags/parsers/haskell.c
16 lines changed, 7 insertions(+), 9 deletions(-)
===================================================================
@@ -1,14 +1,11 @@
-
 /*
 * Copyright (c) 2003, Peter Strand <peter at zarquon.se>
 *
 * This source code is released for free distribution under the terms of the
-* GNU General Public License.
+* GNU General Public License version 2 or (at your opinion) any later version.
 *
 * This module contains functions for generating tags for Haskell language
-* files.
-*
-*
+* files (https://en.wikipedia.org/wiki/Haskell_(programming_language)).
 *
 * Does not handle operators or infix definitions like:
 * a `f` b = ...
@@ -38,10 +35,10 @@ typedef enum {
 } haskellKind;
 
 static kindDefinition HaskellKinds [] = {
-	{ true, 't', "typedef", "types" },
-	{ true, 'c', "macro", "type constructors" },
+	{ true, 't', "type", "types" },
+	{ true, 'c', "constructor", "type constructors" },
 	{ true, 'f', "function", "functions" },
-	{ true, 'm', "namespace", "modules"}
+	{ true, 'm', "module", "modules"}
 };
 
 
@@ -276,6 +273,7 @@ static void findHaskellTags (int is_literate)
 			}
 		}
 		if (is_literate && in_tex_lit_code && c == '\\') {
+			get_line(token);
 			if (strncmp(token, "end{code}", 9) == 0) {
 				in_tex_lit_code = 0;
 				c = get_next_char();
@@ -346,7 +344,7 @@ extern parserDefinition* HaskellParser (void)
 extern parserDefinition* LiterateHaskellParser (void)
 {
 	static const char *const extensions [] = { "lhs", NULL };
-	parserDefinition* def = parserNew ("Literate Haskell");
+	parserDefinition* def = parserNew ("LiterateHaskell");
 	def->kindTable  = HaskellKinds;
 	def->kindCount  = ARRAY_SIZE(HaskellKinds);
 	def->extensions = extensions;


Modified: ctags/parsers/haxe.c
10 lines changed, 5 insertions(+), 5 deletions(-)
===================================================================
@@ -2,9 +2,12 @@
  *       Copyright (c) 2007, Ritchie Turner
  *
  *       This source code is released for free distribution under the terms of the
- *       GNU General Public License.
+ *       GNU General Public License version 2 or (at your opinion) any later version.
  *
- *              borrowed from PHP
+ *       This module contains functions for generating tags for Haxe files
+ *       (https://en.wikipedia.org/wiki/Haxe).
+ *
+ *       Borrowed from PHP.
  */
 
 /*
@@ -212,6 +215,3 @@ extern parserDefinition* HaxeParser (void)
 	/*def->initialize = initialize;*/
 	return def;
 }
-
-
-


Modified: ctags/parsers/json.c
54 lines changed, 43 insertions(+), 11 deletions(-)
===================================================================
@@ -20,11 +20,15 @@
 #include "debug.h"
 #include "entry.h"
 #include "keyword.h"
+#include "options.h"
 #include "parse.h"
 #include "read.h"
 #include "routines.h"
 #include "vstring.h"
 
+#define isIdentChar(c) \
+	(isalnum (c) || (c) == '+' || (c) == '-' || (c) == '.')
+
 typedef enum {
 	TOKEN_EOF,
 	TOKEN_UNDEFINED,
@@ -78,6 +82,12 @@ static kindDefinition JsonKinds [] = {
 	{ true,  'z', "null",		"nulls"		}
 };
 
+static const keywordTable JsonKeywordTable [] = {
+	{"true",  KEYWORD_true },
+	{"false", KEYWORD_false},
+	{"null", KEYWORD_null },
+};
+
 static tokenInfo *newToken (void)
 {
 	tokenInfo *const token = xMalloc (1, tokenInfo);
@@ -132,16 +142,28 @@ static void makeJsonTag (tokenInfo *const token, const jsonKind kind)
 	makeTagEntry (&e);
 }
 
-static bool isIdentChar (int c)
-{
-	return (isalnum (c) || c == '+' || c == '-' || c == '.');
-}
+#define DEPTH_LIMIT 512
+static int depth_counter;
 
 static void readTokenFull (tokenInfo *const token,
 						   bool includeStringRepr)
 {
 	int c;
 
+	if (depth_counter > DEPTH_LIMIT)
+	{
+		token->type = TOKEN_EOF;
+
+		/* Not to repeat warnings. */
+		if (depth_counter == (DEPTH_LIMIT + 1))
+		{
+			notice ("Terminate parsing: too deep brackets recursion in %s at %ld",
+					getInputFileName(), getInputLineNumber());
+			depth_counter++;
+		}
+		return;
+	}
+
 	token->type = TOKEN_UNDEFINED;
 	vStringClear (token->string);
 
@@ -155,10 +177,18 @@ static void readTokenFull (tokenInfo *const token,
 	switch (c)
 	{
 		case EOF: token->type = TOKEN_EOF;			break;
-		case '[': token->type = TOKEN_OPEN_SQUARE;	break;
-		case ']': token->type = TOKEN_CLOSE_SQUARE;	break;
-		case '{': token->type = TOKEN_OPEN_CURLY;	break;
-		case '}': token->type = TOKEN_CLOSE_CURLY;	break;
+		case '[':
+			depth_counter++;
+			token->type = TOKEN_OPEN_SQUARE;		break;
+		case ']':
+			depth_counter--;
+			token->type = TOKEN_CLOSE_SQUARE;		break;
+		case '{':
+			depth_counter++;
+			token->type = TOKEN_OPEN_CURLY;			break;
+		case '}':
+			depth_counter--;
+			token->type = TOKEN_CLOSE_CURLY;		break;
 		case ':': token->type = TOKEN_COLON;		break;
 		case ',': token->type = TOKEN_COMMA;		break;
 
@@ -352,6 +382,8 @@ static void findJsonTags (void)
 {
 	tokenInfo *const token = newToken ();
 
+	depth_counter = 0;
+
 	/* We allow multiple top-level elements, although it's not actually valid
 	 * JSON.  An interesting side effect of this is that we allow a leading
 	 * Unicode BOM mark -- even though ok, many JSON parsers will choke on it */
@@ -368,9 +400,6 @@ static void findJsonTags (void)
 static void initialize (const langType language)
 {
 	Lang_json = language;
-	addKeyword ("true", language, KEYWORD_true);
-	addKeyword ("false", language, KEYWORD_false);
-	addKeyword ("null", language, KEYWORD_null);
 }
 
 /* Create parser definition structure */
@@ -383,6 +412,9 @@ extern parserDefinition* JsonParser (void)
 	def->kindCount	= ARRAY_SIZE (JsonKinds);
 	def->parser		= findJsonTags;
 	def->initialize = initialize;
+	def->keywordTable = JsonKeywordTable;
+	def->keywordCount = ARRAY_SIZE (JsonKeywordTable);
+	def->allowNullTag = true;
 
 	return def;
 }


Modified: ctags/parsers/julia.c
0 lines changed, 0 insertions(+), 0 deletions(-)
===================================================================
No diff available, check online


Modified: ctags/parsers/powershell.c
17 lines changed, 9 insertions(+), 8 deletions(-)
===================================================================
@@ -5,9 +5,10 @@
 *   regarding variable and function definitions.
 *
 *   This source code is released for free distribution under the terms of the
-*   GNU General Public License.
+*   GNU General Public License version 2 or (at your option) any later version.
 *
-*   This module contains code for generating tags for Windows PowerShell scripts.
+*   This module contains code for generating tags for Windows PowerShell scripts
+*   (https://en.wikipedia.org/wiki/PowerShell).
 */
 
 /*
@@ -74,7 +75,7 @@ typedef struct {
 	vString *		scope;
 	unsigned long	lineNumber;
 	MIOPos			filePosition;
-	int 			parentKind; /* -1 if none */
+	int 			parentKind; /* KIND_GHOST_INDEX if none */
 } tokenInfo;
 
 
@@ -151,7 +152,7 @@ static tokenInfo *newToken (void)
 	token->scope		= vStringNew ();
 	token->lineNumber   = getInputLineNumber ();
 	token->filePosition = getInputFilePosition ();
-	token->parentKind	= -1;
+	token->parentKind	= KIND_GHOST_INDEX;
 
 	return token;
 }
@@ -386,9 +387,9 @@ static const char *parsePowerShellScope (tokenInfo *const token)
 		/* extract the scope */
 		vStringNCopyS (powershellScope, tokenName, powershellScopeLen);
 		/* cut the resulting scope string from the identifier */
-		memmove (token->string->buffer,
+		memmove (vStringValue (token->string),
 				 /* +1 to skip the leading colon */
-				 token->string->buffer + powershellScopeLen + 1,
+				 vStringValue (token->string) + powershellScopeLen + 1,
 				 /* +1 for the skipped leading colon and - 1 to include the trailing \0 byte */
 				 token->string->length + 1 - powershellScopeLen - 1);
 		token->string->length -= powershellScopeLen + 1;
@@ -559,7 +560,7 @@ static void enterScope (tokenInfo *const parentToken,
 		switch (token->type)
 		{
 			case TOKEN_OPEN_CURLY:
-				enterScope (token, NULL, -1);
+				enterScope (token, NULL, KIND_GHOST_INDEX);
 				break;
 
 			case TOKEN_KEYWORD:
@@ -588,7 +589,7 @@ static void findPowerShellTags (void)
 
 	do
 	{
-		enterScope (token, NULL, -1);
+		enterScope (token, NULL, KIND_GHOST_INDEX);
 	}
 	while (token->type != TOKEN_EOF); /* keep going even with unmatched braces */
 


Modified: ctags/parsers/rst.c
59 lines changed, 46 insertions(+), 13 deletions(-)
===================================================================
@@ -6,6 +6,8 @@
 *   GNU General Public License version 2 or (at your option) any later version.
 *
 *   This module contains functions for generating tags for reStructuredText (reST) files.
+*
+*   This module was ported from geany.
 */
 
 /*
@@ -33,7 +35,9 @@ typedef enum {
 	K_SECTION,
 	K_SUBSECTION,
 	K_SUBSUBSECTION,
+	K_CITATION,
 	K_TARGET,
+	K_SUBSTDEF,
 	SECTION_COUNT
 } rstKind;
 
@@ -42,7 +46,9 @@ static kindDefinition RstKinds[] = {
 	{ true, 's', "section",       "sections" },
 	{ true, 'S', "subsection",    "subsections" },
 	{ true, 't', "subsubsection", "subsubsections" },
+	{ true, 'C', "citation",      "citations"},
 	{ true, 'T', "target",        "targets" },
+	{ true, 'd', "substdef",      "substitute definitions" },
 };
 
 typedef enum {
@@ -96,11 +102,11 @@ static NestingLevel *getNestingLevel(const int kind)
 	return nl;
 }
 
-static int makeTargetRstTag(const vString* const name)
+static int makeTargetRstTag(const vString* const name, rstKind kindex)
 {
 	tagEntryInfo e;
 
-	initTagEntry (&e, vStringValue (name), K_TARGET);
+	initTagEntry (&e, vStringValue (name), kindex);
 
 	const NestingLevel *nl = nestingLevelsGetCurrent(nestingLevels);
 	tagEntryInfo *parent = NULL;
@@ -231,15 +237,15 @@ static int utf8_strlen(const char *buf, int buf_len)
 }
 
 
-static const unsigned char *is_target_line (const unsigned char *line)
+static const unsigned char *is_markup_line (const unsigned char *line, char reftype)
 {
 	if ((line [0] == '.') && (line [1] == '.') && (line [2] == ' ')
-		&& (line [3] == '_'))
+		&& (line [3] == reftype))
 		return line + 4;
 	return NULL;
 }
 
-static int capture_target (const unsigned char *target_line)
+static int capture_markup (const unsigned char *target_line, char defaultTerminator, rstKind kindex)
 {
 	vString *name = vStringNew ();
 	unsigned char terminator;
@@ -256,7 +262,7 @@ static int capture_target (const unsigned char *target_line)
 		 * -- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#reference-names
 		 */
 		vStringPut (name, *target_line);
-		terminator = ':';
+		terminator = defaultTerminator;
 	}
 	else
 		goto out;
@@ -290,7 +296,7 @@ static int capture_target (const unsigned char *target_line)
 	if (vStringLength (name) == 0)
 		goto out;
 
-	r = makeTargetRstTag (name);
+	r = makeTargetRstTag (name, kindex);
 
  out:
 	vStringDelete (name);
@@ -303,20 +309,42 @@ static void findRstTags (void)
 	vString *name = vStringNew ();
 	MIOPos filepos;
 	const unsigned char *line;
-	const unsigned char *target_line;
+	const unsigned char *markup_line;
 
 	memset(&filepos, 0, sizeof(filepos));
 	memset(kindchars, 0, sizeof kindchars);
 	nestingLevels = nestingLevelsNew(0);
 
 	while ((line = readLineFromInputFile ()) != NULL)
 	{
-		/* Handle .. _target:
-		 * http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-targets
-		 */
-		if ((target_line = is_target_line (line)) != NULL)
+		if ((markup_line = is_markup_line (line, '_')) != NULL)
+		{
+			/* Handle .. _target:
+			 * http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-targets
+			 */
+			if (capture_markup (markup_line, ':', K_TARGET) != CORK_NIL)
+			{
+				vStringClear (name);
+				continue;
+			}
+		}
+		else if ((markup_line = is_markup_line (line, '[')) != NULL)
+		{
+			/* Handle .. [citation]
+			 * https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#citations
+			 */
+			if (capture_markup (markup_line, ']', K_CITATION) != CORK_NIL)
+			{
+				vStringClear (name);
+				continue;
+			}
+		}
+		else if ((markup_line = is_markup_line (line, '|')) != NULL)
 		{
-			if (capture_target (target_line) != CORK_NIL)
+			/* Hanle .. |substitute definition|
+			 * https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#substitution-definitions
+			 */
+			if (capture_markup (markup_line, '|', K_SUBSTDEF) != CORK_NIL)
 			{
 				vStringClear (name);
 				continue;
@@ -364,10 +392,15 @@ extern parserDefinition* RstParser (void)
 {
 	static const char *const extensions [] = { "rest", "reST", "rst", NULL };
 	parserDefinition* const def = parserNew ("ReStructuredText");
+	static const char *const aliases[] = {
+		"rst",					/* The name of emacs's mode */
+		NULL
+	};
 
 	def->kindTable = RstKinds;
 	def->kindCount = ARRAY_SIZE (RstKinds);
 	def->extensions = extensions;
+	def->aliases = aliases;
 	def->parser = findRstTags;
 
 	def->fieldTable = RstFields;


Modified: ctags/parsers/txt2tags.c
10 lines changed, 5 insertions(+), 5 deletions(-)
===================================================================
@@ -5,9 +5,10 @@
 *   Based on work by Jon Strait
 *
 *   This source code is released for free distribution under the terms of the
-*   GNU General Public License.
+*   GNU General Public License version 2 or (at your opinion) any later version.
 *
-*   This module contains functions for generating tags for Txt2tags files.
+*   This module contains functions for generating tags for Txt2tags files
+*   (https://en.wikipedia.org/wiki/Txt2tags).
 */
 
 /*
@@ -26,8 +27,7 @@
 #include "entry.h"
 
 
-/* as any character may happen in an input, use something highly unlikely */
-#define SCOPE_SEPARATOR "\x3" /* ASCII ETX */
+#define SCOPE_SEPARATOR "\"\""
 
 /*
 *   DATA DEFINITIONS
@@ -42,7 +42,7 @@ static scopeSeparator Txt2TagsSeparators [] = {
 };
 
 static kindDefinition Txt2tagsKinds[] = {
-	{ true, 'm', "member", "sections",
+	{ true, 's', "section", "sections",
 	  ATTACH_SEPARATORS(Txt2TagsSeparators) },
 };
 


Modified: src/tagmanager/tm_parser.c
33 lines changed, 14 insertions(+), 19 deletions(-)
===================================================================
@@ -276,7 +276,6 @@ static TMParserMapEntry map_JAVASCRIPT[] = {
 	{'g', tm_tag_function_t},
 };
 
-/* not in universal-ctags */
 static TMParserMapEntry map_HASKELL[] = {
 	{'t', tm_tag_typedef_t},
 	{'c', tm_tag_macro_t},
@@ -309,7 +308,6 @@ static TMParserMapEntry map_FREEBASIC[] = {
 	{'g', tm_tag_externvar_t},
 };
 
-/* not in universal-ctags */
 static TMParserMapEntry map_HAXE[] = {
 	{'m', tm_tag_method_t},
 	{'c', tm_tag_class_t},
@@ -324,7 +322,9 @@ static TMParserMapEntry map_REST[] = {
 	{'s', tm_tag_member_t},
 	{'S', tm_tag_macro_t},
 	{'t', tm_tag_variable_t},
+	{'C', tm_tag_undef_t},
 	{'T', tm_tag_undef_t},
+	{'d', tm_tag_undef_t},
 };
 
 static TMParserMapEntry map_HTML[] = {
@@ -400,7 +400,6 @@ static TMParserMapEntry map_ACTIONSCRIPT[] = {
 	{'x', tm_tag_other_t},
 };
 
-/* not in universal-ctags */
 static TMParserMapEntry map_NSIS[] = {
 	{'n', tm_tag_namespace_t},
 	{'f', tm_tag_function_t},
@@ -412,15 +411,12 @@ static TMParserMapEntry map_MARKDOWN[] = {
 	{'v', tm_tag_variable_t},
 };
 
-/* not in universal-ctags */
 static TMParserMapEntry map_TXT2TAGS[] = {
-	{'m', tm_tag_member_t},
+	{'s', tm_tag_member_t},
 };
 
-/* not in universal-ctags */
 static TMParserMapEntry map_ABC[] = {
-	{'m', tm_tag_member_t},
-	{'s', tm_tag_struct_t},
+	{'s', tm_tag_member_t},
 };
 
 static TMParserMapEntry map_VERILOG[] = {
@@ -477,11 +473,10 @@ static TMParserMapEntry map_ASCIIDOC[] = {
 	{'a', tm_tag_undef_t},
 };
 
-/* not in universal-ctags */
 static TMParserMapEntry map_ABAQUS[] = {
-	{'c', tm_tag_class_t},
-	{'m', tm_tag_member_t},
-	{'n', tm_tag_interface_t},
+	{'p', tm_tag_class_t},
+	{'a', tm_tag_member_t},
+	{'s', tm_tag_interface_t},
 };
 
 static TMParserMapEntry map_RUST[] = {
@@ -775,15 +770,15 @@ const gchar *tm_parser_context_separator(TMParserType lang)
 		case TM_PARSER_ZEPHIR:
 			return "::";
 
-		/* avoid confusion with other possible separators in group/section name */
-		case TM_PARSER_CONF:
-		case TM_PARSER_REST:
-			return ":::";
+		case TM_PARSER_TXT2TAGS:
+			return "\"\"";
 
-		/* no context separator */
+		/* these parsers don't report nested scopes but default "." for scope separator
+		 * might appear in the text so use something more improbable */
 		case TM_PARSER_ASCIIDOC:
-		case TM_PARSER_TXT2TAGS:
-			return "\x03";
+		case TM_PARSER_CONF:
+		case TM_PARSER_REST:
+			return "\x3";
 
 		default:
 			return ".";


Modified: tests/ctags/Makefile.am
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -192,6 +192,7 @@ test_sources = \
 	js-string-continuation.js		\
 	js-sub-block-scope.js			\
 	js-unknown-construct-nesting.js	\
+	julia-corner_cases.jl	\
 	jsFunc_tutorial.js				\
 	keyword_abstract.cs				\
 	keyword_catch_try.cs			\


Modified: tests/ctags/julia-corner_cases.jl.tags
66 lines changed, 66 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,66 @@
+# format=tagmanager
+Base�256�0
+Foo�2048�0
+Foo�4096�0
+Mod1�256�0
+Mod2�256�0
+Module1�256�0
+Module10�256�MyModule�0
+Module11�256�MyModule�0
+Module13�256�0
+Module2�256�0
+Module3�256�0
+Module4�256�0
+Module5�256�0
+Module6�256�0
+Module7�256�0
+Module8�256�MyModule�0
+Module9�256�MyModule�0
+MyModule�256�0
+OurRational�2048�{T<:Integer}�0
+OurRational{Int16}�16�(num::T, den::T) where T<:Integer �0
+OurRational{Int64}�16�(num::T, den::T, test::T) where T<:Integer �OurRational�0
+OurRational{Int8}�16�(num::T, den::T) where T<:Integer �OurRational�0
+OurRational{T}�16�(num::T, den::T) where T<:Integer�OurRational�0
+Point�2048�{T}�0
+Pointy�4096�0
+Test�2048�0
+a�64�::Float64�Test�0
+b�64�::Float64�Test�0
+bar�16�(x, y)�Foo�0
+cell�16�(dims::(Integer...))�0
+den�64�::T�OurRational�0
+elsize�16�(::AbstractArray{T}) where {T} �0
+elsize�16�(::AbstractArray{T}) where T�0
+f�16�(x::FooBar)�0
+foo�16�(x::(Int,))�0
+foo�16�()�0
+foo�16�(x)�Baz�0
+foo_bar!�16�(x,y)�0
+func1�32768�Module11�0
+func1�32768�Module13�0
+func1�32768�Module2�0
+func1�32768�Module4�0
+func1�32768�Module7�0
+func2�32768�Module11�0
+func2�32768�Module2�0
+func2�32768�Module6�0
+func2�32768�Module7�0
+func3�16�(a::Int)�MyModule�0
+func3�32768�Module11�0
+func4�16�(a::Int)�MyModule�0
+func5�16�(b::Int)�MyModule.func4�0
+g�16�(x, y)::Int8�0
+myfun�16�()�0
+norm�16�(p::Point{<:Real})�0
+num�64�::T�OurRational�0
+same_type_numeric�16�(x::T, y::T) where {T <: Number} �0
+same_type_numeric�16�(x::T, y::T) where T �0
+show�32768�Base�0
+test�16�(x)�0
+test�64�::T�OurRational�0
+test_docstring�16�0
+x�64�::Bar�Foo�0
+x�64�::T�Point�0
+y�64�::T�Point�0
+y�16384�0


Modified: tests/ctags/rules.t2t.tags
6 lines changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -16,7 +16,7 @@ Table
 Title�64�0
 Title Level 1�64�0
 Title Level 2�64�Title Level 1�0
-Title Level 3�64�Title Level 1Title Level 2�0
-Title Level 4�64�Title Level 1Title Level 2Title Level 3�0
-Title Level 5�64�Title Level 1Title Level 2Title Level 3Title Level 4�0
+Title Level 3�64�Title Level 1""Title Level 2�0
+Title Level 4�64�Title Level 1""Title Level 2""Title Level 3�0
+Title Level 5�64�Title Level 1""Title Level 2""Title Level 3""Title Level 4�0
 Verbatim�64�0


Modified: tests/ctags/titles.t2t.tags
24 lines changed, 12 insertions(+), 12 deletions(-)
===================================================================
@@ -1,17 +1,17 @@
 # format=tagmanager
-Eighth Title Level 3�64�Second Title Level 1Second Title Level 2�0
-Fifth Title Level 3�64�Second Title Level 1Second Title Level 2�0
+Eighth Title Level 3�64�Second Title Level 1""Second Title Level 2�0
+Fifth Title Level 3�64�Second Title Level 1""Second Title Level 2�0
 First Title Level 1�64�0
 First Title Level 2�64�First Title Level 1�0
-First Title Level 3�64�First Title Level 1First Title Level 2�0
-First Title Level 4�64�First Title Level 1First Title Level 2First Title Level 3�0
-First Title Level 5�64�First Title Level 1First Title Level 2First Title Level 3First Title Level 4�0
-Fourth Title Level 3�64�Second Title Level 1Second Title Level 2�0
+First Title Level 3�64�First Title Level 1""First Title Level 2�0
+First Title Level 4�64�First Title Level 1""First Title Level 2""First Title Level 3�0
+First Title Level 5�64�First Title Level 1""First Title Level 2""First Title Level 3""First Title Level 4�0
+Fourth Title Level 3�64�Second Title Level 1""Second Title Level 2�0
 Second Title Level 1�64�0
 Second Title Level 2�64�Second Title Level 1�0
-Second Title Level 3�64�Second Title Level 1Second Title Level 2�0
-Second Title Level 4�64�Second Title Level 1Second Title Level 2Second Title Level 3�0
-Second Title Level 5�64�Second Title Level 1Second Title Level 2Second Title Level 3Second Title Level 4�0
-Seventh Title Level 3�64�Second Title Level 1Second Title Level 2�0
-Sixth Title Level 3�64�Second Title Level 1Second Title Level 2�0
-Third Title Level 3�64�Second Title Level 1Second Title Level 2�0
+Second Title Level 3�64�Second Title Level 1""Second Title Level 2�0
+Second Title Level 4�64�Second Title Level 1""Second Title Level 2""Second Title Level 3�0
+Second Title Level 5�64�Second Title Level 1""Second Title Level 2""Second Title Level 3""Second Title Level 4�0
+Seventh Title Level 3�64�Second Title Level 1""Second Title Level 2�0
+Sixth Title Level 3�64�Second Title Level 1""Second Title Level 2�0
+Third Title Level 3�64�Second Title Level 1""Second Title Level 2�0



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list