Skip to content

Instantly share code, notes, and snippets.

@dmaestro
Created March 24, 2019 12:29
Show Gist options
  • Save dmaestro/15aa917cd7238f8dcea637ea5a5e3526 to your computer and use it in GitHub Desktop.
Save dmaestro/15aa917cd7238f8dcea637ea5a5e3526 to your computer and use it in GitHub Desktop.
Test for rakudo/rakudo issue #2791
use v6;
grammar Chord {
rule TOP { <key> \S* }
regex bare-key { <key> <!before \S > }
regex bare-key-one { <key> [ <!before \S > | $ ] }
regex bare-key-two { <key> <!before <:!Space> > }
token natural-note { <[ A..G ]> }
token accidental { <[ \# b ]> }
regex key { <natural-note> <accidental>? }
}
use Test;
ok Chord.parse('C#');
ok my $m = Chord.parse('C#m');
note 'C#m: ', $m;
ok ! Chord.subparse(:rule(<bare-key>), 'C#m');
ok Chord.subparse(:rule(<bare-key>), 'C# m');
ok Chord.subparse(:rule(<bare-key>), 'C# ');
ok Chord.subparse(:rule(<bare-key>), 'C#'), 'Character class recognizes end-of-line';
ok Chord.subparse(:rule(<bare-key-one>), 'C#'), 'Alternation recognizes end-of-line';
ok Chord.subparse(:rule(<bare-key-two>), 'C#'), 'Property recognizes end-of-line';
done-testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment