Show HN:有人对探索 C++ AST 的工具感兴趣吗?
Show HN: Anyone interested in a tool helps to explore C++ ASTs

原始链接: https://uvic-aurora.github.io/acav-manual/index.html

ACAV (Aurora Clang AST Viewer) 是一款基于 Clang 和 Qt 构建的交互式 GUI 工具,旨在为 C、C++ 和 Objective-C 项目提供抽象语法树 (AST) 可视化功能。通过利用 JSON 编译数据库 (`compile_commands.json`),ACAV 允许用户探索真实的复杂代码库,而不仅限于简单的示例。 主要功能包括: * **交互式导航**:实现源代码与相应 AST 节点之间的无缝切换。 * **高效性能**:采用三程序架构(`acav` GUI、`query-dependencies` 和 `make-ast`),通过缓存序列化的 AST 文件来确保响应速度。 * **全面探索**:内置文件浏览器、声明上下文面板,以及针对源代码文本和 AST 节点的强大搜索功能。 ACAV 是一款只读工具,非常适合学生、研究人员以及调试 Clang 相关工具的开发者使用。它不执行重构或代码修改。其工作流程包括加载编译数据库、为特定文件生成 AST,并通过直观的界面浏览结构。该工具可通过原生构建或容器化(Docker/Podman)环境轻松使用,详细说明请参考用户手册和类参考文档。

```Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Show HN:有人对探索 C++ AST 的工具感兴趣吗?(uvic-aurora.github.io) 8 积分,由 leomicv 于 1 小时前发布 | 隐藏 | 过往 | 收藏 | 1 条评论 我开发了这个软件,旨在帮助需要对 C/C++ 代码库进行静态代码分析的用户。它可以帮助你以交互方式探索 AST(抽象语法树)。它不仅能完全替代 Clang 的 AST 转储功能,还支持以结构化的方式搜索代码或 AST。例如,你可以搜索特定名称或特定参数数量的函数。 leomicv 40 分钟前 [–] 这是代码仓库:https://github.com/uvic-aurora/acav 如果有任何问题,欢迎随时留言。谢谢! 回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索: ```
相关文章

原文

ACAV (Aurora Clang AST Viewer) is an interactive Abstract Syntax Tree (AST) visualization tool for C, C++, and Objective-C, built with Clang and Qt. Given a JSON compilation database such as compile_commands.json, ACAV lets you open a real project, inspect the AST for a translation unit, and move directly between source code and AST nodes.

Screenshot of the ACAV interface showing the file explorer, source code view, AST tree view, declaration-context panels, and log panel.

Screenshot: ACAV displaying the file explorer, source-code panel, AST tree view, declaration-context panels, and log panel.

With a valid compilation database, ACAV lets you:

  • inspect the AST for a translation unit in a navigable tree,
  • move in both directions between source locations and AST nodes,
  • view declaration context while exploring program structure,
  • search both source text and AST nodes, and
  • reuse dependency and AST-cache artifacts across sessions.

ACAV follows a three-program architecture:

  • acav is the interactive GUI application.
  • query-dependencies extracts dependency information from a compilation database.
  • make-ast builds and caches serialized AST files for individual source files.

ACAV addresses the gap between Clang's powerful front-end infrastructure and the practical difficulty of exploring Clang ASTs interactively. It is designed for real codebases rather than toy examples: it reads a JSON compilation database, applies the recorded build settings for each source file, and keeps the interface responsive through background processing and AST caching.

ACAV is useful for students learning compiler internals, researchers studying program structure, and developers building or debugging Clang-based tools. Its current scope is intentionally limited to read-only AST exploration. ACAV does not modify source code, perform refactoring, or act as a general-purpose editor, and it displays the AST of one translation unit at a time.

The typical workflow is:

  1. Generate or locate a compilation database for the target project.
  2. Build or install ACAV by following Installation.
  3. Launch ACAV:

    acav -c /path/to/compile_commands.json

  4. Browse files in the file explorer, then double-click a file or press F5 to generate or load its AST.
  5. Use the source view, AST view, and declaration context view to navigate the program structure.
  • License points to the authoritative license file.
  • Installation covers prerequisites, native builds, and the containerized workflow.
  • Docker/Podman Demo Image provides detailed OCI demo image instructions.
  • User Manual describes the GUI, common workflows, the command-line programs, keyboard shortcuts, and configuration.
  • References lists related technologies and resources.
  • Classes provides the generated class reference.
  • Files provides the generated file reference.
  • Changelog provides public release notes for ACAV.
  • Notice provides project attribution, authorship, and licensing context.

If you are new to ACAV, start with this overview, then Installation, and then User Manual. If you want to inspect the API surface, use Classes and Files. If you want to review public release notes, see the Changelog.

联系我们 contact @ memedata.com