1 /*
2 * Copyright (c) 2009, Eric Forgeot
3 *
4 * Based on work by Jon Strait
5 *
6 * This source code is released for free distribution under the terms of the
7 * GNU General Public License version 2 or (at your opinion) any later version.
8 *
9 * This module contains functions for generating tags for Abc files
10 * (https://en.wikipedia.org/wiki/ABC_notation).
11 */
12
13 /*
14 * INCLUDE FILES
15 */
16 #include "general.h" /* must always come first */
17
18 #include <ctype.h>
19 #include <string.h>
20
21 #include "parse.h"
22 #include "read.h"
23 #include "vstring.h"
24 #include "routines.h"
25 #include "entry.h"
26
27 /*
28 * DATA DEFINITIONS
29 */
30
31 typedef enum {
32 K_SECTION,
33 } AbcKind;
34
35 static kindDefinition AbcKinds[] = {
36 { true, 's', "section", "sections" },
37 };
38
39 /*
40 * FUNCTION DEFINITIONS
41 */
42
findAbcTags(void)43 static void findAbcTags (void)
44 {
45 vString *name = vStringNew();
46 const unsigned char *line;
47
48 while ((line = readLineFromInputFile()) != NULL)
49 {
50 if (line[0] == 'T') {
51 vStringCatS(name, " / ");
52 vStringCatS(name, (const char *) line);
53 makeSimpleTag(name, K_SECTION);
54 }
55 else {
56 vStringClear (name);
57 if (! isspace(*line))
58 vStringCatS(name, (const char*) line);
59 }
60 }
61 vStringDelete (name);
62 }
63
AbcParser(void)64 extern parserDefinition* AbcParser (void)
65 {
66 static const char *const patterns [] = { "*.abc", NULL };
67 static const char *const extensions [] = { "abc", NULL };
68 parserDefinition* const def = parserNew ("Abc");
69
70 def->kindTable = AbcKinds;
71 def->kindCount = ARRAY_SIZE (AbcKinds);
72 def->patterns = patterns;
73 def->extensions = extensions;
74 def->parser = findAbcTags;
75 return def;
76 }
77
78