Skip to content

Commit

Permalink
Add abc parser from Geany (#2713)
Browse files Browse the repository at this point in the history
  • Loading branch information
techee committed Nov 25, 2020
1 parent 40f9f89 commit 42f590c
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 1 deletion.
1 change: 1 addition & 0 deletions Units/simple-abc.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
6 changes: 6 additions & 0 deletions Units/simple-abc.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
X:0001 / T:The Ranting Highlandman. input.abc /^T:The Ranting Highlandman.$/;" s
X:0001 / T:The Ranting Highlandman. / T:The White Cockade input.abc /^T:The White Cockade$/;" s
X:0002 / T:Quick Step. 25th Regt. input.abc /^T:Quick Step. 25th Regt.$/;" s
X:0003 / T:The Lads of the Village. input.abc /^T:The Lads of the Village.$/;" s
X:0004 / T:I'll Touzle your Kurchy. input.abc /^T:I'll Touzle your Kurchy.$/;" s
X:0005 / T:The Lady's play thing, or Gen Howe's March. input.abc /^T:The Lady's play thing, or Gen Howe's March.$/;" s
78 changes: 78 additions & 0 deletions Units/simple-abc.d/input.abc
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
% A Selection of Scotch, English, Irish and Foreign
% Airs adapted to the Fife, Violin, or German-Flute
% Glasgow
% Printed and Sold by James Aird
% Volume First
% 1778 (often cited as 1782)

X:0001
T:The Ranting Highlandman.
T:The White Cockade
M:C|
L:1/8
Q:1/2=112
I: :: ::
%% G A B c d e ^f g a
Z:Jack Campin * www.campin.me.uk * 2009
K:G
AG|B2B2 B2AG|B2B2 B2g2|B2B2 B2AG|AGAB A2
GA|B2B2 cBAG|A2B2 g2fg|a2gf g2fe|d2B2 B2::
Bc|d2B2 g2B2|d2d2 d2e2|d2cB g2fg|a2A2 A2
GA|B2B2 cBAG|A2B2 g2fg|a2gf g2fe|d2B2 B2:|

X:0002
T:Quick Step. 25th Regt.
N:bars of quavers are all beamed together in the original
M:2/4
L:1/16
Q:1/4=89
I: :: ::
%% D ^F G A B c d e f ^f g a
Z:Jack Campin * www.campin.me.uk * 2009
K:G
g2d2 d2c2|(BcdB) G2D2 |G2B2 (ABcd)| B2``G2 G2d2|
e2c2 c2e2| d2B2 B2d2 |g2d2 c2B2 | B4 A4 :|
F2A2 A2dc| B2G2 G4 |B2d2 d2=f2|(ed)(cB) c4 |
e2a2 a2g2|(gfed) g2c2 |B2AG A2D2 | G2``G2 G4 :|

X:0003
T:The Lads of the Village.
M:2/4
L:1/8
Q:1/4=104
I: :: ::
%% D ^F G A B c d e ^f g a
Z:Jack Campin * www.campin.me.uk * 2009
K:G
G2g>d|ecBG|a>cBG|FA`FD|G2 gd|ecBG|A>cBG|(D/G/``F/A/) G2:|
g>fgd|ecBG|g>fge|a>gfd|g>fgd|ecBG|A>cBG|(D/G/)(F/A/) G2:|

X:0004
T:I'll Touzle your Kurchy.
M:6/8
L:1/8
Q:3/8=120
I: :: ::
%% D E ^F G A B c d e ^f g
Z:Jack Campin * www.campin.me.uk * 2009
K:E Minor
B |E>GE GEG|B>AB e2f|g>fe dgB|A>GA BG
E |E>GE GEG|B>AB e2f|g>fe dcB|AGF E2:|
B |E>GE B2B|GEG B2B|E>GE A2G|FDF A2
G/F/|E>GE B2B|GEG e2f|gfe dcB|AGF E2:|

X:0005
T:The Lady's play thing, or Gen Howe's March.
M:6/8
L:1/8
Q:3/8=120
I: :: ::
%% D G A B c d e g
N:last note printed as G3
Z:Jack Campin * www.campin.me.uk * 2009
K:G
d/c/|B2B Bcd|A2A A2d|G2G GAB|B3 A2
e |dgd BdB|GBG Ddc|BcB AGA|G2G G2:|
d |dBd dBd|e2e e2c|cAc cAc|d2d d2
c |BGB BGB|c2c cBA|Bcd dcB|B3 A2
e |dgd BdB|GBG Ddc|BcB AGA|G2G G2:|
1 change: 1 addition & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ New parsers
The following parsers have been added:

* Abaqus
* Abc
* Ada
* AnsiblePlaybook *libyaml*
* Asciidoc
Expand Down
1 change: 1 addition & 0 deletions main/parsers_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
/* Add the name of any new parser definition function here */
#define PARSER_LIST \
AbaqusParser, \
AbcParser, \
AdaParser, \
AntParser, \
AsciidocParser, \
Expand Down
77 changes: 77 additions & 0 deletions parsers/abc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2009, Eric Forgeot
*
* Based on work by Jon Strait
*
* This source code is released for free distribution under the terms of the
* GNU General Public License version 2 or (at your opinion) any later version.
*
* This module contains functions for generating tags for Abc files
* (https://en.wikipedia.org/wiki/ABC_notation).
*/

/*
* INCLUDE FILES
*/
#include "general.h" /* must always come first */

#include <ctype.h>
#include <string.h>

#include "parse.h"
#include "read.h"
#include "vstring.h"
#include "routines.h"
#include "entry.h"

/*
* DATA DEFINITIONS
*/

typedef enum {
K_SECTION,
} AbcKind;

static kindDefinition AbcKinds[] = {
{ true, 's', "section", "sections" },
};

/*
* FUNCTION DEFINITIONS
*/

static void findAbcTags (void)
{
vString *name = vStringNew();
const unsigned char *line;

while ((line = readLineFromInputFile()) != NULL)
{
if (line[0] == 'T') {
vStringCatS(name, " / ");
vStringCatS(name, (const char *) line);
makeSimpleTag(name, K_SECTION);
}
else {
vStringClear (name);
if (! isspace(*line))
vStringCatS(name, (const char*) line);
}
}
vStringDelete (name);
}

extern parserDefinition* AbcParser (void)
{
static const char *const patterns [] = { "*.abc", NULL };
static const char *const extensions [] = { "abc", NULL };
parserDefinition* const def = parserNew ("Abc");

def->kindTable = AbcKinds;
def->kindCount = ARRAY_SIZE (AbcKinds);
def->patterns = patterns;
def->extensions = extensions;
def->parser = findAbcTags;
return def;
}

1 change: 1 addition & 0 deletions source.mak
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ PARSER_HEADS = \

PARSER_SRCS = \
parsers/abaqus.c \
parsers/abc.c \
parsers/ada.c \
parsers/ant.c \
parsers/asciidoc.c \
Expand Down
3 changes: 2 additions & 1 deletion win32/ctags_vs2013.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@
<ClCompile Include="..\optlib\qemuhx.c" />
<ClCompile Include="..\optlib\scss.c" />
<ClCompile Include="..\optlib\systemtap.c" />
<ClCompile Include="..\parsers\abaqus.c" />
<ClCompile Include="..\parsers\abaqus.c" />
<ClCompile Include="..\parsers\abc.c" />
<ClCompile Include="..\parsers\ada.c" />
<ClCompile Include="..\parsers\ant.c" />
<ClCompile Include="..\parsers\asciidoc.c" />
Expand Down
3 changes: 3 additions & 0 deletions win32/ctags_vs2013.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@
<ClCompile Include="..\parsers\abaqus.c">
<Filter>Source Files\Parsers</Filter>
</ClCompile>
<ClCompile Include="..\parsers\abc.c">
<Filter>Source Files\Parsers</Filter>
</ClCompile>
<ClCompile Include="..\parsers\ant.c">
<Filter>Source Files\Parsers</Filter>
</ClCompile>
Expand Down

0 comments on commit 42f590c

Please sign in to comment.