From 4d6adfa6ad4a420f7f406d6bb6b0092dde3a1563 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Mon, 5 May 2025 18:26:50 +0900 Subject: [PATCH 1/3] SQL: accept LANGUAGE represented as a string Signed-off-by: Masatake YAMATO --- Units/parser-sql.r/funcions.d/args.ctags | 1 + Units/parser-sql.r/funcions.d/expected.tags | 9 +++++++++ parsers/sql.c | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Units/parser-sql.r/funcions.d/args.ctags b/Units/parser-sql.r/funcions.d/args.ctags index 7311baa956..4d86c2c312 100644 --- a/Units/parser-sql.r/funcions.d/args.ctags +++ b/Units/parser-sql.r/funcions.d/args.ctags @@ -1,2 +1,3 @@ --sort=no --fields=+S +--extras=+g diff --git a/Units/parser-sql.r/funcions.d/expected.tags b/Units/parser-sql.r/funcions.d/expected.tags index fd40b95bdb..a0f612c029 100644 --- a/Units/parser-sql.r/funcions.d/expected.tags +++ b/Units/parser-sql.r/funcions.d/expected.tags @@ -4,6 +4,15 @@ isalpha input.sql /^create or replace FUNCTION isalpha(ch CHAR)$/;" f typeref:ty isalphanum input.sql /^create or replace FUNCTION isalphanum(ch CHAR)$/;" f typeref:typename:BOOLEAN signature:(ch CHAR) isdigit input.sql /^create or replace function isdigit(ch CHAR)$/;" f typeref:typename:BOOLEAN signature:(ch CHAR) rpmver_array input.sql /^create or replace FUNCTION rpmver_array (string1 IN VARCHAR)$/;" f typeref:typename:evr_array_item[] signature:(string1 IN VARCHAR) +str1 input.sql /^ str1 VARCHAR := string1;$/;" v +digits input.sql /^ digits VARCHAR(10) := '0123456789';$/;" v +lc_alpha input.sql /^ lc_alpha VARCHAR(27) := 'abcdefghijklmnopqrstuvwxyz';$/;" v +uc_alpha input.sql /^ uc_alpha VARCHAR(27) := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';$/;" v +alpha input.sql /^ alpha VARCHAR(54) := lc_alpha || uc_alpha;$/;" v +one input.sql /^ one VARCHAR;$/;" v +isnum input.sql /^ isnum BOOLEAN;$/;" v +ver_array input.sql /^ ver_array evr_array_item[] := ARRAY[]::evr_array_item[];$/;" v +segment_loop input.sql /^ <>$/;" L dfunc0 input-0.sql /^create function dfunc0(a text DEFAULT '->''Hello', b text DEFAULT 'World''') returns text as $\$$/;" f typeref:typename:text signature:(a text DEFAULT '->''Hello', b text DEFAULT 'World''') dfunc1 input-0.sql /^create function dfunc1(r numeric = 20.39, p numeric DEFAULT 99.88) returns numeric as $\$$/;" f typeref:typename:numeric signature:(r numeric = 20.39, p numeric DEFAULT 99.88) dfunc2 input-0.sql /^create function dfunc2(anyelement = 'World'::text) returns text as $\$$/;" f typeref:typename:text signature:(anyelement = 'World'::text) diff --git a/parsers/sql.c b/parsers/sql.c index bfaa24b48d..25d187636c 100644 --- a/parsers/sql.c +++ b/parsers/sql.c @@ -1356,7 +1356,11 @@ static langType getNamedLanguageFromToken (tokenInfo *const token) { langType lang = LANG_IGNORE; - if (isType (token, TOKEN_IDENTIFIER)) + if (isType (token, TOKEN_IDENTIFIER) + /* https://www.postgresql.org/docs/current/sql-createprocedure.html + ... Enclosing the name in single quotes is deprecated and requires matching + case. ...*/ + || isType (token, TOKEN_STRING)) { if (vStringLength (token->string) > 2 && vStringValue (token->string) [0] == 'p' From 5d93bdee5f431fc1b7b46d355f394b3ba61c6508 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Mon, 5 May 2025 17:38:59 +0900 Subject: [PATCH 2/3] C: add foreigncall role to function kind Update the C parser version to 2.2. Signed-off-by: Masatake YAMATO --- .../stdout-expected.txt | 2 ++ .../json-output-format.d/stdout-expected.txt | 3 ++- Tmain/list-kinds-full.d/stdout-expected.txt | 2 +- Tmain/list-roles.d/stdout-expected.txt | 27 +++++++++++++++++++ Tmain/nested-subparsers.d/stdout-expected.txt | 2 +- Tmain/version-option.d/stdout-expected.txt | 2 +- docs/man/ctags-lang-c.7.rst | 11 ++------ man/ctags-lang-c.7.rst.in | 11 ++------ parsers/cxx/cxx.c | 4 +-- parsers/cxx/cxx_tag.c | 4 ++- parsers/cxx/cxx_tag.h | 1 + 11 files changed, 44 insertions(+), 25 deletions(-) diff --git a/Tmain/extras-field-for-pseudo-tags.d/stdout-expected.txt b/Tmain/extras-field-for-pseudo-tags.d/stdout-expected.txt index 6a8cd374d1..02852769cc 100644 --- a/Tmain/extras-field-for-pseudo-tags.d/stdout-expected.txt +++ b/Tmain/extras-field-for-pseudo-tags.d/stdout-expected.txt @@ -23,6 +23,7 @@ !_TAG_PROGRAM_AUTHOR Universal Ctags Team // !_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/ !_TAG_PROGRAM_URL https://ctags.io/ /official site/ +!_TAG_ROLE_DESCRIPTION!C!function foreigncall /called in foreign languages/ !_TAG_ROLE_DESCRIPTION!C!function foreigndecl /declared in foreign languages/ !_TAG_ROLE_DESCRIPTION!C!header local /local header/ !_TAG_ROLE_DESCRIPTION!C!header system /system header/ @@ -54,6 +55,7 @@ main input.c /^int main (void) { return 0; }$/ !_TAG_PROGRAM_AUTHOR Universal Ctags Team //;" extras:pseudo !_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/;" extras:pseudo !_TAG_PROGRAM_URL https://ctags.io/ /official site/;" extras:pseudo +!_TAG_ROLE_DESCRIPTION!C!function foreigncall /called in foreign languages/;" extras:pseudo !_TAG_ROLE_DESCRIPTION!C!function foreigndecl /declared in foreign languages/;" extras:pseudo !_TAG_ROLE_DESCRIPTION!C!header local /local header/;" extras:pseudo !_TAG_ROLE_DESCRIPTION!C!header system /system header/;" extras:pseudo diff --git a/Tmain/json-output-format.d/stdout-expected.txt b/Tmain/json-output-format.d/stdout-expected.txt index 4f6b4ff2bb..f4794f90ba 100644 --- a/Tmain/json-output-format.d/stdout-expected.txt +++ b/Tmain/json-output-format.d/stdout-expected.txt @@ -83,7 +83,7 @@ {"_type": "ptag", "name": "TAG_KIND_DESCRIPTION", "parserName": "Python", "path": "m,member", "pattern": "class members"} {"_type": "ptag", "name": "TAG_KIND_DESCRIPTION", "parserName": "Python", "path": "v,variable", "pattern": "variables"} {"_type": "ptag", "name": "TAG_OUTPUT_EXCMD", "path": "mixed", "pattern": "number, pattern, mixed, or combineV2"} -{"_type": "ptag", "name": "TAG_PARSER_VERSION", "parserName": "C", "path": "1.1", "pattern": "current.age"} +{"_type": "ptag", "name": "TAG_PARSER_VERSION", "parserName": "C", "path": "2.2", "pattern": "current.age"} {"_type": "ptag", "name": "TAG_PARSER_VERSION", "parserName": "Go", "path": "0.0", "pattern": "current.age"} {"_type": "ptag", "name": "TAG_PARSER_VERSION", "parserName": "Man", "path": "0.0", "pattern": "current.age"} {"_type": "ptag", "name": "TAG_PARSER_VERSION", "parserName": "Python", "path": "1.1", "pattern": "current.age"} @@ -91,6 +91,7 @@ {"_type": "ptag", "name": "TAG_PROGRAM_AUTHOR", "path": "Universal Ctags Team", "pattern": ""} {"_type": "ptag", "name": "TAG_PROGRAM_NAME", "path": "Universal Ctags", "pattern": "Derived from Exuberant Ctags"} {"_type": "ptag", "name": "TAG_PROGRAM_URL", "path": "https://ctags.io/", "pattern": "official site"} +{"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION", "parserName": "C", "kindName": "function", "path": "foreigncall", "pattern": "called in foreign languages"} {"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION", "parserName": "C", "kindName": "function", "path": "foreigndecl", "pattern": "declared in foreign languages"} {"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION", "parserName": "C", "kindName": "header", "path": "local", "pattern": "local header"} {"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION", "parserName": "C", "kindName": "header", "path": "system", "pattern": "system header"} diff --git a/Tmain/list-kinds-full.d/stdout-expected.txt b/Tmain/list-kinds-full.d/stdout-expected.txt index da18e94e27..c5c673edce 100644 --- a/Tmain/list-kinds-full.d/stdout-expected.txt +++ b/Tmain/list-kinds-full.d/stdout-expected.txt @@ -3,7 +3,7 @@ D macroparam no no 0 C 0 parameters inside macro definitions L label no no 0 C 0 goto labels d macro yes no 2 C 0 macro definitions e enumerator yes no 0 C 0 enumerators (values inside an enumeration) -f function yes no 1 C 0 function definitions +f function yes no 2 C 0 function definitions g enum yes no 0 C 0 enumeration names h header yes yes 2 C 0 included header files l local no no 0 C 0 local variables diff --git a/Tmain/list-roles.d/stdout-expected.txt b/Tmain/list-roles.d/stdout-expected.txt index 870c799216..b73d3d975a 100644 --- a/Tmain/list-roles.d/stdout-expected.txt +++ b/Tmain/list-roles.d/stdout-expected.txt @@ -25,6 +25,7 @@ Basic f/function decl on 0 declare Bats S/script loaded on 0 script loaed with "load" command C d/macro condition off 0 used in part of #if/#ifdef/#elif conditions C d/macro undef on 0 undefined +C f/function foreigncall on 2 called in foreign languages C f/function foreigndecl on 1 declared in foreign languages C h/header local on 0 local header C h/header system on 0 system header @@ -176,6 +177,7 @@ Basic f/function decl on 0 declare Bats S/script loaded on 0 script loaed with "load" command C d/macro condition off 0 used in part of #if/#ifdef/#elif conditions C d/macro undef on 0 undefined +C f/function foreigncall on 2 called in foreign languages C f/function foreigndecl on 1 declared in foreign languages C h/header local on 0 local header C h/header system on 0 system header @@ -307,6 +309,7 @@ Zsh s/script loaded on 0 loaded #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -346,6 +349,7 @@ s/script loaded on 0 loaded #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef off 0 undefined +f/function foreigncall off 2 called in foreign languages f/function foreigndecl off 1 declared in foreign languages h/header local off 0 local header h/header system off 0 system header @@ -357,6 +361,7 @@ s/struct foreigndecl off 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef off 0 undefined +f/function foreigncall off 2 called in foreign languages f/function foreigndecl off 1 declared in foreign languages h/header local off 0 local header h/header system off 0 system header @@ -369,6 +374,7 @@ s/struct foreigndecl off 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition on 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -381,6 +387,7 @@ s/struct foreigndecl on 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition on 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -392,6 +399,7 @@ s/struct foreigndecl on 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef off 0 undefined +f/function foreigncall off 2 called in foreign languages f/function foreigndecl off 1 declared in foreign languages h/header local off 0 local header h/header system off 0 system header @@ -410,6 +418,7 @@ s/script loaded on 0 loaded #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef off 0 undefined +f/function foreigncall off 2 called in foreign languages f/function foreigndecl off 1 declared in foreign languages h/header local off 0 local header h/header system off 0 system header @@ -429,6 +438,7 @@ s/script loaded on 0 loaded #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition on 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -449,6 +459,7 @@ s/script loaded off 0 loaded #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition on 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -468,6 +479,7 @@ s/script loaded off 0 loaded #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local off 0 local header h/header system off 0 system header @@ -486,6 +498,7 @@ s/script loaded on 0 loaded #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local off 0 local header h/header system off 0 system header @@ -505,6 +518,7 @@ s/script loaded on 0 loaded #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef off 0 undefined +f/function foreigncall off 2 called in foreign languages f/function foreigndecl off 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -525,6 +539,7 @@ s/script loaded off 0 loaded #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef off 0 undefined +f/function foreigncall off 2 called in foreign languages f/function foreigndecl off 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -544,6 +559,7 @@ s/script loaded off 0 loaded #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local on 0 local header h/header system off 0 system header @@ -555,6 +571,7 @@ s/struct foreigndecl on 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local on 0 local header h/header system off 0 system header @@ -566,6 +583,7 @@ s/struct foreigndecl on 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -577,6 +595,7 @@ s/struct foreigndecl on 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -588,6 +607,7 @@ s/struct foreigndecl on 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local off 0 local header h/header system off 0 system header @@ -599,6 +619,7 @@ s/struct foreigndecl on 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local off 0 local header h/header system off 0 system header @@ -611,6 +632,7 @@ s/struct foreigndecl on 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef off 0 undefined +f/function foreigncall off 2 called in foreign languages f/function foreigndecl off 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -623,6 +645,7 @@ s/struct foreigndecl off 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef off 0 undefined +f/function foreigncall off 2 called in foreign languages f/function foreigndecl off 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -634,6 +657,7 @@ s/struct foreigndecl off 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef off 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local off 0 local header h/header system on 0 system header @@ -645,6 +669,7 @@ s/struct foreigndecl on 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef on 0 undefined +f/function foreigncall on 2 called in foreign languages f/function foreigndecl on 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -656,6 +681,7 @@ s/struct foreigndecl on 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef off 0 undefined +f/function foreigncall off 2 called in foreign languages f/function foreigndecl off 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header @@ -667,6 +693,7 @@ s/struct foreigndecl off 1 declared in foreign languages #KIND(L/N) NAME ENABLED VER DESCRIPTION d/macro condition off 0 used in part of #if/#ifdef/#elif conditions d/macro undef off 0 undefined +f/function foreigncall off 2 called in foreign languages f/function foreigndecl off 1 declared in foreign languages h/header local on 0 local header h/header system on 0 system header diff --git a/Tmain/nested-subparsers.d/stdout-expected.txt b/Tmain/nested-subparsers.d/stdout-expected.txt index 261dc1d495..0ba2f4fd37 100644 --- a/Tmain/nested-subparsers.d/stdout-expected.txt +++ b/Tmain/nested-subparsers.d/stdout-expected.txt @@ -38,7 +38,7 @@ D macroparam no no 0 C 0 parameters inside macro def L label no no 0 C 0 goto labels d macro yes no 2 C 0 macro definitions e enumerator yes no 0 C 0 enumerators (values inside an enumeration) -f function yes no 1 C 0 function definitions +f function yes no 2 C 0 function definitions g enum yes no 0 C 0 enumeration names h header yes yes 2 C 0 included header files l local no no 0 C 0 local variables diff --git a/Tmain/version-option.d/stdout-expected.txt b/Tmain/version-option.d/stdout-expected.txt index 13a656db82..4e1b7acba6 100644 --- a/Tmain/version-option.d/stdout-expected.txt +++ b/Tmain/version-option.d/stdout-expected.txt @@ -1 +1 @@ -parser/C: 1.1 +parser/C: 2.2 diff --git a/docs/man/ctags-lang-c.7.rst b/docs/man/ctags-lang-c.7.rst index 8c4ae89661..c856ac5845 100644 --- a/docs/man/ctags-lang-c.7.rst +++ b/docs/man/ctags-lang-c.7.rst @@ -23,16 +23,9 @@ This man page gathers random notes about tagging C source code. VERSIONS -------- -Change since "0.0" -~~~~~~~~~~~~~~~~~~ +See the output of -* New role ``foreigndecl`` for ``function`` kind - -* New role ``foreigndecl`` for ``struct`` kind - -* New field ``section`` - -* New field ``alias`` +| **ctags** --describe-language=C SEE ALSO -------- diff --git a/man/ctags-lang-c.7.rst.in b/man/ctags-lang-c.7.rst.in index 5da931f7f4..8af0cd3a2c 100644 --- a/man/ctags-lang-c.7.rst.in +++ b/man/ctags-lang-c.7.rst.in @@ -23,16 +23,9 @@ This man page gathers random notes about tagging C source code. VERSIONS -------- -Change since "0.0" -~~~~~~~~~~~~~~~~~~ +See the output of -* New role ``foreigndecl`` for ``function`` kind - -* New role ``foreigndecl`` for ``struct`` kind - -* New field ``section`` - -* New field ``alias`` +| **@CTAGS_NAME_EXECUTABLE@** --describe-language=C SEE ALSO -------- diff --git a/parsers/cxx/cxx.c b/parsers/cxx/cxx.c index 93f36b92ea..f92f4a4e43 100644 --- a/parsers/cxx/cxx.c +++ b/parsers/cxx/cxx.c @@ -101,8 +101,8 @@ parserDefinition * CParser (void) def->dependencyCount = ARRAY_SIZE (dependencies); def->useCork = CORK_QUEUE|CORK_SYMTAB; // We use corking to block output until the end of file - def->versionCurrent = 1; - def->versionAge = 1; + def->versionCurrent = 2; + def->versionAge = 2; return def; } diff --git a/parsers/cxx/cxx_tag.c b/parsers/cxx/cxx_tag.c index 5cbfc01f84..2c61c5bb23 100644 --- a/parsers/cxx/cxx_tag.c +++ b/parsers/cxx/cxx_tag.c @@ -48,10 +48,12 @@ CXX_COMMON_HEADER_ROLES(CUDA); /* Currently V parser wants these items. */ #define RoleTemplateForeignDecl(V) { true, "foreigndecl", "declared in foreign languages", .version = V } +#define RoleTemplateForeignCall(V) { true, "foreigncall", "called in foreign languages", .version = V } #define CXX_COMMON_FUNCTION_ROLES(__langPrefix) \ static roleDefinition __langPrefix##FunctionRoles [] = { \ - RoleTemplateForeignDecl(1), \ + RoleTemplateForeignDecl(1), \ + RoleTemplateForeignCall(2), \ } CXX_COMMON_FUNCTION_ROLES(C); diff --git a/parsers/cxx/cxx_tag.h b/parsers/cxx/cxx_tag.h index 33e9a732aa..1cd0f851f6 100644 --- a/parsers/cxx/cxx_tag.h +++ b/parsers/cxx/cxx_tag.h @@ -221,6 +221,7 @@ typedef enum { typedef enum { CXXTagFUNCTIONRoleFOREIGNDECL, + CXXTagFUNCTIONRoleFOREIGNCALL, } CXXTagCFunctionRole; typedef enum { From 94a2a2a3d5b92d8215bd035f12b43928e8d3b20c Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Mon, 5 May 2025 17:43:26 +0900 Subject: [PATCH 3/3] SQL: make foreign tags for 'interenal' functions Signed-off-by: Masatake YAMATO --- .../args.ctags | 3 ++ .../expected.tags | 4 +++ .../input.sql | 12 ++++++++ parsers/sql.c | 30 +++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 Units/parser-sql.r/sql_pgSQL_with_language_internal.d/args.ctags create mode 100644 Units/parser-sql.r/sql_pgSQL_with_language_internal.d/expected.tags create mode 100644 Units/parser-sql.r/sql_pgSQL_with_language_internal.d/input.sql diff --git a/Units/parser-sql.r/sql_pgSQL_with_language_internal.d/args.ctags b/Units/parser-sql.r/sql_pgSQL_with_language_internal.d/args.ctags new file mode 100644 index 0000000000..439c0f40ac --- /dev/null +++ b/Units/parser-sql.r/sql_pgSQL_with_language_internal.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--fields=+lSr +--extras=+r diff --git a/Units/parser-sql.r/sql_pgSQL_with_language_internal.d/expected.tags b/Units/parser-sql.r/sql_pgSQL_with_language_internal.d/expected.tags new file mode 100644 index 0000000000..ddf76c2ef3 --- /dev/null +++ b/Units/parser-sql.r/sql_pgSQL_with_language_internal.d/expected.tags @@ -0,0 +1,4 @@ +isnlt input.sql /^CREATE FUNCTION isnlt(ean13, ean13)$/;" f language:SQL typeref:typename:boolean signature:(ean13, ean13) roles:def +int8lt input.sql /^ AS 'int8lt'$/;" f language:C roles:foreigncall +isnle input.sql /^CREATE FUNCTION isnle(ean13, ean13)$/;" f language:SQL typeref:typename:boolean signature:(ean13, ean13) roles:def +int8le input.sql /^ AS 'int8le'$/;" f language:C roles:foreigncall diff --git a/Units/parser-sql.r/sql_pgSQL_with_language_internal.d/input.sql b/Units/parser-sql.r/sql_pgSQL_with_language_internal.d/input.sql new file mode 100644 index 0000000000..d7a0ef4d2d --- /dev/null +++ b/Units/parser-sql.r/sql_pgSQL_with_language_internal.d/input.sql @@ -0,0 +1,12 @@ +CREATE FUNCTION isnlt(ean13, ean13) + RETURNS boolean + AS 'int8lt' + LANGUAGE 'internal' + IMMUTABLE STRICT + PARALLEL SAFE; +CREATE FUNCTION isnle(ean13, ean13) + RETURNS boolean + AS 'int8le' + LANGUAGE 'internal' + IMMUTABLE STRICT + PARALLEL SAFE; diff --git a/parsers/sql.c b/parsers/sql.c index 25d187636c..b0745375bf 100644 --- a/parsers/sql.c +++ b/parsers/sql.c @@ -30,6 +30,9 @@ #include "xtag.h" #include "promise.h" +#include "dependency.h" +#include "cxx/cxx_tag.h" + /* * On-line "Oracle Database PL/SQL Language Reference": * http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/toc.htm @@ -505,6 +508,8 @@ static struct SqlReservedWord SqlReservedWord [SQLKEYWORD_COUNT] = { [KEYWORD_without] = {0 & 0&1&1&0 & 0&0 & 0}, }; +static langType Lang_c; + /* * FUNCTION DECLARATIONS */ @@ -2207,6 +2212,16 @@ static void parseBlock (tokenInfo *const token, const bool local) parseBlockFull (token, local, LANG_IGNORE); } +static void makeSqlTagForInternalFunction (tokenInfo *const token) +{ + tagEntryInfo foreignEntry; + initForeignRefTagEntry ( + &foreignEntry, vStringValue (token->string), Lang_c, + CXXTagKindFUNCTION, CXXTagFUNCTIONRoleFOREIGNCALL); + updateTagLine (&foreignEntry, token->lineNumber, token->filePosition); + makeTagEntry (&foreignEntry); +} + static void parseBlockFull (tokenInfo *const token, const bool local, langType lang) { int promise = -1; @@ -2226,6 +2241,9 @@ static void parseBlockFull (tokenInfo *const token, const bool local, langType l promise = token->promise; token->promise = -1; + tokenInfo *const body = newToken (); + copyToken (body, token); + readToken (token); while (! isCmdTerm (token) && !isType (token, TOKEN_EOF)) @@ -2237,10 +2255,16 @@ static void parseBlockFull (tokenInfo *const token, const bool local, langType l lang = getNamedLanguageFromToken (token); if (lang != LANG_IGNORE) readToken (token); + else if (vStringEqC (token->string, "internal")) + { + makeSqlTagForInternalFunction (body); + readToken (token); + } } else readToken (token); } + deleteToken (body); if (promise != -1 && lang != LANG_IGNORE) promiseUpdateLanguage(promise, lang); @@ -3388,6 +3412,10 @@ extern parserDefinition* SqlParser (void) static const char *const extensions [] = { "sql", NULL }; static const char *const aliases [] = {"pgsql", NULL }; parserDefinition* def = parserNew ("SQL"); + static parserDependency dependencies [] = { + [0] = { DEPTYPE_FOREIGNER, "C", &Lang_c }, + }; + def->kindTable = SqlKinds; def->kindCount = ARRAY_SIZE (SqlKinds); def->extensions = extensions; @@ -3397,5 +3425,7 @@ extern parserDefinition* SqlParser (void) def->keywordTable = SqlKeywordTable; def->keywordCount = ARRAY_SIZE (SqlKeywordTable); def->useCork = CORK_QUEUE | CORK_SYMTAB; + def->dependencies = dependencies; + def->dependencyCount = ARRAY_SIZE (dependencies); return def; }