0001 // The MIT License 0002 // 0003 // Copyright (c) 2015 Gwendal Roué 0004 // 0005 // Permission is hereby granted, free of charge, to any person obtaining a copy 0006 // of this software and associated documentation files (the "Software"), to deal 0007 // in the Software without restriction, including without limitation the rights 0008 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 0009 // copies of the Software, and to permit persons to whom the Software is 0010 // furnished to do so, subject to the following conditions: 0011 // 0012 // The above copyright notice and this permission notice shall be included in 0013 // all copies or substantial portions of the Software. 0014 // 0015 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0016 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0017 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 0018 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0019 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 0020 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 0021 // THE SOFTWARE. 0022 0023 /** 0024 The type for expressions that appear in tags: `name`, `user.name`, 0025 `uppercase(user.name)`, etc. 0026 */ 0027 enum Expression{ 0028 0029 // {{ . }} 0030 case ImplicitIterator
Expression.swift:36 indirect case Scoped(baseExpression: Expression, identifier: String)Expression.swift:39 indirect case Filter(filterExpression: Expression, argumentExpression: Expression, partialApplication: Bool)Expression.swift:39 indirect case Filter(filterExpression: Expression, argumentExpression: Expression, partialApplication: Bool)Expression.swift:47 extension Expression: Equatable {Expression.swift:50 func ==(lhs: Expression, rhs: Expression) -> Bool {Expression.swift:50 func ==(lhs: Expression, rhs: Expression) -> Bool {TemplateCompiler.swift:201 var expression: Expression?TemplateCompiler.swift:231 var expression: Expression?TemplateCompiler.swift:385 case Section(openingToken: TemplateToken, expression: Expression)TemplateCompiler.swift:386 case InvertedSection(openingToken: TemplateToken, expression: Expression)ExpressionGenerator.swift:24 extension Expression : CustomDebugStringConvertible {ExpressionGenerator.swift:39 func stringFromExpression(expression: Expression) -> String {ExpressionGenerator.swift:45 func renderExpression(expression: Expression) {ExpressionParser.swift:25 func parse(string: String, inout empty outEmpty: Bool) throws -> Expression {ExpressionParser.swift:40 case ScopingIdentifier(identifierStart: String.Index, baseExpression: Expression)ExpressionParser.swift:43 case WaitingForScopingIdentifier(baseExpression: Expression)ExpressionParser.swift:46 case DoneExpression(expression: Expression)ExpressionParser.swift:49 case DoneExpressionPlusWhiteSpace(expression: Expression)ExpressionParser.swift:53 var filterExpressionStack: [Expression] = []ExpressionParser.swift:79 state = .DoneExpressionPlusWhiteSpace(expression: Expression.ImplicitIterator)ExpressionParser.swift:83 filterExpressionStack.append(Expression.ImplicitIterator)ExpressionParser.swift:88 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.ImplicitIterator, partialApplication: false)ExpressionParser.swift:88 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.ImplicitIterator, partialApplication: false)ExpressionParser.swift:96 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.ImplicitIterator, partialApplication: true))ExpressionParser.swift:96 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.ImplicitIterator, partialApplication: true))ExpressionParser.swift:104 state = .ScopingIdentifier(identifierStart: i, baseExpression: Expression.ImplicitIterator)ExpressionParser.swift:111 state = .DoneExpressionPlusWhiteSpace(expression: Expression.Identifier(identifier: identifier))ExpressionParser.swift:114 state = .WaitingForScopingIdentifier(baseExpression: Expression.Identifier(identifier: identifier))ExpressionParser.swift:117 filterExpressionStack.append(Expression.Identifier(identifier: identifier))ExpressionParser.swift:123 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.Identifier(identifier: identifier), partialApplication: false)ExpressionParser.swift:123 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.Identifier(identifier: identifier), partialApplication: false)ExpressionParser.swift:132 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.Identifier(identifier: identifier), partialApplication: true))ExpressionParser.swift:132 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.Identifier(identifier: identifier), partialApplication: true))ExpressionParser.swift:145 let scopedExpression = Expression.Scoped(baseExpression: baseExpression, identifier: identifier)ExpressionParser.swift:149 let scopedExpression = Expression.Scoped(baseExpression: baseExpression, identifier: identifier)ExpressionParser.swift:153 let scopedExpression = Expression.Scoped(baseExpression: baseExpression, identifier: identifier)ExpressionParser.swift:160 let scopedExpression = Expression.Scoped(baseExpression: baseExpression, identifier: identifier)ExpressionParser.swift:161 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: scopedExpression, partialApplication: false)ExpressionParser.swift:170 let scopedExpression = Expression.Scoped(baseExpression: baseExpression, identifier: identifier)ExpressionParser.swift:171 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: scopedExpression, partialApplication: true))ExpressionParser.swift:210 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: doneExpression, partialApplication: false)ExpressionParser.swift:218 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: doneExpression, partialApplication: true))ExpressionParser.swift:242 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: doneExpression, partialApplication: false)ExpressionParser.swift:251 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: doneExpression, partialApplication: true))ExpressionParser.swift:270 case Valid(expression: Expression)ExpressionParser.swift:285 finalState = .Valid(expression: Expression.ImplicitIterator)ExpressionParser.swift:293 finalState = .Valid(expression: Expression.Identifier(identifier: identifier))ExpressionParser.swift:301 let scopedExpression = Expression.Scoped(baseExpression: baseExpression, identifier: identifier)ExpressionInvocation.swift:24 let expression: ExpressionExpressionInvocation.swift:30 private func evaluate(context context: Context, expression: Expression) throws -> MustacheBox {RenderingEngine.swift:127 private func renderTag(tag: LocatedTag, escapesHTML: Bool, inverted: Bool, expression: Expression, inContext context: Context) throws {TemplateASTNode.swift:53 let expression: ExpressionTemplateASTNode.swift:59 let expression: ExpressionTemplateASTNode.swift:78 static func section(templateAST templateAST: TemplateAST, expression: Expression, inverted: Bool, openingToken: TemplateToken, innerTemplateString: String) -> TemplateASTNode {TemplateASTNode.swift:87 static func variable(expression expression: Expression, contentType: ContentType, escapesHTML: Bool, token: TemplateToken) -> TemplateASTNode {0031 0032 // {{ identifier }} 0033 case Identifier
Expression.swift:52 case (.ImplicitIterator, .ImplicitIterator):Expression.swift:52 case (.ImplicitIterator, .ImplicitIterator):ExpressionGenerator.swift:47 case .ImplicitIterator:ExpressionParser.swift:79 state = .DoneExpressionPlusWhiteSpace(expression: Expression.ImplicitIterator)ExpressionParser.swift:83 filterExpressionStack.append(Expression.ImplicitIterator)ExpressionParser.swift:88 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.ImplicitIterator, partialApplication: false)ExpressionParser.swift:96 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.ImplicitIterator, partialApplication: true))ExpressionParser.swift:104 state = .ScopingIdentifier(identifierStart: i, baseExpression: Expression.ImplicitIterator)ExpressionParser.swift:285 finalState = .Valid(expression: Expression.ImplicitIterator)ExpressionInvocation.swift:32 case .ImplicitIterator:(identifier: String) 0034 0035 // {{ <expression>.identifier }} 0036 indirect case Scoped
Expression.swift:55 case (.Identifier(let lIdentifier), .Identifier(let rIdentifier)):Expression.swift:55 case (.Identifier(let lIdentifier), .Identifier(let rIdentifier)):ExpressionGenerator.swift:52 case .Identifier(let identifier):ExpressionParser.swift:111 state = .DoneExpressionPlusWhiteSpace(expression: Expression.Identifier(identifier: identifier))ExpressionParser.swift:114 state = .WaitingForScopingIdentifier(baseExpression: Expression.Identifier(identifier: identifier))ExpressionParser.swift:117 filterExpressionStack.append(Expression.Identifier(identifier: identifier))ExpressionParser.swift:123 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.Identifier(identifier: identifier), partialApplication: false)ExpressionParser.swift:132 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.Identifier(identifier: identifier), partialApplication: true))ExpressionParser.swift:293 finalState = .Valid(expression: Expression.Identifier(identifier: identifier))ExpressionInvocation.swift:37 case .Identifier(let identifier):(baseExpression: Expression, identifier: String) 0037 0038 // {{ <expression>(<expression>) }} 0039 indirect case Filter
Expression.swift:58 case (.Scoped(let lBase, let lIdentifier), .Scoped(let rBase, let rIdentifier)):Expression.swift:58 case (.Scoped(let lBase, let lIdentifier), .Scoped(let rBase, let rIdentifier)):ExpressionGenerator.swift:57 case .Scoped(let baseExpression, let identifier):ExpressionParser.swift:145 let scopedExpression = Expression.Scoped(baseExpression: baseExpression, identifier: identifier)ExpressionParser.swift:149 let scopedExpression = Expression.Scoped(baseExpression: baseExpression, identifier: identifier)ExpressionParser.swift:153 let scopedExpression = Expression.Scoped(baseExpression: baseExpression, identifier: identifier)ExpressionParser.swift:160 let scopedExpression = Expression.Scoped(baseExpression: baseExpression, identifier: identifier)ExpressionParser.swift:170 let scopedExpression = Expression.Scoped(baseExpression: baseExpression, identifier: identifier)ExpressionParser.swift:301 let scopedExpression = Expression.Scoped(baseExpression: baseExpression, identifier: identifier)ExpressionInvocation.swift:42 case .Scoped(let baseExpression, let identifier):(filterExpression: Expression, argumentExpression: Expression, partialApplication: Bool) 0040 } 0041 0042 /** 0043 Expression conforms to Equatable so that the Compiler can check that section 0044 tags have matching openings and closings: {{# person }}...{{/ person }} is OK 0045 but {{# foo }}...{{/ bar }} is not. 0046 */ 0047 extension Expression: Equatable { 0048 } 0049 0050 func ==(lhs: Expression, rhs: Expression) -> Bool { 0051 switch (lhs, rhs) { 0052 case (.ImplicitIterator, .ImplicitIterator): 0053 return true 0054 0055 case (.Identifier(let lIdentifier), .Identifier(let rIdentifier)): 0056 return lIdentifier == rIdentifier 0057 0058 case (.Scoped(let lBase, let lIdentifier), .Scoped(let rBase, let rIdentifier)): 0059 return lBase == rBase && lIdentifier == rIdentifier 0060 0061 case (.Filter(let lFilter, let lArgument, let lPartialApplication), .Filter(let rFilter, let rArgument, let rPartialApplication)): 0062 return lFilter == rFilter && lArgument == rArgument && lPartialApplication == rPartialApplication 0063 0064 default: 0065 return false 0066 } 0067 } 0068
Expression.swift:61 case (.Filter(let lFilter, let lArgument, let lPartialApplication), .Filter(let rFilter, let rArgument, let rPartialApplication)):Expression.swift:61 case (.Filter(let lFilter, let lArgument, let lPartialApplication), .Filter(let rFilter, let rArgument, let rPartialApplication)):ExpressionGenerator.swift:64 case .Filter(let filterExpression, let argumentExpression, _):ExpressionParser.swift:88 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.ImplicitIterator, partialApplication: false)ExpressionParser.swift:96 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.ImplicitIterator, partialApplication: true))ExpressionParser.swift:123 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.Identifier(identifier: identifier), partialApplication: false)ExpressionParser.swift:132 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: Expression.Identifier(identifier: identifier), partialApplication: true))ExpressionParser.swift:161 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: scopedExpression, partialApplication: false)ExpressionParser.swift:171 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: scopedExpression, partialApplication: true))ExpressionParser.swift:210 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: doneExpression, partialApplication: false)ExpressionParser.swift:218 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: doneExpression, partialApplication: true))ExpressionParser.swift:242 let expression = Expression.Filter(filterExpression: filterExpression, argumentExpression: doneExpression, partialApplication: false)ExpressionParser.swift:251 filterExpressionStack.append(Expression.Filter(filterExpression: filterExpression, argumentExpression: doneExpression, partialApplication: true))ExpressionInvocation.swift:47 case .Filter(let filterExpression, let argumentExpression, let partialApplication):