parse method
Implementation
List<Issue> parse() {
List<Issue> issues = [];
TokenIterator iterator = TokenIterator(tokens);
while (iterator.hasNext()) {
try {
throwErrorIfDoesntMatch(iterator, TokenKind.openingSquareBracket);
iterator.moveNext();
bool wasPosted = false;
if (match(iterator, TokenKind.tilde)) {
wasPosted = true;
iterator.moveNext();
}
throwErrorIfDoesntMatch(iterator, TokenKind.closingSquareBracket);
iterator.moveNext();
throwErrorIfDoesntMatch(iterator, TokenKind.colon);
iterator.moveNext();
throwErrorIfDoesntMatch(iterator, TokenKind.issueText);
String issueTitle = iterator.current.lexeme;
iterator.moveNext();
String issueBodyText = "";
if (match(iterator, TokenKind.issueText)) {
issueBodyText = iterator.current.lexeme;
iterator.moveNext();
}
List<String> labels = [];
if (match(iterator, TokenKind.openingCurlyBrace)) {
labels = parseLabels(iterator);
}
throwErrorIfDoesntMatch(iterator, TokenKind.semicolon);
if (iterator.hasNext()) iterator.moveNext();
final issue = Issue(
wasPosted: wasPosted,
title: issueTitle,
body: issueBodyText,
labels: labels,
);
issues.add(issue);
} catch (error) {
rethrow;
}
}
return issues;
}