{"id":48310059,"url":"https://github.com/ahueck/astprinter","last_synced_at":"2026-04-05T00:15:53.440Z","repository":{"id":53717353,"uuid":"100126500","full_name":"ahueck/astprinter","owner":"ahueck","description":"Conveniently explore the Clang abstract syntax tree","archived":false,"fork":false,"pushed_at":"2026-02-07T12:08:41.000Z","size":76,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-07T19:59:10.012Z","etag":null,"topics":["abstract-syntax-tree","c","clang","clang-tooling","cpp"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ahueck.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-08-12T17:07:52.000Z","updated_at":"2026-02-07T12:07:02.000Z","dependencies_parsed_at":"2026-02-07T13:01:49.481Z","dependency_job_id":null,"html_url":"https://github.com/ahueck/astprinter","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ahueck/astprinter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahueck%2Fastprinter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahueck%2Fastprinter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahueck%2Fastprinter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahueck%2Fastprinter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahueck","download_url":"https://codeload.github.com/ahueck/astprinter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahueck%2Fastprinter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31419642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T20:09:54.854Z","status":"ssl_error","status_checked_at":"2026-04-04T20:09:44.350Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abstract-syntax-tree","c","clang","clang-tooling","cpp"],"created_at":"2026-04-05T00:15:50.862Z","updated_at":"2026-04-05T00:15:52.767Z","avatar_url":"https://github.com/ahueck.png","language":"C++","readme":"# astprinter \u0026middot; ![License](https://img.shields.io/github/license/ahueck/astprinter)\n\n\n**astprinter** is a command-line tool for exploring the Clang abstract syntax tree (AST). It is designed to simplify retrieving specific AST nodes by specifying line numbers from C/C++ source code.\n\n\n## Features\n* Retrieve AST nodes corresponding to specific lines of C/C++ source code.\n* Use regular expressions to match function names and display the AST nodes for their declarations or definitions.\n\n## Usage\nSee [main.cpp](src/main.cpp) for all possible command-line arguments.\n\n### Example of using *astprinter*\nAssume *test.c* contains the code:\n\n  ```c\n  1  int foo () {\n  2      return 2; \n  3  }\n  4  int main() {\n  5      int val;\n  6      val = foo();    \n  7      return 0;\n  8  }\n  ```\n#### Using astprinter on test.c\nIn this example we\n  1) load `test.c` with standard Clang flags,\n  2) list all function declarations in `test.c`,\n  3) print the AST definition of foo,,\n  4) print the AST of the return statement in line 2, and, finally,\n  5) enable source output; print the source *and* AST of foo in lines 1-3.\n\n```console\nahueck@sys:~/astprint/install$ ./bin/clang-ast-printer ../test.c --\nast-printer\u003e l\nfoo:/path/to/test.c:1:1-\u003e3:2\nmain:/path/to/test.c:4:1-\u003e8:2\n\nast-printer\u003e p foo\nFunctionDecl 0x62eed65573d8 \u003c/path/to/test.c:1:1, line:3:1\u003e line:1:5 used foo 'int ()'\n`-CompoundStmt 0x62eed65574f8 \u003ccol:12, line:3:1\u003e\n  `-ReturnStmt 0x62eed65574e8 \u003cline:2:5, col:12\u003e\n    `-IntegerLiteral 0x62eed65574c8 \u003ccol:12\u003e 'int' 2\n/path/to/test.c:1:1-\u003e3:2\n\nast-printer\u003e 2\nReturnStmt 0x62eed65574e8 \u003c/path/to/test.c:2:5, col:12\u003e\n`-IntegerLiteral 0x62eed65574c8 \u003ccol:12\u003e 'int' 2\n/path/to/test.c:2:5-\u003e2:13\n\nast-printer\u003e source\nShow source on.\nast-printer\u003e 1 3\nint foo() {\n    return 2;\n}\n\nFunctionDecl 0x62eed65573d8 \u003c/path/to/test.c:1:1, line:3:1\u003e line:1:5 used foo 'int ()'\n`-CompoundStmt 0x62eed65574f8 \u003ccol:12, line:3:1\u003e\n  `-ReturnStmt 0x62eed65574e8 \u003cline:2:5, col:12\u003e\n    `-IntegerLiteral 0x62eed65574c8 \u003ccol:12\u003e 'int' 2\n/path/to/test.c:1:1-\u003e3:2\n```\n\n## How to build\n\n###### Requirements\n\n- CMake \u003e= 3.21\n- Clang/LLVM 14, 18-21 (CMake needs to find the installation, see\n  the [LLVM CMake documentation](https://llvm.org/docs/CMake.html) or the [CI workflow](.github/workflows/basic-ci.yml))\n- C++17 compiler\n\n###### Build steps\n\nIn the root project folder, execute the following commands (see also [CI workflow](.github/workflows/basic-ci.yml))\n\n  ```\n  cmake -B build --preset=release\n  cmake --build build --target install --parallel\n  ```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahueck%2Fastprinter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahueck%2Fastprinter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahueck%2Fastprinter/lists"}