musa-dsl 0.14.29 → 0.21.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/Gemfile +0 -1
- data/README.md +5 -1
- data/lib/musa-dsl.rb +54 -11
- data/lib/musa-dsl/core-ext.rb +7 -13
- data/lib/musa-dsl/core-ext/array-explode-ranges.rb +15 -23
- data/lib/musa-dsl/core-ext/arrayfy.rb +30 -12
- data/lib/musa-dsl/core-ext/attribute-builder.rb +194 -0
- data/lib/musa-dsl/core-ext/deep-copy.rb +185 -0
- data/lib/musa-dsl/core-ext/dynamic-proxy.rb +44 -40
- data/lib/musa-dsl/core-ext/inspect-nice.rb +40 -22
- data/lib/musa-dsl/core-ext/smart-proc-binder.rb +108 -0
- data/lib/musa-dsl/core-ext/with.rb +26 -0
- data/lib/musa-dsl/datasets.rb +8 -3
- data/lib/musa-dsl/datasets/dataset.rb +3 -0
- data/lib/musa-dsl/datasets/delta-d.rb +12 -0
- data/lib/musa-dsl/datasets/e.rb +61 -0
- data/lib/musa-dsl/datasets/gdv.rb +51 -411
- data/lib/musa-dsl/datasets/gdvd.rb +179 -0
- data/lib/musa-dsl/datasets/helper.rb +41 -0
- data/lib/musa-dsl/datasets/p.rb +68 -0
- data/lib/musa-dsl/datasets/packed-v.rb +19 -0
- data/lib/musa-dsl/datasets/pdv.rb +22 -15
- data/lib/musa-dsl/datasets/ps.rb +113 -0
- data/lib/musa-dsl/datasets/score.rb +210 -0
- data/lib/musa-dsl/datasets/score/queriable.rb +48 -0
- data/lib/musa-dsl/datasets/score/render.rb +31 -0
- data/lib/musa-dsl/datasets/score/to-mxml/process-pdv.rb +160 -0
- data/lib/musa-dsl/datasets/score/to-mxml/process-ps.rb +51 -0
- data/lib/musa-dsl/datasets/score/to-mxml/process-time.rb +153 -0
- data/lib/musa-dsl/datasets/score/to-mxml/to-mxml.rb +158 -0
- data/lib/musa-dsl/datasets/v.rb +23 -0
- data/lib/musa-dsl/generative.rb +5 -5
- data/lib/musa-dsl/generative/backboner.rb +274 -0
- data/lib/musa-dsl/generative/darwin.rb +102 -96
- data/lib/musa-dsl/generative/generative-grammar.rb +182 -187
- data/lib/musa-dsl/generative/markov.rb +56 -53
- data/lib/musa-dsl/generative/variatio.rb +234 -222
- data/lib/musa-dsl/logger.rb +1 -0
- data/lib/musa-dsl/logger/logger.rb +31 -0
- data/lib/musa-dsl/matrix.rb +1 -0
- data/lib/musa-dsl/matrix/matrix.rb +210 -0
- data/lib/musa-dsl/midi.rb +2 -2
- data/lib/musa-dsl/midi/midi-recorder.rb +54 -52
- data/lib/musa-dsl/midi/midi-voices.rb +187 -182
- data/lib/musa-dsl/music.rb +5 -5
- data/lib/musa-dsl/music/chord-definition.rb +54 -50
- data/lib/musa-dsl/music/chord-definitions.rb +13 -9
- data/lib/musa-dsl/music/chords.rb +236 -238
- data/lib/musa-dsl/music/equally-tempered-12-tone-scale-system.rb +187 -183
- data/lib/musa-dsl/music/scales.rb +331 -332
- data/lib/musa-dsl/musicxml.rb +1 -0
- data/lib/musa-dsl/musicxml/builder/attributes.rb +155 -0
- data/lib/musa-dsl/musicxml/builder/backup-forward.rb +45 -0
- data/lib/musa-dsl/musicxml/builder/direction.rb +322 -0
- data/lib/musa-dsl/musicxml/builder/helper.rb +90 -0
- data/lib/musa-dsl/musicxml/builder/measure.rb +137 -0
- data/lib/musa-dsl/musicxml/builder/note-complexities.rb +152 -0
- data/lib/musa-dsl/musicxml/builder/note.rb +577 -0
- data/lib/musa-dsl/musicxml/builder/part-group.rb +44 -0
- data/lib/musa-dsl/musicxml/builder/part.rb +67 -0
- data/lib/musa-dsl/musicxml/builder/pitched-note.rb +126 -0
- data/lib/musa-dsl/musicxml/builder/rest.rb +117 -0
- data/lib/musa-dsl/musicxml/builder/score-partwise.rb +120 -0
- data/lib/musa-dsl/musicxml/builder/typed-text.rb +43 -0
- data/lib/musa-dsl/musicxml/builder/unpitched-note.rb +112 -0
- data/lib/musa-dsl/neumalang.rb +1 -1
- data/lib/musa-dsl/neumalang/datatypes.citrus +79 -0
- data/lib/musa-dsl/neumalang/neuma.citrus +165 -0
- data/lib/musa-dsl/neumalang/neumalang.citrus +32 -242
- data/lib/musa-dsl/neumalang/neumalang.rb +373 -142
- data/lib/musa-dsl/neumalang/process.citrus +21 -0
- data/lib/musa-dsl/neumalang/terminals.citrus +67 -0
- data/lib/musa-dsl/neumalang/vectors.citrus +23 -0
- data/lib/musa-dsl/neumas.rb +5 -0
- data/lib/musa-dsl/neumas/array-to-neumas.rb +34 -0
- data/lib/musa-dsl/neumas/neuma-decoder.rb +63 -0
- data/lib/musa-dsl/neumas/neuma-gdv-decoder.rb +57 -0
- data/lib/musa-dsl/neumas/neuma-gdvd-decoder.rb +15 -0
- data/lib/musa-dsl/neumas/neumas.rb +37 -0
- data/lib/musa-dsl/neumas/string-to-neumas.rb +34 -0
- data/lib/musa-dsl/repl.rb +1 -1
- data/lib/musa-dsl/repl/repl.rb +128 -105
- data/lib/musa-dsl/sequencer.rb +1 -1
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-control.rb +163 -136
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-helper.rb +301 -286
- data/lib/musa-dsl/sequencer/base-sequencer-implementation.rb +552 -308
- data/lib/musa-dsl/sequencer/base-sequencer-public.rb +198 -176
- data/lib/musa-dsl/sequencer/base-sequencer-tick-based.rb +77 -0
- data/lib/musa-dsl/sequencer/base-sequencer-tickless-based.rb +75 -0
- data/lib/musa-dsl/sequencer/sequencer-dsl.rb +105 -85
- data/lib/musa-dsl/sequencer/timeslots.rb +34 -0
- data/lib/musa-dsl/series.rb +1 -1
- data/lib/musa-dsl/{core-ext → series}/array-to-serie.rb +1 -1
- data/lib/musa-dsl/series/base-series.rb +171 -168
- data/lib/musa-dsl/series/hash-serie-splitter.rb +134 -132
- data/lib/musa-dsl/series/holder-serie.rb +1 -1
- data/lib/musa-dsl/series/main-serie-constructors.rb +6 -1
- data/lib/musa-dsl/series/main-serie-operations.rb +807 -797
- data/lib/musa-dsl/series/proxy-serie.rb +6 -6
- data/lib/musa-dsl/series/queue-serie.rb +5 -5
- data/lib/musa-dsl/series/series.rb +2 -0
- data/lib/musa-dsl/transcription.rb +4 -0
- data/lib/musa-dsl/transcription/from-gdv-to-midi.rb +227 -0
- data/lib/musa-dsl/transcription/from-gdv-to-musicxml.rb +36 -0
- data/lib/musa-dsl/transcription/from-gdv.rb +17 -0
- data/lib/musa-dsl/transcription/transcription.rb +55 -0
- data/lib/musa-dsl/transport.rb +6 -6
- data/lib/musa-dsl/transport/clock.rb +26 -26
- data/lib/musa-dsl/transport/dummy-clock.rb +32 -30
- data/lib/musa-dsl/transport/external-tick-clock.rb +21 -20
- data/lib/musa-dsl/transport/input-midi-clock.rb +82 -80
- data/lib/musa-dsl/transport/timer-clock.rb +72 -71
- data/lib/musa-dsl/transport/timer.rb +28 -26
- data/lib/musa-dsl/transport/transport.rb +111 -93
- data/musa-dsl.gemspec +3 -3
- metadata +73 -24
- data/lib/musa-dsl/core-ext/array-apply-get.rb +0 -18
- data/lib/musa-dsl/core-ext/array-to-neumas.rb +0 -28
- data/lib/musa-dsl/core-ext/as-context-run.rb +0 -44
- data/lib/musa-dsl/core-ext/duplicate.rb +0 -134
- data/lib/musa-dsl/core-ext/key-parameters-procedure-binder.rb +0 -85
- data/lib/musa-dsl/core-ext/proc-nice.rb +0 -13
- data/lib/musa-dsl/core-ext/send-nice.rb +0 -21
- data/lib/musa-dsl/core-ext/string-to-neumas.rb +0 -27
- data/lib/musa-dsl/datasets/gdv-decorators.rb +0 -221
- data/lib/musa-dsl/generative/rules.rb +0 -282
- data/lib/musa-dsl/neuma.rb +0 -1
- data/lib/musa-dsl/neuma/neuma.rb +0 -181
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
module Musa
|
4
|
+
module MusicXML
|
5
|
+
module Builder
|
6
|
+
module Internal
|
7
|
+
class TypedText
|
8
|
+
include Helper::ToXML
|
9
|
+
|
10
|
+
def initialize(type = nil, text)
|
11
|
+
@type = type
|
12
|
+
@text = text
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_accessor :type, :text
|
16
|
+
attr_reader :tag
|
17
|
+
|
18
|
+
def _to_xml(io, indent:, tabs:)
|
19
|
+
io.puts "#{tabs}<#{tag}#{" type=\"#{@type}\"" if @type}>#{@text}</#{tag}>"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private_constant :TypedText
|
24
|
+
|
25
|
+
class Creator < TypedText
|
26
|
+
def initialize(type, name)
|
27
|
+
@tag = 'creator'
|
28
|
+
super type, name
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Rights < TypedText
|
33
|
+
def initialize(type, name)
|
34
|
+
@tag = 'rights'
|
35
|
+
super type, name
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require_relative 'note'
|
2
|
+
|
3
|
+
module Musa
|
4
|
+
module MusicXML
|
5
|
+
module Builder
|
6
|
+
module Internal
|
7
|
+
class UnpitchedNote < Note
|
8
|
+
def initialize( pizzicato: nil, # true
|
9
|
+
grace: nil, # true
|
10
|
+
cue: nil, # true
|
11
|
+
chord: nil, # true
|
12
|
+
duration: nil, # number positive divisions
|
13
|
+
tie_start: nil, tie_stop: nil, # true
|
14
|
+
voice: nil, # number
|
15
|
+
type: nil, # whole / half / quarter / ...
|
16
|
+
dots: nil, # number
|
17
|
+
accidental: nil, # sharp / flat / ...
|
18
|
+
time_modification: nil, # TimeModification class instance
|
19
|
+
stem: nil, # up / down / double
|
20
|
+
notehead: nil, # Notehead class instance
|
21
|
+
staff: nil, # number
|
22
|
+
|
23
|
+
# notations
|
24
|
+
accidental_mark: nil, # sharp / natural / flat / ...
|
25
|
+
arpeggiate: nil, # true / up / down
|
26
|
+
|
27
|
+
tied: nil, # start / stop / continue
|
28
|
+
tuplet: nil, # Tuplet class instance
|
29
|
+
|
30
|
+
dynamics: nil, # pppp...ffff (single or array of)
|
31
|
+
fermata: nil, # true / upright / inverted
|
32
|
+
glissando: nil, # start / stop
|
33
|
+
non_arpeggiate: nil, # top / bottom
|
34
|
+
|
35
|
+
slide: nil, # start / stop
|
36
|
+
slur: nil, # start / stop / continue
|
37
|
+
|
38
|
+
## articulations
|
39
|
+
accent: nil, # true
|
40
|
+
breath_mark: nil, # comma / tick
|
41
|
+
caesura: nil, # true
|
42
|
+
detached_legato:nil, # true
|
43
|
+
doit: nil, # true
|
44
|
+
falloff: nil, # true
|
45
|
+
other_articulation: nil, # text
|
46
|
+
plop: nil, # true
|
47
|
+
scoop: nil, # true
|
48
|
+
spiccato: nil, # true
|
49
|
+
staccatissimo: nil, # true
|
50
|
+
staccato: nil, # true
|
51
|
+
stress: nil, # true
|
52
|
+
strong_accent: nil, # true / up / down
|
53
|
+
tenuto: nil, # true
|
54
|
+
unstress: nil, # true
|
55
|
+
|
56
|
+
## ornaments
|
57
|
+
delayed_inverted_turn: nil, # true
|
58
|
+
delayed_turn: nil, # true
|
59
|
+
inverted_mordent: nil, # true
|
60
|
+
inverted_turn: nil, # true
|
61
|
+
mordent: nil, # true
|
62
|
+
schleifer: nil, # true
|
63
|
+
shake: nil, # true
|
64
|
+
tremolo: nil, # start / stop / single,
|
65
|
+
trill_mark: nil, # true
|
66
|
+
turn: nil, # true
|
67
|
+
vertical_turn: nil, # true
|
68
|
+
wavy_line: nil, # true
|
69
|
+
other_ornament: nil, # true
|
70
|
+
ornament_accidental_mark: nil, # sharp / natural / flat / ...
|
71
|
+
|
72
|
+
## technical
|
73
|
+
arrow: nil, # Arrow class instance
|
74
|
+
bend: nil, # Bend class instance
|
75
|
+
double_tongue: nil, # true
|
76
|
+
down_bow: nil, # true
|
77
|
+
fingering: nil, # Fingering class instance
|
78
|
+
fingernails: nil, # true
|
79
|
+
fret: nil, # number
|
80
|
+
hammer_on: nil, # HammerOnPullOff class instance
|
81
|
+
handbell: nil, # damp / echo / ...
|
82
|
+
harmonic: nil, # Harmonic class instance
|
83
|
+
heel: nil, # true
|
84
|
+
hole: nil, # Hole class instance
|
85
|
+
open_string: nil, # true
|
86
|
+
other_technical: nil, # text
|
87
|
+
pluck: nil, # text
|
88
|
+
pull_off: nil, # HammerOnPullOff class insstance
|
89
|
+
snap_pizzicato: nil, # true
|
90
|
+
stopped: nil, # true
|
91
|
+
string: nil, # number (string number)
|
92
|
+
tap: nil, # text
|
93
|
+
thumb_position: nil, # true
|
94
|
+
toe: nil, # true
|
95
|
+
triple_tongue: nil, # true
|
96
|
+
up_bow: nil, # true
|
97
|
+
&block)
|
98
|
+
|
99
|
+
super
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def specific_to_xml(io, indent:)
|
105
|
+
tabs = "\t" * indent
|
106
|
+
io.puts "#{tabs}<unpitched />"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/lib/musa-dsl/neumalang.rb
CHANGED
@@ -0,0 +1,79 @@
|
|
1
|
+
grammar Musa::Neumalang::Neumalang::Parser::Grammar::Datatypes
|
2
|
+
include Musa::Neumalang::Neumalang::Parser::Grammar::Terminals
|
3
|
+
|
4
|
+
rule constant
|
5
|
+
number | symbol | string | special
|
6
|
+
end
|
7
|
+
|
8
|
+
rule special
|
9
|
+
(true | false | nil) <Musa::Neumalang::Neumalang::Parser::Special>
|
10
|
+
end
|
11
|
+
|
12
|
+
rule symbol
|
13
|
+
(colon name) <Musa::Neumalang::Neumalang::Parser::Symbol>
|
14
|
+
end
|
15
|
+
|
16
|
+
rule raw_symbol
|
17
|
+
(name) { to_str.to_sym }
|
18
|
+
end
|
19
|
+
|
20
|
+
rule name
|
21
|
+
/[[:alpha:]]\w*/
|
22
|
+
end
|
23
|
+
|
24
|
+
rule string
|
25
|
+
(double_quote everything_except_double_quote double_quote) <Musa::Neumalang::Neumalang::Parser::String>
|
26
|
+
end
|
27
|
+
|
28
|
+
rule raw_string
|
29
|
+
(double_quote everything_except_double_quote double_quote) { capture(:everything_except_double_quote).value }
|
30
|
+
end
|
31
|
+
|
32
|
+
rule number
|
33
|
+
(optional_separation raw_number) <Musa::Neumalang::Neumalang::Parser::Number>
|
34
|
+
end
|
35
|
+
|
36
|
+
rule raw_number
|
37
|
+
raw_float | raw_rational | raw_integer
|
38
|
+
end
|
39
|
+
|
40
|
+
rule raw_unsigned_number
|
41
|
+
raw_unsigned_float | raw_unsigned_rational | raw_unsigned_integer
|
42
|
+
end
|
43
|
+
|
44
|
+
rule raw_float
|
45
|
+
raw_unsigned_float | raw_minus_float
|
46
|
+
end
|
47
|
+
|
48
|
+
rule raw_minus_float
|
49
|
+
(minus raw_unsigned_float) { -capture(:raw_unsigned_float).value }
|
50
|
+
end
|
51
|
+
|
52
|
+
rule raw_unsigned_float
|
53
|
+
(a:raw_unsigned_integer dot b:raw_unsigned_integer) { "#{capture(:a).value}.#{capture(:b).value}".to_f }
|
54
|
+
end
|
55
|
+
|
56
|
+
rule raw_rational
|
57
|
+
raw_unsigned_rational | raw_minus_rational
|
58
|
+
end
|
59
|
+
|
60
|
+
rule raw_minus_rational
|
61
|
+
(minus raw_unsigned_rational) { -capture(:raw_unsigned_rational).value }
|
62
|
+
end
|
63
|
+
|
64
|
+
rule raw_unsigned_rational
|
65
|
+
(a:raw_unsigned_integer slash b:raw_unsigned_integer) { Rational(capture(:a).value, capture(:b).value) }
|
66
|
+
end
|
67
|
+
|
68
|
+
rule raw_integer
|
69
|
+
raw_unsigned_integer | raw_minus_integer
|
70
|
+
end
|
71
|
+
|
72
|
+
rule raw_minus_integer
|
73
|
+
(minus raw_unsigned_integer) { -capture(:raw_unsigned_integer).value }
|
74
|
+
end
|
75
|
+
|
76
|
+
rule raw_unsigned_integer
|
77
|
+
([0-9]+ ('_' [0-9]+)*) { to_str.to_i }
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
grammar Musa::Neumalang::Neumalang::Parser::Grammar::Neuma
|
2
|
+
include Musa::Neumalang::Neumalang::Parser::Grammar::Datatypes
|
3
|
+
|
4
|
+
rule neuma
|
5
|
+
neuma_between_parenthesis | appogiatura_neuma_between_parenthesis
|
6
|
+
end
|
7
|
+
|
8
|
+
rule appogiatura_neuma_between_parenthesis
|
9
|
+
(lacute optional_separation appogiatura:neuma_between_parenthesis optional_separation racute base:neuma_between_parenthesis) <Musa::Neumalang::Neumalang::Parser::AppogiaturaNeuma>
|
10
|
+
end
|
11
|
+
|
12
|
+
rule neuma_between_parenthesis
|
13
|
+
neuma_between_parenthesis_beginning_with_grade_or_dot |
|
14
|
+
neuma_between_parenthesis_beginning_with_duration |
|
15
|
+
neuma_between_parenthesis_beginning_with_modifiers |
|
16
|
+
neuma_between_parenthesis_empty
|
17
|
+
end
|
18
|
+
|
19
|
+
rule neuma_between_parenthesis_beginning_with_grade_or_dot
|
20
|
+
(lpar optional_separation
|
21
|
+
(grade:grade_attribute | grade_dot:dot)
|
22
|
+
(optional_separation octave:octave_attribute)?
|
23
|
+
(optional_separation duration:duration_attribute)?
|
24
|
+
(optional_separation velocity:velocity_attribute)?
|
25
|
+
(optional_separation modifiers:modifier_attribute)*
|
26
|
+
optional_separation rpar)
|
27
|
+
<Musa::Neumalang::Neumalang::Parser::NeumaAsAttributes>
|
28
|
+
end
|
29
|
+
|
30
|
+
rule neuma_between_parenthesis_beginning_with_duration
|
31
|
+
(lpar optional_separation
|
32
|
+
(duration:duration_attribute)
|
33
|
+
(optional_separation velocity:velocity_attribute)?
|
34
|
+
(optional_separation modifiers:modifier_attribute)*
|
35
|
+
optional_separation rpar)
|
36
|
+
<Musa::Neumalang::Neumalang::Parser::NeumaAsAttributes>
|
37
|
+
end
|
38
|
+
|
39
|
+
rule neuma_between_parenthesis_beginning_with_modifiers
|
40
|
+
(lpar (optional_separation modifiers:modifier_attribute)* optional_separation rpar)
|
41
|
+
<Musa::Neumalang::Neumalang::Parser::NeumaAsAttributes>
|
42
|
+
end
|
43
|
+
|
44
|
+
rule neuma_between_parenthesis_empty
|
45
|
+
(lpar optional_separation rpar) <Musa::Neumalang::Neumalang::Parser::NeumaAsAttributes>
|
46
|
+
end
|
47
|
+
|
48
|
+
rule grade_attribute
|
49
|
+
delta_grade_attribute | abs_grade_attribute | delta_accidentals_attribute
|
50
|
+
end
|
51
|
+
|
52
|
+
rule abs_grade_attribute
|
53
|
+
((grade:raw_unsigned_integer | (interval:name !lpar)) accidentals?) <Musa::Neumalang::Neumalang::Parser::AbsGradeAttribute>
|
54
|
+
end
|
55
|
+
|
56
|
+
rule delta_grade_attribute
|
57
|
+
(sign (grade:raw_unsigned_integer | interval:name) accidentals?) <Musa::Neumalang::Neumalang::Parser::DeltaGradeAttribute>
|
58
|
+
end
|
59
|
+
|
60
|
+
rule delta_accidentals_attribute
|
61
|
+
(sign? accidentals) <Musa::Neumalang::Neumalang::Parser::DeltaGradeAttribute>
|
62
|
+
end
|
63
|
+
|
64
|
+
rule octave_attribute
|
65
|
+
delta_octave_attribute | abs_octave_attribute
|
66
|
+
end
|
67
|
+
|
68
|
+
rule delta_octave_attribute
|
69
|
+
(sign 'o' number:raw_unsigned_integer) <Musa::Neumalang::Neumalang::Parser::DeltaOctaveAttribute>
|
70
|
+
end
|
71
|
+
|
72
|
+
rule abs_octave_attribute
|
73
|
+
('o' number:raw_integer) <Musa::Neumalang::Neumalang::Parser::AbsOctaveAttribute>
|
74
|
+
end
|
75
|
+
|
76
|
+
rule duration_attribute
|
77
|
+
factor_duration_attribute | delta_duration_attribute | abs_duration_attribute
|
78
|
+
end
|
79
|
+
|
80
|
+
rule factor_duration_attribute
|
81
|
+
(factor number:raw_unsigned_number) <Musa::Neumalang::Neumalang::Parser::FactorDurationAttribute>
|
82
|
+
end
|
83
|
+
|
84
|
+
rule abs_duration_attribute
|
85
|
+
((number:raw_unsigned_number | slashes) mid_dots?) <Musa::Neumalang::Neumalang::Parser::AbsDurationAttribute>
|
86
|
+
end
|
87
|
+
|
88
|
+
rule delta_duration_attribute
|
89
|
+
(sign ((number:raw_unsigned_number | slashes) mid_dots?)) <Musa::Neumalang::Neumalang::Parser::DeltaDurationAttribute>
|
90
|
+
end
|
91
|
+
|
92
|
+
rule velocity_attribute
|
93
|
+
(abs_velocity_attribute | delta_velocity_attribute)
|
94
|
+
end
|
95
|
+
|
96
|
+
rule abs_velocity_attribute
|
97
|
+
(dynamics) <Musa::Neumalang::Neumalang::Parser::AbsVelocityAttribute>
|
98
|
+
end
|
99
|
+
|
100
|
+
rule delta_velocity_attribute
|
101
|
+
(sign delta:delta_dynamics) <Musa::Neumalang::Neumalang::Parser::DeltaVelocityAttribute>
|
102
|
+
end
|
103
|
+
|
104
|
+
rule modifier_attribute
|
105
|
+
(modifier_call_with_parameters | modifier_call_without_parameters)
|
106
|
+
end
|
107
|
+
|
108
|
+
rule modifier_call_without_parameters
|
109
|
+
((name &attribute_change) | (name lpar optional_separation rpar)) { { capture(:name).value.to_sym => true } }
|
110
|
+
end
|
111
|
+
|
112
|
+
rule modifier_call_with_parameters
|
113
|
+
(name lpar modifier_positional_parameters rpar) { { capture(:name).value.to_sym => capture(:modifier_positional_parameters).value } }
|
114
|
+
end
|
115
|
+
|
116
|
+
rule modifier_positional_parameters
|
117
|
+
(optional_separation a:modifier_parameter_constant (optional_separation comma optional_separation b:modifier_parameter_constant optional_separation)* optional_separation) {
|
118
|
+
if capture(:b)
|
119
|
+
[ capture(:a).value ] + captures(:b).collect { |c| c.value }
|
120
|
+
else
|
121
|
+
capture(:a).value
|
122
|
+
end
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
rule modifier_parameter_constant
|
127
|
+
raw_number | raw_symbol | raw_string
|
128
|
+
end
|
129
|
+
|
130
|
+
rule accidentals
|
131
|
+
hashes | underscores
|
132
|
+
end
|
133
|
+
|
134
|
+
rule hashes
|
135
|
+
(hsh+) { captures(:hsh).size }
|
136
|
+
end
|
137
|
+
|
138
|
+
rule underscores
|
139
|
+
(underscore+) { -captures(:underscore).size }
|
140
|
+
end
|
141
|
+
|
142
|
+
rule sign
|
143
|
+
(plus | minus) { capture(:plus) ? 1 : -1 }
|
144
|
+
end
|
145
|
+
|
146
|
+
rule factor
|
147
|
+
(asterisk | slash)
|
148
|
+
end
|
149
|
+
|
150
|
+
rule mid_dots
|
151
|
+
(mid_dot+) { captures(:mid_dot).size }
|
152
|
+
end
|
153
|
+
|
154
|
+
rule slashes
|
155
|
+
(slash+) { captures(:slash).size }
|
156
|
+
end
|
157
|
+
|
158
|
+
rule dynamics
|
159
|
+
(p:/p+/ | mp:'mp' | mf:'mf' | f:/f+/)
|
160
|
+
end
|
161
|
+
|
162
|
+
rule delta_dynamics
|
163
|
+
(/p+/ | /f+/)
|
164
|
+
end
|
165
|
+
end
|
@@ -1,43 +1,49 @@
|
|
1
|
-
grammar Neumalang
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
grammar Musa::Neumalang::Neumalang::Parser::Grammar::Grammar
|
2
|
+
include Musa::Neumalang::Neumalang::Parser::Grammar::Terminals
|
3
|
+
include Musa::Neumalang::Neumalang::Parser::Grammar::Datatypes
|
4
|
+
include Musa::Neumalang::Neumalang::Parser::Grammar::Neuma
|
5
|
+
include Musa::Neumalang::Neumalang::Parser::Grammar::Vectors
|
6
|
+
include Musa::Neumalang::Neumalang::Parser::Grammar::Process
|
6
7
|
|
7
8
|
rule sentences
|
8
|
-
(
|
9
|
-
end
|
10
|
-
|
11
|
-
rule sentence
|
12
|
-
expression
|
9
|
+
(optional_separation (expression optional_separation)*) <Musa::Neumalang::Neumalang::Parser::Sentences>
|
13
10
|
end
|
14
11
|
|
15
12
|
rule expression
|
16
|
-
variable_assign | call_methods_expression | object_expression | event
|
13
|
+
(variable_assign | call_methods_expression | object_expression | event)
|
17
14
|
end
|
18
15
|
|
19
16
|
rule object_expression
|
20
|
-
braced_command |
|
17
|
+
braced_command |
|
18
|
+
reference_expression |
|
19
|
+
bracketed_expression |
|
20
|
+
use_variable |
|
21
|
+
constant |
|
22
|
+
neuma_between_parenthesis |
|
23
|
+
appogiatura_neuma_between_parenthesis |
|
24
|
+
process |
|
25
|
+
packed_vector |
|
26
|
+
vector
|
21
27
|
end
|
22
28
|
|
23
29
|
rule reference_expression
|
24
|
-
(ampersand
|
30
|
+
(ampersand optional_separation expression) <Musa::Neumalang::Neumalang::Parser::ReferenceExpression>
|
25
31
|
end
|
26
32
|
|
27
33
|
rule variable_assign
|
28
|
-
((use_variable
|
34
|
+
((use_variable optional_separation equal optional_separation)+ expression) <Musa::Neumalang::Neumalang::Parser::VariableAssign>
|
29
35
|
end
|
30
36
|
|
31
37
|
rule event
|
32
|
-
(double_colon name parameters?) <Musa::Neumalang::Parser::Event>
|
38
|
+
(double_colon name parameters?) <Musa::Neumalang::Neumalang::Parser::Event>
|
33
39
|
end
|
34
40
|
|
35
41
|
rule braced_command
|
36
|
-
(lbrace
|
42
|
+
(lbrace optional_separation complex_command optional_separation rbrace parameters?) <Musa::Neumalang::Neumalang::Parser::BracedCommand>
|
37
43
|
end
|
38
44
|
|
39
45
|
rule call_methods_expression
|
40
|
-
(object_expression (dot method_call)+) <Musa::Neumalang::Parser::CallMethodsExpression>
|
46
|
+
(object_expression (dot method_call)+) <Musa::Neumalang::Neumalang::Parser::CallMethodsExpression>
|
41
47
|
end
|
42
48
|
|
43
49
|
rule bracketed_expression
|
@@ -48,247 +54,31 @@ grammar Neumalang
|
|
48
54
|
(name parameters?) { { method: capture(:name).value.to_sym }.merge(capture(:parameters) ? capture(:parameters).value : {}) }
|
49
55
|
end
|
50
56
|
|
51
|
-
rule neuma
|
52
|
-
appogiatura_neuma | simple_neuma
|
53
|
-
end
|
54
|
-
|
55
|
-
rule appogiatura_neuma
|
56
|
-
(lpar spaces a:simple_neuma spaces rpar spaces b:simple_neuma) { capture(:b).value.tap { |_| _[:neuma] << { appogiatura: capture(:a).value[:neuma] } } }
|
57
|
-
end
|
58
|
-
|
59
|
-
rule simple_neuma
|
60
|
-
neuma_as_dotted_attributes_beginning_with_dot | neuma_as_dotted_attributes_beginning_with_simple_attribute | neuma_between_angles_attributes
|
61
|
-
end
|
62
|
-
|
63
|
-
rule constant
|
64
|
-
number | symbol | string
|
65
|
-
end
|
66
|
-
|
67
57
|
rule bracketed_bar_sentences
|
68
|
-
(lbracket
|
58
|
+
(lbracket aa:sentences (double_bar bb:sentences)+ rbracket) <Musa::Neumalang::Neumalang::Parser::BracketedBarSentences>
|
69
59
|
end
|
70
60
|
|
71
61
|
rule bracketed_sentences
|
72
|
-
(lbracket
|
62
|
+
(lbracket sentences rbracket) <Musa::Neumalang::Neumalang::Parser::BracketedSentences>
|
73
63
|
end
|
74
64
|
|
75
65
|
rule use_variable
|
76
|
-
(at name) <Musa::Neumalang::Parser::UseVariable>
|
66
|
+
(at name) <Musa::Neumalang::Neumalang::Parser::UseVariable>
|
77
67
|
end
|
78
68
|
|
79
69
|
rule parameters
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
rule parameters_a
|
84
|
-
(lpar positional_parameters comma key_parameters rpar) { { value_parameters: capture(:positional_parameters).value, key_parameters: capture(:key_parameters).value } }
|
70
|
+
(lpar parameter (comma parameter)* optional_separation rpar) <Musa::Neumalang::Neumalang::Parser::Parameters>
|
85
71
|
end
|
86
72
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
rule parameters_c
|
92
|
-
(lpar positional_parameters rpar) { { value_parameters: capture(:positional_parameters).value } }
|
93
|
-
end
|
94
|
-
|
95
|
-
rule positional_parameters
|
96
|
-
(spaces a:sentence (spaces comma spaces b:sentence spaces)* spaces) {
|
97
|
-
[ capture(:a).value ] + captures(:b).collect { |c| c.value }
|
98
|
-
}
|
99
|
-
end
|
100
|
-
|
101
|
-
rule key_parameters
|
102
|
-
(spaces a:key_value_parameter (spaces comma spaces b:key_value_parameter spaces)* spaces) {
|
103
|
-
|
104
|
-
result = capture(:a).value.clone
|
105
|
-
|
106
|
-
captures(:b).each { |c| result.merge! c.value }
|
107
|
-
|
108
|
-
result
|
109
|
-
}
|
110
|
-
end
|
73
|
+
rule parameter
|
74
|
+
(optional_separation (key_value_parameter | expression)) <Musa::Neumalang::Neumalang::Parser::Parameter>
|
75
|
+
end
|
111
76
|
|
112
77
|
rule key_value_parameter
|
113
|
-
(
|
78
|
+
(name colon optional_separation expression) { { capture(:name).value.to_sym => capture(:expression).value } }
|
114
79
|
end
|
115
80
|
|
116
81
|
rule complex_command
|
117
|
-
(everything_except_braces? lbrace
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
rule neuma_as_dotted_attributes_beginning_with_simple_attribute
|
122
|
-
(a:simple_attribute (dot b:attribute)*) <Musa::Neumalang::Parser::NeumaAsDottedAttributesBeginningWithSimpleAttribute>
|
123
|
-
end
|
124
|
-
|
125
|
-
rule neuma_as_dotted_attributes_beginning_with_dot
|
126
|
-
((dot attribute)+ | dot) <Musa::Neumalang::Parser::NeumaAsDottedAttributesBeginningWithDot>
|
127
|
-
end
|
128
|
-
|
129
|
-
rule neuma_between_angles_attributes
|
130
|
-
(langle spaces simple_attribute? spaces (attribute spaces)* rangle) <Musa::Neumalang::Parser::NeumaBetweenAnglesAttributes>
|
131
|
-
end
|
132
|
-
|
133
|
-
rule attribute
|
134
|
-
(modifier_attribute | simple_attribute)
|
135
|
-
end
|
136
|
-
|
137
|
-
rule simple_attribute
|
138
|
-
everything_that_can_be_an_attribute !colon
|
139
|
-
end
|
140
|
-
|
141
|
-
rule modifier_attribute
|
142
|
-
modifier_call_without_parameters | modifier_call_with_parameters
|
143
|
-
end
|
144
|
-
|
145
|
-
rule modifier_call_without_parameters
|
146
|
-
(name &attribute_change) { { modifier: capture(:name).value.to_sym } }
|
147
|
-
end
|
148
|
-
|
149
|
-
rule modifier_call_with_parameters
|
150
|
-
(name modifier_parameters) { { modifier: capture(:name).value.to_sym }.merge(capture(:modifier_parameters) ? capture(:modifier_parameters).value : {}) }
|
151
|
-
end
|
152
|
-
|
153
|
-
rule modifier_parameters
|
154
|
-
(lpar modifier_positional_parameters rpar) { { parameters: capture(:modifier_positional_parameters).value } }
|
155
|
-
end
|
156
|
-
|
157
|
-
rule modifier_positional_parameters
|
158
|
-
(spaces a:modifier_parameter_constant (spaces comma spaces b:modifier_parameter_constant spaces)* spaces) {
|
159
|
-
if capture(:b)
|
160
|
-
[ capture(:a).value ] + captures(:b).collect { |c| c.value }
|
161
|
-
else
|
162
|
-
capture(:a).value
|
163
|
-
end
|
164
|
-
}
|
165
|
-
end
|
166
|
-
|
167
|
-
rule modifier_parameter_constant
|
168
|
-
raw_number | raw_symbol | raw_string
|
169
|
-
end
|
170
|
-
|
171
|
-
rule number
|
172
|
-
float | rational | integer
|
173
|
-
end
|
174
|
-
|
175
|
-
rule raw_number
|
176
|
-
raw_float | raw_rational | raw_integer
|
177
|
-
end
|
178
|
-
|
179
|
-
rule symbol
|
180
|
-
(colon name) <Musa::Neumalang::Parser::Symbol>
|
181
|
-
end
|
182
|
-
|
183
|
-
rule raw_symbol
|
184
|
-
(name &spaces) { capture(:name).value.to_sym }
|
185
|
-
end
|
186
|
-
|
187
|
-
rule string
|
188
|
-
(double_quote everything_except_double_quote double_quote) <Musa::Neumalang::Parser::String>
|
189
|
-
end
|
190
|
-
|
191
|
-
rule raw_string
|
192
|
-
(double_quote everything_except_double_quote double_quote) { capture(:everything_except_double_quote).value }
|
193
|
-
end
|
194
|
-
|
195
|
-
rule float
|
196
|
-
(single_quote str:(digits dot digits) spaces) <Musa::Neumalang::Parser::Float>
|
197
|
-
end
|
198
|
-
|
199
|
-
rule raw_float
|
200
|
-
(str:(digits dot digits) spaces) { capture(:str).value.to_f }
|
201
|
-
end
|
202
|
-
|
203
|
-
rule integer
|
204
|
-
(single_quote digits spaces) <Musa::Neumalang::Parser::Integer>
|
205
|
-
end
|
206
|
-
|
207
|
-
rule raw_integer
|
208
|
-
(digits spaces) { capture(:digits).value.to_i }
|
209
|
-
end
|
210
|
-
|
211
|
-
rule rational
|
212
|
-
(single_quote str:(digits slash digits) spaces) <Musa::Neumalang::Parser::Rational>
|
213
|
-
end
|
214
|
-
|
215
|
-
rule raw_rational
|
216
|
-
(str: (digits slash digits) spaces) { capture(:str).value.to_r }
|
217
|
-
end
|
218
|
-
|
219
|
-
rule comment
|
220
|
-
(lcomment complex_comment rcomment) | hash_comment
|
82
|
+
(everything_except_braces? lbrace optional_separation complex_command optional_separation rbrace)* everything_except_braces?
|
221
83
|
end
|
222
|
-
|
223
|
-
rule hash_comment
|
224
|
-
(hsh_at_start_of_line | space+) everything_until_eol
|
225
|
-
end
|
226
|
-
|
227
|
-
rule complex_comment
|
228
|
-
everything_except_comment? (lcomment complex_comment rcomment)* everything_except_comment?
|
229
|
-
end
|
230
|
-
|
231
|
-
rule digits
|
232
|
-
[0-9]+ ('_' [0-9]+)*
|
233
|
-
end
|
234
|
-
|
235
|
-
rule name
|
236
|
-
/[[:alpha:]]\w*/
|
237
|
-
end
|
238
|
-
|
239
|
-
rule everything_that_can_be_an_attribute
|
240
|
-
/[^({|}|\[|\]|\(|\)|\<|\>|.|,|:|=| |\t|\n|\r|\"|@|&|\|)]+/m
|
241
|
-
end
|
242
|
-
|
243
|
-
rule attribute_change
|
244
|
-
space | dot | rbracket | rpar | rbrace | eol
|
245
|
-
end
|
246
|
-
|
247
|
-
rule everything_until_eol
|
248
|
-
~/$/
|
249
|
-
end
|
250
|
-
|
251
|
-
rule everything_except_comment
|
252
|
-
~/((\*\/)|(\/\*))/m
|
253
|
-
end
|
254
|
-
|
255
|
-
rule everything_except_braces
|
256
|
-
~/({|})/m
|
257
|
-
end
|
258
|
-
|
259
|
-
rule everything_except_double_quote
|
260
|
-
~/(\")/m
|
261
|
-
end
|
262
|
-
|
263
|
-
rule hsh_at_start_of_line
|
264
|
-
/\A#/
|
265
|
-
end
|
266
|
-
|
267
|
-
rule double_quote '"' end
|
268
|
-
rule single_quote '\'' end
|
269
|
-
rule dot '.' end
|
270
|
-
rule comma ',' end
|
271
|
-
rule colon ':' end
|
272
|
-
rule double_colon '::' end
|
273
|
-
rule bar '|' end
|
274
|
-
rule slash '/' end
|
275
|
-
rule lpar '(' end
|
276
|
-
rule rpar ')' end
|
277
|
-
rule lbrace '{' end
|
278
|
-
rule rbrace '}' end
|
279
|
-
rule lbracket '[' end
|
280
|
-
rule rbracket ']' end
|
281
|
-
rule langle '<' end
|
282
|
-
rule rangle '>' end
|
283
|
-
rule at '@' end
|
284
|
-
rule ampersand '&' end
|
285
|
-
rule equal '=' end
|
286
|
-
rule lcomment '/*' end
|
287
|
-
rule rcomment '*/' end
|
288
|
-
rule hsh '#' end
|
289
|
-
rule eol /$/ end
|
290
|
-
|
291
|
-
rule space /[ \t\n\r]/m end
|
292
|
-
rule spaces (space | comment)* end
|
293
|
-
|
294
84
|
end
|