Module: Brevity::Note
- Included in:
- Expression, NoteParser, Sequence
- Defined in:
- lib/brevity/parsing/note/note.rb
Defined Under Namespace
Modules: MonophonicNote0, PitchLink0, PolyphonicNote0, PolyphonicNote1, RestNote0
Instance Method Summary collapse
- #_nt_monophonic_note ⇒ Object
- #_nt_note ⇒ Object
- #_nt_pitch_link ⇒ Object
- #_nt_polyphonic_note ⇒ Object
- #_nt_rest_note ⇒ Object
- #root ⇒ Object
Methods included from Duration
#_nt_den_only, #_nt_duration, #_nt_num_and_den, #_nt_num_only
Methods included from PositiveInteger
Methods included from NonnegativeInteger
Methods included from Link
Methods included from Pitch
Methods included from Accent
Instance Method Details
#_nt_monophonic_note ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/brevity/parsing/note/note.rb', line 106 def _nt_monophonic_note start_index = index if node_cache[:monophonic_note].has_key?(index) cached = node_cache[:monophonic_note][index] if cached node_cache[:monophonic_note][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_duration s0 << r1 if r1 r2 = _nt_pitch_link s0 << r2 if r2 r4 = _nt_accent if r4 r3 = r4 else r3 = instantiate_node(SyntaxNode,input, index...index) end s0 << r3 end end if s0.last r0 = instantiate_node(MonophonicNoteNode,input, i0...index, s0) r0.extend(MonophonicNote0) else @index = i0 r0 = nil end node_cache[:monophonic_note][start_index] = r0 r0 end |
#_nt_note ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/brevity/parsing/note/note.rb', line 21 def _nt_note start_index = index if node_cache[:note].has_key?(index) cached = node_cache[:note][index] if cached node_cache[:note][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_polyphonic_note if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else r2 = _nt_monophonic_note if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 else r3 = _nt_rest_note if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r0 = r3 else @index = i0 r0 = nil end end end node_cache[:note][start_index] = r0 r0 end |
#_nt_pitch_link ⇒ Object
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/brevity/parsing/note/note.rb', line 257 def _nt_pitch_link start_index = index if node_cache[:pitch_link].has_key?(index) cached = node_cache[:pitch_link][index] if cached node_cache[:pitch_link][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_pitch s0 << r1 if r1 r3 = _nt_link if r3 r2 = r3 else r2 = instantiate_node(SyntaxNode,input, index...index) end s0 << r2 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(PitchLink0) else @index = i0 r0 = nil end node_cache[:pitch_link][start_index] = r0 r0 end |
#_nt_polyphonic_note ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/brevity/parsing/note/note.rb', line 170 def _nt_polyphonic_note start_index = index if node_cache[:polyphonic_note].has_key?(index) cached = node_cache[:polyphonic_note][index] if cached node_cache[:polyphonic_note][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_duration s0 << r1 if r1 r2 = _nt_pitch_link s0 << r2 if r2 s3, i3 = [], index loop do i4, s4 = index, [] if (match_len = has_terminal?(",", false, index)) r5 = true @index += match_len else terminal_parse_failure(",") r5 = nil end s4 << r5 if r5 r6 = _nt_pitch_link s4 << r6 end if s4.last r4 = instantiate_node(SyntaxNode,input, i4...index, s4) r4.extend(PolyphonicNote0) else @index = i4 r4 = nil end if r4 s3 << r4 else break end end if s3.empty? @index = i3 r3 = nil else r3 = instantiate_node(SyntaxNode,input, i3...index, s3) end s0 << r3 if r3 r8 = _nt_accent if r8 r7 = r8 else r7 = instantiate_node(SyntaxNode,input, index...index) end s0 << r7 end end end if s0.last r0 = instantiate_node(PolyphonicNoteNode,input, i0...index, s0) r0.extend(PolyphonicNote1) else @index = i0 r0 = nil end node_cache[:polyphonic_note][start_index] = r0 r0 end |
#_nt_rest_note ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/brevity/parsing/note/note.rb', line 65 def _nt_rest_note start_index = index if node_cache[:rest_note].has_key?(index) cached = node_cache[:rest_note][index] if cached node_cache[:rest_note][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_duration s0 << r1 if s0.last r0 = instantiate_node(RestNoteNode,input, i0...index, s0) r0.extend(RestNote0) else @index = i0 r0 = nil end node_cache[:rest_note][start_index] = r0 r0 end |
#root ⇒ Object
9 10 11 |
# File 'lib/brevity/parsing/note/note.rb', line 9 def root @root ||= :note end |