Adding a new Ctags Language Definition

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Adding a new Ctags Language Definition

Post by jussij »

Zeus integrates with Exuberant Ctags which supports about 40 programming languages.

But even if your language is not on the list of supported langauges, it is very easy to add new language using a ctags configuration file.

For example consider the following ctags configuration file:

Code: Select all

--langdef=Clipper
--langmap=Clipper:.prg
--regex-clipper=/^FUNCTION[ \t]*([a-zA-Z0-9_]+)/\1/f,function/
--regex-clipper=/^PROCEDURE[ \t]*([a-zA-Z0-9_]+)/\1/p,procedure/
This file defines a new language definition for the Clipper language and maps the prg file extension to this map.

The two regular expressions define the function and procedure ctags items.

To make ctags use this configuration file just do the following:
  1. Save the configuration details above to the .ctags file.
  2. If the HOMEDRIVE and HOMEPATH environment variables are defined copy the .ctags file to this location.
  3. Otherwise define these new environmental variables as follows.
  4. Set the HOMEDRIVE environment variable to be c:
  5. Set the HOMEPATH environment variable to be C:\Users\<your userid>
  6. Put this .ctags file in that C:\Users\<your userid> location.
  7. Start a new version of Zeus so that it picks up this environment change.
Now when you add prg files to a Zeus workspace these files will get tagged and the tags found will get displayed in the Classes tab of the Navigator Panel.

Cheers Jussi
Last edited by jussij on Tue Sep 20, 2011 1:00 am, edited 1 time in total.
wolivo
Posts: 6
Joined: Wed Feb 16, 2005 7:38 pm

Post by wolivo »

since i don't find a .ctags file anywhere on my hard drive, in this example would the .ctags file consist of only these 4 lines of code?
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

since i don't find a .ctags file anywhere on my hard drive, in this example would the .ctags file consist of only these 4 lines of code?
That is correct. I am no expert in .ctags but I think the way it works is the 'Clipper' word ties these four lines together to define a language.

This allows the file to contain multiple language definitions.

Below is a list of how the ctags words are mapped to the Zeus types:

Code: Select all

class     Tag_Class
function  Tag_Function
method    Tag_Method
macro     Tag_Macro
procedure Tag_Procedure
variable  Tag_Variable
You can also change the names of the labels displayed in the Classes panel by using the Labels panel found in the Workspace, Options menu.

Cheers Jussi
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Here is a VB.Net ctags configuration:

Code: Select all

--langdef=vb
--langmap=vb:.vb
--regex-vb=/^[ \t]*(Public|Private)[ \t]+Sub[ \t]+([a-zA-Z0-9_]+)/\2/s,subroutine/i
--regex-vb=/^[ \t]*(Public|Private)[ \t]+Function[ \t]+([a-zA-Z0-9_]+)/\2/f,function/i
--regex-vb=/^[ \t]*(Public|Private)[ \t]+([a-zA-Z0-9_]+)[ \t]+As[ \t]+/\2/v,variable/i
--regex-vb=/^[ \t]*(Public|Private)[ \t]+Const[ \t]+([a-zA-Z0-9_]+)[ \t]+(As|=)[ \t]+/\2/c,const/i
--regex-vb=/^[ \t]*(Public|Private)[ \t]+Enum[ \t]+([a-zA-Z0-9_]+)/\2/e,enum/i
--regex-vb=/^[ \t]*(Public)[ \t]+Property[ \t]+(Get|Let|Set)[ \t]+([a-zA-Z0-9_]+)/\3/n,name/i
--regex-vb=/^[ \t]*([a-zA-Z_]+):/\1/l,label/i
Cheers Jussi
Post Reply