exuberant-ctags

assembly .macro defined defined in .h file, how should I add ctags regex for that?


I've added a reg express for asm (.S) file for exuberant ctags program.
The added express is like this.

--regex-Asm=/^ENTRY\(([a-zA-Z_0-9]+)\)$/\1/m,macro/
--regex-Asm=/\.macro[\t ]+([a-zA-Z_0-9]+)/\1/m,macro/

Using this, I could find tags for lines like .macro addruart, rp, rv, tmp.
(see can't figure out what's wrong with ctag regex for assembly macro extraction)

Today, I found a macro is defined in .h file and is not in the tag file.
So I added the same line for .macro ... in the ~/.ctags for C language too hoping it will just see the assembly macro in .h file.

--regex-C=/\.macro[\t ]+([a-zA-Z_0-9]+)/\1/m,macro/

The definition in .h file is like this:

/*
 * Branch according to exception level
 */
.macro  switch_el, xreg, el3_label, el2_label, el1_label
    mrs \xreg, CurrentEL
    cmp \xreg, 0xc
    b.eq    \el3_label
    cmp \xreg, 0x8
    b.eq    \el2_label
    cmp \xreg, 0x4
    b.eq    \el1_label
.endm

But looks like it doesn't work. How can I do it?


Solution

  • By default, ".h" is associated with C++ parser, not C parser.

    Therefore, the command line should be:

    --regex-C++=/\.macro[\t ]+([a-zA-Z_0-9]+)/\1/m,macro/
    

    Such associations are called mapping. --list-maps option is for showing the mapping.

    $ ctags --list-maps | grep '\.h\>'
    C++      *.c++ *.cc *.cp *.cpp *.cxx *.h *.h++ *.hh *.hp *.hpp *.hxx *.inl *.C *.H *.CPP *.CXX
    ObjectiveC *.mm *.m *.h