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 extension Expression : CustomDebugStringConvertible { 0025 /// A textual representation of `self`, suitable for debugging. 0026 var debugDescription: String { 0027 let string = ExpressionGenerator().stringFromExpression(self) 0028 return "Expression(\(string))" 0029 } 0030 } 0031 0032 final class ExpressionGenerator{ 0033 let configuration
ExpressionGenerator.swift:27 let string = ExpressionGenerator().stringFromExpression(self)TemplateGenerator.swift:88 let expression = ExpressionGenerator().stringFromExpression(section.expression)TemplateGenerator.swift:105 let expression = ExpressionGenerator().stringFromExpression(variable.expression): Configuration 0034 0035 init
ExpressionGenerator.swift:36 self.configuration = configuration ?? DefaultConfiguration(configuration: Configuration? = nil) { 0036 self.configuration = configuration ?? DefaultConfiguration 0037 } 0038 0039 func stringFromExpression
ExpressionGenerator.swift:27 let string = ExpressionGenerator().stringFromExpression(self)TemplateGenerator.swift:88 let expression = ExpressionGenerator().stringFromExpression(section.expression)TemplateGenerator.swift:105 let expression = ExpressionGenerator().stringFromExpression(variable.expression)(expression: Expression) -> String { 0040 buffer = "" 0041 renderExpression(expression) 0042 return buffer 0043 } 0044 0045 func renderExpression
ExpressionGenerator.swift:27 let string = ExpressionGenerator().stringFromExpression(self)TemplateGenerator.swift:88 let expression = ExpressionGenerator().stringFromExpression(section.expression)TemplateGenerator.swift:105 let expression = ExpressionGenerator().stringFromExpression(variable.expression)(expression: Expression) { 0046 switch expression { 0047 case .ImplicitIterator: 0048 // {{ . }} 0049 0050 buffer.appendContentsOf(".") 0051 0052 case .Identifier(let identifier): 0053 // {{ identifier }} 0054 0055 buffer.appendContentsOf(identifier) 0056 0057 case .Scoped(let baseExpression, let identifier): 0058 // {{ <expression>.identifier }} 0059 0060 renderExpression(baseExpression) 0061 buffer.appendContentsOf(".") 0062 buffer.appendContentsOf(identifier) 0063 0064 case .Filter(let filterExpression, let argumentExpression, _): 0065 // {{ <expression>(<expression>) }} 0066 // 0067 // Support for variadic filters is not implemented: 0068 // `f(a,b)` is rendered `f(a)(b)`. 0069 0070 renderExpression(filterExpression) 0071 buffer.appendContentsOf("(") 0072 renderExpression(argumentExpression) 0073 buffer.appendContentsOf(")") 0074 } 0075 } 0076 0077 private var buffer
ExpressionGenerator.swift:41 renderExpression(expression)ExpressionGenerator.swift:60 renderExpression(baseExpression)ExpressionGenerator.swift:70 renderExpression(filterExpression)ExpressionGenerator.swift:72 renderExpression(argumentExpression): String = "" 0078 } 0079
ExpressionGenerator.swift:40 buffer = ""ExpressionGenerator.swift:42 return bufferExpressionGenerator.swift:50 buffer.appendContentsOf(".")ExpressionGenerator.swift:55 buffer.appendContentsOf(identifier)ExpressionGenerator.swift:61 buffer.appendContentsOf(".")ExpressionGenerator.swift:62 buffer.appendContentsOf(identifier)ExpressionGenerator.swift:71 buffer.appendContentsOf("(")ExpressionGenerator.swift:73 buffer.appendContentsOf(")")