325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
# File 'lib/musa-dsl/neumalang/neumalang.rb', line 325
def parse(string_or_file, decode_with: nil, debug: nil)
case string_or_file
when String
match = Parser::Grammar::Grammar.parse string_or_file
when File
match = Parser::Grammar::Grammar.parse string_or_file.read
else
raise ArgumentError, 'Only String or File allowed to be parsed'
end
match.dump if debug
serie = match.value
if decode_with
serie.eval do |e|
if e[:kind] == :gdvd
decode_with.decode(e[:gdvd])
else
raise ArgumentError, "Don't know how to convert #{e} to neumas"
end
end
else
serie
end
end
|