Top.Mail.Ru
Haskell ctags - Poetry is a good reason — LiveJournal
? ?
Poetry is a good reason

> Recent Entries
> Archive
> Friends
> Profile

April 25th, 2005


Previous Entry Share Flag Next Entry
08:12 pm - Haskell ctags
The last version of exuberant ctags was while ago, so I guess I might as well post this here. If you use vi|emacs|fte and code in Haskell, this can come in useful.

diff -ruaN ctags-5.5.4/haskell.c ../exuberant-ctags-5.5.4/haskell.c
--- ctags-5.5.4/haskell.c	1970-01-01 02:00:00.000000000 +0200
+++ ../exuberant-ctags-5.5.4/haskell.c	2005-04-23 20:08:46.120496320 +0300
@@ -0,0 +1,39 @@
+/*
+*
+*   Copyright (c) 2005 Gaal Yahas <gaal@forum2.org>
+*
+*   This source code is released for free distribution under the terms of the
+*   GNU General Public License.
+*
+*   This module contains functions for generating tags for the Haskell language
+*/
+
+/*
+*   INCLUDE FILES
+*/
+#include "general.h"    /* always include first */
+#include "parse.h"      /* always include */
+
+/*
+*   FUNCTION DEFINITIONS
+*/
+
+static void installHaskellRegex (const langType language)
+{
+    addTagRegex (language, "^module[ \t]*([A-Z][a-zA-Z0-9'_.]*)", "\\1", "m,module", NULL);
+    addTagRegex (language, "^(new)?type[ \t]*([A-Z][a-zA-Z0-9'_]*).*=", "\\2", "t,type", NULL);
+    addTagRegex (language, "^data[ \t]*([A-Z][a-zA-Z0-9'_]*).*=", "\\1", "d,data", NULL);
+    addTagRegex (language, "^([a-z_][a-zA-Z0-9'_]*).*=", "\\1", "f,function", NULL);
+}
+
+extern parserDefinition* HaskellParser (void)
+{
+    static const char *const extensions [] = { "hs", "lhs", NULL };
+    parserDefinition* const def = parserNew ("Haskell");
+    def->extensions = extensions;
+    def->initialize = installHaskellRegex;
+    def->regex      = TRUE;
+    return def;
+}
+
+/* vi:set tabstop=8 shiftwidth=4: */
diff -ruaN ctags-5.5.4/mk_mpw.mak ../exuberant-ctags-5.5.4/mk_mpw.mak
--- ctags-5.5.4/mk_mpw.mak	2003-02-13 04:59:30.000000000 +0200
+++ ../exuberant-ctags-5.5.4/mk_mpw.mak	2005-04-23 20:13:40.813696144 +0300
@@ -22,6 +22,7 @@
 	erlang.c ¶
 	fortran.c ¶
 	get.c ¶
+	haskell.c ¶ ¶
 	keyword.c ¶
 	lisp.c ¶
 	lregex.c ¶
diff -ruaN ctags-5.5.4/parsers.h ../exuberant-ctags-5.5.4/parsers.h
--- ctags-5.5.4/parsers.h	2003-07-18 05:58:22.000000000 +0300
+++ ../exuberant-ctags-5.5.4/parsers.h	2005-04-23 15:22:58.000000000 +0300
@@ -27,6 +27,7 @@
     EiffelParser, \
     ErlangParser, \
     FortranParser, \
+    HaskellParser, \
     HtmlParser, \
     JavaParser, \
     JavaScriptParser, \
diff -ruaN ctags-5.5.4/source.mak ../exuberant-ctags-5.5.4/source.mak
--- ctags-5.5.4/source.mak	2003-04-01 08:02:13.000000000 +0300
+++ ../exuberant-ctags-5.5.4/source.mak	2005-04-23 20:18:20.994102248 +0300
@@ -20,6 +20,7 @@
 	erlang.c \
 	fortran.c \
 	get.c \
+	haskell.c \
 	html.c \
 	jscript.c \
 	keyword.c \
@@ -71,6 +72,7 @@
 	fortran.$(OBJEXT) \
 	get.$(OBJEXT) \
 	html.$(OBJEXT) \
+	haskell.$(OBJEXT) \
 	jscript.$(OBJEXT) \
 	keyword.$(OBJEXT) \
 	lisp.$(OBJEXT) \
== end diff ==


(Also here but I don't know how much it can last.)
Current Music: Keith Jarrett - The Köln Concert

(see my 1 | call my bluff)

Comments:


[User Picture]
From:gaal
Date:April 25th, 2005 05:20 pm (UTC)
(Link)
This is a very rudimentary version, you will quickly realize. It does not support type constructors, even. Patches welcome, as they say!

> Go to Top
LiveJournal.com