Sources are useable already (the API's used in ./examples are not expected to change).
PHP bindings for the famous tree-sitter library, thanks to FFI (available since php 7.4).
By using this library you can:
- create static code analysis tools
- automate refactoring
- create a language server
- .. your idea
Version must be specified when requiring unstable packages:
composer require talbergs/tree-sitter=0.19.0-rc3
composer require talbergs/tree-sitter-php=0.19.0-rc3
composer require talbergs/tree-sitter-html=0.19.0-rc3
Requirements:
- ext-ffi
- php >= 8.0
For more extensive examples see ./examples directory.
$parser = TS\Parser::new();
$parser->setLanguage(TS\Language::php());
$tree = $parser->parseString(null, '<?php $code;');
var_dump($tree->getRootNode());
Contributions are very welcome! Just start your project and use this library, your project will be also plugged here and this library will be adjusted to fit everyone's needs, just submit PR or open an issue.
Your project, if using this binding will be plugged here as well, just open a ticket or submit PR.
- https://github.com/talbergs/php-language-server-lsp - PHP Language Server (implements LSP)
Yes this is mono repo to ease dev.
- This means all packages will have the same version.
- This means all packages are testable all together.
- This means
packagist
will remain in many, many[read-only]
repositories (as a workaround for packagist.org approach).
- cross compile (new just few builds are available and not tested)
- create a way to load grammar source files as language (non performant, for grammar development purposes).
- provide some working examples
- coverage (100%)
- check if all malloc's are freed
- Investigation #1, #2
binding is versioned along with TS & grammar versions.
Using semantic versioning standard.
- MAJOR.MINOR.PATCH version corresponds to tree-sitter the build of parsing library and their grammars.
- Pre-release version affix
-
is used to denote incremental improvement to this bindings library. -- backwards incompatible changes are MAJOR -- memory leak fixes are MAJOR -- additional builds are considered MINOR -- additional methods are considered MINOR -- coding style changes are PATCH
i.e. 0.19.0-1.3.22
- run all or one example:
> ./scripts/run-examples.sh
or> ./scripts/run-examples.sh 02