Module: Musicality::Parsing::Articulation

Includes:
Treetop::Runtime
Included in:
ArticulationParser, Note
Defined in:
lib/musicality/notation/parsing/articulation_parsing.rb

Defined Under Namespace

Modules: Accent0, Marcato0, Portato0, Staccatissimo0, Staccato0, Tenuto0

Instance Method Summary collapse

Instance Method Details

#_nt_accentObject



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/musicality/notation/parsing/articulation_parsing.rb', line 107

def _nt_accent
  start_index = index
  if node_cache[:accent].has_key?(index)
    cached = node_cache[:accent][index]
    if cached
      node_cache[:accent][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(SyntaxNode,input, index...(index + match_len))
    r0.extend(Accent0)
    @index += match_len
  else
    terminal_parse_failure('">"')
    r0 = nil
  end

  node_cache[:accent][start_index] = r0

  r0
end

#_nt_articulationObject



14
15
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/musicality/notation/parsing/articulation_parsing.rb', line 14

def _nt_articulation
  start_index = index
  if node_cache[:articulation].has_key?(index)
    cached = node_cache[:articulation][index]
    if cached
      node_cache[:articulation][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  r1 = _nt_tenuto
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    r2 = _nt_accent
    if r2
      r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
      r0 = r2
    else
      r3 = _nt_marcato
      if r3
        r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
        r0 = r3
      else
        r4 = _nt_portato
        if r4
          r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
          r0 = r4
        else
          r5 = _nt_staccato
          if r5
            r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
            r0 = r5
          else
            r6 = _nt_staccatissimo
            if r6
              r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
              r0 = r6
            else
              @index = i0
              r0 = nil
            end
          end
        end
      end
    end
  end

  node_cache[:articulation][start_index] = r0

  r0
end

#_nt_marcatoObject



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/musicality/notation/parsing/articulation_parsing.rb', line 138

def _nt_marcato
  start_index = index
  if node_cache[:marcato].has_key?(index)
    cached = node_cache[:marcato][index]
    if cached
      node_cache[:marcato][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(SyntaxNode,input, index...(index + match_len))
    r0.extend(Marcato0)
    @index += match_len
  else
    terminal_parse_failure('"^"')
    r0 = nil
  end

  node_cache[:marcato][start_index] = r0

  r0
end

#_nt_portatoObject



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/musicality/notation/parsing/articulation_parsing.rb', line 169

def _nt_portato
  start_index = index
  if node_cache[:portato].has_key?(index)
    cached = node_cache[:portato][index]
    if cached
      node_cache[:portato][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(SyntaxNode,input, index...(index + match_len))
    r0.extend(Portato0)
    @index += match_len
  else
    terminal_parse_failure('"_"')
    r0 = nil
  end

  node_cache[:portato][start_index] = r0

  r0
end

#_nt_staccatissimoObject



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/musicality/notation/parsing/articulation_parsing.rb', line 231

def _nt_staccatissimo
  start_index = index
  if node_cache[:staccatissimo].has_key?(index)
    cached = node_cache[:staccatissimo][index]
    if cached
      node_cache[:staccatissimo][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(SyntaxNode,input, index...(index + match_len))
    r0.extend(Staccatissimo0)
    @index += match_len
  else
    terminal_parse_failure('"!"')
    r0 = nil
  end

  node_cache[:staccatissimo][start_index] = r0

  r0
end

#_nt_staccatoObject



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/musicality/notation/parsing/articulation_parsing.rb', line 200

def _nt_staccato
  start_index = index
  if node_cache[:staccato].has_key?(index)
    cached = node_cache[:staccato][index]
    if cached
      node_cache[:staccato][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(SyntaxNode,input, index...(index + match_len))
    r0.extend(Staccato0)
    @index += match_len
  else
    terminal_parse_failure('"."')
    r0 = nil
  end

  node_cache[:staccato][start_index] = r0

  r0
end

#_nt_tenutoObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/musicality/notation/parsing/articulation_parsing.rb', line 76

def _nt_tenuto
  start_index = index
  if node_cache[:tenuto].has_key?(index)
    cached = node_cache[:tenuto][index]
    if cached
      node_cache[:tenuto][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(SyntaxNode,input, index...(index + match_len))
    r0.extend(Tenuto0)
    @index += match_len
  else
    terminal_parse_failure('"-"')
    r0 = nil
  end

  node_cache[:tenuto][start_index] = r0

  r0
end

#rootObject



10
11
12
# File 'lib/musicality/notation/parsing/articulation_parsing.rb', line 10

def root
  @root ||= :articulation
end