Adding a new Ctags Language Definition

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

Adding a new Ctags Language Definition

Postby jussij » Wed Apr 07, 2010 3:26 am

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 defined copy the .ctags file to this location.
  3. Otherwise put the file in the Zeus install folder: c:\program files\zeus\.ctags
  4. Set the HOMEDRIVE environment variable to be c:
  5. Set the HOMEPATH environment variable to be \program files\zeus\
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

Postby wolivo » Mon May 03, 2010 7:35 pm

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: 2228
Joined: Fri Aug 13, 2004 5:10 pm

Postby jussij » Tue May 04, 2010 12:53 am

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: 2228
Joined: Fri Aug 13, 2004 5:10 pm

Postby jussij » Sun Sep 23, 2012 1:33 am

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


Return to “Tutorials, Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 0 guests