processedString method
Implementation
String processedString(
{Iterable<UnprocessedToken>? unprocessedTokens, String? text}) {
unprocessedTokens ??= getTokensUnprocessed(text!);
var out = '';
String? currentTokenName;
var newlineNeeded = false;
for (var token in unprocessedTokens) {
if (token.token == Token.Text) {
if (currentTokenName != null) {
out += ')';
currentTokenName = null;
}
out += token.match;
} else {
if (token.tokenName != currentTokenName) {
if (currentTokenName != null) {
out += ')';
if (newlineNeeded == true) {
out += '\n';
newlineNeeded = false;
}
}
out += token.tokenName + '(';
currentTokenName = token.tokenName;
if (token.match.contains('\n')) {
newlineNeeded = true;
}
}
out += token.prettyMatch;
}
}
if (currentTokenName != null) {
out += ')';
if (newlineNeeded == true) {
out += '\n';
}
}
return out;
}