brevity 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/.document +3 -0
  3. data/.gitignore +7 -0
  4. data/.rspec +1 -0
  5. data/.ruby-version +1 -0
  6. data/.yardopts +1 -0
  7. data/ChangeLog.rdoc +4 -0
  8. data/Gemfile +3 -0
  9. data/LICENSE.txt +20 -0
  10. data/README.rdoc +27 -0
  11. data/Rakefile +67 -0
  12. data/bin/debrief +56 -0
  13. data/brevity.gemspec +28 -0
  14. data/examples/alley_cat.br +50 -0
  15. data/examples/hip.br +15 -0
  16. data/examples/missed_connection.br +6 -0
  17. data/examples/song1.br +11 -0
  18. data/examples/song2.br +10 -0
  19. data/examples/twinkle.br +18 -0
  20. data/lib/brevity/commands/constants.rb +18 -0
  21. data/lib/brevity/commands/expr.rb +17 -0
  22. data/lib/brevity/commands/meter.rb +20 -0
  23. data/lib/brevity/commands/part.rb +47 -0
  24. data/lib/brevity/commands/tempo.rb +13 -0
  25. data/lib/brevity/itemization.rb +73 -0
  26. data/lib/brevity/parsing/expression/dynamic.rb +280 -0
  27. data/lib/brevity/parsing/expression/dynamic.treetop +41 -0
  28. data/lib/brevity/parsing/expression/dynamic_nodes.rb +55 -0
  29. data/lib/brevity/parsing/expression/expression.rb +429 -0
  30. data/lib/brevity/parsing/expression/expression.treetop +39 -0
  31. data/lib/brevity/parsing/expression/expression_nodes.rb +26 -0
  32. data/lib/brevity/parsing/expression/gradual.rb +44 -0
  33. data/lib/brevity/parsing/expression/gradual.treetop +9 -0
  34. data/lib/brevity/parsing/expression/gradual_node.rb +11 -0
  35. data/lib/brevity/parsing/expression/label.rb +75 -0
  36. data/lib/brevity/parsing/expression/label.treetop +9 -0
  37. data/lib/brevity/parsing/expression/label_node.rb +15 -0
  38. data/lib/brevity/parsing/expression/sequence.rb +130 -0
  39. data/lib/brevity/parsing/expression/sequence.treetop +12 -0
  40. data/lib/brevity/parsing/expression/sequence_node.rb +14 -0
  41. data/lib/brevity/parsing/file/command.rb +216 -0
  42. data/lib/brevity/parsing/file/command.treetop +17 -0
  43. data/lib/brevity/parsing/file/command_node.rb +11 -0
  44. data/lib/brevity/parsing/file/comment.rb +178 -0
  45. data/lib/brevity/parsing/file/comment.treetop +21 -0
  46. data/lib/brevity/parsing/file/comment_node.rb +3 -0
  47. data/lib/brevity/parsing/file/file.rb +152 -0
  48. data/lib/brevity/parsing/file/file.treetop +16 -0
  49. data/lib/brevity/parsing/file/file_node.rb +7 -0
  50. data/lib/brevity/parsing/file/path.rb +235 -0
  51. data/lib/brevity/parsing/file/path.treetop +12 -0
  52. data/lib/brevity/parsing/modifiers/duplicate_modifier.rb +65 -0
  53. data/lib/brevity/parsing/modifiers/duplicate_modifier.treetop +11 -0
  54. data/lib/brevity/parsing/modifiers/duplicate_modifier_node.rb +8 -0
  55. data/lib/brevity/parsing/modifiers/modifier.rb +64 -0
  56. data/lib/brevity/parsing/modifiers/modifier.treetop +13 -0
  57. data/lib/brevity/parsing/modifiers/stretch_modifier.rb +69 -0
  58. data/lib/brevity/parsing/modifiers/stretch_modifier.treetop +11 -0
  59. data/lib/brevity/parsing/modifiers/stretch_modifier_node.rb +21 -0
  60. data/lib/brevity/parsing/modifiers/transpose_modifier.rb +69 -0
  61. data/lib/brevity/parsing/modifiers/transpose_modifier.treetop +11 -0
  62. data/lib/brevity/parsing/modifiers/transpose_modifier_node.rb +13 -0
  63. data/lib/brevity/parsing/note/accent.rb +44 -0
  64. data/lib/brevity/parsing/note/accent.treetop +9 -0
  65. data/lib/brevity/parsing/note/duration.rb +203 -0
  66. data/lib/brevity/parsing/note/duration.treetop +23 -0
  67. data/lib/brevity/parsing/note/duration_nodes.rb +19 -0
  68. data/lib/brevity/parsing/note/link.rb +69 -0
  69. data/lib/brevity/parsing/note/link.treetop +11 -0
  70. data/lib/brevity/parsing/note/link_node.rb +19 -0
  71. data/lib/brevity/parsing/note/note.rb +300 -0
  72. data/lib/brevity/parsing/note/note.treetop +30 -0
  73. data/lib/brevity/parsing/note/note_nodes.rb +77 -0
  74. data/lib/brevity/parsing/note/pitch.rb +81 -0
  75. data/lib/brevity/parsing/note/pitch.treetop +9 -0
  76. data/lib/brevity/parsing/note/pitch_node.rb +50 -0
  77. data/lib/brevity/parsing/numbers/nonnegative_integer.rb +53 -0
  78. data/lib/brevity/parsing/numbers/nonnegative_integer.treetop +9 -0
  79. data/lib/brevity/parsing/numbers/positive_integer.rb +91 -0
  80. data/lib/brevity/parsing/numbers/positive_integer.treetop +15 -0
  81. data/lib/brevity/read_file.rb +18 -0
  82. data/lib/brevity/score_maker.rb +64 -0
  83. data/lib/brevity/version.rb +4 -0
  84. data/lib/brevity.rb +53 -0
  85. data/manuals/brevity.pdf +0 -0
  86. data/manuals/brevity.tex +273 -0
  87. data/spec/brevity_spec.rb +8 -0
  88. data/spec/commands/expr_spec.rb +15 -0
  89. data/spec/commands/meter_spec.rb +21 -0
  90. data/spec/commands/part_spec.rb +16 -0
  91. data/spec/commands/tempo_spec.rb +20 -0
  92. data/spec/itemization_spec.rb +46 -0
  93. data/spec/parsing/expression/dynamic_nodes_spec.rb +32 -0
  94. data/spec/parsing/expression/dynamic_spec.rb +23 -0
  95. data/spec/parsing/expression/expression_nodes_spec.rb +87 -0
  96. data/spec/parsing/expression/expression_spec.rb +85 -0
  97. data/spec/parsing/expression/gradual_spec.rb +10 -0
  98. data/spec/parsing/expression/label_node_spec.rb +13 -0
  99. data/spec/parsing/expression/label_spec.rb +35 -0
  100. data/spec/parsing/file/command_node_spec.rb +29 -0
  101. data/spec/parsing/file/command_spec.rb +18 -0
  102. data/spec/parsing/file/comment_spec.rb +14 -0
  103. data/spec/parsing/file/file_node_spec.rb +19 -0
  104. data/spec/parsing/file/file_spec.rb +30 -0
  105. data/spec/parsing/modifiers/modifier_nodes_spec.rb +25 -0
  106. data/spec/parsing/modifiers/modifier_parsers_spec.rb +20 -0
  107. data/spec/parsing/note/accent_spec.rb +27 -0
  108. data/spec/parsing/note/duration_nodes_spec.rb +79 -0
  109. data/spec/parsing/note/duration_spec.rb +69 -0
  110. data/spec/parsing/note/link_node_spec.rb +30 -0
  111. data/spec/parsing/note/link_spec.rb +23 -0
  112. data/spec/parsing/note/note_nodes_spec.rb +82 -0
  113. data/spec/parsing/note/note_spec.rb +188 -0
  114. data/spec/parsing/note/pitch_node_spec.rb +48 -0
  115. data/spec/parsing/note/pitch_spec.rb +23 -0
  116. data/spec/parsing/numbers/nonnegative_integer_spec.rb +11 -0
  117. data/spec/parsing/numbers/positive_integer_spec.rb +17 -0
  118. data/spec/spec_helper.rb +112 -0
  119. metadata +293 -0
@@ -0,0 +1,280 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
4
+ module Brevity
5
+
6
+ module Dynamic
7
+ include Treetop::Runtime
8
+
9
+ def root
10
+ @root ||= :dynamic
11
+ end
12
+
13
+ def _nt_dynamic
14
+ start_index = index
15
+ if node_cache[:dynamic].has_key?(index)
16
+ cached = node_cache[:dynamic][index]
17
+ if cached
18
+ node_cache[:dynamic][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
19
+ @index = cached.interval.end
20
+ end
21
+ return cached
22
+ end
23
+
24
+ i0 = index
25
+ r1 = _nt_ppp
26
+ if r1
27
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
28
+ r0 = r1
29
+ else
30
+ r2 = _nt_pp
31
+ if r2
32
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
33
+ r0 = r2
34
+ else
35
+ r3 = _nt_p
36
+ if r3
37
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
38
+ r0 = r3
39
+ else
40
+ r4 = _nt_mp
41
+ if r4
42
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
43
+ r0 = r4
44
+ else
45
+ r5 = _nt_mf
46
+ if r5
47
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
48
+ r0 = r5
49
+ else
50
+ r6 = _nt_fff
51
+ if r6
52
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
53
+ r0 = r6
54
+ else
55
+ r7 = _nt_ff
56
+ if r7
57
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
58
+ r0 = r7
59
+ else
60
+ r8 = _nt_f
61
+ if r8
62
+ r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
63
+ r0 = r8
64
+ else
65
+ @index = i0
66
+ r0 = nil
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ node_cache[:dynamic][start_index] = r0
77
+
78
+ r0
79
+ end
80
+
81
+ def _nt_ppp
82
+ start_index = index
83
+ if node_cache[:ppp].has_key?(index)
84
+ cached = node_cache[:ppp][index]
85
+ if cached
86
+ node_cache[:ppp][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
87
+ @index = cached.interval.end
88
+ end
89
+ return cached
90
+ end
91
+
92
+ if (match_len = has_terminal?("ppp", false, index))
93
+ r0 = instantiate_node(PianississimoNode,input, index...(index + match_len))
94
+ @index += match_len
95
+ else
96
+ terminal_parse_failure("ppp")
97
+ r0 = nil
98
+ end
99
+
100
+ node_cache[:ppp][start_index] = r0
101
+
102
+ r0
103
+ end
104
+
105
+ def _nt_pp
106
+ start_index = index
107
+ if node_cache[:pp].has_key?(index)
108
+ cached = node_cache[:pp][index]
109
+ if cached
110
+ node_cache[:pp][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
111
+ @index = cached.interval.end
112
+ end
113
+ return cached
114
+ end
115
+
116
+ if (match_len = has_terminal?("pp", false, index))
117
+ r0 = instantiate_node(PianissimoNode,input, index...(index + match_len))
118
+ @index += match_len
119
+ else
120
+ terminal_parse_failure("pp")
121
+ r0 = nil
122
+ end
123
+
124
+ node_cache[:pp][start_index] = r0
125
+
126
+ r0
127
+ end
128
+
129
+ def _nt_p
130
+ start_index = index
131
+ if node_cache[:p].has_key?(index)
132
+ cached = node_cache[:p][index]
133
+ if cached
134
+ node_cache[:p][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
135
+ @index = cached.interval.end
136
+ end
137
+ return cached
138
+ end
139
+
140
+ if (match_len = has_terminal?("p", false, index))
141
+ r0 = instantiate_node(PianoNode,input, index...(index + match_len))
142
+ @index += match_len
143
+ else
144
+ terminal_parse_failure("p")
145
+ r0 = nil
146
+ end
147
+
148
+ node_cache[:p][start_index] = r0
149
+
150
+ r0
151
+ end
152
+
153
+ def _nt_mp
154
+ start_index = index
155
+ if node_cache[:mp].has_key?(index)
156
+ cached = node_cache[:mp][index]
157
+ if cached
158
+ node_cache[:mp][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
159
+ @index = cached.interval.end
160
+ end
161
+ return cached
162
+ end
163
+
164
+ if (match_len = has_terminal?("mp", false, index))
165
+ r0 = instantiate_node(MezzoPianoNode,input, index...(index + match_len))
166
+ @index += match_len
167
+ else
168
+ terminal_parse_failure("mp")
169
+ r0 = nil
170
+ end
171
+
172
+ node_cache[:mp][start_index] = r0
173
+
174
+ r0
175
+ end
176
+
177
+ def _nt_mf
178
+ start_index = index
179
+ if node_cache[:mf].has_key?(index)
180
+ cached = node_cache[:mf][index]
181
+ if cached
182
+ node_cache[:mf][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
183
+ @index = cached.interval.end
184
+ end
185
+ return cached
186
+ end
187
+
188
+ if (match_len = has_terminal?("mf", false, index))
189
+ r0 = instantiate_node(MezzoForteNode,input, index...(index + match_len))
190
+ @index += match_len
191
+ else
192
+ terminal_parse_failure("mf")
193
+ r0 = nil
194
+ end
195
+
196
+ node_cache[:mf][start_index] = r0
197
+
198
+ r0
199
+ end
200
+
201
+ def _nt_f
202
+ start_index = index
203
+ if node_cache[:f].has_key?(index)
204
+ cached = node_cache[:f][index]
205
+ if cached
206
+ node_cache[:f][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
207
+ @index = cached.interval.end
208
+ end
209
+ return cached
210
+ end
211
+
212
+ if (match_len = has_terminal?("f", false, index))
213
+ r0 = instantiate_node(ForteNode,input, index...(index + match_len))
214
+ @index += match_len
215
+ else
216
+ terminal_parse_failure("f")
217
+ r0 = nil
218
+ end
219
+
220
+ node_cache[:f][start_index] = r0
221
+
222
+ r0
223
+ end
224
+
225
+ def _nt_ff
226
+ start_index = index
227
+ if node_cache[:ff].has_key?(index)
228
+ cached = node_cache[:ff][index]
229
+ if cached
230
+ node_cache[:ff][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
231
+ @index = cached.interval.end
232
+ end
233
+ return cached
234
+ end
235
+
236
+ if (match_len = has_terminal?("ff", false, index))
237
+ r0 = instantiate_node(FortissimoNode,input, index...(index + match_len))
238
+ @index += match_len
239
+ else
240
+ terminal_parse_failure("ff")
241
+ r0 = nil
242
+ end
243
+
244
+ node_cache[:ff][start_index] = r0
245
+
246
+ r0
247
+ end
248
+
249
+ def _nt_fff
250
+ start_index = index
251
+ if node_cache[:fff].has_key?(index)
252
+ cached = node_cache[:fff][index]
253
+ if cached
254
+ node_cache[:fff][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
255
+ @index = cached.interval.end
256
+ end
257
+ return cached
258
+ end
259
+
260
+ if (match_len = has_terminal?("fff", false, index))
261
+ r0 = instantiate_node(FortississimoNode,input, index...(index + match_len))
262
+ @index += match_len
263
+ else
264
+ terminal_parse_failure("fff")
265
+ r0 = nil
266
+ end
267
+
268
+ node_cache[:fff][start_index] = r0
269
+
270
+ r0
271
+ end
272
+
273
+ end
274
+
275
+ class DynamicParser < Treetop::Runtime::CompiledParser
276
+ include Dynamic
277
+ end
278
+
279
+
280
+ end
@@ -0,0 +1,41 @@
1
+ module Brevity
2
+
3
+ grammar Dynamic
4
+ rule dynamic
5
+ ppp / pp / p / mp / mf / fff / ff / f
6
+ end
7
+
8
+ rule ppp
9
+ "ppp" <PianississimoNode>
10
+ end
11
+
12
+ rule pp
13
+ "pp" <PianissimoNode>
14
+ end
15
+
16
+ rule p
17
+ "p" <PianoNode>
18
+ end
19
+
20
+ rule mp
21
+ "mp" <MezzoPianoNode>
22
+ end
23
+
24
+ rule mf
25
+ "mf" <MezzoForteNode>
26
+ end
27
+
28
+ rule f
29
+ "f" <ForteNode>
30
+ end
31
+
32
+ rule ff
33
+ "ff" <FortissimoNode>
34
+ end
35
+
36
+ rule fff
37
+ "fff" <FortississimoNode>
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,55 @@
1
+ module Brevity
2
+ class DynamicNode < Treetop::Runtime::SyntaxNode
3
+ def primitives env
4
+ [ self.to_dynamic ]
5
+ end
6
+ end
7
+
8
+ class PianississimoNode < DynamicNode
9
+ def to_dynamic
10
+ Music::Transcription::Dynamic::Pianississimo.new
11
+ end
12
+ end
13
+
14
+ class PianissimoNode < DynamicNode
15
+ def to_dynamic
16
+ Music::Transcription::Dynamic::Pianissimo.new
17
+ end
18
+ end
19
+
20
+ class PianoNode < DynamicNode
21
+ def to_dynamic
22
+ Music::Transcription::Dynamic::Piano.new
23
+ end
24
+ end
25
+
26
+ class MezzoPianoNode < DynamicNode
27
+ def to_dynamic
28
+ Music::Transcription::Dynamic::MezzoPiano.new
29
+ end
30
+ end
31
+
32
+ class MezzoForteNode < DynamicNode
33
+ def to_dynamic
34
+ Music::Transcription::Dynamic::MezzoForte.new
35
+ end
36
+ end
37
+
38
+ class ForteNode < DynamicNode
39
+ def to_dynamic
40
+ Music::Transcription::Dynamic::Forte.new
41
+ end
42
+ end
43
+
44
+ class FortissimoNode < DynamicNode
45
+ def to_dynamic
46
+ Music::Transcription::Dynamic::Fortissimo.new
47
+ end
48
+ end
49
+
50
+ class FortississimoNode < DynamicNode
51
+ def to_dynamic
52
+ Music::Transcription::Dynamic::Fortississimo.new
53
+ end
54
+ end
55
+ end