Module: Musicality::Parsing::Link
- Includes:
- Pitch, Treetop::Runtime
- Included in:
- LinkParser, Note
- Defined in:
- lib/musicality/notation/parsing/link_parsing.rb
Defined Under Namespace
Modules: Glissando0, Portamento0
Instance Method Summary
collapse
Methods included from Pitch
#_nt_cent, #_nt_letter_a, #_nt_letter_b, #_nt_letter_c, #_nt_letter_d, #_nt_letter_e, #_nt_letter_f, #_nt_letter_g, #_nt_octave, #_nt_pitch, #_nt_pitch_letter
#_nt_nonnegative_integer
Instance Method Details
#_nt_glissando ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/musicality/notation/parsing/link_parsing.rb', line 84
def _nt_glissando
start_index = index
if node_cache[:glissando].has_key?(index)
cached = node_cache[:glissando][index]
if cached
node_cache[:glissando][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
i0, s0 = index, []
if (match_len = has_terminal?(";", false, index))
r1 = true
@index += match_len
else
terminal_parse_failure('";"')
r1 = nil
end
s0 << r1
if r1
r2 = _nt_pitch
s0 << r2
end
if s0.last
r0 = instantiate_node(GlissandoNode,input, i0...index, s0)
r0.extend(Glissando0)
else
@index = i0
r0 = nil
end
node_cache[:glissando][start_index] = r0
r0
end
|
#_nt_link ⇒ Object
16
17
18
19
20
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
|
# File 'lib/musicality/notation/parsing/link_parsing.rb', line 16
def _nt_link
start_index = index
if node_cache[:link].has_key?(index)
cached = node_cache[:link][index]
if cached
node_cache[:link][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
i0 = index
r1 = _nt_tie
if r1
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
r0 = r1
else
r2 = _nt_glissando
if r2
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
r0 = r2
else
r3 = _nt_portamento
if r3
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
r0 = r3
else
@index = i0
r0 = nil
end
end
end
node_cache[:link][start_index] = r0
r0
end
|
#_nt_portamento ⇒ Object
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/musicality/notation/parsing/link_parsing.rb', line 127
def _nt_portamento
start_index = index
if node_cache[:portamento].has_key?(index)
cached = node_cache[:portamento][index]
if cached
node_cache[:portamento][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
i0, s0 = index, []
if (match_len = has_terminal?(":", false, index))
r1 = true
@index += match_len
else
terminal_parse_failure('":"')
r1 = nil
end
s0 << r1
if r1
r2 = _nt_pitch
s0 << r2
end
if s0.last
r0 = instantiate_node(PortamentoNode,input, i0...index, s0)
r0.extend(Portamento0)
else
@index = i0
r0 = nil
end
node_cache[:portamento][start_index] = r0
r0
end
|
#_nt_tie ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/musicality/notation/parsing/link_parsing.rb', line 54
def _nt_tie
start_index = index
if node_cache[:tie].has_key?(index)
cached = node_cache[:tie][index]
if cached
node_cache[:tie][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
if (match_len = has_terminal?("~", false, index))
r0 = instantiate_node(TieNode,input, index...(index + match_len))
@index += match_len
else
terminal_parse_failure('"~"')
r0 = nil
end
node_cache[:tie][start_index] = r0
r0
end
|
#root ⇒ Object
10
11
12
|
# File 'lib/musicality/notation/parsing/link_parsing.rb', line 10
def root
@root ||= :link
end
|