Loop labels

This commit is contained in:
Ilya Puchka
2017-12-28 14:17:24 +01:00
committed by David Jennes
parent a7448b74cf
commit 91df84b1a5
4 changed files with 112 additions and 11 deletions

View File

@@ -45,7 +45,12 @@ extension String {
if !components.isEmpty {
if let precedingChar = components.last?.last, specialCharacters.contains(precedingChar) {
components[components.count - 1] += word
// special case for labeled for-loops
if components.count == 1 && word == "for" {
components.append(word)
} else {
components[components.count - 1] += word
}
} else if specialCharacters.contains(word) {
components[components.count - 1] += word
} else if word != "(" && word.first == "(" || word != ")" && word.first == ")" {