# Abstract syntax tree (llmcpp) An **abstract syntax tree (AST)** represents compiler-recognized declarations and expressions. llmcpp traverses declarations in the main file to collect generation candidates: ```cpp FrontendCandidateCollector collector; for (Decl *d : ctx.getTranslationUnitDecl()->decls()) { if (sm.isInMainFile(sm.getExpansionLoc(d->getLocation()))) { collector.TraverseDecl(d); } } ``` `getTranslationUnitDecl()` supplies the root declarations. The source-location check restricts traversal to the main file, and the collector visits functions and lambdas as typed AST nodes. This supports questions about actual parameters, classes, and captures instead of guessing from source text. Before parsing, prompt prose is hidden in a coordinate-preserving view. The resulting AST describes the surrounding C++ structure, while the generation agent still has to supply the requested implementation. Source: [generation_pass.cpp](https://github.com/yanevskiv/llmcpp/blob/main/src/llmcpp/generation_pass.cpp).