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    struct TemplateToken
TemplateCompiler.swift:61
    func parser(parser: TemplateParser, shouldContinueAfterParsingToken token: TemplateToken) -> Bool {
TemplateCompiler.swift:385
            case Section(openingToken: TemplateToken, expression: Expression)
TemplateCompiler.swift:386
            case InvertedSection(openingToken: TemplateToken, expression: Expression)
TemplateCompiler.swift:387
            case PartialOverride(openingToken: TemplateToken, parentPartialName: String)
TemplateCompiler.swift:388
            case Block(openingToken: TemplateToken, blockName: String)
TemplateCompiler.swift:392
    private func blockNameFromString(string: String, inToken token: TemplateToken, inout empty: Bool) throws -> String {
TemplateCompiler.swift:405
    private func partialNameFromString(string: String, inToken token: TemplateToken, inout empty: Bool) throws -> String {
TemplateParser.swift:24
    func parser(parser:TemplateParser, shouldContinueAfterParsingToken token:TemplateToken) -> Bool
TemplateParser.swift:94
                        let token = TemplateToken(
TemplateParser.swift:109
                        let token = TemplateToken(
TemplateParser.swift:124
                        let token = TemplateToken(
TemplateParser.swift:146
                        let token = TemplateToken(
TemplateParser.swift:157
                        let token = TemplateToken(
TemplateParser.swift:168
                        let token = TemplateToken(
TemplateParser.swift:179
                        let token = TemplateToken(
TemplateParser.swift:190
                        let token = TemplateToken(
TemplateParser.swift:201
                        let token = TemplateToken(
TemplateParser.swift:212
                        let token = TemplateToken(
TemplateParser.swift:223
                        let token = TemplateToken(
TemplateParser.swift:234
                        let token = TemplateToken(
TemplateParser.swift:245
                        let token = TemplateToken(
TemplateParser.swift:265
                    let token = TemplateToken(
TemplateParser.swift:290
                    let token = TemplateToken(
TemplateParser.swift:318
            let token = TemplateToken(
SectionTag.swift:28
    let openingToken: TemplateToken
SectionTag.swift:31
    init(innerTemplateAST: TemplateAST, openingToken: TemplateToken, innerTemplateString: String) {
TemplateASTNode.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 {
VariableTag.swift:27
    let token: TemplateToken
VariableTag.swift:30
    init(contentType: ContentType, token: TemplateToken) {
{ 0025 enum TemplateTokenType
TemplateToken.swift:63
    let type: TemplateTokenType
{ 0026 /// text 0027 case Text
TemplateCompiler.swift:97
                case .Text(text: let text):
TemplateParser.swift:95
                            type: .Text(text: templateString[range]),
TemplateParser.swift:110
                            type: .Text(text: templateString[range]),
TemplateParser.swift:125
                            type: .Text(text: templateString[range]),
TemplateParser.swift:319
                type: .Text(text: templateString[range]),
(text: String) 0028 0029 /// {{ content }} 0030 case EscapedVariable
TemplateCompiler.swift:114
                case .EscapedVariable(content: let content, tagDelimiterPair: _):
TemplateParser.swift:246
                            type: .EscapedVariable(content: content, tagDelimiterPair: currentDelimiters.tagDelimiterPair),
TemplateToken.swift:73
        case .EscapedVariable(content: _, tagDelimiterPair: let tagDelimiterPair):
(content: String, tagDelimiterPair: TagDelimiterPair) 0031 0032 /// {{{ content }}} 0033 case UnescapedVariable
TemplateCompiler.swift:131
                case .UnescapedVariable(content: let content, tagDelimiterPair: _):
TemplateParser.swift:224
                            type: .UnescapedVariable(content: content, tagDelimiterPair: currentDelimiters.tagDelimiterPair),
TemplateParser.swift:266
                        type: .UnescapedVariable(content: content, tagDelimiterPair: currentDelimiters.tagDelimiterPair),
TemplateToken.swift:75
        case .UnescapedVariable(content: _, tagDelimiterPair: let tagDelimiterPair):
(content: String, tagDelimiterPair: TagDelimiterPair) 0034 0035 /// {{! comment }} 0036 case Comment
TemplateCompiler.swift:73
                case .Comment:
TemplateParser.swift:147
                            type: .Comment,
0037 0038 /// {{# content }} 0039 case Section
TemplateCompiler.swift:148
                case .Section(content: let content, tagDelimiterPair: _):
TemplateParser.swift:158
                            type: .Section(content: content, tagDelimiterPair: currentDelimiters.tagDelimiterPair),
TemplateToken.swift:77
        case .Section(content: _, tagDelimiterPair: let tagDelimiterPair):
(content: String, tagDelimiterPair: TagDelimiterPair) 0040 0041 /// {{^ content }} 0042 case InvertedSection
TemplateCompiler.swift:165
                case .InvertedSection(content: let content, tagDelimiterPair: _):
TemplateParser.swift:169
                            type: .InvertedSection(content: content, tagDelimiterPair: currentDelimiters.tagDelimiterPair),
TemplateToken.swift:79
        case .InvertedSection(content: _, tagDelimiterPair: let tagDelimiterPair):
(content: String, tagDelimiterPair: TagDelimiterPair) 0043 0044 /// {{/ content }} 0045 case Close
TemplateCompiler.swift:194
                case .Close(content: let content):
TemplateParser.swift:191
                            type: .Close(content: content),
(content: String) 0046 0047 /// {{> content }} 0048 case Partial
TemplateCompiler.swift:310
                case .Partial(content: let content):
TemplateParser.swift:202
                            type: .Partial(content: content),
(content: String) 0049 0050 /// {{= ... ... =}} 0051 case SetDelimiters
TemplateCompiler.swift:69
                case .SetDelimiters:
TemplateParser.swift:291
                        type: .SetDelimiters,
0052 0053 /// {{% content }} 0054 case Pragma
TemplateCompiler.swift:77
                case .Pragma(content: let content):
TemplateParser.swift:235
                            type: .Pragma(content: content),
(content: String) 0055 0056 /// {{< content }} 0057 case PartialOverride
TemplateCompiler.swift:188
                case .PartialOverride(content: let content):
TemplateParser.swift:213
                            type: .PartialOverride(content: content),
(content: String) 0058 0059 /// {{$ content }} 0060 case Block
TemplateCompiler.swift:182
                case .Block(content: let content):
TemplateParser.swift:180
                            type: .Block(content: content),
(content: String) 0061 } 0062 0063 let type
TemplateCompiler.swift:67
                switch(token.type) {
TemplateToken.swift:72
        switch type {
: TemplateTokenType 0064 let lineNumber
TemplateCompiler.swift:41
                throw MustacheError(kind: .ParseError, message: "Unclosed Mustache tag", templateID: openingToken.templateID, lineNumber: openingToken.lineNumber)
TemplateCompiler.swift:43
                throw MustacheError(kind: .ParseError, message: "Unclosed Mustache tag", templateID: openingToken.templateID, lineNumber: openingToken.lineNumber)
TemplateCompiler.swift:45
                throw MustacheError(kind: .ParseError, message: "Unclosed Mustache tag", templateID: openingToken.templateID, lineNumber: openingToken.lineNumber)
TemplateCompiler.swift:47
                throw MustacheError(kind: .ParseError, message: "Unclosed Mustache tag", templateID: openingToken.templateID, lineNumber: openingToken.lineNumber)
TemplateCompiler.swift:84
                            throw MustacheError(kind: .ParseError, message:"CONTENT_TYPE:TEXT pragma tag must prepend any Mustache variable, section, or partial tag.", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:91
                            throw MustacheError(kind: .ParseError, message:"CONTENT_TYPE:HTML pragma tag must prepend any Mustache variable, section, or partial tag.", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:94
                        throw MustacheError(kind: .ParseError, message:"Syntax should be \"CONTENT_TYPE : TEXT\" or \"CONTENT_TYPE : HTML\"", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:117
                        throw MustacheError(kind: .ParseError, message:"Illegal tag inside a partial override tag.", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:125
                            throw error.errorWith(templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:127
                            throw MustacheError(kind: .ParseError, templateID: token.templateID, lineNumber: token.lineNumber, underlyingError: error)
TemplateCompiler.swift:134
                        throw MustacheError(kind: .ParseError, message: "Illegal tag inside a partial override tag: \(token.templateSubstring)", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:142
                            throw error.errorWith(templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:144
                            throw MustacheError(kind: .ParseError, templateID: token.templateID, lineNumber: token.lineNumber, underlyingError: error)
TemplateCompiler.swift:151
                        throw MustacheError(kind: .ParseError, message: "Illegal tag inside a partial override tag: \(token.templateSubstring)", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:159
                            throw error.errorWith(templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:161
                            throw MustacheError(kind: .ParseError, templateID: token.templateID, lineNumber: token.lineNumber, underlyingError: error)
TemplateCompiler.swift:168
                        throw MustacheError(kind: .ParseError, message: "Illegal tag inside a partial override tag: \(token.templateSubstring)", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:176
                            throw error.errorWith(templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:178
                            throw MustacheError(kind: .ParseError, templateID: token.templateID, lineNumber: token.lineNumber, underlyingError: error)
TemplateCompiler.swift:197
                        throw MustacheError(kind: .ParseError, message: "Unmatched closing tag", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:206
                                throw error.errorWith(templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:209
                            throw MustacheError(kind: .ParseError, templateID: token.templateID, lineNumber: token.lineNumber, underlyingError: error)
TemplateCompiler.swift:212
                            throw MustacheError(kind: .ParseError, message: "Unmatched closing tag", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:236
                                throw error.errorWith(templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:239
                            throw MustacheError(kind: .ParseError, templateID: token.templateID, lineNumber: token.lineNumber, underlyingError: error)
TemplateCompiler.swift:242
                            throw MustacheError(kind: .ParseError, message: "Unmatched closing tag", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:270
                            throw MustacheError(kind: .ParseError, message: "Unmatched closing tag", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:279
                                throw MustacheError(kind: .ParseError, message: "Content type mismatch", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:300
                            throw MustacheError(kind: .ParseError, message: "Unmatched closing tag", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:397
            throw MustacheError(kind: .ParseError, message: "Missing block name", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:400
            throw MustacheError(kind: .ParseError, message: "Invalid block name", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:410
            throw MustacheError(kind: .ParseError, message: "Missing template name", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:413
            throw MustacheError(kind: .ParseError, message: "Invalid template name", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateToken.swift:88
            return "line \(lineNumber) of template \(templateID)"
TemplateToken.swift:90
            return "line \(lineNumber)"
SectionTag.swift:55
    var lineNumber: Int { return openingToken.lineNumber }
VariableTag.swift:53
    var lineNumber: Int { return token.lineNumber }
: Int 0065 let templateID
TemplateCompiler.swift:41
                throw MustacheError(kind: .ParseError, message: "Unclosed Mustache tag", templateID: openingToken.templateID, lineNumber: openingToken.lineNumber)
TemplateCompiler.swift:43
                throw MustacheError(kind: .ParseError, message: "Unclosed Mustache tag", templateID: openingToken.templateID, lineNumber: openingToken.lineNumber)
TemplateCompiler.swift:45
                throw MustacheError(kind: .ParseError, message: "Unclosed Mustache tag", templateID: openingToken.templateID, lineNumber: openingToken.lineNumber)
TemplateCompiler.swift:47
                throw MustacheError(kind: .ParseError, message: "Unclosed Mustache tag", templateID: openingToken.templateID, lineNumber: openingToken.lineNumber)
TemplateCompiler.swift:84
                            throw MustacheError(kind: .ParseError, message:"CONTENT_TYPE:TEXT pragma tag must prepend any Mustache variable, section, or partial tag.", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:91
                            throw MustacheError(kind: .ParseError, message:"CONTENT_TYPE:HTML pragma tag must prepend any Mustache variable, section, or partial tag.", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:94
                        throw MustacheError(kind: .ParseError, message:"Syntax should be \"CONTENT_TYPE : TEXT\" or \"CONTENT_TYPE : HTML\"", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:117
                        throw MustacheError(kind: .ParseError, message:"Illegal tag inside a partial override tag.", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:125
                            throw error.errorWith(templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:127
                            throw MustacheError(kind: .ParseError, templateID: token.templateID, lineNumber: token.lineNumber, underlyingError: error)
TemplateCompiler.swift:134
                        throw MustacheError(kind: .ParseError, message: "Illegal tag inside a partial override tag: \(token.templateSubstring)", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:142
                            throw error.errorWith(templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:144
                            throw MustacheError(kind: .ParseError, templateID: token.templateID, lineNumber: token.lineNumber, underlyingError: error)
TemplateCompiler.swift:151
                        throw MustacheError(kind: .ParseError, message: "Illegal tag inside a partial override tag: \(token.templateSubstring)", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:159
                            throw error.errorWith(templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:161
                            throw MustacheError(kind: .ParseError, templateID: token.templateID, lineNumber: token.lineNumber, underlyingError: error)
TemplateCompiler.swift:168
                        throw MustacheError(kind: .ParseError, message: "Illegal tag inside a partial override tag: \(token.templateSubstring)", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:176
                            throw error.errorWith(templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:178
                            throw MustacheError(kind: .ParseError, templateID: token.templateID, lineNumber: token.lineNumber, underlyingError: error)
TemplateCompiler.swift:197
                        throw MustacheError(kind: .ParseError, message: "Unmatched closing tag", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:206
                                throw error.errorWith(templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:209
                            throw MustacheError(kind: .ParseError, templateID: token.templateID, lineNumber: token.lineNumber, underlyingError: error)
TemplateCompiler.swift:212
                            throw MustacheError(kind: .ParseError, message: "Unmatched closing tag", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:236
                                throw error.errorWith(templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:239
                            throw MustacheError(kind: .ParseError, templateID: token.templateID, lineNumber: token.lineNumber, underlyingError: error)
TemplateCompiler.swift:242
                            throw MustacheError(kind: .ParseError, message: "Unmatched closing tag", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:270
                            throw MustacheError(kind: .ParseError, message: "Unmatched closing tag", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:279
                                throw MustacheError(kind: .ParseError, message: "Content type mismatch", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:300
                            throw MustacheError(kind: .ParseError, message: "Unmatched closing tag", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:397
            throw MustacheError(kind: .ParseError, message: "Missing block name", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:400
            throw MustacheError(kind: .ParseError, message: "Invalid block name", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:410
            throw MustacheError(kind: .ParseError, message: "Missing template name", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:413
            throw MustacheError(kind: .ParseError, message: "Invalid template name", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateToken.swift:87
        if let templateID = templateID {
SectionTag.swift:54
    var templateID: TemplateID? { return openingToken.templateID }
VariableTag.swift:52
    var templateID: TemplateID? { return token.templateID }
: TemplateID? 0066 let templateString
TemplateCompiler.swift:222
                        let templateString = token.templateString
TemplateCompiler.swift:252
                        let templateString = token.templateString
TemplateToken.swift:69
    var templateSubstring: String { return templateString[range] }
: String 0067 let range
TemplateCompiler.swift:223
                        let innerContentRange = openingToken.range.endIndex..<token.range.startIndex
TemplateCompiler.swift:223
                        let innerContentRange = openingToken.range.endIndex..<token.range.startIndex
TemplateCompiler.swift:253
                        let innerContentRange = openingToken.range.endIndex..<token.range.startIndex
TemplateCompiler.swift:253
                        let innerContentRange = openingToken.range.endIndex..<token.range.startIndex
TemplateToken.swift:69
    var templateSubstring: String { return templateString[range] }
: Range<String.Index> 0068 0069 var templateSubstring
TemplateCompiler.swift:134
                        throw MustacheError(kind: .ParseError, message: "Illegal tag inside a partial override tag: \(token.templateSubstring)", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:151
                        throw MustacheError(kind: .ParseError, message: "Illegal tag inside a partial override tag: \(token.templateSubstring)", templateID: token.templateID, lineNumber: token.lineNumber)
TemplateCompiler.swift:168
                        throw MustacheError(kind: .ParseError, message: "Illegal tag inside a partial override tag: \(token.templateSubstring)", templateID: token.templateID, lineNumber: token.lineNumber)
SectionTag.swift:44
        return "\(openingToken.templateSubstring) at \(openingToken.locationDescription)"
VariableTag.swift:42
        return "\(token.templateSubstring) at \(token.locationDescription)"
: String { return templateString[range] } 0070 0071 var tagDelimiterPair
SectionTag.swift:41
    var tagDelimiterPair: TagDelimiterPair { return openingToken.tagDelimiterPair! }
VariableTag.swift:39
    var tagDelimiterPair: TagDelimiterPair { return token.tagDelimiterPair! }
: TagDelimiterPair? { 0072 switch type { 0073 case .EscapedVariable(content: _, tagDelimiterPair: let tagDelimiterPair): 0074 return tagDelimiterPair 0075 case .UnescapedVariable(content: _, tagDelimiterPair: let tagDelimiterPair): 0076 return tagDelimiterPair 0077 case .Section(content: _, tagDelimiterPair: let tagDelimiterPair): 0078 return tagDelimiterPair 0079 case .InvertedSection(content: _, tagDelimiterPair: let tagDelimiterPair): 0080 return tagDelimiterPair 0081 default: 0082 return nil 0083 } 0084 } 0085 0086 var locationDescription
SectionTag.swift:44
        return "\(openingToken.templateSubstring) at \(openingToken.locationDescription)"
VariableTag.swift:42
        return "\(token.templateSubstring) at \(token.locationDescription)"
: String { 0087 if let templateID = templateID { 0088 return "line \(lineNumber) of template \(templateID)" 0089 } else { 0090 return "line \(lineNumber)" 0091 } 0092 } 0093 } 0094