PHP Parser
tree-sitter
| PHP Parser | tree-sitter | |
|---|---|---|
| 16 | 74 | |
| 17,393 | 23,043 | |
| 0.2% | 2.2% | |
| 7.9 | 9.8 | |
| 16 days ago | 6 days ago | |
| PHP | Rust | |
| BSD 3-clause "New" or "Revised" License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
PHP Parser
- PHP 8.4 Released
Once rector gets 8.4 rules out, this will be pretty awesome:
https://github.com/rectorphp/rector/issues/8701
https://github.com/nikic/PHP-Parser/commit/7b0384cdbe03431c4...
- Showcasing PHP-Parser: A Native PHP Parser Written in PHP
- PHP Is the Best Choice for Long‑Term Business
- PHP-Parser: A Native PHP Parser for Parsing and Analyzing PHP Code
heh, I'll be straight that I'm sad it doesn't parse its own source in the tests ... or maybe it does <https://github.com/nikic/PHP-Parser/blob/v5.1.0/test/bootstr...>, who knows (joking but not joking)
- PHP-Parser: A PHP parser written in PHP
- Diff Speeding - Rector and sebastian/diff speed improvements through profiling
Interesting. One of the reasons I stopped considering Rector is because of how memory, CPU, and time intensive it is for a non-trivial project. Instead I've been using Nikita's PHP Parser directly and getting much better results even though it isn't multi-threaded out of the box.
- PHP Skeleton for Bison
nikic/PHP-Parser uses a Bison equivalent for PHP parsing. See the grammar file https://github.com/nikic/PHP-Parser/blob/4.x/grammar/php7.y.
- Alternative for nette/tokenizer?
Maybe nikic/PHP-Parser is an alternative. If you only need to tokenizer part, PHP has an extension too.
- How PHP engine builds AST
nikic/PHP-Parser
- Parsing with PHP, Bison and re2c
Code parsing. Many linters and code builders use php-parser. It uses YACC (analog Bison) to build AST.
tree-sitter
- Show HN: Cdecl-dump: represent C declarations visually
We use the tree-sitter[1] for parsing C declarations in Rizin[2] (see the "td" command, for example). See our custom grammar[3] (modified mainstream tree-sitter-c). The custom grammar was sadly necessary, due to the inability of Tree-Sitter to have the alternate roots[4].
P.S. Please add a license for your code.
[1] https://tree-sitter.github.io/
[2] https://github.com/rizinorg/rizin/tree/dev/librz/type/parser
[3] https://github.com/rizinorg/tree-sitter-c/
[4] https://github.com/tree-sitter/tree-sitter/issues/711
- Building Code Retrieval for Claude Code from Scratch
This is the default and recommended strategy. Through the tree-sitter parser, it understands the syntactic structure of code and splits according to semantic units.
- Decoding Tree-sitter Playground Output For Fun
Paste this into the Playground (try it here). You’ll get something like:
- Diving into Tree-Sitter: Parsing Code with Python Like a Pro
This code sets up a parser for Python code. The tree-sitter-python package provides a precompiled grammar, so no manual compilation is needed. If you’re targeting another language, check for its grammar package on Tree-Sitter Wiki.
- Making Sense of tree-sitter's C API
The API is defined in tree_sitter/api.h (available on GitHub). It revolves around a few key concepts: parsers, trees, nodes, and queries. Let’s dive into the essentials.
- Want AI to Actually Understand Your Code? This Tool Says It Can Help
Tree-sitter is a parser generator tool and an incremental parsing library, it is available in Rust 🦀 - GitHub. CocoIndex has built-in Rust integration with Tree-sitter to efficiently parse code and extract syntax trees for various programming languages.
- Emacs Tree-sitter custom highlighting
I think the main problem is that highligthing framework used by tree-sitter (https://github.com/tree-sitter/tree-sitter/tree/master/highl...) is not easily pluggable into emacs font-lock-mode.
- Highlighting Parts of Lua as Bash
Although I am not certain if tree-sitter allows matching on comments, but https://github.com/tree-sitter/tree-sitter/issues/1138 seems to imply that it does
- I wrote my own "proper" programming language
Hard agree. Even without going deep on a "serious language" there's a universe of DSLs that's mostly unexplored.
Debuggers are the outlier in your group but there's not exactly a void for those other wishes. As just one slice, building a tree-sitter [1] grammar gives the basis for good editor integration [2], formatters [3], structural diff [4] and other dev tools. Similarly if you're expressing some form of program, mapping to LLVM IR connects your creation with a fairly extensive compiler toolchain.
Language agnostic tooling exists, but there still needs to be some abstraction layer.
[1]: https://tree-sitter.github.io/
[2]: https://zed.dev/blog/syntax-aware-editing
[3]: https://topiary.tweag.io
[4]: https://difftastic.wilfred.me.uk
- Tbsp – treesitter-based source processing language
For those that want to explore the grammars listed at https://github.com/tree-sitter/tree-sitter/wiki/List-of-pars... in a more friendly railroad diagram format I made https://mingodad.github.io/plgh/json2ebnf.html that reads the "src/grammar.json" and try it's best to generate an EBNF understood by (IPV6) https://www.bottlecaps.de/rr/ui or (IPV4) https://rr.red-dove.com/ui where we get a nice navigable railroad diagram (see https://github.com/GuntherRademacher/rr for offline usage).
What are some alternatives?
PHP Analyser - Performs advanced static analysis on PHP code
nvim-treesitter - Nvim Treesitter configurations and abstraction layer
PHP Semantic Versioning Checker - Compares two source sets and determines the appropriate semantic versioning to apply.
language-server-protocol - Defines a common protocol for language servers.
PHPCPD - Copy/Paste Detector (CPD) for PHP code.
sourcegraph - Code AI platform with Code Search & Cody