Last active
October 27, 2015 13:40
-
-
Save tanikawa04/b1f4aeee79ce78a06ab4 to your computer and use it in GitHub Desktop.
Snake parser (https://carrotflakes.github.io/Snake-Parser/) を使ってコードネームのパーサを作成(メジャーコードのみ完成)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Grammer | |
start = search<chord> | |
chord | |
= | |
{ | |
root: `root | |
quality | |
?slash | |
bass: `?bass | |
} | |
root | |
= [A-G] ?[♯##♭b] | |
quality | |
= type: `(?ct_major '6') | |
space | |
tension: @?tn_maj6 | |
| type: `(ct_major '7') | |
space | |
tension: @?tn_maj7 | |
| type: `(ct_major '9') | |
space | |
tension: @?tn_maj9 | |
| type: `(?ct_major) | |
space | |
tension: @?tn_maj | |
bass | |
= [A-G] ?[♯##♭b] | |
ct_major | |
= 'M' | |
| '△' | |
| 'maj' | |
tn_maj6 | |
= | |
'(' | |
`'9' | |
')' | |
tn_maj7 | |
= !'()' | |
'(' | |
?(`'9' delimiter) | |
?(`(dg_sharp '11') delimiter) | |
?(`'13' delimiter) | |
')' | |
tn_maj9 | |
= !'()' | |
'(' | |
?(`(dg_sharp '11') delimiter) | |
?(`'13' delimiter) | |
')' | |
tn_maj | |
= | |
'(' | |
`(dg_sharp '5') | |
')' | |
dg_sharp | |
= '♯' | |
| '#' | |
| '#' | |
| '+' | |
| '+' | |
dg_flat | |
= '♭' | |
| 'b' | |
| '-' | |
| '−' | |
delimiter | |
= &')' | |
| ', ' | |
| ',' | |
| ' ' | |
slash | |
= space ('/' | '/' | 'on') space | |
space | |
= *' ' | |
search<x> = @(*(!x .) *(x *(!x .))) | |
// Input text | |
// eg) CM7(#11) D♯M9 (+11 13) EonG# F / C |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment