feat(for loop): Support range literals (#192)

This commit is contained in:
Ilya Puchka
2018-04-05 01:56:58 +01:00
committed by Kyle Fuller
parent 2e6a7215c5
commit fe01beb4bb
8 changed files with 131 additions and 16 deletions

View File

@@ -40,7 +40,7 @@ public class TokenParser {
case .text(let text):
nodes.append(TextNode(text: text))
case .variable:
nodes.append(VariableNode(variable: try compileFilter(token.contents)))
nodes.append(VariableNode(variable: try compileResolvable(token.contents)))
case .block:
if let parse_until = parse_until , parse_until(self, token) {
prependToken(token)
@@ -114,6 +114,11 @@ public class TokenParser {
return try FilterExpression(token: token, parser: self)
}
public func compileResolvable(_ token: String) throws -> Resolvable {
return try RangeVariable(token, parser: self)
?? compileFilter(token)
}
}
// https://en.wikipedia.org/wiki/Levenshtein_distance#Iterative_with_two_matrix_rows