             }
             
         }
+        //所有字符消耗完毕，输出是否成功识别此语言，以及识别到的所有token
         return (ok: ok, tokens: tokens)
     }
 }

    }
    
    func recognize(source: String) -> (ok: Bool, tokens: [RecognizedToken]) {
        var ok: Bool = true
        var tokens = [RecognizedToken]()
        var workingIndex = source.startIndex
        var workingStringLocation: String.Index? = nil
        var lastTerminatorParentIndex: String.Index? = nil
        var workingTrie = dfa
        while workingIndex < source.endIndex {
            let codeUnit = source[workingIndex]
            if workingTrie.hasTernimatorChild() {
                lastTerminatorParentIndex = workingIndex
            }
            if let exists = workingTrie.child(key: codeUnit) {
                if workingStringLocation == nil {
                    workingStringLocation = workingIndex
                }
                workingIndex = source.index(after: workingIndex)
                workingTrie = exists
                if workingIndex == source.endIndex, workingTrie.hasTernimatorChild() {
                    if let tokenFrom = workingStringLocation {
                        let tokenRange = Range(uncheckedBounds: (lower: tokenFrom, upper: workingIndex))
                        let tokenString = source.substring(with: tokenRange)
                        let token = RecognizedToken(range: tokenRange, string: tokenString)

}

extension Trie {
    //将一个单词(输入的字符串)插入到前缀树中
    mutating func insert(string: String) {
        guard !string.isEmpty else {
            self.insert(child: Trie.terminator)
