4 * Copyright (c) 2000-2003, Darren Hiebert
6 * This source code is released for free distribution under the terms of the
7 * GNU General Public License.
9 * This module contains functions for generating tags for TCL scripts.
15 #include "general.h" /* must always come first */
27 K_CLASS
, K_METHOD
, K_PROCEDURE
30 static kindOption TclKinds
[] = {
31 { TRUE
, 'c', "class", "classes" },
32 { TRUE
, 'm', "method", "methods" },
33 { TRUE
, 'p', "procedure", "procedures" }
37 * FUNCTION DEFINITIONS
40 static const unsigned char *makeTclTag (
41 const unsigned char *cp
,
46 while ((int) *cp
!= '\0' && ! isspace ((int) *cp
))
48 vStringPut (name
, (int) *cp
);
51 vStringTerminate (name
);
52 makeSimpleTag (name
, TclKinds
, kind
);
56 static boolean
match (const unsigned char *line
, const char *word
)
58 return (boolean
) (strncmp ((const char*) line
, word
, strlen (word
)) == 0);
61 static void findTclTags (void)
63 vString
*name
= vStringNew ();
64 const unsigned char *line
;
66 while ((line
= fileReadLine ()) != NULL
)
68 const unsigned char *cp
;
70 while (isspace (line
[0]))
73 if (line
[0] == '\0' || line
[0] == '#')
77 for (cp
= line
; *cp
!= '\0' && ! isspace ((int) *cp
) ; ++cp
)
79 if (! isspace ((int) *cp
))
81 while (isspace ((int) *cp
))
83 /* Now `line' points at first word and `cp' points at next word */
85 if (match (line
, "proc"))
86 cp
= makeTclTag (cp
, name
, K_PROCEDURE
);
87 else if (match (line
, "class") || match (line
, "itcl::class"))
88 cp
= makeTclTag (cp
, name
, K_CLASS
);
89 else if (match (line
, "public") ||
90 match (line
, "protected") ||
91 match (line
, "private"))
93 if (match (cp
, "method"))
96 while (isspace ((int) *cp
))
98 cp
= makeTclTag (cp
, name
, K_METHOD
);
102 vStringDelete (name
);
105 extern parserDefinition
* TclParser (void)
107 static const char *const extensions
[] = { "tcl", "tk", "wish", "itcl", NULL
};
108 parserDefinition
* def
= parserNew ("Tcl");
109 def
->kinds
= TclKinds
;
110 def
->kindCount
= KIND_COUNT (TclKinds
);
111 def
->extensions
= extensions
;
112 def
->parser
= findTclTags
;
116 /* vi:set tabstop=4 shiftwidth=4: */