Skip to content

Commit

Permalink
Merge pull request #4022 from masatake/readtags--minor-fix-cmd_or
Browse files Browse the repository at this point in the history
readtags: mark <or> as a specfial form
  • Loading branch information
masatake authored Jun 17, 2024
2 parents 08e07dc + 7c2160c commit ec69d6f
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Tmain/readtags-sorter-cmp_or-sform.d/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
How to generate output.tags::

ctags --kinds-C=+p -o output.tags input.d/foo.c input.d/bar.c input.d/decl.h

This is taken from https://github.com/universal-ctags/ctags/issues/4015#issuecomment-2157023359
1 change: 1 addition & 0 deletions Tmain/readtags-sorter-cmp_or-sform.d/exit-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
2 changes: 2 additions & 0 deletions Tmain/readtags-sorter-cmp_or-sform.d/input.d/bar.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
void bar(void);
void bar(void) {}
1 change: 1 addition & 0 deletions Tmain/readtags-sorter-cmp_or-sform.d/input.d/decl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void foo(void);
1 change: 1 addition & 0 deletions Tmain/readtags-sorter-cmp_or-sform.d/input.d/foo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void foo(void) {}
59 changes: 59 additions & 0 deletions Tmain/readtags-sorter-cmp_or-sform.d/output.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
!_TAG_EXTRA_DESCRIPTION anonymous /Include tags for non-named objects like lambda/
!_TAG_EXTRA_DESCRIPTION fileScope /Include tags of file scope/
!_TAG_EXTRA_DESCRIPTION pseudo /Include pseudo tags/
!_TAG_EXTRA_DESCRIPTION subparser /Include tags generated by subparsers/
!_TAG_FIELD_DESCRIPTION epoch /the last modified time of the input file (only for F\/file kind tag)/
!_TAG_FIELD_DESCRIPTION file /File-restricted scoping/
!_TAG_FIELD_DESCRIPTION input /input file/
!_TAG_FIELD_DESCRIPTION name /tag name/
!_TAG_FIELD_DESCRIPTION pattern /pattern/
!_TAG_FIELD_DESCRIPTION typeref /Type and name of a variable or typedef/
!_TAG_FIELD_DESCRIPTION!C++ name /aliased names/
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_KIND_DESCRIPTION!C d,macro /macro definitions/
!_TAG_KIND_DESCRIPTION!C e,enumerator /enumerators (values inside an enumeration)/
!_TAG_KIND_DESCRIPTION!C f,function /function definitions/
!_TAG_KIND_DESCRIPTION!C g,enum /enumeration names/
!_TAG_KIND_DESCRIPTION!C h,header /included header files/
!_TAG_KIND_DESCRIPTION!C m,member /struct, and union members/
!_TAG_KIND_DESCRIPTION!C p,prototype /function prototypes/
!_TAG_KIND_DESCRIPTION!C s,struct /structure names/
!_TAG_KIND_DESCRIPTION!C t,typedef /typedefs/
!_TAG_KIND_DESCRIPTION!C u,union /union names/
!_TAG_KIND_DESCRIPTION!C v,variable /variable definitions/
!_TAG_KIND_DESCRIPTION!C++ c,class /classes/
!_TAG_KIND_DESCRIPTION!C++ d,macro /macro definitions/
!_TAG_KIND_DESCRIPTION!C++ e,enumerator /enumerators (values inside an enumeration)/
!_TAG_KIND_DESCRIPTION!C++ f,function /function definitions/
!_TAG_KIND_DESCRIPTION!C++ g,enum /enumeration names/
!_TAG_KIND_DESCRIPTION!C++ h,header /included header files/
!_TAG_KIND_DESCRIPTION!C++ m,member /class, struct, and union members/
!_TAG_KIND_DESCRIPTION!C++ n,namespace /namespaces/
!_TAG_KIND_DESCRIPTION!C++ p,prototype /function prototypes/
!_TAG_KIND_DESCRIPTION!C++ s,struct /structure names/
!_TAG_KIND_DESCRIPTION!C++ t,typedef /typedefs/
!_TAG_KIND_DESCRIPTION!C++ u,union /union names/
!_TAG_KIND_DESCRIPTION!C++ v,variable /variable definitions/
!_TAG_OUTPUT_EXCMD mixed /number, pattern, mixed, or combineV2/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_OUTPUT_VERSION 0.0 /current.age/
!_TAG_PARSER_VERSION!C 0.0 /current.age/
!_TAG_PARSER_VERSION!C++ 0.0 /current.age/
!_TAG_PATTERN_LENGTH_LIMIT 96 /0 for no limit/
!_TAG_PROC_CWD /home/yamato/var/ctags-github/Tmain/readtags-sorter-if3-sform.d/ //
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 6.0.0 //
!_TAG_ROLE_DESCRIPTION!C!header local /local header/
!_TAG_ROLE_DESCRIPTION!C!header system /system header/
!_TAG_ROLE_DESCRIPTION!C!macro undef /undefined/
!_TAG_ROLE_DESCRIPTION!C++!header local /local header/
!_TAG_ROLE_DESCRIPTION!C++!header system /system header/
!_TAG_ROLE_DESCRIPTION!C++!macro undef /undefined/
bar input.d/bar.c /^void bar(void) {}$/;" f typeref:typename:void
bar input.d/bar.c /^void bar(void);$/;" p typeref:typename:void file:
foo input.d/decl.h /^void foo(void);$/;" p typeref:typename:void
foo input.d/foo.c /^void foo(void) {}$/;" f typeref:typename:void
25 changes: 25 additions & 0 deletions Tmain/readtags-sorter-cmp_or-sform.d/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

# Copyright: 2024 Masatake YAMATO
# License: GPL-2

READTAGS=$3

. ../utils.sh

#V="valgrind --leak-check=full -v"
V=

if ! [ -x "${READTAGS}" ]; then
skip "no readtags"
fi

if ! ( "${READTAGS}" -h | grep -q -e -S ); then
skip "no sorter function in readtags"
fi

ERRLOG=/tmp/ctags-Tmain-$$
${READTAGS} -et output.tags -S '
(<or> (<> $name &name)
(and (eq? $kind "p") (eq? &kind "f") 1)
(and (eq? $kind "f") (eq? &kind "p") -1))' -l
Empty file.
4 changes: 4 additions & 0 deletions Tmain/readtags-sorter-cmp_or-sform.d/stdout-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bar input.d/bar.c /^void bar(void) {}$/;" kind:f typeref:typename:void
bar input.d/bar.c /^void bar(void);$/;" kind:p file: typeref:typename:void
foo input.d/foo.c /^void foo(void) {}$/;" kind:f typeref:typename:void
foo input.d/decl.h /^void foo(void);$/;" kind:p typeref:typename:void
4 changes: 2 additions & 2 deletions dsl/sorter.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ static DSLProcBind pbinds [] = {
.helpstr = "(<> <any:a> <any:b>) -> -1|0|1; compare a b. The types of a and b must be the same." },
{ "*-", sorter_proc_flip, NULL, DSL_PATTR_CHECK_ARITY, 1,
.helpstr = "(*- <interger:n>) -> -<integer:n>; filp the result of comparison." },
{ "<or>", sorter_sform_cmp_or, NULL, DSL_PATTR_CHECK_ARITY_OPT, 1,
.helpstr = "(<or> <any> ...) -> -1|0|1; evaluate arguments left to right till one of thme returns -1 or 1." },
{ "<or>", sorter_sform_cmp_or, NULL, DSL_PATTR_SELF_EVAL|DSL_PATTR_CHECK_ARITY_OPT, 1,
.helpstr = "(<or> <any> ...) -> -1|0|1; evaluate arguments left to right till one of them returns -1 or 1." },

{ "&", sorter_alt_entry_ref, NULL, DSL_PATTR_CHECK_ARITY_OPT, 1,
.helpstr = "(& <string:field>) -> <string>|#f\n"
Expand Down

0 comments on commit ec69d6f

Please sign in to comment.