
A Tree-sitter grammar supporting Pascal with focus on Delphi's Object Pascal, updated and focused on the latest language features. Support of other Pascal dialects like Free Pascal and Oxygene are also planned, and pull requests are welcome.
See also Delphi-tree-sitter bindings for consuming tree-sitter grammars from Delphi.
- What is Tree-sitter?
- Supported language features
- Tree-sitter features
- Python Package
- Pre-built Binaries
- Contributing
- Contributors
- License
Tree-sitter is a incremental parsing system for programming tools. It is currently one of the most popular systems and grammars across all programming languages. It is useful for syntax highlighting, code navigation, and most recently for powering AST-based semantic code search (my next project).
- Classes, records, interfaces, class helpers
- Nested declarations
- Variant records
- Generics (Delphi & FPC flavored)
- Anonymous procedures & functions
- Inline assembler (but no highlighting)
- Extended RTTI attributes
- FPC PasCocoa extensions
- Ternary
ifExpressions (Delphi 13) - Extended Logical Operators (
is notandnot in) (Delphi 13) - Custom Managed Records (Delphi 10.4)
- Multi-line String Literals (Delphi 12)
- Numeric Separators (Delphi 12)
- Binary Literals (Delphi 12)
- Inline Variable & Constant Declarations (Delphi 10.3 / 12)
- Case
otherwiseKeyword (Free Pascal / ISO Pascal) - Nested Preprocessor Directives
- Syntax highlighting
- Scopes
The Python binding is published as tree-sitter-pascal and imported as tree_sitter_pascal.
python -m pip install tree-sitter-pascalPython wheels are built with cibuildwheel and published through PyPI Trusted Publishing. Use the manual TestPyPI workflow first when validating a new release path. Production PyPI publishing runs only when a GitHub Release is published for a non-hyphenated release tag such as v0.11.0; auto-generated tags like v0.11.0-abc1234 are ignored.
Before the first upload, configure PyPI trusted publishers for the publish-testpypi.yml and publish-pypi.yml workflows, using the testpypi and pypi GitHub environments respectively.
Pre-built native libraries for all supported platforms are published with each GitHub Release:
| Platform | File |
|---|---|
| Windows x86 (32-bit) | tree-sitter-pascal-windows-x86.dll |
| Windows x64 (64-bit) | tree-sitter-pascal-windows-x64.dll |
| Linux x64 | tree-sitter-pascal-linux-x64.so |
| macOS Intel | tree-sitter-pascal-macos-x64.dylib |
| macOS Apple Silicon | tree-sitter-pascal-macos-arm64.dylib |
| WebAssembly | tree-sitter-pascal.wasm |
The tree-sitter.wasm core runtime (required for WASM use) is available from the tree-sitter releases.
The committed tree-sitter-pascal.wasm at the repository root is the release asset copy. The npm package also ships a second copy from bindings/node/tree-sitter-pascal.wasm because bindings/node/package.json includes *.wasm in its published files list.
This is ultimately based on an original implementation by Isopod, with updates by Warren Postma. See our contributing guide.
I've migrated my updates to AGPL. I'm a big fan of open source. Unfortunately, I've seen too many companies take advantage of permissive licenses and turn an open source project into a closed source one. This is why I prefer AGPL. At the same time, I'm also a big fan of commercial software, which might seem incompatible. That is why I'm happy to provide a dual license. I'll set up a pricing structure later, but I just want to announce it is an option. Let me know if you are interested.
