Skip to content

Instantly share code, notes, and snippets.

@tanikawa04
Last active October 27, 2015 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanikawa04/b1f4aeee79ce78a06ab4 to your computer and use it in GitHub Desktop.
Save tanikawa04/b1f4aeee79ce78a06ab4 to your computer and use it in GitHub Desktop.
Snake parser (https://carrotflakes.github.io/Snake-Parser/) を使ってコードネームのパーサを作成(メジャーコードのみ完成)
// 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