Skip to content

fschetterer/ast-grep-pascal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ast-grep Pascal Plugin

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.

Quick Start

# 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.

Usage Examples

# 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 Reference

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

Contents

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

Platform

pascal.so is pre-built for Linux/WSL x64. To build for other platforms, see ref/tree-sitter-pascal.

License

MPL 2.0 — see LICENSE.

About

Structural code search for Delphi/Pascal source using ast-grep

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors