parseLick function

List<LickNote> parseLick(
  1. String text
)

Lê um lick (0e 2e 3q). Lança FormatException com o token que não se lê; o leitor do curso já confere o texto dos licks, e os testes do app também.

Implementation

List<LickNote> parseLick(String text) {
  final notes = <LickNote>[];
  for (final token in text.split(' ')) {
    final match = _token.firstMatch(token);
    if (match == null) {
      throw FormatException('token de lick inválido: `$token`', text);
    }
    final degree = match.group(1) == 'r' ? null : int.parse(match.group(1)!);
    final figure = match.group(2)!;
    final beats = _figureBeats[figure.isEmpty ? 'q' : figure]!;
    notes.add(LickNote(degree, beats));
  }
  return notes;
}