With Parle, it is possible to implement lexing and parsing in PHP while relying on features and principles of the parser/lexer generator tools for C/C++.
Documentation: http://php.net/parle
Package built for PHP 8.2 as Software Collection (php82 by remi).