Cython cppclass not recognized
The name of the parser:
Python, IPythonCell
The command line you used to run ctags:
$ ctags --options=NONE -o - /tmp/a.pyx
The content of input file: (extracted from SageMath source code)
cdef extern from "bliss/graph.hh" namespace "bliss":
cdef cppclass Stats:
pass
cdef cppclass AbstractGraph:
pass
cdef cppclass Graph(AbstractGraph):
Graph(const unsigned int)
The tags output you are not satisfied with:
Graph /tmp/a.pyx /^ cdef cppclass Graph(AbstractGraph):$/;" f
The tags output you expect:
AbstractGraph /tmp/a.pyx /^ cdef cppclass AbstractGraph:$/;" c
Graph /tmp/a.pyx /^ cdef cppclass Graph(AbstractGraph):$/;" c
Stats /tmp/a.pyx /^ cdef cppclass Stats:$/;" c
The version of ctags:
$ ctags --version
Universal Ctags 6.1.0(v6.1.0), Copyright (C) 2015-2023 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Mar 17 2024, 12:18:39
URL: https://ctags.io/
Output version: 0.0
Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +xpath, +json, +interactive, +sandbox, +yaml, +packcc, +optscript, +pcre2
How do you get ctags binary:
Arch Linux package
Thank you. Cython is yet another parser I would like to rewrite. Here is a quick solution.
diff --git a/parsers/python.c b/parsers/python.c
index 0403fcc43..f23ccdbdd 100644
--- a/parsers/python.c
+++ b/parsers/python.c
@@ -156,6 +156,7 @@ static const keywordTable PythonKeywordTable[] = {
{ "cimport", KEYWORD_import },
{ "class", KEYWORD_class },
{ "cpdef", KEYWORD_cpdef },
+ { "cppclass", KEYWORD_class },
{ "def", KEYWORD_def },
{ "extern", KEYWORD_extern },
{ "from", KEYWORD_from },
I will make a pull request after solving the CI/CD related issues.
I read https://github.com/mkoeppe/bliss/blob/sage_package/graph.hh.
It is challenging (and interesting) to make a model for a language to glue languages together.
cdef cppclass Stats:
pass
The primary task of ctags is extracting the name defining something. e.g.
ctags extracts foo from the following Python script:
def foo(n):
pass
However, ctags doesn't extract bar as a definition tag from the following Python script:
import bar;
because this code doesn't define bar. This code refers bar defined somewhere. Instead, ctags extracts bar as a reference tag.
cdef cppclass Stats:
pass
I wonder whether this code defines Stats.
From a point of view, this code refers to a C++ class defined somewhere and declared in bliss/graph.hh. ctags can make a reference tag in this case.
From a point of view, this code defines a new Python class.
Making two tag entries for Stats looks better.
I discussed a similar topic ago when enhancing Basic parser. https://github.com/universal-ctags/ctags/pull/3284
The modeling for solving this issue must be consistent with the discussion.