Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move the grammar to the ABC.pm file.

  • Loading branch information...
commit c08cd27dcc22f76d2fd858d81c58991f0b905e00 1 parent a0e8c61
@LastOfTheCarelessMen authored
Showing with 20 additions and 17 deletions.
  1. +17 −0 lib/ABC.pm
  2. +3 −17 playing.pl
View
17 lib/ABC.pm
@@ -1,5 +1,22 @@
use v6;
+grammar ABC
+{
+ regex header_field_name { \w }
+ regex header_field_data { \N* }
+ regex header_field { ^^ <header_field_name> ':' \s* <header_field_data> $$ }
+ regex header { [<header_field> \n]+ }
+
+ regex basenote { <[a..g]+[A..G]> }
+ regex octave { \'+ | \,+ }
+ regex accidental { '^' | '^^' | '_' | '__' | '=' }
+ regex pitch { <accidental>? <basenote> <octave>? }
+
+ regex tie { '-' }
+ regex note_length { [\d* ['/' \d*] ] | '/' }
+ regex note { <pitch> <note_length>? <tie>? }
+}
+
class ABCHeader
{
View
20 playing.pl
@@ -1,5 +1,8 @@
use v6;
+BEGIN { push @*INC, "lib" }
+use ABC;
+
my $abc = q«X:64
T:Cuckold Come Out o' the Amrey
S:Northumbrian Minstrelsy
@@ -11,23 +14,6 @@
g>ecg ec e/f/g/e/ | d/c/B/A/ Gd BG B/c/d/B/ |
g/f/e/d/ c/d/e/f/ gc e/f/g/e/ | dB/A/ gB +trill+A2 +trill+e2 :|»;
-grammar ABC
-{
- regex header_field_name { \w }
- regex header_field_data { \N* }
- regex header_field { ^^ <header_field_name> ':' \s* <header_field_data> $$ }
- regex header { [<header_field> \n]+ }
-
- regex basenote { <[a..g]+[A..G]> }
- regex octave { \'+ | \,+ }
- regex accidental { '^' | '^^' | '_' | '__' | '=' }
- regex pitch { <accidental>? <basenote> <octave>? }
-
- regex tie { '-' }
- regex note_length { [\d* ['/' \d*] ] | '/' }
- regex note { <pitch> <note_length>? <tie>? }
-}
-
if $abc ~~ m/ <ABC::header> /
{
for $<ABC::header><header_field> -> $line
Please sign in to comment.
Something went wrong with that request. Please try again.