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
@@ -1,179 +1,410 @@
|
|
1
|
-
require 'musa-dsl/series'
|
2
1
|
require 'citrus'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
include Musa::Series
|
3
|
+
require_relative '../series'
|
4
|
+
require_relative '../neumas'
|
5
|
+
require_relative '../datasets'
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
module Musa
|
8
|
+
module Neumalang
|
9
|
+
module Neumalang
|
10
|
+
module Parser
|
11
|
+
module Grammar; end
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
module Sentences
|
14
|
+
include Musa::Series
|
15
|
+
include Musa::Neumas
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
17
|
+
def value
|
18
|
+
_SE(captures(:expression).collect(&:value), extends: Neuma::Serie)
|
19
|
+
end
|
20
|
+
end
|
23
21
|
|
24
|
-
|
25
|
-
|
22
|
+
module BracketedBarSentences
|
23
|
+
include Musa::Series
|
24
|
+
include Musa::Neumas
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
def value
|
27
|
+
{ kind: :parallel,
|
28
|
+
parallel: [{ kind: :serie,
|
29
|
+
serie: S(*capture(:aa).value) }] +
|
30
|
+
captures(:bb).collect { |c| { kind: :serie, serie: S(*c.value) } }
|
31
|
+
}.extend(Neuma::Parallel)
|
32
|
+
end
|
33
|
+
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
reference: capture(:expression).value }.extend Neuma
|
37
|
-
end
|
38
|
-
end
|
35
|
+
module BracketedSentences
|
36
|
+
include Musa::Series
|
37
|
+
include Musa::Neumas
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
39
|
+
def value
|
40
|
+
{ kind: :serie,
|
41
|
+
serie: S(*capture(:sentences).value) }.extend Neuma
|
42
|
+
end
|
43
|
+
end
|
47
44
|
|
48
|
-
|
49
|
-
|
50
|
-
{ kind: :event,
|
51
|
-
event: capture(:name).value.to_sym
|
52
|
-
}.merge(capture(:parameters) ? capture(:parameters).value : {}).extend Neuma
|
53
|
-
end
|
54
|
-
end
|
45
|
+
module ReferenceExpression
|
46
|
+
include Musa::Neumas
|
55
47
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
48
|
+
def value
|
49
|
+
{ kind: :reference,
|
50
|
+
reference: capture(:expression).value }.extend Neuma
|
51
|
+
end
|
52
|
+
end
|
63
53
|
|
64
|
-
|
65
|
-
|
66
|
-
{ kind: :call_methods,
|
67
|
-
call_methods: captures(:method_call).collect(&:value),
|
68
|
-
on: capture(:object_expression).value }.extend Neuma
|
69
|
-
end
|
70
|
-
end
|
54
|
+
module VariableAssign
|
55
|
+
include Musa::Neumas
|
71
56
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
57
|
+
def value
|
58
|
+
{ kind: :assign_to,
|
59
|
+
assign_to: captures(:use_variable).collect { |c| c.value[:use_variable] },
|
60
|
+
assign_value: capture(:expression).value
|
61
|
+
}.extend Neuma
|
62
|
+
end
|
63
|
+
end
|
78
64
|
|
79
|
-
|
80
|
-
|
81
|
-
{ kind: :neuma,
|
82
|
-
neuma: (capture(:a) ? [capture(:a).value] : []) + captures(:b).collect(&:value) }.extend Neuma
|
83
|
-
end
|
84
|
-
end
|
65
|
+
module Event
|
66
|
+
include Musa::Neumas
|
85
67
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
68
|
+
def value
|
69
|
+
{ kind: :event,
|
70
|
+
event: capture(:name).value.to_sym
|
71
|
+
}.merge(capture(:parameters) ? capture(:parameters).value : {}).extend Neuma
|
72
|
+
end
|
73
|
+
end
|
92
74
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
98
|
-
end
|
75
|
+
module Parameters
|
76
|
+
def value
|
77
|
+
value_parameters = []
|
78
|
+
key_value_parameters = {}
|
99
79
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
80
|
+
captures(:parameter).each do |pp|
|
81
|
+
p = pp.value
|
82
|
+
if p.has_key? :key_value
|
83
|
+
key_value_parameters.merge! p[:key_value]
|
84
|
+
else
|
85
|
+
value_parameters << p[:value]
|
86
|
+
end
|
87
|
+
end
|
106
88
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
89
|
+
{}.tap do |_|
|
90
|
+
_[:value_parameters] = value_parameters unless value_parameters.empty?
|
91
|
+
_[:key_parameters] = key_value_parameters unless key_value_parameters.empty?
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
113
95
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
96
|
+
module Parameter
|
97
|
+
def value
|
98
|
+
if capture(:key_value_parameter)
|
99
|
+
{ key_value: capture(:key_value_parameter).value }
|
100
|
+
else
|
101
|
+
{ value: capture(:expression).value }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
120
105
|
|
121
|
-
|
122
|
-
|
123
|
-
{ kind: :value,
|
124
|
-
value: capture(:digits).value.to_i }.extend Neuma
|
125
|
-
end
|
126
|
-
end
|
106
|
+
module BracedCommand
|
107
|
+
include Musa::Neumas
|
127
108
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
end
|
109
|
+
def value
|
110
|
+
{ kind: :command,
|
111
|
+
command: eval("proc { #{capture(:complex_command).value.strip} }")
|
112
|
+
}.merge(capture(:parameters) ? capture(:parameters).value : {}).extend Neuma
|
113
|
+
end
|
114
|
+
end
|
135
115
|
|
136
|
-
|
137
|
-
|
138
|
-
|
116
|
+
module CallMethodsExpression
|
117
|
+
include Musa::Neumas
|
118
|
+
|
119
|
+
def value
|
120
|
+
{ kind: :call_methods,
|
121
|
+
call_methods: captures(:method_call).collect(&:value),
|
122
|
+
on: capture(:object_expression).value }.extend Neuma
|
123
|
+
end
|
124
|
+
end
|
139
125
|
|
140
|
-
|
141
|
-
|
126
|
+
module UseVariable
|
127
|
+
include Musa::Neumas
|
142
128
|
|
143
|
-
|
129
|
+
def value
|
130
|
+
{ kind: :use_variable,
|
131
|
+
use_variable: "@#{capture(:name).value}".to_sym }.extend Neuma
|
132
|
+
end
|
133
|
+
end
|
144
134
|
|
145
|
-
|
146
|
-
|
135
|
+
module NeumaAsAttributes
|
136
|
+
include Musa::Neumas
|
137
|
+
include Musa::Datasets
|
147
138
|
|
148
|
-
|
149
|
-
|
139
|
+
def value
|
140
|
+
h = {}.extend GDVd
|
150
141
|
|
151
|
-
|
152
|
-
|
153
|
-
|
142
|
+
capture(:grade)&.value&.tap { |_| h.merge! _ if _ }
|
143
|
+
capture(:octave)&.value&.tap { |_| h.merge! _ if _ }
|
144
|
+
capture(:duration)&.value&.tap { |_| h.merge! _ if _ }
|
145
|
+
capture(:velocity)&.value&.tap { |_| h.merge! _ if _ }
|
154
146
|
|
155
|
-
|
147
|
+
h[:modifiers] = {} unless captures(:modifiers).empty?
|
148
|
+
captures(:modifiers).collect(&:value).each { |_| h[:modifiers].merge! _ if _ }
|
149
|
+
|
150
|
+
{ kind: :gdvd, gdvd: h }.extend Neuma
|
151
|
+
end
|
152
|
+
end
|
156
153
|
|
157
|
-
|
154
|
+
module PackedVector
|
155
|
+
include Musa::Neumas
|
156
|
+
|
157
|
+
def value
|
158
|
+
{ kind: :packed_v, packed_v: capture(:raw_packed_vector).value }.extend(Neuma)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
module RawPackedVector
|
163
|
+
include Musa::Datasets
|
164
|
+
|
165
|
+
def value
|
166
|
+
captures(:key_value).collect(&:value).to_h.extend(PackedV)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
module Vector
|
171
|
+
include Musa::Neumas
|
172
|
+
|
173
|
+
def value
|
174
|
+
{ kind: :v, v: capture(:raw_vector).value }.extend(Neuma)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
module RawVector
|
179
|
+
include Musa::Datasets
|
180
|
+
|
181
|
+
def value
|
182
|
+
captures(:raw_number).collect(&:value).extend(V)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
module ProcessOfVectors
|
187
|
+
include Musa::Datasets
|
188
|
+
include Musa::Neumas
|
189
|
+
|
190
|
+
def value
|
191
|
+
durations_rest = []
|
192
|
+
i = 0
|
193
|
+
|
194
|
+
rests = captures(:rest).collect(&:value)
|
195
|
+
captures(:durations).collect(&:value).each do |duration|
|
196
|
+
durations_rest[i * 2] = duration
|
197
|
+
durations_rest[i * 2 + 1] = rests[i]
|
198
|
+
i += 1
|
199
|
+
end
|
200
|
+
|
201
|
+
p = ([ capture(:first).value ] + durations_rest).extend(P)
|
202
|
+
{ kind: :p, p: p }.extend(Neuma)
|
203
|
+
end
|
204
|
+
end
|
158
205
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
206
|
+
module DeltaGradeAttribute
|
207
|
+
def value
|
208
|
+
|
209
|
+
value = {}
|
210
|
+
|
211
|
+
sign = capture(:sign)&.value || 1
|
212
|
+
|
213
|
+
value[:delta_grade] = capture(:grade).value * sign if capture(:grade)
|
214
|
+
value[:delta_sharps] = capture(:accidentals).value * sign if capture(:accidentals)
|
215
|
+
|
216
|
+
value[:delta_interval] = capture(:interval).value if capture(:interval)
|
217
|
+
value[:delta_interval_sign] = sign if capture(:interval) && capture(:sign)
|
218
|
+
|
219
|
+
value
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
module AbsGradeAttribute
|
224
|
+
def value
|
225
|
+
value = {}
|
226
|
+
|
227
|
+
value[:abs_grade] = capture(:grade).value if capture(:grade)
|
228
|
+
value[:abs_grade] ||= capture(:interval).value.to_sym if capture(:interval)
|
229
|
+
|
230
|
+
value[:abs_sharps] = capture(:accidentals).value if capture(:accidentals)
|
231
|
+
|
232
|
+
value
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
module DeltaOctaveAttribute
|
237
|
+
def value
|
238
|
+
{ delta_octave: capture(:sign).value * capture(:number).value }
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
module AbsOctaveAttribute
|
243
|
+
def value
|
244
|
+
{ abs_octave: capture(:number).value }
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
module DurationCalculation
|
249
|
+
def duration
|
250
|
+
base = capture(:number)&.value
|
251
|
+
|
252
|
+
slashes = capture(:slashes)&.value || 0
|
253
|
+
base ||= Rational(1, 2**slashes.to_r)
|
254
|
+
|
255
|
+
dots_extension = 0
|
256
|
+
capture(:mid_dots)&.value&.times do |i|
|
257
|
+
dots_extension += Rational(base, 2**(i+1))
|
258
|
+
end
|
259
|
+
|
260
|
+
base + dots_extension
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
module DeltaDurationAttribute
|
265
|
+
include DurationCalculation
|
266
|
+
|
267
|
+
def value
|
268
|
+
sign = capture(:sign).value
|
269
|
+
|
270
|
+
{ delta_duration: sign * duration }
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
module AbsDurationAttribute
|
275
|
+
include DurationCalculation
|
276
|
+
|
277
|
+
def value
|
278
|
+
{ abs_duration: duration }
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
module FactorDurationAttribute
|
283
|
+
def value
|
284
|
+
{ factor_duration: capture(:number).value ** (capture(:factor).value == '/' ? -1 : 1) }
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
module AbsVelocityAttribute
|
289
|
+
def value
|
290
|
+
if capture(:p)
|
291
|
+
v = -capture(:p).length
|
292
|
+
elsif capture(:mp)
|
293
|
+
v = 0
|
294
|
+
elsif capture(:mf)
|
295
|
+
v = 1
|
296
|
+
else
|
297
|
+
v = capture(:f).length + 1
|
298
|
+
end
|
299
|
+
|
300
|
+
{ abs_velocity: v }
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
module DeltaVelocityAttribute
|
305
|
+
def value
|
306
|
+
d = capture(:delta).value
|
307
|
+
s = capture(:sign).value
|
308
|
+
|
309
|
+
if /p+/.match?(d)
|
310
|
+
v = -d.length
|
311
|
+
else
|
312
|
+
v = d.length
|
313
|
+
end
|
314
|
+
|
315
|
+
{ delta_velocity: s * v }
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
module AppogiaturaNeuma
|
320
|
+
def value
|
321
|
+
capture(:base).value.tap do |_|
|
322
|
+
_[:gdvd][:modifiers] ||= {}
|
323
|
+
_[:gdvd][:modifiers][:appogiatura] = capture(:appogiatura).value[:gdvd]
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
module Symbol
|
329
|
+
include Musa::Neumas
|
330
|
+
|
331
|
+
def value
|
332
|
+
{ kind: :value,
|
333
|
+
value: capture(:name).value.to_sym }.extend Neuma
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
module String
|
338
|
+
include Musa::Neumas
|
339
|
+
|
340
|
+
def value
|
341
|
+
{ kind: :value,
|
342
|
+
value: capture(:everything_except_double_quote).value }.extend Neuma
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
module Number
|
347
|
+
include Musa::Neumas
|
348
|
+
|
349
|
+
def value
|
350
|
+
{ kind: :value,
|
351
|
+
value: capture(:raw_number).value }.extend Neuma
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
module Special
|
356
|
+
include Musa::Neumas
|
357
|
+
|
358
|
+
def value
|
359
|
+
v = captures(0)
|
360
|
+
{ kind: :value,
|
361
|
+
value: v == 'nil' ? nil : (v == 'true' ? true : false) }.extend Neuma
|
362
|
+
end
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
extend self
|
367
|
+
|
368
|
+
def parse(string_or_file, decode_with: nil, debug: nil)
|
369
|
+
if string_or_file.is_a? String
|
370
|
+
match = Parser::Grammar::Grammar.parse string_or_file
|
371
|
+
|
372
|
+
elsif string_or_file.is_a? File
|
373
|
+
match = Parser::Grammar::Grammar.parse string_or_file.read
|
374
|
+
|
375
|
+
else
|
376
|
+
raise ArgumentError, 'Only String or File allowed to be parsed'
|
377
|
+
end
|
378
|
+
|
379
|
+
match.dump if debug
|
380
|
+
|
381
|
+
serie = match.value
|
382
|
+
|
383
|
+
if decode_with
|
384
|
+
serie.eval do |e|
|
385
|
+
if e[:kind] == :gdvd
|
386
|
+
decode_with.decode(e[:gdvd])
|
387
|
+
else
|
388
|
+
raise ArgumentError, "Don't know how to convert #{e} to neumas"
|
389
|
+
end
|
390
|
+
end
|
163
391
|
else
|
164
|
-
|
392
|
+
serie
|
165
393
|
end
|
166
394
|
end
|
167
|
-
else
|
168
|
-
serie
|
169
|
-
end
|
170
|
-
end
|
171
395
|
|
172
|
-
|
173
|
-
|
174
|
-
|
396
|
+
def parse_file(filename, decode_with: nil, debug: nil)
|
397
|
+
File.open filename do |file|
|
398
|
+
parse file, decode_with: decode_with, debug: debug
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
Citrus.load File.join(File.dirname(__FILE__), 'terminals.citrus')
|
403
|
+
Citrus.load File.join(File.dirname(__FILE__), 'datatypes.citrus')
|
404
|
+
Citrus.load File.join(File.dirname(__FILE__), 'neuma.citrus')
|
405
|
+
Citrus.load File.join(File.dirname(__FILE__), 'vectors.citrus')
|
406
|
+
Citrus.load File.join(File.dirname(__FILE__), 'process.citrus')
|
407
|
+
Citrus.load File.join(File.dirname(__FILE__), 'neumalang.citrus')
|
175
408
|
end
|
176
409
|
end
|
177
|
-
|
178
|
-
register File.join(File.dirname(__FILE__), 'neumalang')
|
179
410
|
end
|