Updated Spanish translation
[anjuta-git-plugin.git] / tagmanager / tcl.c
blob987f27e4692add8b598dd07396e2d1269022a1c4
1 /*
2 * $Id$
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.
13 * INCLUDE FILES
15 #include "general.h" /* must always come first */
17 #include <string.h>
19 #include "parse.h"
20 #include "read.h"
21 #include "vstring.h"
24 * DATA DEFINITIONS
26 typedef enum {
27 K_CLASS, K_METHOD, K_PROCEDURE
28 } tclKind;
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,
42 vString *const name,
43 const tclKind kind)
45 vStringClear (name);
46 while ((int) *cp != '\0' && ! isspace ((int) *cp))
48 vStringPut (name, (int) *cp);
49 ++cp;
51 vStringTerminate (name);
52 makeSimpleTag (name, TclKinds, kind);
53 return cp;
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]))
71 ++line;
73 if (line [0] == '\0' || line [0] == '#')
74 continue;
76 /* read first word */
77 for (cp = line ; *cp != '\0' && ! isspace ((int) *cp) ; ++cp)
79 if (! isspace ((int) *cp))
80 continue;
81 while (isspace ((int) *cp))
82 ++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"))
95 cp += 6;
96 while (isspace ((int) *cp))
97 ++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;
113 return def;
116 /* vi:set tabstop=4 shiftwidth=4: */