gtags and ctags like --regex support

View: New views
4 Messages — Rating Filter:   Alert me  

gtags and ctags like --regex support

by Aneesh Kumar K.V-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Is there a way i can make gtags makes tags based on the regex matching
in addition to the tags made with the standard parsing based on
language ?
What i wanted to achive is to  use something like
--regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/'
That would help me have tag data generated with name like
sys_fallocate where in the code it will appear
as SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len)

-aneesh


_______________________________________________
Bug-global mailing list
Bug-global@...
http://lists.gnu.org/mailman/listinfo/bug-global

Re: gtags and ctags like --regex support

by Shigio YAMAGUCHI-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
> Is there a way i can make gtags makes tags based on the regex matching
> in addition to the tags made with the standard parsing based on
> language ?
> What i wanted to achive is to  use something like
> --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/'
> That would help me have tag data generated with name like
> sys_fallocate where in the code it will appear
> as SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len)

This kind of option is available in Exuberant Ctags.
You can use Exuberant Ctag as a parser for GLOBAL.
(It cannot make GRTAGS and GSYMS files though.)
Please see the section 'Plug-in parser' in the info manual and
gtags.conf file.

However, it might be quicker to rewrite gtags-parser/C.c directly.
You can refer the code for recognizing Guile function entries (SCM_DEFINE).

By the way, the help mailing list (Help-global@...) would be better
to post such a question. You can get answers easily there. :)
--
Shigio YAMAGUCHI <shigio@...>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3


_______________________________________________
Bug-global mailing list
Bug-global@...
http://lists.gnu.org/mailman/listinfo/bug-global

Re: gtags and ctags like --regex support

by Aneesh Kumar K.V-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Jun 21, 2009 at 6:44 AM, Shigio YAMAGUCHI<shigio@...> wrote:

> Hi,
>> Is there a way i can make gtags makes tags based on the regex matching
>> in addition to the tags made with the standard parsing based on
>> language ?
>> What i wanted to achive is to  use something like
>> --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/'
>> That would help me have tag data generated with name like
>> sys_fallocate where in the code it will appear
>> as SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len)
>
> This kind of option is available in Exuberant Ctags.
> You can use Exuberant Ctag as a parser for GLOBAL.
> (It cannot make GRTAGS and GSYMS files though.)
> Please see the section 'Plug-in parser' in the info manual and
> gtags.conf file.
>
> However, it might be quicker to rewrite gtags-parser/C.c directly.
> You can refer the code for recognizing Guile function entries (SCM_DEFINE).
>

I did that and it mostly works. But the linux kernel have complex
indirection like
SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len)
which it doesn't match.

it works for SYSCALL_DEFINE3(open, const char __user *, filename, int,
flags, int, mode)

+                                               linux_kernel =
getenv("LINUX_KERNEL_SOURCE");
+                                               if (linux_kernel &&
!strcmp(linux_kernel, "yes") &&
+
!strncmp(savetok, "SYSCALL_DEFINE", 14 ) && *arg1) {
+
strcpy(savetok, "sys_");
+
strncat(savetok, arg1, sizeof(savetok) - 4);
+                                               }


But it is better than what i had till now.

> By the way, the help mailing list (Help-global@...) would be better
> to post such a question. You can get answers easily there. :)

I did post to help-global. But didn't receive any response.


http://lists.gnu.org/archive/html/help-global/2009-02/msg00000.html

-aneesh


_______________________________________________
Bug-global mailing list
Bug-global@...
http://lists.gnu.org/mailman/listinfo/bug-global

Re: gtags and ctags like --regex support

by Aneesh Kumar K.V-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Jun 21, 2009 at 12:11 PM, Aneesh Kumar<aneesh.kumar@...> wrote:

> On Sun, Jun 21, 2009 at 6:44 AM, Shigio YAMAGUCHI<shigio@...> wrote:
>> Hi,
>>> Is there a way i can make gtags makes tags based on the regex matching
>>> in addition to the tags made with the standard parsing based on
>>> language ?
>>> What i wanted to achive is to  use something like
>>> --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/'
>>> That would help me have tag data generated with name like
>>> sys_fallocate where in the code it will appear
>>> as SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len)
>>
>> This kind of option is available in Exuberant Ctags.
>> You can use Exuberant Ctag as a parser for GLOBAL.
>> (It cannot make GRTAGS and GSYMS files though.)
>> Please see the section 'Plug-in parser' in the info manual and
>> gtags.conf file.
>>
>> However, it might be quicker to rewrite gtags-parser/C.c directly.
>> You can refer the code for recognizing Guile function entries (SCM_DEFINE).
>>
>
> I did that and it mostly works. But the linux kernel have complex
> indirection like
> SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len)
> which it doesn't match.
>
> it works for SYSCALL_DEFINE3(open, const char __user *, filename, int,
> flags, int, mode)
>
>

The change below make the above function definition recognized. Not
sure what is the patter ';' and ',' is trying to match. So the change
may be really bogus.

@@ -609,11 +618,11 @@ function_definition(int target, char arg
                }
        }
        if (c == EOF)
                return 0;
        brace_level = 0;
-       while ((c = nexttoken(",;[](){}=", c_reserved_word)) != EOF) {
+       while ((c = nexttoken("[](){}=", c_reserved_word)) != EOF) {
                switch (c) {
                case SHARP_IFDEF:
                case SHARP_IFNDEF:
                case SHARP_IF:
                case SHARP_ELIF:

-aneesh


_______________________________________________
Bug-global mailing list
Bug-global@...
http://lists.gnu.org/mailman/listinfo/bug-global