tomzx / abstract-parser
An abstract parser written in PHP
Installs: 49
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 2
pkg:composer/tomzx/abstract-parser
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: ~4
This package is auto-updated.
Last update: 2025-10-10 08:52:44 UTC
README
An abstract parser written in PHP. Based on nikic's PHP Parser.
Getting started
Abstract parser
offers 2 interfaces which you'll want to implement:
NodeInterface
: A basic interface for all of the elements of your tree structured data structure.NodeVisitorInterface
: Actions to execute when entering/exiting aNodeInterface
element or at the beginning/end of a traversal.
Once you have implemented the NodeInterface
for your data elements, you can walk through them using something like the following:
<?php $rootElement = ...; // Root element of your data structure $traverser = new NodeTraverser(); $traverser->addVisitor(new MyVisitor()); $traverser->traverse([$rootElement]);
License
The code is licensed under the MIT license. See LICENSE.