dump_syntax_tree
Debug code rules by inspecting syntax tree structures. Use to discover correct syntax kinds and analyze how patterns are interpreted in ast-grep.
Instructions
Dump code's syntax structure or dump a query's pattern structure.
This is useful to discover correct syntax kind and syntax tree structure. Call it when debugging a rule.
The tool requires three arguments: code, language and format. The first two are self-explanatory.
format is the output format of the syntax tree.
use format=cst to inspect the code's concrete syntax tree structure, useful to debug target code.
use format=pattern to inspect how ast-grep interprets a pattern, useful to debug pattern rule.
Internally calls: ast-grep run --pattern --lang --debug-query=
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The code you need | |
| language | Yes | The language of the code. Supported: bash, c, cpp, csharp, css, elixir, go, haskell, html, java, javascript, json, jsx, kotlin, lua, nix, php, python, ruby, rust, scala, solidity, swift, tsx, typescript, yaml | |
| format | No | Code dump format. Available values: pattern, ast, cst | cst |