Skip to content
 
 

Latest commit

 

History

164 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tree-Sitter-Pascal (and Delphi)

CI and Release Python Wheels

tree sitter Delphi logo - a hoplite/spartan warrior sitting in a tree next to a treehouse
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.

Contents

What is Tree-sitter?

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

Supported language features

  • 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 if Expressions (Delphi 13)
  • Extended Logical Operators (is not and not 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 otherwise Keyword (Free Pascal / ISO Pascal)
  • Nested Preprocessor Directives

Tree-sitter features

  • Syntax highlighting
  • Scopes

Python Package

The Python binding is published as tree-sitter-pascal and imported as tree_sitter_pascal.

python -m pip install tree-sitter-pascal

Python 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 Binaries

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.

Contributors

This is ultimately based on an original implementation by Isopod, with updates by Warren Postma. See our contributing guide.

License

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.

Object Pascal

About

Tree-sitter grammar for Delphi's Object Pascal and related dialects like Free Pascal

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages