Slide 75
Slide 75 text
struct CodeChunk {
let tokens: [String]
let block: CodeBlockSyntax
}
class Visitor: SyntaxVisitor {
var chunks = [CodeChunk]()
override func visit(_ node: CodeBlockSyntax) -> SyntaxVisitorContinueKind {
let tokens: [String] = node.tokens.map { $0.text }
let chunk = CodeChunk(tokens: tokens, block: node)
chunks.append(chunk)
return super.visit(node)
}
}