Making "inline" behave like an attribute. Fixes #1
[arduino-ctags.git] / scheme.c
blobe7f61f4c8284188bb0c65afb4364d09d37d17792
1 /*
2 * $Id: scheme.c 443 2006-05-30 04:37:13Z darren $
4 * Copyright (c) 2000-2002, 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 Scheme language
10 * files.
14 * INCLUDE FILES
16 #include "general.h" /* must always come first */
18 #include <string.h>
20 #include "parse.h"
21 #include "read.h"
22 #include "vstring.h"
25 * DATA DEFINITIONS
27 typedef enum {
28 K_FUNCTION, K_SET
29 } schemeKind;
31 static kindOption SchemeKinds [] = {
32 { TRUE, 'f', "function", "functions" },
33 { TRUE, 's', "set", "sets" }
37 * FUNCTION DEFINITIONS
40 /* Algorithm adapted from from GNU etags.
41 * Scheme tag functions
42 * look for (def... xyzzy
43 * look for (def... (xyzzy
44 * look for (def ... ((... (xyzzy ....
45 * look for (set! xyzzy
47 static void readIdentifier (vString *const name, const unsigned char *cp)
49 const unsigned char *p;
50 vStringClear (name);
51 /* Go till you get to white space or a syntactic break */
52 for (p = cp; *p != '\0' && *p != '(' && *p != ')' && !isspace (*p); p++)
53 vStringPut (name, (int) *p);
54 vStringTerminate (name);
57 static void findSchemeTags (void)
59 vString *name = vStringNew ();
60 const unsigned char *line;
62 while ((line = fileReadLine ()) != NULL)
64 const unsigned char *cp = line;
66 if (cp [0] == '(' &&
67 (cp [1] == 'D' || cp [1] == 'd') &&
68 (cp [2] == 'E' || cp [2] == 'e') &&
69 (cp [3] == 'F' || cp [3] == 'f'))
71 while (!isspace (*cp))
72 cp++;
73 /* Skip over open parens and white space */
74 while (*cp != '\0' && (isspace (*cp) || *cp == '('))
75 cp++;
76 readIdentifier (name, cp);
77 makeSimpleTag (name, SchemeKinds, K_FUNCTION);
79 if (cp [0] == '(' &&
80 (cp [1] == 'S' || cp [1] == 's') &&
81 (cp [2] == 'E' || cp [2] == 'e') &&
82 (cp [3] == 'T' || cp [3] == 't') &&
83 (cp [4] == '!' || cp [4] == '!') &&
84 (isspace (cp [5])))
86 while (*cp != '\0' && !isspace (*cp))
87 cp++;
88 /* Skip over white space */
89 while (isspace (*cp))
90 cp++;
91 readIdentifier (name, cp);
92 makeSimpleTag (name, SchemeKinds, K_SET);
95 vStringDelete (name);
98 extern parserDefinition* SchemeParser (void)
100 static const char *const extensions [] = {
101 "SCM", "SM", "sch", "scheme", "scm", "sm", NULL
103 parserDefinition* def = parserNew ("Scheme");
104 def->kinds = SchemeKinds;
105 def->kindCount = KIND_COUNT (SchemeKinds);
106 def->extensions = extensions;
107 def->parser = findSchemeTags;
108 return def;
111 /* vi:set tabstop=4 shiftwidth=4: */