A custom ast-grep language plugin for structural code search over Delphi/Pascal source files, powered by tree-sitter-pascal.
Unlike text-based search (grep, ripgrep), ast-grep understands code structure — find patterns like assignments, function calls, try/except blocks, and class declarations by their AST shape rather than string matching.
# 1. Install ast-grep
npm install -g @ast-grep/napi @ast-grep/cli
# 2. Copy config and plugin to your project root
cp agent-skill/sgconfig.yml your-project/
cp agent-skill/pascal.so your-project/
# 3. Search!
ast-grep run --pattern '$CALL($$$ARGS)' -l pascal Source/See SETUP.md for detailed installation instructions.
# Find any function/method call
ast-grep run --pattern '$CALL($$$ARGS)' -l pascal Source/
# Find all assignments
ast-grep run --pattern '$A := $B' -l pascal Source/
# Find all try/except blocks
ast-grep run --pattern 'try $$$BODY except $$$HANDLER end' -l pascal Source/
# Debug the AST for a file
ast-grep run --pattern 'procedure $NAME;' -l pascal --debug-query=ast myfile.pas| Pattern | Matches |
|---|---|
$A := $B |
Any assignment |
$CALL($$$ARGS) |
Any function/method call |
procedure $NAME; |
Any procedure declaration |
function $NAME($$$): $RET; |
Any function declaration |
type $NAME = class($BASE) |
Any class declaration |
if $COND then $THEN |
Any if statement |
for $VAR := $FROM to $TO do $BODY |
Any for loop |
try $$$BODY except $$$HANDLER end |
Any try/except block |
| Path | Purpose |
|---|---|
agent-skill/ |
Distributable plugin: pascal.so, sgconfig.yml, usage docs |
ref/ |
Reference repos (submodules): ast-grep source, tree-sitter-pascal, agent-skill marketplace |
pascal.so is pre-built for Linux/WSL x64. To build for other platforms, see ref/tree-sitter-pascal.
MPL 2.0 — see LICENSE.