replaced Lexeme protocol with Token

This commit is contained in:
Ilya Puchka
2017-12-26 15:28:46 +01:00
parent 218822fcb0
commit 8d68edd725
7 changed files with 35 additions and 54 deletions

View File

@@ -54,8 +54,8 @@ public class TokenParser {
let node = try parser(self, token)
nodes.append(node)
} catch {
if var syntaxError = error as? TemplateSyntaxError, syntaxError.lexeme == nil {
syntaxError.lexeme = token
if var syntaxError = error as? TemplateSyntaxError, syntaxError.token == nil {
syntaxError.token = token
throw syntaxError
} else {
throw error
@@ -106,11 +106,11 @@ public class TokenParser {
do {
return try FilterExpression(token: filterToken, parser: self)
} catch {
if var syntaxError = error as? TemplateSyntaxError, syntaxError.lexeme == nil {
if var syntaxError = error as? TemplateSyntaxError, syntaxError.token == nil {
if let filterTokenRange = environment.template?.templateString.range(of: filterToken, range: containingToken.range) {
syntaxError.lexeme = Token.block(value: filterToken, at: filterTokenRange)
syntaxError.token = Token.block(value: filterToken, at: filterTokenRange)
} else {
syntaxError.lexeme = containingToken
syntaxError.token = containingToken
}
throw syntaxError
} else {